#811 Export ActionScript fail fixed

Creating buttons simplified (common code lines moved to function)
This commit is contained in:
2015-02-21 19:14:01 +01:00
parent 6902b4d716
commit e5f233c32c
7 changed files with 54 additions and 72 deletions
@@ -123,7 +123,7 @@ public class AboutDialog extends AppDialog {
dateLabel.setHorizontalAlignment(SwingConstants.CENTER);
cp.add(dateLabel);
LinkLabel wwwLabel = new LinkLabel(ApplicationInfo.PROJECT_PAGE,ApplicationInfo.PROJECT_PAGE+"?utm_source=app&utm_medium=about&utm_campaign=app");
LinkLabel wwwLabel = new LinkLabel(ApplicationInfo.PROJECT_PAGE, ApplicationInfo.PROJECT_PAGE + "?utm_source=app&utm_medium=about&utm_campaign=app");
wwwLabel.setAlignmentX(0.5f);
wwwLabel.setForeground(Color.blue);
//wwwLabel.setPreferredSize(new Dimension(300, 25));
@@ -1,16 +1,16 @@
/*
* Copyright (C) 2010-2015 JPEXS
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -32,7 +32,7 @@ public class LinkLabel extends JLabel {
* The normal text set by the user.
*/
private String text;
private String url;
/**
@@ -40,16 +40,16 @@ public class LinkLabel extends JLabel {
*
* @param text
*/
public LinkLabel(String text,String url) {
public LinkLabel(String text, String url) {
super(text);
this.url = url;
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
enableEvents(MouseEvent.MOUSE_EVENT_MASK);
}
public LinkLabel(String text) {
this(text,text);
this(text, text);
}
/**
+2 -2
View File
@@ -641,7 +641,7 @@ public class Main {
return AppStrings.translate("filter.swf");
}
};
FileFilter exeFilter = new FileFilter() {
@Override
public boolean accept(File f) {
@@ -653,7 +653,7 @@ public class Main {
return AppStrings.translate("filter.exe");
}
};
if(mode == SaveFileMode.EXE){
if (mode == SaveFileMode.EXE) {
fc.setFileFilter(exeFilter);
} else if (!swf.gfx) {
fc.setFileFilter(swfFilter);
@@ -251,7 +251,7 @@ public abstract class MainFrameMenu {
}
protected void homePage() {
String homePageURL = ApplicationInfo.PROJECT_PAGE+"?utm_source=app&utm_medium=menu&utm_campaign=app";
String homePageURL = ApplicationInfo.PROJECT_PAGE + "?utm_source=app&utm_medium=menu&utm_campaign=app";
if (!View.navigateUrl(homePageURL)) {
View.showMessageDialog(null, translate("message.homepage").replace("%url%", homePageURL));
}
@@ -134,7 +134,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener
private static final String ACTION_EXPORT = "EXPORT";
private static final String ACTION_IMPORT_TEXT = "IMPORTTEXT";
private static final String ACTION_IMPORT_TEXT = "IMPORTTEXT";
private static final String ACTION_CHECK_UPDATES = "CHECKUPDATES";
@@ -199,7 +199,9 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener
private JCommandButton exportSelectionCommandButton;
private JCommandButton importTextCommandButton;
private JCommandButton importXmlCommandButton;
private JCommandButton exportXmlCommandButton;
private JCommandToggleButton viewModeResourcesToggleButton;
@@ -411,7 +413,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener
reloadCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.reload")), View.getResizableIcon("reload16"));
assignListener(reloadCommandButton, ACTION_RELOAD);
saveasexeCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.saveasexe")), View.getResizableIcon("saveasexe16"));
assignListener(saveasexeCommandButton, ACTION_SAVE_AS_EXE);
@@ -419,7 +421,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener
editBand.addCommandButton(saveCommandButton, RibbonElementPriority.TOP);
editBand.addCommandButton(saveasCommandButton, RibbonElementPriority.MEDIUM);
editBand.addCommandButton(saveasexeCommandButton, RibbonElementPriority.MEDIUM);
editBand.addCommandButton(reloadCommandButton, RibbonElementPriority.MEDIUM);
editBand.addCommandButton(reloadCommandButton, RibbonElementPriority.MEDIUM);
JRibbonBand exportBand = new JRibbonBand(translate("menu.export"), null);
exportBand.setResizePolicies(getResizePolicies(exportBand));
@@ -429,8 +431,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener
assignListener(exportAllCommandButton, ACTION_EXPORT);
exportSelectionCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.export.selection")), View.getResizableIcon("exportsel16"));
assignListener(exportSelectionCommandButton, ACTION_EXPORT_SEL);
exportXmlCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.export.xml")), View.getResizableIcon("exportxml32"));
assignListener(exportXmlCommandButton, ACTION_EXPORT_SWF_XML);
@@ -438,18 +439,17 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener
exportBand.addCommandButton(exportAllCommandButton, RibbonElementPriority.MEDIUM);
exportBand.addCommandButton(exportSelectionCommandButton, RibbonElementPriority.MEDIUM);
exportBand.addCommandButton(exportXmlCommandButton, RibbonElementPriority.MEDIUM);
JRibbonBand importBand = new JRibbonBand(translate("menu.import"), null);
importBand.setResizePolicies(getResizePolicies(importBand));
importTextCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.import.text")), View.getResizableIcon("importtext32"));
assignListener(importTextCommandButton, ACTION_IMPORT_TEXT);
importXmlCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.import.xml")), View.getResizableIcon("importxml32"));
assignListener(importXmlCommandButton, ACTION_IMPORT_SWF_XML);
importBand.addCommandButton(importXmlCommandButton, RibbonElementPriority.TOP);
importBand.addCommandButton(importTextCommandButton, RibbonElementPriority.TOP);
importBand.addCommandButton(importTextCommandButton, RibbonElementPriority.TOP);
JRibbonBand viewBand = new JRibbonBand(translate("menu.view"), null);
viewBand.setResizePolicies(getResizePolicies(viewBand));
@@ -948,7 +948,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener
case ACTION_IMPORT_TEXT:
importText();
break;
case ACTION_EXPORT_SWF_XML:
mainFrame.getPanel().exportSwfXml();
break;
@@ -27,7 +27,6 @@ import com.jpexs.decompiler.flash.tags.text.TextAlign;
import com.jpexs.decompiler.flash.tags.text.TextParseException;
import com.jpexs.decompiler.flash.treeitems.TreeItem;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Insets;
@@ -124,74 +123,48 @@ public class TextPanel extends JPanel implements ActionListener {
JPanel textButtonsPanel = new JPanel();
textButtonsPanel.setLayout(new FlowLayout(SwingConstants.WEST));
textAlignLeftButton = new JButton("", View.getIcon("textalignleft16"));
textAlignLeftButton.setMargin(new Insets(3, 3, 3, 10));
textAlignLeftButton.setActionCommand(ACTION_TEXT_ALIGN_LEFT);
textAlignLeftButton.addActionListener(this);
textAlignLeftButton.setToolTipText(AppStrings.translate("text.align.left"));
textAlignLeftButton = createButton(null, "textalignleft16", ACTION_TEXT_ALIGN_LEFT, "text.align.left");
textAlignCenterButton = createButton(null, "textaligncenter16", ACTION_TEXT_ALIGN_CENTER, "text.align.center");
textAlignRightButton = createButton(null, "textalignright16", ACTION_TEXT_ALIGN_RIGHT, "text.align.right");
textAlignJustifyButton = createButton(null, "textalignjustify16", ACTION_TEXT_ALIGN_JUSTIFY, "text.align.justify");
undoChangesButton = createButton(null, "reload16", ACTION_UNDO_CHANGES, "text.undo");
textAlignCenterButton = new JButton("", View.getIcon("textaligncenter16"));
textAlignCenterButton.setMargin(new Insets(3, 3, 3, 10));
textAlignCenterButton.setActionCommand(ACTION_TEXT_ALIGN_CENTER);
textAlignCenterButton.addActionListener(this);
textAlignCenterButton.setToolTipText(AppStrings.translate("text.align.center"));
textAlignRightButton = new JButton("", View.getIcon("textalignright16"));
textAlignRightButton.setMargin(new Insets(3, 3, 3, 10));
textAlignRightButton.setActionCommand(ACTION_TEXT_ALIGN_RIGHT);
textAlignRightButton.addActionListener(this);
textAlignRightButton.setToolTipText(AppStrings.translate("text.align.right"));
textAlignJustifyButton = new JButton("", View.getIcon("textalignjustify16"));
textAlignJustifyButton.setMargin(new Insets(3, 3, 3, 10));
textAlignJustifyButton.setActionCommand(ACTION_TEXT_ALIGN_JUSTIFY);
textAlignJustifyButton.addActionListener(this);
textAlignJustifyButton.setToolTipText(AppStrings.translate("text.align.justify"));
undoChangesButton = new JButton("", View.getIcon("reload16"));
undoChangesButton.setMargin(new Insets(3, 3, 3, 10));
undoChangesButton.setActionCommand(ACTION_UNDO_CHANGES);
undoChangesButton.addActionListener(this);
undoChangesButton.setToolTipText(AppStrings.translate("text.undo"));
textButtonsPanel.add(textAlignLeftButton);
textButtonsPanel.add(textAlignCenterButton);
textButtonsPanel.add(textAlignRightButton);
textButtonsPanel.add(textAlignJustifyButton);
textButtonsPanel.add(undoChangesButton);
textButtonsPanel.setAlignmentX(0);
topPanel.add(textButtonsPanel);
add(topPanel,BorderLayout.NORTH);
add(topPanel, BorderLayout.NORTH);
JPanel buttonsPanel = new JPanel(new FlowLayout());
textSaveButton = new JButton(mainPanel.translate("button.save"), View.getIcon("save16"));
textSaveButton.setMargin(new Insets(3, 3, 3, 10));
textSaveButton.setActionCommand(ACTION_SAVE_TEXT);
textSaveButton.addActionListener(this);
textSaveButton = createButton("button.save", "save16", ACTION_SAVE_TEXT, null);
textEditButton = createButton("button.edit", "edit16", ACTION_EDIT_TEXT, null);
textCancelButton = createButton("button.cancel", "cancel16", ACTION_CANCEL_TEXT, null);
textEditButton = new JButton(mainPanel.translate("button.edit"), View.getIcon("edit16"));
textEditButton.setMargin(new Insets(3, 3, 3, 10));
textEditButton.setActionCommand(ACTION_EDIT_TEXT);
textEditButton.addActionListener(this);
textCancelButton = new JButton(mainPanel.translate("button.cancel"), View.getIcon("cancel16"));
textCancelButton.setMargin(new Insets(3, 3, 3, 10));
textCancelButton.setActionCommand(ACTION_CANCEL_TEXT);
textCancelButton.addActionListener(this);
textSaveButton.setVisible(false);
textCancelButton.setVisible(false);
buttonsPanel.add(textEditButton);
buttonsPanel.add(textSaveButton);
buttonsPanel.add(textCancelButton);
add(buttonsPanel,BorderLayout.SOUTH);
add(buttonsPanel, BorderLayout.SOUTH);
}
private JButton createButton(String textResource, String iconName, String command, String toolTipResource) {
String text = textResource == null ? "" : mainPanel.translate(textResource);
JButton button = new JButton(text, View.getIcon(iconName));
button.setMargin(new Insets(3, 3, 3, 10));
button.setActionCommand(command);
button.addActionListener(this);
if (toolTipResource != null) {
button.setToolTipText(mainPanel.translate(toolTipResource));
}
return button;
}
public SearchPanel<TextTag> getSearchPanel() {