/*
* Copyright (C) 2010-2013 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 .
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler;
import com.jpexs.decompiler.flash.ApplicationInfo;
import com.jpexs.decompiler.flash.FrameNode;
import com.jpexs.decompiler.flash.PackageNode;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.TagNode;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.RenameType;
import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.TraitClass;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.console.ContextMenuTools;
import com.jpexs.decompiler.flash.gui.abc.ABCPanel;
import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel;
import com.jpexs.decompiler.flash.gui.abc.DeobfuscationDialog;
import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane;
import com.jpexs.decompiler.flash.gui.abc.TreeElement;
import com.jpexs.decompiler.flash.gui.action.ActionPanel;
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
import com.jpexs.decompiler.flash.gui.player.PlayerControls;
import com.jpexs.decompiler.flash.helpers.Freed;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag;
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG3Tag;
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG4Tag;
import com.jpexs.decompiler.flash.tags.DefineBitsLossless2Tag;
import com.jpexs.decompiler.flash.tags.DefineBitsLosslessTag;
import com.jpexs.decompiler.flash.tags.DefineBitsTag;
import com.jpexs.decompiler.flash.tags.DefineButton2Tag;
import com.jpexs.decompiler.flash.tags.DefineButtonTag;
import com.jpexs.decompiler.flash.tags.DefineEditTextTag;
import com.jpexs.decompiler.flash.tags.DefineFont2Tag;
import com.jpexs.decompiler.flash.tags.DefineFont3Tag;
import com.jpexs.decompiler.flash.tags.DefineFont4Tag;
import com.jpexs.decompiler.flash.tags.DefineFontTag;
import com.jpexs.decompiler.flash.tags.DefineMorphShape2Tag;
import com.jpexs.decompiler.flash.tags.DefineMorphShapeTag;
import com.jpexs.decompiler.flash.tags.DefineShape2Tag;
import com.jpexs.decompiler.flash.tags.DefineShape3Tag;
import com.jpexs.decompiler.flash.tags.DefineShape4Tag;
import com.jpexs.decompiler.flash.tags.DefineShapeTag;
import com.jpexs.decompiler.flash.tags.DefineSoundTag;
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
import com.jpexs.decompiler.flash.tags.DefineText2Tag;
import com.jpexs.decompiler.flash.tags.DefineTextTag;
import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag;
import com.jpexs.decompiler.flash.tags.DoActionTag;
import com.jpexs.decompiler.flash.tags.EndTag;
import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
import com.jpexs.decompiler.flash.tags.JPEGTablesTag;
import com.jpexs.decompiler.flash.tags.PlaceObject2Tag;
import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag;
import com.jpexs.decompiler.flash.tags.ShowFrameTag;
import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag;
import com.jpexs.decompiler.flash.tags.SoundStreamHead2Tag;
import com.jpexs.decompiler.flash.tags.SoundStreamHeadTag;
import com.jpexs.decompiler.flash.tags.SymbolClassTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.VideoFrameTag;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.tags.base.AloneTag;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.Container;
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
import com.jpexs.decompiler.flash.tags.base.FontTag;
import com.jpexs.decompiler.flash.tags.base.ImageTag;
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
import com.jpexs.decompiler.flash.tags.base.TextTag;
import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont;
import com.jpexs.decompiler.flash.tags.text.ParseException;
import com.jpexs.decompiler.flash.types.GLYPHENTRY;
import com.jpexs.decompiler.flash.types.MATRIX;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.RGB;
import com.jpexs.decompiler.flash.types.TEXTRECORD;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.helpers.Cache;
import com.jpexs.helpers.CancellableWorker;
import com.jpexs.helpers.Helper;
import com.jpexs.process.ProcessTools;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragSource;
import java.awt.dnd.DragSourceDragEvent;
import java.awt.dnd.DragSourceDropEvent;
import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceListener;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowStateListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.Stack;
import java.util.Timer;
import java.util.TimerTask;
import java.util.TreeSet;
import java.util.concurrent.CancellationException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.filechooser.FileFilter;
import javax.swing.plaf.basic.BasicLabelUI;
import javax.swing.plaf.basic.BasicTreeUI;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import org.pushingpixels.flamingo.api.common.AbstractCommandButton;
import org.pushingpixels.flamingo.api.common.CommandButtonDisplayState;
import org.pushingpixels.flamingo.api.common.CommandButtonLayoutManager;
import org.pushingpixels.flamingo.api.common.JCommandButton;
import org.pushingpixels.flamingo.api.common.JCommandButton.CommandButtonKind;
import org.pushingpixels.flamingo.api.common.JCommandButtonPanel;
import org.pushingpixels.flamingo.api.common.icon.ResizableIcon;
import org.pushingpixels.flamingo.api.ribbon.JRibbon;
import org.pushingpixels.flamingo.api.ribbon.JRibbonBand;
import org.pushingpixels.flamingo.api.ribbon.JRibbonComponent;
import org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenu;
import org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenuEntryFooter;
import org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenuEntryPrimary;
import org.pushingpixels.flamingo.api.ribbon.RibbonElementPriority;
import org.pushingpixels.flamingo.api.ribbon.RibbonTask;
import org.pushingpixels.flamingo.api.ribbon.resize.BaseRibbonBandResizePolicy;
import org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies;
import org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy;
import org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy;
import org.pushingpixels.flamingo.internal.ui.ribbon.AbstractBandControlPanel;
import org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationMenuButton;
/**
*
* @author JPEXS
*/
public final class MainFrame extends AppRibbonFrame implements ActionListener, TreeSelectionListener, Freed {
private SWF swf;
public ABCPanel abcPanel;
public ActionPanel actionPanel;
public MainFrameStatusPanel statusPanel;
public JProgressBar progressBar = new JProgressBar(0, 100);
private DeobfuscationDialog deobfuscationDialog;
public JTree tagTree;
public FlashPlayerPanel flashPanel;
public JPanel displayPanel;
public ImagePanel imagePanel;
public ImagePanel previewImagePanel;
public SWFPreviwPanel swfPreviewPanel;
final static String CARDFLASHPANEL = "Flash card";
final static String CARDSWFPREVIEWPANEL = "SWF card";
final static String CARDDRAWPREVIEWPANEL = "Draw card";
final static String CARDIMAGEPANEL = "Image card";
final static String CARDEMPTYPANEL = "Empty card";
final static String CARDACTIONSCRIPTPANEL = "ActionScript card";
final static String DETAILCARDAS3NAVIGATOR = "Traits list";
final static String DETAILCARDEMPTYPANEL = "Empty card";
final static String CARDTEXTPANEL = "Text card";
final static String CARDFONTPANEL = "Font card";
private LineMarkedEditorPane textValue;
private JPEGTablesTag jtt;
private HashMap characters;
private List abcList;
JSplitPane splitPane1;
JSplitPane splitPane2;
private boolean splitsInited = false;
private JPanel detailPanel;
private JTextField filterField = new MyTextField("");
private JPanel searchPanel;
private JCheckBox miAutoDeobfuscation;
private JPanel displayWithPreview;
private JButton textSaveButton;
private JButton textEditButton;
private JButton textCancelButton;
private JPanel parametersPanel;
private JSplitPane previewSplitPane;
private JButton imageReplaceButton;
private JPanel imageButtonsPanel;
private JCheckBox miInternalViewer;
private JCheckBox miParallelSpeedUp;
private JCheckBox miAssociate;
private JCheckBox miDecompile;
private JCheckBox miCacheDisk;
private JCheckBox miGotoMainClassOnStartup;
private JLabel fontNameLabel;
private JLabel fontIsBoldLabel;
private JLabel fontIsItalicLabel;
private JLabel fontAscentLabel;
private JLabel fontDescentLabel;
private JLabel fontLeadingLabel;
private JTextArea fontCharactersTextArea;
private JTextField fontAddCharactersField;
private ComponentListener fontChangeList;
private JComboBox fontSelection;
private JCommandButton saveCommandButton;
private PlayerControls flashControls;
private ImagePanel internelViewerPanel;
private JPanel viewerCards;
public static final String FLASH_VIEWER_CARD = "FLASHVIEWER";
public static final String INTERNAL_VIEWER_CARD = "INTERNALVIEWER";
private Map sourceFontsMap = new HashMap<>();
private AbortRetryIgnoreHandler errorHandler = new GuiAbortRetryIgnoreHandler();
private CancellableWorker setSourceWorker;
static final String ACTION_FONT_EMBED = "FONTEMBED";
static final String ACTION_SELECT_COLOR = "SELECTCOLOR";
static final String ACTION_RELOAD = "RELOAD";
static final String ACTION_ADVANCED_SETTINGS = "ADVANCEDSETTINGS";
static final String ACTION_LOAD_MEMORY = "LOADMEMORY";
static final String ACTION_LOAD_CACHE = "LOADCACHE";
static final String ACTION_FONT_ADD_CHARS = "FONTADDCHARS";
static final String ACTION_GOTO_DOCUMENT_CLASS_ON_STARTUP = "GOTODOCUMENTCLASSONSTARTUP";
static final String ACTION_CACHE_ON_DISK = "CACHEONDISK";
static final String ACTION_SET_LANGUAGE = "SETLANGUAGE";
static final String ACTION_DISABLE_DECOMPILATION = "DISABLEDECOMPILATION";
static final String ACTION_ASSOCIATE = "ASSOCIATE";
static final String ACTION_GOTO_DOCUMENT_CLASS = "GOTODOCUMENTCLASS";
static final String ACTION_PARALLEL_SPEED_UP = "PARALLELSPEEDUP";
static final String ACTION_INTERNAL_VIEWER_SWITCH = "INTERNALVIEWERSWITCH";
static final String ACTION_SEARCH_AS = "SEARCHAS";
static final String ACTION_REPLACE_IMAGE = "REPLACEIMAGE";
static final String ACTION_REMOVE_ITEM = "REMOVEITEM";
static final String ACTION_EDIT_TEXT = "EDITTEXT";
static final String ACTION_CANCEL_TEXT = "CANCELTEXT";
static final String ACTION_SAVE_TEXT = "SAVETEXT";
static final String ACTION_AUTO_DEOBFUSCATE = "AUTODEOBFUSCATE";
static final String ACTION_EXIT = "EXIT";
static final String ACTION_RENAME_ONE_IDENTIFIER = "RENAMEONEIDENTIFIER";
static final String ACTION_ABOUT = "ABOUT";
static final String ACTION_SHOW_PROXY = "SHOWPROXY";
static final String ACTION_SUB_LIMITER = "SUBLIMITER";
static final String ACTION_SAVE = "SAVE";
static final String ACTION_SAVE_AS = "SAVEAS";
static final String ACTION_OPEN = "OPEN";
static final String ACTION_EXPORT_FLA = "EXPORTFLA";
static final String ACTION_EXPORT_SEL = "EXPORTSEL";
static final String ACTION_EXPORT = "EXPORT";
static final String ACTION_CHECK_UPDATES = "CHECKUPDATES";
static final String ACTION_HELP_US = "HELPUS";
static final String ACTION_HOMEPAGE = "HOMEPAGE";
static final String ACTION_RESTORE_CONTROL_FLOW = "RESTORECONTROLFLOW";
static final String ACTION_RESTORE_CONTROL_FLOW_ALL = "RESTORECONTROLFLOWALL";
static final String ACTION_RENAME_IDENTIFIERS = "RENAMEIDENTIFIERS";
static final String ACTION_DEOBFUSCATE = "DEOBFUSCATE";
static final String ACTION_DEOBFUSCATE_ALL = "DEOBFUSCATEALL";
static final String ACTION_REMOVE_NON_SCRIPTS = "REMOVENONSCRIPTS";
static final String ACTION_REFRESH_DECOMPILED = "REFRESHDECOMPILED";
public void setPercent(int percent) {
progressBar.setValue(percent);
progressBar.setVisible(true);
}
public void hidePercent() {
if (progressBar.isVisible()) {
progressBar.setVisible(false);
}
}
static {
try {
File.createTempFile("temp", ".swf").delete(); //First call to this is slow, so make it first
} catch (IOException ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
}
}
private static void addTab(JTabbedPane tabbedPane, Component tab, String title, Icon icon) {
tabbedPane.add(tab);
JLabel lbl = new JLabel(title);
lbl.setIcon(icon);
lbl.setIconTextGap(5);
lbl.setHorizontalTextPosition(SwingConstants.RIGHT);
tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1, lbl);
}
public void setStatus(String s) {
statusPanel.setStatus(s);
}
public void setWorkStatus(String s, CancellableWorker worker) {
statusPanel.setWorkStatus(s, worker);
}
private String fixCommandTitle(String title) {
if (title.length() > 2) {
if (title.charAt(1) == ' ') {
title = title.charAt(0) + "\u00A0" + title.substring(2);
}
}
return title;
}
private void assignListener(JCheckBox b, final String command) {
b.setActionCommand(command);
b.addActionListener(this);
}
private void assignListener(JCommandButton b, final String command) {
final MainFrame t = this;
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
t.actionPerformed(new ActionEvent(e.getSource(), 0, command));
}
});
}
private RibbonApplicationMenu createMainMenu(boolean swfLoaded) {
RibbonApplicationMenu mainMenu = new RibbonApplicationMenu();
RibbonApplicationMenuEntryPrimary exportFlaMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("exportfla32"), translate("menu.file.export.fla"), new ActionRedirector(this, "EXPORTFLA"), CommandButtonKind.ACTION_ONLY);
RibbonApplicationMenuEntryPrimary exportAllMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("export32"), translate("menu.file.export.all"), new ActionRedirector(this, "EXPORT"), CommandButtonKind.ACTION_ONLY);
RibbonApplicationMenuEntryPrimary exportSelMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("exportsel32"), translate("menu.file.export.selection"), new ActionRedirector(this, "EXPORTSEL"), CommandButtonKind.ACTION_ONLY);
RibbonApplicationMenuEntryPrimary checkUpdatesMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("update32"), translate("menu.help.checkupdates"), new ActionRedirector(this, "CHECKUPDATES"), CommandButtonKind.ACTION_ONLY);
RibbonApplicationMenuEntryPrimary aboutMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("about32"), translate("menu.help.about"), new ActionRedirector(this, "ABOUT"), CommandButtonKind.ACTION_ONLY);
RibbonApplicationMenuEntryPrimary openFileMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("open32"), translate("menu.file.open"), new ActionRedirector(this, "OPEN"), CommandButtonKind.ACTION_AND_POPUP_MAIN_ACTION);
openFileMenu.setRolloverCallback(new RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback() {
@Override
public void menuEntryActivated(JPanel targetPanel) {
targetPanel.removeAll();
JCommandButtonPanel openHistoryPanel = new JCommandButtonPanel(CommandButtonDisplayState.MEDIUM);
String groupName = translate("menu.recentFiles");
openHistoryPanel.addButtonGroup(groupName);
List recentFiles = Configuration.getRecentFiles();
int j = 0;
for (int i = recentFiles.size() - 1; i >= 0; i--) {
String path = recentFiles.get(i);
RecentFilesButton historyButton = new RecentFilesButton(j + " " + path, null);
historyButton.fileName = path;
historyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
RecentFilesButton source = (RecentFilesButton) ae.getSource();
if (Main.openFile(source.fileName) == OpenFileResult.NOT_FOUND) {
if (View.showConfirmDialog(null, translate("message.confirm.recentFileNotFound"), translate("message.confirm"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_NO_OPTION) {
Configuration.removeRecentFile(source.fileName);
}
}
}
});
j++;
historyButton.setHorizontalAlignment(SwingUtilities.LEFT);
openHistoryPanel.addButtonToLastGroup(historyButton);
}
openHistoryPanel.setMaxButtonColumns(1);
targetPanel.setLayout(new BorderLayout());
targetPanel.add(openHistoryPanel, BorderLayout.CENTER);
}
});
RibbonApplicationMenuEntryFooter exitMenu = new RibbonApplicationMenuEntryFooter(View.getResizableIcon("exit32"), translate("menu.file.exit"), new ActionRedirector(this, "EXIT"));
mainMenu.addMenuEntry(openFileMenu);
mainMenu.addMenuSeparator();
mainMenu.addMenuEntry(exportFlaMenu);
mainMenu.addMenuEntry(exportAllMenu);
mainMenu.addMenuEntry(exportSelMenu);
mainMenu.addMenuSeparator();
mainMenu.addMenuEntry(checkUpdatesMenu);
mainMenu.addMenuEntry(aboutMenu);
mainMenu.addFooterEntry(exitMenu);
mainMenu.addMenuSeparator();
if (!swfLoaded) {
exportAllMenu.setEnabled(false);
exportFlaMenu.setEnabled(false);
exportSelMenu.setEnabled(false);
}
return mainMenu;
}
private List getResizePolicies(JRibbonBand ribbonBand) {
List resizePolicies = new ArrayList<>();
resizePolicies.add(new CoreRibbonResizePolicies.Mirror(ribbonBand.getControlPanel()));
resizePolicies.add(new IconRibbonBandResizePolicy(ribbonBand.getControlPanel()));
return resizePolicies;
}
private RibbonTask createFileRibbonTask(boolean swfLoaded) {
JRibbonBand editBand = new JRibbonBand(translate("menu.general"), null);
editBand.setResizePolicies(getResizePolicies(editBand));
JCommandButton openCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.open")), View.getResizableIcon("open32"));
assignListener(openCommandButton, ACTION_OPEN);
saveCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.save")), View.getResizableIcon("save32"));
assignListener(saveCommandButton, ACTION_SAVE);
JCommandButton saveasCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.saveas")), View.getResizableIcon("saveas16"));
assignListener(saveasCommandButton, ACTION_SAVE_AS);
JCommandButton reloadCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.reload")), View.getResizableIcon("reload16"));
assignListener(reloadCommandButton, ACTION_RELOAD);
editBand.addCommandButton(openCommandButton, RibbonElementPriority.TOP);
editBand.addCommandButton(saveCommandButton, RibbonElementPriority.TOP);
editBand.addCommandButton(saveasCommandButton, RibbonElementPriority.MEDIUM);
editBand.addCommandButton(reloadCommandButton, RibbonElementPriority.MEDIUM);
saveCommandButton.setEnabled(!Main.readOnly);
JRibbonBand exportBand = new JRibbonBand(translate("menu.export"), null);
exportBand.setResizePolicies(getResizePolicies(exportBand));
JCommandButton exportFlaCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.export.fla")), View.getResizableIcon("exportfla32"));
assignListener(exportFlaCommandButton, ACTION_EXPORT_FLA);
JCommandButton exportAllCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.export.all")), View.getResizableIcon("export16"));
assignListener(exportAllCommandButton, ACTION_EXPORT);
JCommandButton exportSelectionCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.export.selection")), View.getResizableIcon("exportsel16"));
assignListener(exportSelectionCommandButton, ACTION_EXPORT_SEL);
exportBand.addCommandButton(exportFlaCommandButton, RibbonElementPriority.TOP);
exportBand.addCommandButton(exportAllCommandButton, RibbonElementPriority.MEDIUM);
exportBand.addCommandButton(exportSelectionCommandButton, RibbonElementPriority.MEDIUM);
if (!swfLoaded) {
saveasCommandButton.setEnabled(false);
exportAllCommandButton.setEnabled(false);
exportFlaCommandButton.setEnabled(false);
exportSelectionCommandButton.setEnabled(false);
reloadCommandButton.setEnabled(false);
}
return new RibbonTask(translate("menu.file"), editBand, exportBand);
}
private RibbonTask createToolsRibbonTask(boolean swfLoaded, boolean hasAbc) {
//----------------------------------------- TOOLS -----------------------------------
JRibbonBand toolsBand = new JRibbonBand(translate("menu.tools"), null);
toolsBand.setResizePolicies(getResizePolicies(toolsBand));
JCommandButton searchCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.searchas")), View.getResizableIcon("search32"));
assignListener(searchCommandButton, ACTION_SEARCH_AS);
JCommandButton gotoDocumentClassCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.gotodocumentclass")), View.getResizableIcon("gotomainclass32"));
assignListener(gotoDocumentClassCommandButton, ACTION_GOTO_DOCUMENT_CLASS);
JCommandButton proxyCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.proxy")), View.getResizableIcon("proxy16"));
assignListener(proxyCommandButton, ACTION_SHOW_PROXY);
JCommandButton loadMemoryCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.searchmemory")), View.getResizableIcon("loadmemory16"));
assignListener(loadMemoryCommandButton, ACTION_LOAD_MEMORY);
JCommandButton loadCacheCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.searchcache")), View.getResizableIcon("loadcache16"));
assignListener(loadCacheCommandButton, ACTION_LOAD_CACHE);
toolsBand.addCommandButton(searchCommandButton, RibbonElementPriority.TOP);
toolsBand.addCommandButton(gotoDocumentClassCommandButton, RibbonElementPriority.TOP);
toolsBand.addCommandButton(proxyCommandButton, RibbonElementPriority.MEDIUM);
toolsBand.addCommandButton(loadMemoryCommandButton, RibbonElementPriority.MEDIUM);
toolsBand.addCommandButton(loadCacheCommandButton, RibbonElementPriority.MEDIUM);
if (!ProcessTools.toolsAvailable()) {
loadMemoryCommandButton.setEnabled(false);
}
JRibbonBand deobfuscationBand = new JRibbonBand(translate("menu.tools.deobfuscation"), null);
deobfuscationBand.setResizePolicies(getResizePolicies(deobfuscationBand));
JCommandButton deobfuscationCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.deobfuscation.pcode")), View.getResizableIcon("deobfuscate32"));
assignListener(deobfuscationCommandButton, ACTION_DEOBFUSCATE);
JCommandButton globalrenameCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.deobfuscation.globalrename")), View.getResizableIcon("rename16"));
assignListener(globalrenameCommandButton, ACTION_RENAME_ONE_IDENTIFIER);
JCommandButton renameinvalidCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.deobfuscation.renameinvalid")), View.getResizableIcon("renameall16"));
assignListener(renameinvalidCommandButton, ACTION_RENAME_IDENTIFIERS);
deobfuscationBand.addCommandButton(deobfuscationCommandButton, RibbonElementPriority.TOP);
deobfuscationBand.addCommandButton(globalrenameCommandButton, RibbonElementPriority.MEDIUM);
deobfuscationBand.addCommandButton(renameinvalidCommandButton, RibbonElementPriority.MEDIUM);
if (!swfLoaded) {
renameinvalidCommandButton.setEnabled(false);
globalrenameCommandButton.setEnabled(false);
saveCommandButton.setEnabled(false);
deobfuscationCommandButton.setEnabled(false);
searchCommandButton.setEnabled(false);
}
if (!hasAbc) {
gotoDocumentClassCommandButton.setEnabled(false);
deobfuscationCommandButton.setEnabled(false);
//miDeobfuscation.setEnabled(false);
}
return new RibbonTask(translate("menu.tools"), toolsBand, deobfuscationBand);
}
private RibbonTask createSettingsRibbonTask() {
//----------------------------------------- SETTINGS -----------------------------------
JRibbonBand settingsBand = new JRibbonBand(translate("menu.settings"), null);
settingsBand.setResizePolicies(getResizePolicies(settingsBand));
miAutoDeobfuscation = new JCheckBox(translate("menu.settings.autodeobfuscation"));
miInternalViewer = new JCheckBox(translate("menu.settings.internalflashviewer"));
miParallelSpeedUp = new JCheckBox(translate("menu.settings.parallelspeedup"));
miDecompile = new JCheckBox(translate("menu.settings.disabledecompilation"));
miAssociate = new JCheckBox(translate("menu.settings.addtocontextmenu"));
miCacheDisk = new JCheckBox(translate("menu.settings.cacheOnDisk"));
miGotoMainClassOnStartup = new JCheckBox(translate("menu.settings.gotoMainClassOnStartup"));
settingsBand.addRibbonComponent(new JRibbonComponent(miAutoDeobfuscation));
settingsBand.addRibbonComponent(new JRibbonComponent(miInternalViewer));
settingsBand.addRibbonComponent(new JRibbonComponent(miParallelSpeedUp));
settingsBand.addRibbonComponent(new JRibbonComponent(miDecompile));
settingsBand.addRibbonComponent(new JRibbonComponent(miAssociate));
settingsBand.addRibbonComponent(new JRibbonComponent(miCacheDisk));
settingsBand.addRibbonComponent(new JRibbonComponent(miGotoMainClassOnStartup));
JRibbonBand languageBand = new JRibbonBand(translate("menu.language"), null);
List languageBandResizePolicies = new ArrayList<>();
languageBandResizePolicies.add(new BaseRibbonBandResizePolicy(languageBand.getControlPanel()) {
@Override
public int getPreferredWidth(int i, int i1) {
return 105;
}
@Override
public void install(int i, int i1) {
}
});
languageBandResizePolicies.add(new IconRibbonBandResizePolicy(languageBand.getControlPanel()));
languageBand.setResizePolicies(languageBandResizePolicies);
JCommandButton setLanguageCommandButton = new JCommandButton(fixCommandTitle(translate("menu.settings.language")), View.getResizableIcon("setlanguage32"));
assignListener(setLanguageCommandButton, ACTION_SET_LANGUAGE);
languageBand.addCommandButton(setLanguageCommandButton, RibbonElementPriority.TOP);
JRibbonBand advancedSettingsBand = new JRibbonBand(translate("menu.advancedsettings.advancedsettings"), null);
advancedSettingsBand.setResizePolicies(getResizePolicies(advancedSettingsBand));
JCommandButton advancedSettingsCommandButton = new JCommandButton(fixCommandTitle(translate("menu.advancedsettings.advancedsettings")), View.getResizableIcon("settings16"));
assignListener(advancedSettingsCommandButton, ACTION_ADVANCED_SETTINGS);
advancedSettingsBand.addCommandButton(advancedSettingsCommandButton, RibbonElementPriority.MEDIUM);
return new RibbonTask(translate("menu.settings"), settingsBand, languageBand, advancedSettingsBand);
}
private RibbonTask createHelpRibbonTask() {
//----------------------------------------- HELP -----------------------------------
JRibbonBand helpBand = new JRibbonBand(translate("menu.help"), null);
helpBand.setResizePolicies(getResizePolicies(helpBand));
JCommandButton checkForUpdatesCommandButton = new JCommandButton(fixCommandTitle(translate("menu.help.checkupdates")), View.getResizableIcon("update16"));
assignListener(checkForUpdatesCommandButton, ACTION_CHECK_UPDATES);
JCommandButton helpUsUpdatesCommandButton = new JCommandButton(fixCommandTitle(translate("menu.help.helpus")), View.getResizableIcon("donate32"));
assignListener(helpUsUpdatesCommandButton, ACTION_HELP_US);
JCommandButton homepageCommandButton = new JCommandButton(fixCommandTitle(translate("menu.help.homepage")), View.getResizableIcon("homepage16"));
assignListener(homepageCommandButton, ACTION_HOMEPAGE);
JCommandButton aboutCommandButton = new JCommandButton(fixCommandTitle(translate("menu.help.about")), View.getResizableIcon("about32"));
assignListener(aboutCommandButton, ACTION_ABOUT);
helpBand.addCommandButton(aboutCommandButton, RibbonElementPriority.TOP);
helpBand.addCommandButton(checkForUpdatesCommandButton, RibbonElementPriority.MEDIUM);
helpBand.addCommandButton(homepageCommandButton, RibbonElementPriority.MEDIUM);
helpBand.addCommandButton(helpUsUpdatesCommandButton, RibbonElementPriority.TOP);
return new RibbonTask(translate("menu.help"), helpBand);
}
private RibbonTask createDebugRibbonTask() {
//----------------------------------------- DEBUG -----------------------------------
JRibbonBand debugBand = new JRibbonBand("Debug", null);
debugBand.setResizePolicies(getResizePolicies(debugBand));
JCommandButton removeNonScriptsCommandButton = new JCommandButton(fixCommandTitle("Remove non scripts"), View.getResizableIcon("update16"));
assignListener(removeNonScriptsCommandButton, ACTION_REMOVE_NON_SCRIPTS);
JCommandButton refreshDecompiledCommandButton = new JCommandButton(fixCommandTitle("Refresh decompiled script"), View.getResizableIcon("update16"));
assignListener(refreshDecompiledCommandButton, ACTION_REFRESH_DECOMPILED);
debugBand.addCommandButton(removeNonScriptsCommandButton, RibbonElementPriority.MEDIUM);
debugBand.addCommandButton(refreshDecompiledCommandButton, RibbonElementPriority.MEDIUM);
return new RibbonTask("Debug", debugBand);
}
// not used
private void createMenuBar(boolean hasAbc) {
JMenuBar menuBar = new JMenuBar();
JMenu menuFile = new JMenu(translate("menu.file"));
JMenuItem miOpen = new JMenuItem(translate("menu.file.open"));
miOpen.setIcon(View.getIcon("open16"));
miOpen.setActionCommand(ACTION_OPEN);
miOpen.addActionListener(this);
JMenuItem miSave = new JMenuItem(translate("menu.file.save"));
miSave.setIcon(View.getIcon("save16"));
miSave.setActionCommand(ACTION_SAVE);
miSave.addActionListener(this);
JMenuItem miSaveAs = new JMenuItem(translate("menu.file.saveas"));
miSaveAs.setIcon(View.getIcon("saveas16"));
miSaveAs.setActionCommand(ACTION_SAVE_AS);
miSaveAs.addActionListener(this);
JMenuItem menuExportFla = new JMenuItem(translate("menu.file.export.fla"));
menuExportFla.setActionCommand(ACTION_EXPORT_FLA);
menuExportFla.addActionListener(this);
menuExportFla.setIcon(View.getIcon("flash16"));
JMenuItem menuExportAll = new JMenuItem(translate("menu.file.export.all"));
menuExportAll.setActionCommand(ACTION_EXPORT);
menuExportAll.addActionListener(this);
JMenuItem menuExportSel = new JMenuItem(translate("menu.file.export.selection"));
menuExportSel.setActionCommand(ACTION_EXPORT_SEL);
menuExportSel.addActionListener(this);
menuExportAll.setIcon(View.getIcon("export16"));
menuExportSel.setIcon(View.getIcon("exportsel16"));
menuFile.add(miOpen);
menuFile.add(miSave);
menuFile.add(miSaveAs);
menuFile.add(menuExportFla);
menuFile.add(menuExportAll);
menuFile.add(menuExportSel);
menuFile.addSeparator();
JMenuItem miClose = new JMenuItem(translate("menu.file.exit"));
miClose.setIcon(View.getIcon("exit16"));
miClose.setActionCommand(ACTION_EXIT);
miClose.addActionListener(this);
menuFile.add(miClose);
menuBar.add(menuFile);
JMenu menuDeobfuscation = new JMenu(translate("menu.tools.deobfuscation"));
menuDeobfuscation.setIcon(View.getIcon("deobfuscate16"));
JMenuItem miDeobfuscation = new JMenuItem(translate("menu.tools.deobfuscation.pcode"));
miDeobfuscation.setActionCommand(ACTION_DEOBFUSCATE);
miDeobfuscation.addActionListener(this);
miAutoDeobfuscation.setSelected(Configuration.autoDeobfuscate.get());
miAutoDeobfuscation.addActionListener(this);
miAutoDeobfuscation.setActionCommand(ACTION_AUTO_DEOBFUSCATE);
JMenuItem miRenameOneIdentifier = new JMenuItem(translate("menu.tools.deobfuscation.globalrename"));
miRenameOneIdentifier.setActionCommand(ACTION_RENAME_ONE_IDENTIFIER);
miRenameOneIdentifier.addActionListener(this);
JMenuItem miRenameIdentifiers = new JMenuItem(translate("menu.tools.deobfuscation.renameinvalid"));
miRenameIdentifiers.setActionCommand(ACTION_RENAME_IDENTIFIERS);
miRenameIdentifiers.addActionListener(this);
menuDeobfuscation.add(miRenameOneIdentifier);
menuDeobfuscation.add(miRenameIdentifiers);
menuDeobfuscation.add(miDeobfuscation);
JMenu menuTools = new JMenu(translate("menu.tools"));
JMenuItem miProxy = new JMenuItem(translate("menu.tools.proxy"));
miProxy.setActionCommand(ACTION_SHOW_PROXY);
miProxy.setIcon(View.getIcon("proxy16"));
miProxy.addActionListener(this);
JMenuItem miSearchScript = new JMenuItem(translate("menu.tools.searchas"));
miSearchScript.addActionListener(this);
miSearchScript.setActionCommand(ACTION_SEARCH_AS);
miSearchScript.setIcon(View.getIcon("search16"));
menuTools.add(miSearchScript);
boolean externalFlashPlayerUnavailable = flashPanel == null;
miInternalViewer.setSelected(Configuration.internalFlashViewer.get() || externalFlashPlayerUnavailable);
if (externalFlashPlayerUnavailable) {
miInternalViewer.setEnabled(false);
}
miInternalViewer.setActionCommand(ACTION_INTERNAL_VIEWER_SWITCH);
miInternalViewer.addActionListener(this);
miParallelSpeedUp.setSelected(Configuration.parallelSpeedUp.get());
miParallelSpeedUp.setActionCommand(ACTION_PARALLEL_SPEED_UP);
miParallelSpeedUp.addActionListener(this);
menuTools.add(miProxy);
menuTools.add(menuDeobfuscation);
JMenuItem miGotoDocumentClass = new JMenuItem(translate("menu.tools.gotodocumentclass"));
miGotoDocumentClass.setActionCommand(ACTION_GOTO_DOCUMENT_CLASS);
miGotoDocumentClass.addActionListener(this);
menuBar.add(menuTools);
miDecompile.setSelected(!Configuration.decompile.get());
miDecompile.setActionCommand(ACTION_DISABLE_DECOMPILATION);
miDecompile.addActionListener(this);
miCacheDisk.setSelected(Configuration.cacheOnDisk.get());
miCacheDisk.setActionCommand(ACTION_CACHE_ON_DISK);
miCacheDisk.addActionListener(this);
miGotoMainClassOnStartup.setSelected(Configuration.gotoMainClassOnStartup.get());
miGotoMainClassOnStartup.setActionCommand(ACTION_GOTO_DOCUMENT_CLASS_ON_STARTUP);
miGotoMainClassOnStartup.addActionListener(this);
/*JMenu menuSettings = new JMenu(translate("menu.settings"));
menuSettings.add(autoDeobfuscateMenuItem);
menuSettings.add(miInternalViewer);
menuSettings.add(miParallelSpeedUp);
menuSettings.add(miDecompile);
menuSettings.add(miCacheDisk);
menuSettings.add(miGotoMainClassOnStartup);*/
miAssociate.setActionCommand(ACTION_ASSOCIATE);
miAssociate.addActionListener(this);
miAssociate.setSelected(ContextMenuTools.isAddedToContextMenu());
JMenuItem miLanguage = new JMenuItem(translate("menu.settings.language"));
miLanguage.setActionCommand(ACTION_SET_LANGUAGE);
miLanguage.addActionListener(this);
/* if (Platform.isWindows()) {
menuSettings.add(miAssociate);
}
menuSettings.add(miLanguage);
menuBar.add(menuSettings);*/
JMenu menuHelp = new JMenu(translate("menu.help"));
JMenuItem miAbout = new JMenuItem(translate("menu.help.about"));
miAbout.setIcon(View.getIcon("about16"));
miAbout.setActionCommand(ACTION_ABOUT);
miAbout.addActionListener(this);
JMenuItem miCheckUpdates = new JMenuItem(translate("menu.help.checkupdates"));
miCheckUpdates.setActionCommand(ACTION_CHECK_UPDATES);
miCheckUpdates.setIcon(View.getIcon("update16"));
miCheckUpdates.addActionListener(this);
JMenuItem miHelpUs = new JMenuItem(translate("menu.help.helpus"));
miHelpUs.setActionCommand(ACTION_HELP_US);
miHelpUs.setIcon(View.getIcon("donate16"));
miHelpUs.addActionListener(this);
JMenuItem miHomepage = new JMenuItem(translate("menu.help.homepage"));
miHomepage.setActionCommand(ACTION_HOMEPAGE);
miHomepage.setIcon(View.getIcon("homepage16"));
miHomepage.addActionListener(this);
menuHelp.add(miCheckUpdates);
menuHelp.add(miHelpUs);
menuHelp.add(miHomepage);
menuHelp.add(miAbout);
menuBar.add(menuHelp);
//setJMenuBar(menuBar);
if (hasAbc) {
menuTools.add(miGotoDocumentClass);
}
}
private void createContextMenu() {
final JPopupMenu contextPopupMenu = new JPopupMenu();
final JMenuItem removeMenuItem = new JMenuItem(translate("contextmenu.remove"));
removeMenuItem.addActionListener(this);
removeMenuItem.setActionCommand(ACTION_REMOVE_ITEM);
JMenuItem exportSelectionMenuItem = new JMenuItem(translate("menu.file.export.selection"));
exportSelectionMenuItem.setActionCommand(ACTION_EXPORT_SEL);
exportSelectionMenuItem.addActionListener(this);
contextPopupMenu.add(exportSelectionMenuItem);
contextPopupMenu.add(removeMenuItem);
tagTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
int row = tagTree.getClosestRowForLocation(e.getX(), e.getY());
int[] selectionRows = tagTree.getSelectionRows();
if (!Helper.contains(selectionRows, row)) {
tagTree.setSelectionRow(row);
}
TreePath[] paths = tagTree.getSelectionPaths();
if (paths == null || paths.length == 0) {
return;
}
boolean allSelectedIsTag = true;
for (TreePath treePath : paths) {
Object tagObj = treePath.getLastPathComponent();
if (tagObj instanceof TagNode) {
Object tag = ((TagNode) tagObj).tag;
if (!(tag instanceof Tag)) {
allSelectedIsTag = false;
break;
}
}
}
removeMenuItem.setVisible(allSelectedIsTag);
contextPopupMenu.show(e.getComponent(), e.getX(), e.getY());
}
}
});
}
private JPanel createWelcomePanel() {
JPanel welcomePanel = new JPanel();
welcomePanel.setLayout(new BoxLayout(welcomePanel, BoxLayout.Y_AXIS));
JLabel welcomeToLabel = new JLabel(translate("startup.welcometo"));
welcomeToLabel.setFont(welcomeToLabel.getFont().deriveFont(40));
welcomeToLabel.setAlignmentX(0.5f);
JPanel appNamePanel = new JPanel(new FlowLayout());
JLabel jpLabel = new JLabel("JPEXS ");
jpLabel.setAlignmentX(0.5f);
jpLabel.setForeground(new Color(0, 0, 160));
jpLabel.setFont(new Font("Tahoma", Font.BOLD, 50));
jpLabel.setHorizontalAlignment(SwingConstants.CENTER);
appNamePanel.add(jpLabel);
JLabel ffLabel = new JLabel("Free Flash ");
ffLabel.setAlignmentX(0.5f);
ffLabel.setFont(new Font("Tahoma", Font.BOLD, 50));
ffLabel.setHorizontalAlignment(SwingConstants.CENTER);
appNamePanel.add(ffLabel);
JLabel decLabel = new JLabel("Decompiler");
decLabel.setAlignmentX(0.5f);
decLabel.setForeground(Color.red);
decLabel.setFont(new Font("Tahoma", Font.BOLD, 50));
decLabel.setHorizontalAlignment(SwingConstants.CENTER);
appNamePanel.add(decLabel);
appNamePanel.setAlignmentX(0.5f);
welcomePanel.add(Box.createGlue());
welcomePanel.add(welcomeToLabel);
welcomePanel.add(appNamePanel);
JLabel startLabel = new JLabel(translate("startup.selectopen"));
startLabel.setAlignmentX(0.5f);
startLabel.setFont(startLabel.getFont().deriveFont(30));
welcomePanel.add(startLabel);
welcomePanel.add(Box.createGlue());
return welcomePanel;
}
private JPanel createImagesCard() {
JPanel imagesCard = new JPanel(new BorderLayout());
imagePanel = new ImagePanel();
imagesCard.add(imagePanel, BorderLayout.CENTER);
imageReplaceButton = new JButton(translate("button.replace"), View.getIcon("edit16"));
imageReplaceButton.setMargin(new Insets(3, 3, 3, 10));
imageReplaceButton.setActionCommand(ACTION_REPLACE_IMAGE);
imageReplaceButton.addActionListener(this);
imageButtonsPanel = new JPanel(new FlowLayout());
imageButtonsPanel.add(imageReplaceButton);
imagesCard.add(imageButtonsPanel, BorderLayout.SOUTH);
return imagesCard;
}
public MainFrame(SWF swf) {
super();
List objs = new ArrayList<>();
if (swf != null) {
objs.addAll(swf.tags);
}
abcList = new ArrayList<>();
getActionScript3(objs, abcList);
JRibbon rib = getRibbon();
rib.addTask(createFileRibbonTask(swf != null));
rib.addTask(createToolsRibbonTask(swf != null, !abcList.isEmpty()));
rib.addTask(createSettingsRibbonTask());
rib.addTask(createHelpRibbonTask());
if (Configuration.debugMode.get()) {
rib.addTask(createDebugRibbonTask());
}
rib.setApplicationMenu(createMainMenu(swf != null));
int w = Configuration.guiWindowWidth.get();
int h = Configuration.guiWindowHeight.get();
Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
if (w > dim.width) {
w = dim.width;
}
if (h > dim.height) {
h = dim.height;
}
setSize(w, h);
boolean maximizedHorizontal = Configuration.guiWindowMaximizedHorizontal.get();
boolean maximizedVertical = Configuration.guiWindowMaximizedVertical.get();
int state = 0;
if (maximizedHorizontal) {
state |= JFrame.MAXIMIZED_HORIZ;
}
if (maximizedVertical) {
state |= JFrame.MAXIMIZED_VERT;
}
setExtendedState(state);
View.setWindowIcon(this);
addWindowStateListener(new WindowStateListener() {
@Override
public void windowStateChanged(WindowEvent e) {
int state = e.getNewState();
Configuration.guiWindowMaximizedHorizontal.set((state & JFrame.MAXIMIZED_HORIZ) == JFrame.MAXIMIZED_HORIZ);
Configuration.guiWindowMaximizedVertical.set((state & JFrame.MAXIMIZED_VERT) == JFrame.MAXIMIZED_VERT);
}
});
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
int state = getExtendedState();
if ((state & JFrame.MAXIMIZED_HORIZ) == 0) {
Configuration.guiWindowWidth.set(getWidth());
}
if ((state & JFrame.MAXIMIZED_VERT) == 0) {
Configuration.guiWindowHeight.set(getHeight());
}
}
});
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
if (Main.proxyFrame != null) {
if (Main.proxyFrame.isVisible()) {
return;
}
}
if (Main.loadFromMemoryFrame != null) {
if (Main.loadFromMemoryFrame.isVisible()) {
return;
}
}
if (Main.loadFromCacheFrame != null) {
if (Main.loadFromCacheFrame.isVisible()) {
return;
}
}
Main.exit();
}
});
setTitle(ApplicationInfo.applicationVerName + ((swf != null && Configuration.displayFileName.get()) ? " - " + Main.getFileTitle() : ""));
try {
flashPanel = new FlashPlayerPanel(this);
} catch (FlashUnsupportedException fue) {
}
createMenuBar(!abcList.isEmpty());
this.swf = swf;
java.awt.Container cnt = getContentPane();
cnt.setLayout(new BorderLayout());
cnt.add(getRibbon(), BorderLayout.NORTH);
detailPanel = new JPanel();
detailPanel.setLayout(new CardLayout());
JPanel whitePanel = new JPanel();
whitePanel.setBackground(Color.white);
detailPanel.add(whitePanel, DETAILCARDEMPTYPANEL);
CardLayout cl2 = (CardLayout) (detailPanel.getLayout());
cl2.show(detailPanel, DETAILCARDEMPTYPANEL);
if (!abcList.isEmpty()) {
abcPanel = new ABCPanel(abcList, swf);
detailPanel.add(abcPanel.tabbedPane, DETAILCARDAS3NAVIGATOR);
} else {
actionPanel = new ActionPanel();
}
UIManager.getDefaults().put("TreeUI", BasicTreeUI.class.getName());
if (swf == null) {
tagTree = new JTree((TreeModel) null);
} else {
tagTree = new JTree(new TagTreeModel(createTagList(objs, null), new SWFRoot((new File(Main.file)).getName())));
}
tagTree.addTreeSelectionListener(this);
tagTree.setBackground(Color.white);
tagTree.setUI(new BasicTreeUI() {
@Override
public void paint(Graphics g, JComponent c) {
setHashColor(Color.gray);
super.paint(g, c);
}
});
DragSource dragSource = DragSource.getDefaultDragSource();
dragSource.createDefaultDragGestureRecognizer(tagTree, DnDConstants.ACTION_COPY_OR_MOVE, new DragGestureListener() {
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
dge.startDrag(DragSource.DefaultCopyDrop, new Transferable() {
@Override
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[]{DataFlavor.javaFileListFlavor};
}
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavor.equals(DataFlavor.javaFileListFlavor);
}
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (flavor.equals(DataFlavor.javaFileListFlavor)) {
List files = new ArrayList<>();
String tempDir = System.getProperty("java.io.tmpdir");
if (!tempDir.endsWith(File.separator)) {
tempDir += File.separator;
}
Random rnd = new Random();
tempDir += "ffdec" + File.separator + "export" + File.separator + System.currentTimeMillis() + "_" + rnd.nextInt(1000);
File fTempDir = new File(tempDir);
if (!fTempDir.exists()) {
if (!fTempDir.mkdirs()) {
if (!fTempDir.exists()) {
throw new IOException("cannot create directory " + fTempDir);
}
}
}
final ExportDialog export = new ExportDialog();
try {
File ftemp = new File(tempDir);
files = exportSelection(errorHandler, tempDir, export);
files.clear();
File[] fs = ftemp.listFiles();
files.addAll(Arrays.asList(fs));
Main.stopWork();
} catch (IOException ex) {
return null;
}
for (File f : files) {
f.deleteOnExit();
}
new File(tempDir).deleteOnExit();
return files;
}
return null;
}
}, new DragSourceListener() {
@Override
public void dragEnter(DragSourceDragEvent dsde) {
enableDrop(false);
}
@Override
public void dragOver(DragSourceDragEvent dsde) {
}
@Override
public void dropActionChanged(DragSourceDragEvent dsde) {
}
@Override
public void dragExit(DragSourceEvent dse) {
}
@Override
public void dragDropEnd(DragSourceDropEvent dsde) {
enableDrop(true);
}
});
}
});
createContextMenu();
TreeCellRenderer tcr = new DefaultTreeCellRenderer() {
@Override
public Component getTreeCellRendererComponent(
JTree tree,
Object value,
boolean sel,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
super.getTreeCellRendererComponent(
tree, value, sel,
expanded, leaf, row,
hasFocus);
Object val = value;
if (val instanceof TagNode) {
val = ((TagNode) val).tag;
}
String type = getTagType(val);
if (row == 0) {
setIcon(View.getIcon("flash16"));
} else if (type != null) {
if (type.equals("folder") && expanded) {
type = "folderopen";
}
setIcon(View.getIcon(type + "16"));
//setToolTipText("This book is in the Tutorial series.");
} else {
//setToolTipText(null); //no tool tip
}
String tos = value.toString();
int sw = getFontMetrics(getFont()).stringWidth(tos);
setPreferredSize(new Dimension(18 + sw, getPreferredSize().height));
setUI(new BasicLabelUI());
setOpaque(false);
//setBackground(Color.green);
setBackgroundNonSelectionColor(Color.white);
//setBackgroundSelectionColor(Color.ORANGE);
return this;
}
};
tagTree.setCellRenderer(tcr);
statusPanel = new MainFrameStatusPanel(this);
cnt.add(statusPanel, BorderLayout.SOUTH);
if (swf != null) {
for (Tag t : swf.tags) {
if (t instanceof JPEGTablesTag) {
jtt = (JPEGTablesTag) t;
}
}
}
characters = new HashMap<>();
List list2 = new ArrayList<>();
if (swf != null) {
list2.addAll(swf.tags);
}
parseCharacters(list2);
JPanel textTopPanel = new JPanel(new BorderLayout());
textValue = new LineMarkedEditorPane();
textTopPanel.add(new JScrollPane(textValue), BorderLayout.CENTER);
textValue.setEditable(false);
//textValue.setFont(UIManager.getFont("TextField.font"));
JPanel textButtonsPanel = new JPanel();
textButtonsPanel.setLayout(new FlowLayout());
textSaveButton = new JButton(translate("button.save"), View.getIcon("save16"));
textSaveButton.setMargin(new Insets(3, 3, 3, 10));
textSaveButton.setActionCommand(ACTION_SAVE_TEXT);
textSaveButton.addActionListener(this);
textEditButton = new JButton(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(translate("button.cancel"), View.getIcon("cancel16"));
textCancelButton.setMargin(new Insets(3, 3, 3, 10));
textCancelButton.setActionCommand(ACTION_CANCEL_TEXT);
textCancelButton.addActionListener(this);
textButtonsPanel.add(textEditButton);
textButtonsPanel.add(textSaveButton);
textButtonsPanel.add(textCancelButton);
textSaveButton.setVisible(false);
textCancelButton.setVisible(false);
textTopPanel.add(textButtonsPanel, BorderLayout.SOUTH);
displayWithPreview = new JPanel(new CardLayout());
displayWithPreview.add(textTopPanel, CARDTEXTPANEL);
//TODO: This layout SUCKS! If you know something better, please fix it!
final JPanel fontPanel = new JPanel();
final JPanel fontParams2 = new JPanel();
fontParams2.setLayout(null);
final Component[][] ctable = new Component[][]{
{new JLabel(translate("font.name")), fontNameLabel = new JLabel(translate("value.unknown"))},
{new JLabel(translate("font.isbold")), fontIsBoldLabel = new JLabel(translate("value.unknown"))},
{new JLabel(translate("font.isitalic")), fontIsItalicLabel = new JLabel(translate("value.unknown"))},
{new JLabel(translate("font.ascent")), fontAscentLabel = new JLabel(translate("value.unknown"))},
{new JLabel(translate("font.descent")), fontDescentLabel = new JLabel(translate("value.unknown"))},
{new JLabel(translate("font.leading")), fontLeadingLabel = new JLabel(translate("value.unknown"))},
{new JLabel(translate("font.characters")), fontCharactersTextArea = new JTextArea("")}
};
fontCharactersTextArea.setLineWrap(true);
fontCharactersTextArea.setWrapStyleWord(true);
fontCharactersTextArea.setOpaque(false);
fontCharactersTextArea.setEditable(false);
fontCharactersTextArea.setFont(new JLabel().getFont());
final int borderLeft = 10;
final int[] maxws = new int[ctable[0].length];
for (int x = 0; x < ctable[0].length; x++) {
int maxw = 0;
for (int y = 0; y < ctable.length; y++) {
Dimension d = ctable[y][x].getPreferredSize();
if (d.width > maxw) {
maxw = d.width;
}
}
maxws[x] = maxw;
}
for (int i = 0; i < ctable.length; i++) {
fontParams2.add(ctable[i][0]);
fontParams2.add(ctable[i][1]);
}
//fontParams2.setPreferredSize(new Dimension(600, ctable.length * 25));
fontChangeList = new ComponentListener() {
@Override
public void componentResized(ComponentEvent e) {
int h = 0;
Insets is = fontPanel.getInsets();
Insets is2 = fontParams2.getInsets();
for (int i = 0; i < ctable.length; i++) {
Dimension d = ctable[i][0].getPreferredSize();
Dimension d2 = ctable[i][1].getPreferredSize();
ctable[i][0].setBounds(borderLeft, h, maxws[0], d2.height);
int w2 = fontPanel.getWidth() - 3 * borderLeft - maxws[0] - is.left - is.right - 10;
ctable[i][1].setBounds(borderLeft + maxws[0] + borderLeft, h, w2, d2.height);
h += Math.max(d.height, d2.height);
}
fontParams2.setPreferredSize(new Dimension(fontPanel.getWidth() - 20, h));
fontPanel.revalidate();
}
@Override
public void componentMoved(ComponentEvent e) {
componentResized(null);
}
@Override
public void componentShown(ComponentEvent e) {
componentResized(null);
}
@Override
public void componentHidden(ComponentEvent e) {
componentResized(null);
}
};
final JPanel fontParams1 = new JPanel();
fontPanel.addComponentListener(fontChangeList);
fontChangeList.componentResized(null);
fontParams1.setLayout(new BoxLayout(fontParams1, BoxLayout.Y_AXIS));
fontParams1.add(fontParams2);
JPanel fontAddCharsPanel = new JPanel(new FlowLayout());
fontAddCharsPanel.add(new JLabel(translate("font.characters.add")));
fontAddCharactersField = new MyTextField();
fontAddCharactersField.setPreferredSize(new Dimension(150, fontAddCharactersField.getPreferredSize().height));
fontAddCharsPanel.add(fontAddCharactersField);
JButton fontAddCharsButton = new JButton(translate("button.ok"));
fontAddCharsButton.setActionCommand(ACTION_FONT_ADD_CHARS);
fontAddCharsButton.addActionListener(this);
fontAddCharsPanel.add(fontAddCharsButton);
JButton fontEmbedButton = new JButton(translate("button.font.embed"));
fontEmbedButton.setActionCommand(ACTION_FONT_EMBED);
fontEmbedButton.addActionListener(this);
//fontAddCharsPanel.add(fontEmbedButton);
fontParams1.add(fontAddCharsPanel);
JPanel fontSelectionPanel = new JPanel(new FlowLayout());
fontSelectionPanel.add(new JLabel(translate("font.source")));
fontSelection = new JComboBox<>(FontTag.fontNames.toArray(new String[FontTag.fontNames.size()]));
fontSelection.setSelectedIndex(0);
fontSelection.setSelectedItem("Times New Roman");
fontSelection.setSelectedItem("Arial");
fontSelection.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (oldValue instanceof FontTag) {
FontTag f = (FontTag) oldValue;
sourceFontsMap.put(f.getFontId(), (String) fontSelection.getSelectedItem());
}
}
});
fontSelectionPanel.add(fontSelection);
JPanel fontCharPanel = new JPanel();
fontCharPanel.setLayout(new ListLayout());
fontCharPanel.add(fontAddCharsPanel);
fontCharPanel.add(fontSelectionPanel);
fontParams1.add(fontCharPanel);
fontParams1.add(fontEmbedButton);
fontPanel.setLayout(new BorderLayout());
fontParams1.add(Box.createVerticalGlue());
fontPanel.add(new JScrollPane(fontParams1), BorderLayout.CENTER);
displayWithPreview.add(fontPanel, CARDFONTPANEL);
Component leftComponent;
displayPanel = new JPanel(new CardLayout());
if (flashPanel != null) {
JPanel flashPlayPanel = new JPanel(new BorderLayout());
flashPlayPanel.add(flashPanel, BorderLayout.CENTER);
flashPlayPanel.add(flashControls = new PlayerControls(flashPanel), BorderLayout.SOUTH);
leftComponent = flashPlayPanel;
} else {
JPanel swtPanel = new JPanel(new BorderLayout());
swtPanel.add(new JLabel("" + translate("notavailonthisplatform") + "", JLabel.CENTER), BorderLayout.CENTER);
swtPanel.setBackground(View.DEFAULT_BACKGROUND_COLOR);
leftComponent = swtPanel;
}
textValue.setContentType("text/swf_text");
previewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
previewSplitPane.setDividerLocation(300);
JPanel pan = new JPanel(new BorderLayout());
JLabel prevLabel = new HeaderLabel(translate("swfpreview"));
prevLabel.setHorizontalAlignment(SwingConstants.CENTER);
//prevLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
JLabel paramsLabel = new HeaderLabel(translate("parameters"));
paramsLabel.setHorizontalAlignment(SwingConstants.CENTER);
//paramsLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
pan.add(prevLabel, BorderLayout.NORTH);
viewerCards = new JPanel();
viewerCards.setLayout(new CardLayout());
//viewerCards.add(leftComponent,FLASH_VIEWER_CARD);
internelViewerPanel = new ImagePanel();
JPanel ivPanel = new JPanel(new BorderLayout());
ivPanel.add(new HeaderLabel(translate("swfpreview.internal")), BorderLayout.NORTH);
ivPanel.add(internelViewerPanel, BorderLayout.CENTER);
viewerCards.add(ivPanel, INTERNAL_VIEWER_CARD);
((CardLayout) viewerCards.getLayout()).show(viewerCards, FLASH_VIEWER_CARD);
if (flashPanel != null) {
JPanel bottomPanel = new JPanel(new BorderLayout());
JPanel buttonsPanel = new JPanel(new FlowLayout());
JButton selectColorButton = new JButton(View.getIcon("color16"));
selectColorButton.addActionListener(this);
selectColorButton.setActionCommand(ACTION_SELECT_COLOR);
selectColorButton.setToolTipText(AppStrings.translate("button.selectcolor.hint"));
buttonsPanel.add(selectColorButton);
bottomPanel.add(buttonsPanel, BorderLayout.EAST);
pan.add(bottomPanel, BorderLayout.SOUTH);
}
pan.add(leftComponent, BorderLayout.CENTER);
viewerCards.add(pan, FLASH_VIEWER_CARD);
previewSplitPane.setLeftComponent(viewerCards);
parametersPanel = new JPanel(new BorderLayout());
parametersPanel.add(paramsLabel, BorderLayout.NORTH);
parametersPanel.add(displayWithPreview, BorderLayout.CENTER);
previewSplitPane.setRightComponent(parametersPanel);
parametersPanel.setVisible(false);
displayPanel.add(previewSplitPane, CARDFLASHPANEL);
displayPanel.add(createImagesCard(), CARDIMAGEPANEL);
JPanel shapesCard = new JPanel(new BorderLayout());
JPanel previewPanel = new JPanel(new BorderLayout());
previewImagePanel = new ImagePanel();
JPanel previewCnt = new JPanel(new BorderLayout());
previewCnt.add(previewImagePanel, BorderLayout.CENTER);
previewCnt.add(new PlayerControls(previewImagePanel), BorderLayout.SOUTH);
previewPanel.add(previewCnt, BorderLayout.CENTER);
JLabel prevIntLabel = new HeaderLabel(translate("swfpreview.internal"));
prevIntLabel.setHorizontalAlignment(SwingConstants.CENTER);
//prevIntLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
previewPanel.add(prevIntLabel, BorderLayout.NORTH);
shapesCard.add(previewPanel, BorderLayout.CENTER);
displayPanel.add(shapesCard, CARDDRAWPREVIEWPANEL);
swfPreviewPanel = new SWFPreviwPanel();
displayPanel.add(swfPreviewPanel, CARDSWFPREVIEWPANEL);
displayPanel.add(new JPanel(), CARDEMPTYPANEL);
if (actionPanel != null) {
displayPanel.add(actionPanel, CARDACTIONSCRIPTPANEL);
}
if (abcPanel != null) {
displayPanel.add(abcPanel, CARDACTIONSCRIPTPANEL);
}
CardLayout cl = (CardLayout) (displayPanel.getLayout());
cl.show(displayPanel, CARDEMPTYPANEL);
searchPanel = new JPanel();
searchPanel.setLayout(new BorderLayout());
searchPanel.add(filterField, BorderLayout.CENTER);
searchPanel.add(new JLabel(View.getIcon("search16")), BorderLayout.WEST);
JLabel closeSearchButton = new JLabel(View.getIcon("cancel16"));
closeSearchButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
filterField.setText("");
doFilter();
searchPanel.setVisible(false);
}
});
searchPanel.add(closeSearchButton, BorderLayout.EAST);
JPanel pan1 = new JPanel(new BorderLayout());
pan1.add(new JScrollPane(tagTree), BorderLayout.CENTER);
pan1.add(searchPanel, BorderLayout.SOUTH);
filterField.setActionCommand(ABCPanel.ACTION_FILTER_SCRIPT);
filterField.addActionListener(this);
searchPanel.setVisible(false);
filterField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent e) {
warn();
}
@Override
public void removeUpdate(DocumentEvent e) {
warn();
}
@Override
public void insertUpdate(DocumentEvent e) {
warn();
}
public void warn() {
doFilter();
}
});
//displayPanel.setBorder(BorderFactory.createLineBorder(Color.black));
splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pan1, detailPanel);
splitPane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitPane2, displayPanel);
if (swf == null) {
cnt.add(createWelcomePanel(), BorderLayout.CENTER);
actionPanel = null;
abcPanel = null;
} else {
cnt.add(splitPane1, BorderLayout.CENTER);
}
//splitPane1.setDividerLocation(0.5);
splitPane1.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent pce) {
if (splitsInited) {
Configuration.guiSplitPane1DividerLocation.set((int) pce.getNewValue());
}
}
});
splitPane2.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent pce) {
if (detailPanel.isVisible()) {
Configuration.guiSplitPane2DividerLocation.set((int) pce.getNewValue());
}
}
});
View.centerScreen(this);
tagTree.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if ((e.getKeyCode() == 'F') && (e.isControlDown())) {
searchPanel.setVisible(true);
filterField.requestFocusInWindow();
}
}
});
detailPanel.setVisible(false);
//Opening files with drag&drop to main window
enableDrop(true);
}
public void enableDrop(boolean value) {
if (value) {
setDropTarget(new DropTarget() {
@Override
public synchronized void drop(DropTargetDropEvent dtde) {
try {
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
@SuppressWarnings("unchecked")
List droppedFiles = (List) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
if (!droppedFiles.isEmpty()) {
Main.openFile(droppedFiles.get(0).getAbsolutePath());
}
} catch (UnsupportedFlavorException | IOException ex) {
}
}
});
} else {
setDropTarget(null);
}
}
public void doFilter() {
TagNode n = getASTagNode(tagTree);
if (n != null) {
if (n.tag instanceof ClassesListTreeModel) {
n.tag = new ClassesListTreeModel(abcPanel.classTree.treeList, filterField.getText());
}
View.execInEventDispatch(new Runnable() {
@Override
public void run() {
tagTree.updateUI();
}
});
}
}
private static void getApplicationMenuButtons(Component comp, List ret) {
if (comp instanceof JRibbonApplicationMenuButton) {
ret.add((JRibbonApplicationMenuButton) comp);
return;
}
if (comp instanceof java.awt.Container) {
java.awt.Container cont = (java.awt.Container) comp;
for (int i = 0; i < cont.getComponentCount(); i++) {
getApplicationMenuButtons(cont.getComponent(i), ret);
}
}
}
@Override
public void setVisible(boolean b) {
super.setVisible(b);
if (b) {
if (abcPanel != null) {
abcPanel.initSplits();
}
if (actionPanel != null) {
actionPanel.initSplits();
}
final MainFrame t = this;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
List mbuttons = new ArrayList<>();
getApplicationMenuButtons(t, mbuttons);
for (final JRibbonApplicationMenuButton mbutton : mbuttons) {
mbutton.setIcon(View.getResizableIcon("buttonicon_256"));
mbutton.setDisplayState(new CommandButtonDisplayState(
"My Ribbon Application Menu Button", mbutton.getSize().width) {
@Override
public org.pushingpixels.flamingo.api.common.CommandButtonLayoutManager createLayoutManager(
org.pushingpixels.flamingo.api.common.AbstractCommandButton commandButton) {
return new CommandButtonLayoutManager() {
@Override
public int getPreferredIconSize() {
return mbutton.getSize().width;
}
@Override
public CommandButtonLayoutManager.CommandButtonLayoutInfo getLayoutInfo(
AbstractCommandButton commandButton, Graphics g) {
CommandButtonLayoutManager.CommandButtonLayoutInfo result = new CommandButtonLayoutManager.CommandButtonLayoutInfo();
result.actionClickArea = new Rectangle(0, 0, 0, 0);
result.popupClickArea = new Rectangle(0, 0, commandButton
.getWidth(), commandButton.getHeight());
result.popupActionRect = new Rectangle(0, 0, 0, 0);
ResizableIcon icon = commandButton.getIcon();
icon.setDimension(new Dimension(commandButton.getWidth(), commandButton.getHeight()));
result.iconRect = new Rectangle(
0,
0,
commandButton.getWidth(), commandButton.getHeight());
result.isTextInActionArea = false;
return result;
}
@Override
public Dimension getPreferredSize(
AbstractCommandButton commandButton) {
return new Dimension(40, 40);
}
@Override
public void propertyChange(PropertyChangeEvent evt) {
}
@Override
public Point getKeyTipAnchorCenterPoint(
AbstractCommandButton commandButton) {
// dead center
return new Point(commandButton.getWidth() / 2,
commandButton.getHeight() / 2);
}
};
}
});
MyRibbonApplicationMenuButtonUI mui = (MyRibbonApplicationMenuButtonUI) mbutton.getUI();
mui.setHoverIcon(View.getResizableIcon("buttonicon_hover_256"));
mui.setNormalIcon(View.getResizableIcon("buttonicon_256"));
mui.setClickIcon(View.getResizableIcon("buttonicon_down_256"));
}
splitPane1.setDividerLocation(Configuration.guiSplitPane1DividerLocation.get(getWidth() / 3));
int confDivLoc = Configuration.guiSplitPane2DividerLocation.get(splitPane2.getHeight() * 3 / 5);
if (confDivLoc > splitPane2.getHeight() - 10) { //In older releases, divider location was saved when detailPanel was invisible too
confDivLoc = splitPane2.getHeight() * 3 / 5;
}
splitPane2.setDividerLocation(confDivLoc);
splitPos = splitPane2.getDividerLocation();
splitsInited = true;
if (miGotoMainClassOnStartup.isSelected()) {
gotoDocumentClass();
}
}
});
}
}
private void parseCharacters(List list) {
for (ContainerItem t : list) {
if (t instanceof CharacterTag) {
characters.put(((CharacterTag) t).getCharacterId(), (CharacterTag) t);
}
if (t instanceof Container) {
parseCharacters(((Container) t).getSubItems());
}
}
}
public static void getShapes(List list, List shapes) {
for (ContainerItem t : list) {
if (t instanceof Container) {
getShapes(((Container) t).getSubItems(), shapes);
}
if ((t instanceof DefineShapeTag)
|| (t instanceof DefineShape2Tag)
|| (t instanceof DefineShape3Tag)
|| (t instanceof DefineShape4Tag)) {
shapes.add((Tag) t);
}
}
}
public static void getFonts(List list, List fonts) {
for (ContainerItem t : list) {
if (t instanceof Container) {
getFonts(((Container) t).getSubItems(), fonts);
}
if ((t instanceof DefineFontTag)
|| (t instanceof DefineFont2Tag)
|| (t instanceof DefineFont3Tag)
|| (t instanceof DefineFont4Tag)) {
fonts.add((Tag) t);
}
}
}
public static void getActionScript3(List list, List actionScripts) {
for (ContainerItem t : list) {
if (t instanceof Container) {
getActionScript3(((Container) t).getSubItems(), actionScripts);
}
if (t instanceof ABCContainerTag) {
actionScripts.add((ABCContainerTag) t);
}
}
}
public static void getMorphShapes(List list, List morphShapes) {
for (ContainerItem t : list) {
if (t instanceof Container) {
getMorphShapes(((Container) t).getSubItems(), morphShapes);
}
if ((t instanceof DefineMorphShapeTag) || (t instanceof DefineMorphShape2Tag)) {
morphShapes.add((Tag) t);
}
}
}
public static void getImages(List list, List images) {
for (ContainerItem t : list) {
if (t instanceof Container) {
getImages(((Container) t).getSubItems(), images);
}
if ((t instanceof DefineBitsTag)
|| (t instanceof DefineBitsJPEG2Tag)
|| (t instanceof DefineBitsJPEG3Tag)
|| (t instanceof DefineBitsJPEG4Tag)
|| (t instanceof DefineBitsLosslessTag)
|| (t instanceof DefineBitsLossless2Tag)) {
images.add((Tag) t);
}
}
}
public static void getTexts(List list, List texts) {
for (ContainerItem t : list) {
if (t instanceof Container) {
getTexts(((Container) t).getSubItems(), texts);
}
if ((t instanceof DefineTextTag)
|| (t instanceof DefineText2Tag)
|| (t instanceof DefineEditTextTag)) {
texts.add((Tag) t);
}
}
}
public static void getSprites(List list, List sprites) {
for (ContainerItem t : list) {
if (t instanceof Container) {
getSprites(((Container) t).getSubItems(), sprites);
}
if (t instanceof DefineSpriteTag) {
sprites.add((Tag) t);
}
}
}
public static void getButtons(List list, List buttons) {
for (ContainerItem t : list) {
if (t instanceof Container) {
getButtons(((Container) t).getSubItems(), buttons);
}
if ((t instanceof DefineButtonTag) || (t instanceof DefineButton2Tag)) {
buttons.add((Tag) t);
}
}
}
public List getSelectedNodes() {
List ret = new ArrayList<>();
TreePath[] tps = tagTree.getSelectionPaths();
if (tps == null) {
return ret;
}
for (TreePath tp : tps) {
TagNode te = (TagNode) tp.getLastPathComponent();
ret.add(te);
}
return ret;
}
public String getTagType(Object t) {
if ((t instanceof DefineFontTag)
|| (t instanceof DefineFont2Tag)
|| (t instanceof DefineFont3Tag)
|| (t instanceof DefineFont4Tag)
|| (t instanceof DefineCompactedFont)) {
return "font";
}
if ((t instanceof DefineTextTag)
|| (t instanceof DefineText2Tag)
|| (t instanceof DefineEditTextTag)) {
return "text";
}
if ((t instanceof DefineBitsTag)
|| (t instanceof DefineBitsJPEG2Tag)
|| (t instanceof DefineBitsJPEG3Tag)
|| (t instanceof DefineBitsJPEG4Tag)
|| (t instanceof DefineBitsLosslessTag)
|| (t instanceof DefineBitsLossless2Tag)) {
return "image";
}
if ((t instanceof DefineShapeTag)
|| (t instanceof DefineShape2Tag)
|| (t instanceof DefineShape3Tag)
|| (t instanceof DefineShape4Tag)) {
return "shape";
}
if ((t instanceof DefineMorphShapeTag) || (t instanceof DefineMorphShape2Tag)) {
return "morphshape";
}
if (t instanceof DefineSpriteTag) {
return "sprite";
}
if ((t instanceof DefineButtonTag) || (t instanceof DefineButton2Tag)) {
return "button";
}
if (t instanceof ASMSource) {
return "as";
}
if (t instanceof TreeElement) {
TreeElement te = (TreeElement) t;
if (te.getItem() instanceof ScriptPack) {
return "as";
} else {
return "package";
}
}
if (t instanceof PackageNode) {
return "package";
}
if (t instanceof FrameNode) {
return "frame";
}
if (t instanceof ShowFrameTag) {
return "showframe";
}
if (t instanceof DefineVideoStreamTag) {
return "movie";
}
if ((t instanceof DefineSoundTag) || (t instanceof SoundStreamHeadTag) || (t instanceof SoundStreamHead2Tag)) {
return "sound";
}
if (t instanceof DefineBinaryDataTag) {
return "binaryData";
}
return "folder";
}
public List