diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index bde7218b7..b73a1b5e3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -203,6 +203,9 @@ public final class SWF { * ScaleForm GFx */ public boolean gfx = false; + + public String file; + public String fileTitle; /** * Gets all tags with specified id @@ -398,6 +401,18 @@ public final class SWF { } } + /** + * Get title of the file + * + * @return file title + */ + public String getFileTitle() { + if (fileTitle != null) { + return fileTitle; + } + return file; + } + private void findFileAttributes() { for (Tag t : tags) { if (t instanceof FileAttributesTag) { @@ -781,7 +796,7 @@ public final class SWF { } TagNode addNode = null; if (t instanceof ShowFrameTag) { - TagNode tti = new TagNode(new FrameNode(t.getSwf(), frame, parent, false)); + TagNode tti = new TagNode(new FrameNode(t.getSwf(), frame, parent, false), t.getSwf()); for (int r = ret.size() - 1; r >= 0; r--) { if (!(ret.get(r).tag instanceof DefineSpriteTag)) { @@ -856,7 +871,7 @@ public final class SWF { } } if (selNode == null) { - items.add(pkgCount, selNode = new TagNode(new PackageNode(pathParts[pos]))); + items.add(pkgCount, selNode = new TagNode(new PackageNode(pathParts[pos]), t.getSwf())); } pos++; if (selNode != null) { diff --git a/trunk/src/com/jpexs/decompiler/flash/TagNode.java b/trunk/src/com/jpexs/decompiler/flash/TagNode.java index e29323ef2..d22aec591 100644 --- a/trunk/src/com/jpexs/decompiler/flash/TagNode.java +++ b/trunk/src/com/jpexs/decompiler/flash/TagNode.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.gui.TreeNode; import com.jpexs.decompiler.flash.helpers.FileTextWriter; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG3Tag; @@ -65,10 +66,11 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; import java.util.logging.Logger; -public class TagNode { +public class TagNode implements TreeNode { public List subItems; public Object tag; + private SWF swf; public boolean export = false; public String mark; @@ -81,17 +83,27 @@ public class TagNode { return ret; } - public TagNode(Object tag) { + public TagNode(ContainerItem containerItem) { + this(containerItem, containerItem.getSwf()); + } + + public TagNode(Object tag, SWF swf) { + this.swf = swf; this.tag = tag; this.subItems = new ArrayList<>(); } + @Override + public SWF getSwf() { + return swf; + } + @Override public String toString() { return tag.toString(); } - public static List createTagList(List list) { + public static List createTagList(List list, SWF swf) { List ret = new ArrayList<>(); int frame = 1; List frames = new ArrayList<>(); @@ -105,7 +117,7 @@ public class TagNode { List exportAssetsTags = new ArrayList<>(); - for (Object t : list) { + for (ContainerItem t : list) { if (t instanceof ExportAssetsTag) { exportAssetsTags.add((ExportAssetsTag) t); } @@ -147,7 +159,7 @@ public class TagNode { buttons.add(new TagNode(t)); } if (t instanceof ShowFrameTag) { - TagNode tti = new TagNode("frame" + frame); + TagNode tti = new TagNode("frame" + frame, t.getSwf()); /* for (int r = ret.size() - 1; r >= 0; r--) { if (!(ret.get(r).tag instanceof DefineSpriteTag)) { @@ -171,35 +183,35 @@ public class TagNode { TagNode tti = new TagNode(t); if (((Container) t).getItemCount() > 0) { List subItems = ((Container) t).getSubItems(); - tti.subItems = createTagList(subItems); + tti.subItems = createTagList(subItems, t.getSwf()); } //ret.add(tti); } } - TagNode textsNode = new TagNode("texts"); + TagNode textsNode = new TagNode("texts", swf); textsNode.subItems.addAll(texts); - TagNode imagesNode = new TagNode("images"); + TagNode imagesNode = new TagNode("images", swf); imagesNode.subItems.addAll(images); - TagNode fontsNode = new TagNode("fonts"); + TagNode fontsNode = new TagNode("fonts", swf); fontsNode.subItems.addAll(fonts); - TagNode spritesNode = new TagNode("sprites"); + TagNode spritesNode = new TagNode("sprites", swf); spritesNode.subItems.addAll(sprites); - TagNode shapesNode = new TagNode("shapes"); + TagNode shapesNode = new TagNode("shapes", swf); shapesNode.subItems.addAll(shapes); - TagNode morphShapesNode = new TagNode("morphshapes"); + TagNode morphShapesNode = new TagNode("morphshapes", swf); morphShapesNode.subItems.addAll(morphShapes); - TagNode buttonsNode = new TagNode("buttons"); + TagNode buttonsNode = new TagNode("buttons", swf); buttonsNode.subItems.addAll(buttons); - TagNode framesNode = new TagNode("frames"); + TagNode framesNode = new TagNode("frames", swf); framesNode.subItems.addAll(frames); ret.add(shapesNode); ret.add(morphShapesNode);; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java index 773c0c982..b30d6601d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.abc; import com.jpexs.decompiler.flash.EventListener; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.AVM2Deobfuscation; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; @@ -66,6 +67,7 @@ public class ABC { protected HashSet listeners = new HashSet<>(); private static final Logger logger = Logger.getLogger(ABC.class.getName()); private AVM2Deobfuscation deobfuscation; + public SWF swf; public int addMethodBody(MethodBody body) { bodies = Arrays.copyOf(bodies, bodies.length + 1); @@ -304,7 +306,8 @@ public class ABC { } } - public ABC(InputStream is) throws IOException { + public ABC(InputStream is, SWF swf) throws IOException { + this.swf = swf; ABCInputStream ais = new ABCInputStream(is); minor_version = ais.readU16(); major_version = ais.readU16(); diff --git a/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 18303b199..92187e638 100644 --- a/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -49,6 +49,8 @@ public class Configuration { */ private static List replacements = new ArrayList<>(); + @ConfigurationDefaultBoolean(false) + public static final ConfigurationItem openMultiple = null; @ConfigurationDefaultBoolean(true) public static final ConfigurationItem decompile = null; @ConfigurationDefaultBoolean(true) diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/FontPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/FontPanel.java index bd74e9806..03d4b8d8c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/FontPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/FontPanel.java @@ -55,7 +55,6 @@ public class FontPanel extends JPanel implements ActionListener { static final String ACTION_FONT_ADD_CHARS = "FONTADDCHARS"; private MainFrame mainFrame; - private SWF swf; public Map sourceFontsMap = new HashMap<>(); @@ -70,9 +69,8 @@ public class FontPanel extends JPanel implements ActionListener { private ComponentListener fontChangeList; private JComboBox fontSelection; - public FontPanel(MainFrame mainFrame, SWF swf) { + public FontPanel(MainFrame mainFrame) { this.mainFrame = mainFrame; - this.swf = swf; createFontPanel(); } @@ -214,6 +212,7 @@ public class FontPanel extends JPanel implements ActionListener { private void fontAddChars(FontTag ft, Set selChars, String selFont) { FontTag f = (FontTag) mainFrame.oldValue; + SWF swf = ft.getSwf(); String oldchars = f.getCharacters(swf.tags); for (int ic : selChars) { char c = (char) ic; @@ -260,6 +259,7 @@ public class FontPanel extends JPanel implements ActionListener { } public void showFontTag(FontTag ft) { + SWF swf = ft.getSwf(); fontNameLabel.setText(ft.getFontName(swf.tags)); fontIsBoldLabel.setText(ft.isBold() ? translate("yes") : translate("no")); fontIsItalicLabel.setText(ft.isItalic() ? translate("yes") : translate("no")); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/LoadFromCacheFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/LoadFromCacheFrame.java index bc90e5de1..f95fdd002 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/LoadFromCacheFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/LoadFromCacheFrame.java @@ -225,7 +225,7 @@ public class LoadFromCacheFrame extends AppFrame implements ActionListener { CacheEntry en = list.getSelectedValue(); if (en != null) { ReReadableInputStream str = new ReReadableInputStream(en.getResponseDataStream()); - Main.openFile(entryToFileName(en), str); + Main.openFile(str, entryToFileName(en)); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java index 4a2e8dba9..ca7d5f24b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java @@ -78,6 +78,7 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener { static final String ACTION_OPEN_SWF = "OPENSWF"; static final String ACTION_SAVE = "SAVE"; + private MainFrame mainFrame; private List processlist; private List foundIs; private com.jpexs.process.Process selProcess; @@ -170,7 +171,7 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener { return; } str.mark(Integer.MAX_VALUE); - Main.openFile("" + selProcess + " [" + (index + 1) + "]", str); + Main.openFile(str, selProcess + " [" + (index + 1) + "]"); } } @@ -221,16 +222,18 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener { } @SuppressWarnings("unchecked") - public LoadFromMemoryFrame() { + public LoadFromMemoryFrame(final MainFrame mainFrame) { setSize(800, 600); //setAlwaysOnTop(true); setTitle(translate("dialog.title")); + this.mainFrame = mainFrame; + addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { - if (!Main.mainFrame.isVisible()) { - Main.mainFrame.setVisible(true); + if (!mainFrame.isVisible()) { + mainFrame.setVisible(true); } } }); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index b933222a8..99f2e83e5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -40,6 +40,7 @@ import java.awt.event.MouseEvent; import java.io.*; import java.net.Socket; import java.util.ArrayList; +import java.util.List; import java.util.Calendar; import java.util.Locale; import java.util.logging.ConsoleHandler; @@ -66,21 +67,17 @@ import javax.swing.filechooser.FileFilter; public class Main { public static ProxyFrame proxyFrame; - public static String file; - public static InputStream inputStream; - public static String fileTitle; - public static SWF swf; + private static List sourceInfos = new ArrayList<>(); public static LoadingDialog loadingDialog; public static ModeFrame modeFrame; private static boolean working = false; private static TrayIcon trayIcon; private static MenuItem stopMenuItem; - public static MainFrame mainFrame; + private static MainFrame mainFrame; private static final int UPDATE_SYSTEM_MAJOR = 1; private static final int UPDATE_SYSTEM_MINOR = 0; public static LoadFromMemoryFrame loadFromMemoryFrame; public static LoadFromCacheFrame loadFromCacheFrame; - public static boolean readOnly = false; private static ErrorLogFrame errorLogFrame; public static void loadFromCache() { @@ -92,23 +89,11 @@ public class Main { public static void loadFromMemory() { if (loadFromMemoryFrame == null) { - loadFromMemoryFrame = new LoadFromMemoryFrame(); + loadFromMemoryFrame = new LoadFromMemoryFrame(mainFrame); } loadFromMemoryFrame.setVisible(true); } - /** - * Get title of the file - * - * @return file title - */ - public static String getFileTitle() { - if (fileTitle != null) { - return fileTitle; - } - return file; - } - public static void setSubLimiter(boolean value) { if (value) { AVM2Code.toSourceLimit = Configuration.sublimiter.get(); @@ -126,7 +111,7 @@ public class Main { @Override public void run() { if (proxyFrame == null) { - proxyFrame = new ProxyFrame(); + proxyFrame = new ProxyFrame(mainFrame); } } }); @@ -137,7 +122,7 @@ public class Main { public static void showProxy() { if (proxyFrame == null) { - proxyFrame = new ProxyFrame(); + proxyFrame = new ProxyFrame(mainFrame); } proxyFrame.setVisible(true); proxyFrame.setState(Frame.NORMAL); @@ -200,10 +185,10 @@ public class Main { } public static SWF parseSWF(String file) throws Exception { - return parseSWF(new FileInputStream(file)); + return parseSWF(new FileInputStream(file), file, null); } - public static SWF parseSWF(InputStream fis) throws Exception { + public static SWF parseSWF(InputStream fis, String file, String fileTitle) throws Exception { SWF locswf; locswf = new SWF(fis, new ProgressListener() { @Override @@ -211,6 +196,8 @@ public class Main { startWork(AppStrings.translate("work.reading.swf"), p); } }, Configuration.parallelSpeedUp.get()); + locswf.file = file; + locswf.fileTitle = fileTitle; locswf.addEventListener(new EventListener() { @Override public void handleEvent(String event, Object data) { @@ -232,8 +219,8 @@ public class Main { return locswf; } - public static void saveFile(String outfile) throws IOException { - file = outfile; + public static void saveFile(SWF swf, String outfile) throws IOException { + swf.file = outfile; File outfileF = new File(outfile); File tmpFile = new File(outfile + ".tmp"); swf.saveTo(new FileOutputStream(tmpFile)); @@ -252,36 +239,42 @@ public class Main { private static class OpenFileWorker extends SwingWorker { + private SWFSourceInfo sourceInfo; + + public OpenFileWorker(SWFSourceInfo sourceInfo) { + this.sourceInfo = sourceInfo; + } + @Override protected Object doInBackground() throws Exception { + SWF swf = null; try { Main.startWork(AppStrings.translate("work.reading.swf") + "..."); - swf = parseSWF(Main.inputStream); - if (Main.inputStream instanceof FileInputStream) { - Main.inputStream.close(); + InputStream inputStream = sourceInfo.getInputStream(); + swf = parseSWF(inputStream, sourceInfo.getFile(), sourceInfo.getFileTitle()); + if (inputStream instanceof FileInputStream) { + inputStream.close(); } } catch (OutOfMemoryError ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); View.showMessageDialog(null, "Cannot load SWF file. Out of memory."); loadingDialog.setVisible(false); - swf = null; } catch (Exception ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); View.showMessageDialog(null, "Cannot load SWF file."); loadingDialog.setVisible(false); - swf = null; } + final SWF swf1 = swf; try { Main.startWork(AppStrings.translate("work.creatingwindow") + "..."); View.execInEventDispatch(new Runnable() { @Override public void run() { - try{ - mainFrame = new MainFrame(swf); - } catch(Exception ex) { - String a = ex.toString(); + if (mainFrame == null) { + mainFrame = new MainFrame(); } + mainFrame.load(swf1); if (errorState) { mainFrame.setErrorState(); } @@ -306,33 +299,35 @@ public class Main { } } - public static boolean reloadSWF() { + public static boolean reloadSWFs() { CancellableWorker.cancelBackgroundThreads(); - if (Main.inputStream == null) { - mainFrame.setVisible(false); - Helper.emptyObject(mainFrame); + if (Main.sourceInfos.isEmpty()) { Cache.clearAll(); System.gc(); - mainFrame = null; showModeFrame(); return true; } else { - if (inputStream instanceof FileInputStream) { - openFile(file); - } else if (inputStream instanceof SeekableInputStream) { - try { - ((SeekableInputStream) inputStream).seek(0); - } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + SWFSourceInfo[] sourceInfosCopy = new SWFSourceInfo[sourceInfos.size()]; + sourceInfos.toArray(sourceInfosCopy); + for (SWFSourceInfo sourceInfo : sourceInfosCopy) { + InputStream inputStream = sourceInfo.getInputStream(); + if (inputStream instanceof FileInputStream) { + openFile(sourceInfo.getFile(), null); + } else if (inputStream instanceof SeekableInputStream) { + try { + ((SeekableInputStream) inputStream).seek(0); + } catch (IOException ex) { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } + return openFile(inputStream, sourceInfo.getFileTitle()) == OpenFileResult.OK; + } else if (inputStream instanceof BufferedInputStream) { + try { + ((BufferedInputStream) inputStream).reset(); + } catch (IOException ex) { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } + return openFile(inputStream, sourceInfo.getFileTitle()) == OpenFileResult.OK; } - return openFile(fileTitle, inputStream) == OpenFileResult.OK; - } else if (inputStream instanceof BufferedInputStream) { - try { - ((BufferedInputStream) inputStream).reset(); - } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); - } - return openFile(fileTitle, inputStream) == OpenFileResult.OK; } return false; } @@ -355,18 +350,16 @@ public class Main { loadFromCacheFrame.setVisible(false); loadFromCacheFrame = null; } - reloadSWF(); + reloadSWFs(); } - public static OpenFileResult openFile(String swfFile) { + public static OpenFileResult openFile(String swfFile, String fileTitle) { try { File file = new File(swfFile); swfFile = file.getCanonicalPath(); Configuration.addRecentFile(swfFile); - OpenFileResult openResult = openFile(swfFile, new FileInputStream(swfFile)); - if (openResult == OpenFileResult.OK) { - readOnly = false; - } + SWFSourceInfo sourceInfo = new SWFSourceInfo(new FileInputStream(swfFile), swfFile, fileTitle); + OpenFileResult openResult = openFile(sourceInfo); return openResult; } catch (FileNotFoundException ex) { View.showMessageDialog(null, "File not found", "Error", JOptionPane.ERROR_MESSAGE); @@ -377,19 +370,14 @@ public class Main { } } - public static OpenFileResult openFile(String fileTitle, InputStream is) { - Main.file = fileTitle; - Main.inputStream = is; - Main.fileTitle = fileTitle; - readOnly = true; - if (mainFrame != null) { + public static OpenFileResult openFile(SWFSourceInfo sourceInfo) { + if (mainFrame != null && !Configuration.openMultiple.get()) { + mainFrame.closeAll(); mainFrame.setVisible(false); - Helper.emptyObject(mainFrame); - swf = null; - mainFrame = null; Cache.clearAll(); System.gc(); } + View.execInEventDispatch(new Runnable() { @Override public void run() { @@ -400,12 +388,18 @@ public class Main { }); Main.loadingDialog.setVisible(true); - OpenFileWorker wrk = new OpenFileWorker(); + OpenFileWorker wrk = new OpenFileWorker(sourceInfo); wrk.execute(); + sourceInfos.add(sourceInfo); return OpenFileResult.OK; } + + public static OpenFileResult openFile(InputStream is, String fileTitle) { + SWFSourceInfo sourceInfo = new SWFSourceInfo(is, null, fileTitle); + return openFile(sourceInfo); + } - public static boolean saveFileDialog() { + public static boolean saveFileDialog(SWF swf) { JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(Configuration.lastSaveDir.get())); FileFilter swfFilter = new FileFilter() { @@ -461,10 +455,8 @@ public class Main { } swf.gfx = true; } - Main.saveFile(fileName); + Main.saveFile(swf, fileName); Configuration.lastSaveDir.set(file.getParentFile().getAbsolutePath()); - fileTitle = null; - readOnly = false; return true; } catch (IOException ex) { View.showMessageDialog(null, AppStrings.translate("error.file.write")); @@ -474,7 +466,6 @@ public class Main { } public static boolean openFileDialog() { - fileTitle = null; JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(Configuration.lastOpenDir.get())); FileFilter allSupportedFilter = new FileFilter() { @@ -522,7 +513,7 @@ public class Main { if (returnVal == JFileChooser.APPROVE_OPTION) { Configuration.lastOpenDir.set(Helper.fixDialogFile(fc.getSelectedFile()).getParentFile().getAbsolutePath()); File selfile = Helper.fixDialogFile(fc.getSelectedFile()); - Main.openFile(selfile.getAbsolutePath()); + Main.openFile(selfile.getAbsolutePath(), null); return true; } else { return false; @@ -582,7 +573,7 @@ public class Main { @Override public void run() { if (mainFrame == null) { - mainFrame = new MainFrame(null); + mainFrame = new MainFrame(); if (errorState) { mainFrame.setErrorState(); } @@ -741,7 +732,7 @@ public class Main { String fileToOpen = CommandLineArgumentParser.parseArguments(args); if (fileToOpen != null) { initGui(); - openFile(fileToOpen); + openFile(fileToOpen, null); } } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index e6eb177ff..6f4b5c1a2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -151,6 +151,7 @@ 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; @@ -204,35 +205,40 @@ import org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationM public final class MainFrame extends AppRibbonFrame implements ActionListener, TreeSelectionListener, Freed { private List swfs; - public ABCPanel abcPanel; - public ActionPanel actionPanel; + private ABCPanel abcPanel; + private ActionPanel actionPanel; + private JPanel welcomePanel; private MainFrameStatusPanel statusPanel; private MainFrameRibbon mainRibbon; private FontPanel fontPanel; - public JProgressBar progressBar = new JProgressBar(0, 100); + private 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 FlashPlayerPanel flashPanel; + private JPanel displayPanel; + private ImagePanel imagePanel; + private ImagePanel previewImagePanel; + private SWFPreviwPanel swfPreviewPanel; + private boolean isWelcomeScreen = true; + private static final String CARDFLASHPANEL = "Flash card"; + private static final String CARDSWFPREVIEWPANEL = "SWF card"; + private static final String CARDDRAWPREVIEWPANEL = "Draw card"; + private static final String CARDIMAGEPANEL = "Image card"; + private static final String CARDEMPTYPANEL = "Empty card"; + private static final String CARDACTIONSCRIPTPANEL = "ActionScript card"; + private static final String CARDACTIONSCRIPT3PANEL = "ActionScript card"; + private static final String DETAILCARDAS3NAVIGATOR = "Traits list"; + private static final String DETAILCARDEMPTYPANEL = "Empty card"; + private static final String CARDTEXTPANEL = "Text card"; + private static final String CARDFONTPANEL = "Font card"; + private static final String FLASH_VIEWER_CARD = "FLASHVIEWER"; + private static final String INTERNAL_VIEWER_CARD = "INTERNALVIEWER"; private LineMarkedEditorPane textValue; - private JPEGTablesTag jtt; + private Map jtts; private HashMap characters; - private List abcList; - JSplitPane splitPane1; - JSplitPane splitPane2; + private Map> abcLists; + private JSplitPane splitPane1; + private JSplitPane splitPane2; private boolean splitsInited = false; private JPanel detailPanel; private JTextField filterField = new MyTextField(""); @@ -248,18 +254,17 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T 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 AbortRetryIgnoreHandler errorHandler = new GuiAbortRetryIgnoreHandler(); private CancellableWorker setSourceWorker; - static final String ACTION_SELECT_COLOR = "SELECTCOLOR"; - static final String ACTION_REPLACE_IMAGE = "REPLACEIMAGE"; - static final String ACTION_REPLACE_BINARY = "REPLACEBINARY"; - 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"; + private static final String ACTION_SELECT_COLOR = "SELECTCOLOR"; + private static final String ACTION_REPLACE_IMAGE = "REPLACEIMAGE"; + private static final String ACTION_REPLACE_BINARY = "REPLACEBINARY"; + private static final String ACTION_REMOVE_ITEM = "REMOVEITEM"; + private static final String ACTION_EDIT_TEXT = "EDITTEXT"; + private static final String ACTION_CANCEL_TEXT = "CANCELTEXT"; + private static final String ACTION_SAVE_TEXT = "SAVETEXT"; + private static final String ACTION_CLOSE_SWF = "CLOSESWF"; public void setPercent(int percent) { progressBar.setValue(percent); @@ -316,6 +321,10 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T replaceBinarySelectionMenuItem.setActionCommand(ACTION_REPLACE_BINARY); replaceBinarySelectionMenuItem.addActionListener(this); contextPopupMenu.add(replaceBinarySelectionMenuItem); + final JMenuItem closeSelectionMenuItem = new JMenuItem(translate("contextmenu.closeSwf")); + closeSelectionMenuItem.setActionCommand(ACTION_CLOSE_SWF); + closeSelectionMenuItem.addActionListener(this); + contextPopupMenu.add(closeSelectionMenuItem); contextPopupMenu.add(removeMenuItem); tagTree.addMouseListener(new MouseAdapter() { @@ -362,6 +371,10 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T replaceBinarySelectionMenuItem.setVisible(true); } } + + if (tagObj instanceof SWFRoot) { + closeSelectionMenuItem.setVisible(true); + } } removeMenuItem.setVisible(allSelectedIsTag); @@ -437,16 +450,10 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T imageButtonsPanel.setVisible(visible); } - public MainFrame(final SWF swf) { + public MainFrame() { super(); - List objs = new ArrayList<>(); - if (swf != null) { - objs.addAll(swf.tags); - } - - abcList = new ArrayList<>(); - getActionScript3(objs, abcList); + abcLists = new HashMap<>(); try { flashPanel = new FlashPlayerPanel(this); @@ -454,7 +461,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } boolean externalFlashPlayerUnavailable = flashPanel == null; - mainRibbon = new MainFrameRibbon(this, getRibbon(), swf != null, !abcList.isEmpty(), externalFlashPlayerUnavailable); + mainRibbon = new MainFrameRibbon(this, getRibbon(), externalFlashPlayerUnavailable); int w = Configuration.guiWindowWidth.get(); int h = Configuration.guiWindowHeight.get(); @@ -521,9 +528,9 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T Main.exit(); } }); - setTitle(ApplicationInfo.applicationVerName + ((swf != null && Configuration.displayFileName.get()) ? " - " + Main.getFileTitle() : "")); + setTitle(ApplicationInfo.applicationVerName); - this.swfs = Arrays.asList(swf); + swfs = new ArrayList<>(); java.awt.Container cnt = getContentPane(); cnt.setLayout(new BorderLayout()); cnt.add(getRibbon(), BorderLayout.NORTH); @@ -536,19 +543,9 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T 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(this, swfs, abcPanel)); - } + tagTree = new JTree((TreeModel) null); + tagTree.setRootVisible(false); tagTree.addTreeSelectionListener(this); tagTree.setBackground(Color.white); tagTree.setUI(new BasicTreeUI() { @@ -598,7 +595,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T try { File ftemp = new File(tempDir); - files = exportSelection(swf, errorHandler, tempDir, export); + files = exportSelection(errorHandler, tempDir, export); files.clear(); File[] fs = ftemp.listFiles(); @@ -665,7 +662,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T val = ((TagNode) val).tag; } TagType type = getTagType(val); - if (row == 0) { + if (val instanceof SWFRoot) { setIcon(View.getIcon("flash16")); } else if (type != null) { if (type == TagType.FOLDER && expanded) { @@ -695,19 +692,8 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T statusPanel = new MainFrameStatusPanel(this); cnt.add(statusPanel, BorderLayout.SOUTH); - if (swf != null) { - for (Tag t : swf.tags) { - if (t instanceof JPEGTablesTag) { - jtt = (JPEGTablesTag) t; - } - } - } + jtts = new HashMap<>(); 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); @@ -748,7 +734,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T displayWithPreview.add(textTopPanel, CARDTEXTPANEL); - fontPanel = new FontPanel(this, swf); + fontPanel = new FontPanel(this); displayWithPreview.add(fontPanel, CARDFONTPANEL); @@ -841,12 +827,6 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T 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); @@ -899,13 +879,9 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T 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); - } + welcomePanel = createWelcomePanel(); + actionPanel = null; + abcPanel = null; //splitPane1.setDividerLocation(0.5); splitPane1.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() { @@ -938,9 +914,103 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T }); detailPanel.setVisible(false); + updateUi(); + //Opening files with drag&drop to main window enableDrop(true); } + + public void load(SWF swf) { + List objs = new ArrayList<>(); + if (swf != null) { + objs.addAll(swf.tags); + } + + ArrayList abcList = new ArrayList<>(); + getActionScript3(objs, abcList); + + swfs.add(swf); + abcLists.put(swf, abcList); + + if (!abcList.isEmpty()) { + if (abcPanel == null) { + abcPanel = new ABCPanel(this); + abcPanel.setSwf(abcList, swf); + displayPanel.add(abcPanel, CARDACTIONSCRIPT3PANEL); + detailPanel.add(abcPanel.tabbedPane, DETAILCARDAS3NAVIGATOR); + } + } else { + if (actionPanel == null) { + actionPanel = new ActionPanel(this); + displayPanel.add(actionPanel, CARDACTIONSCRIPTPANEL); + } + } + + tagTree.setModel(new TagTreeModel(this, swfs, abcPanel)); + expandSwfRoots(); + + for (Tag t : swf.tags) { + if (t instanceof JPEGTablesTag) { + jtts.put(swf, (JPEGTablesTag) t); + } + } + + List list2 = new ArrayList<>(); + list2.addAll(swf.tags); + parseCharacters(list2); + + updateUi(swf); + } + + private void updateUi(final SWF swf) { + + setTitle(ApplicationInfo.applicationVerName + (Configuration.displayFileName.get() ? " - " + swf.getFileTitle() : "")); + + List abcList = abcLists.get(swf); + + if (abcList != null && !abcList.isEmpty()) { + abcPanel.setSwf(abcList, swf); + } + + if (isWelcomeScreen) { + java.awt.Container cnt = getContentPane(); + cnt.remove(welcomePanel); + cnt.add(splitPane1, BorderLayout.CENTER); + isWelcomeScreen = false; + } + + mainRibbon.updateComponets(swf, abcList); + } + + private void updateUi() { + if (!isWelcomeScreen) { + java.awt.Container cnt = getContentPane(); + cnt.remove(splitPane1); + cnt.add(welcomePanel, BorderLayout.CENTER); + isWelcomeScreen = true; + } + + if (swfs.isEmpty()) { + mainRibbon.updateComponets(null, null); + } else { + SWF swf = swfs.get(0); + updateUi(swf); + } + } + + public void closeAll() { + swfs.clear(); + abcLists.clear(); + jtts.clear(); + updateUi(); + } + + public void close(SWF swf) { + swfs.remove(swf); + abcLists.remove(swf); + jtts.remove(swf); + updateUi(); + } public void enableDrop(boolean value) { if (value) { @@ -952,7 +1022,8 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T @SuppressWarnings("unchecked") List droppedFiles = (List) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor); if (!droppedFiles.isEmpty()) { - Main.openFile(droppedFiles.get(0).getAbsolutePath()); + String path = droppedFiles.get(0).getAbsolutePath(); + Main.openFile(path, null); } } catch (UnsupportedFlavorException | IOException ex) { } @@ -964,18 +1035,22 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } public void doFilter() { - TagNode n = getASTagNode(tagTree); - if (n != null) { + List nodes = getASTagNode(tagTree); + boolean updateNeeded = false; + for (TagNode n : nodes) { if (n.tag instanceof ClassesListTreeModel) { - n.tag = new ClassesListTreeModel(abcPanel.classTree.treeList, filterField.getText()); + n.tag = new ClassesListTreeModel(abcPanel.classTree.treeList, n.getSwf(), filterField.getText()); + updateNeeded = true; } + } + + if (updateNeeded) { View.execInEventDispatch(new Runnable() { @Override public void run() { tagTree.updateUI(); } }); - } } @@ -1311,7 +1386,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } } - public void renameMultiname(int multiNameIndex) { + public void renameMultiname(List abcList, int multiNameIndex) { String oldName = ""; if (abcPanel.abc.constants.getMultiname(multiNameIndex).name_index > 0) { oldName = abcPanel.abc.constants.getString(abcPanel.abc.constants.getMultiname(multiNameIndex).name_index); @@ -1387,10 +1462,11 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T return ret; } - public TagNode getASTagNode(JTree tree) { + public List getASTagNode(JTree tree) { + List result = new ArrayList<>(); TreeModel tm = tree.getModel(); if (tm == null) { - return null; + return result; } Object root = tm.getRoot(); for (int i = 0; i < tm.getChildCount(root); i++) { @@ -1399,12 +1475,12 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T Object tag = ((TagNode) tm.getChild(root, i)).tag; if (tag != null) { if ("scripts".equals(((TagNode) node).mark)) { - return (TagNode) node; + result.add((TagNode) node); } } } } - return null; + return result; } public boolean confirmExperimental() { @@ -1412,7 +1488,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } private SearchDialog searchDialog; - public List exportSelection(SWF swf, AbortRetryIgnoreHandler handler, String selFile, ExportDialog export) throws IOException { + public List exportSelection(AbortRetryIgnoreHandler handler, String selFile, ExportDialog export) throws IOException { final ExportMode exportMode = ExportMode.get(export.getOption(ExportDialog.OPTION_ACTIONSCRIPT)); final boolean isMp3OrWav = export.getOption(ExportDialog.OPTION_SOUNDS) == 0; final boolean isFormatted = export.getOption(ExportDialog.OPTION_TEXTS) == 1; @@ -1420,79 +1496,97 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T List ret = new ArrayList<>(); List sel = getAllSelected(tagTree); - List tlsList = new ArrayList<>(); - JPEGTablesTag jtt = null; - for (Tag t : swf.tags) { - if (t instanceof JPEGTablesTag) { - jtt = (JPEGTablesTag) t; - break; - } - } - List images = new ArrayList<>(); - List shapes = new ArrayList<>(); - List movies = new ArrayList<>(); - List sounds = new ArrayList<>(); - List texts = new ArrayList<>(); - List actionNodes = new ArrayList<>(); - List binaryData = new ArrayList<>(); - for (Object d : sel) { - if (d instanceof TagNode) { - TagNode n = (TagNode) d; - if (getTagType(n.tag) == TagType.IMAGE) { - images.add((Tag) n.tag); - } - if (getTagType(n.tag) == TagType.SHAPE) { - shapes.add((Tag) n.tag); - } - if (getTagType(n.tag) == TagType.AS) { - actionNodes.add(n); - } - if (getTagType(n.tag) == TagType.MOVIE) { - movies.add((Tag) n.tag); - } - if (getTagType(n.tag) == TagType.SOUND) { - sounds.add((Tag) n.tag); - } - if (getTagType(n.tag) == TagType.BINARY_DATA) { - binaryData.add((Tag) n.tag); - } - if (getTagType(n.tag) == TagType.TEXT) { - texts.add((Tag) n.tag); + for (SWF swf : swfs) { + List tlsList = new ArrayList<>(); + JPEGTablesTag jtt = null; + for (Tag t : swf.tags) { + if (t instanceof JPEGTablesTag) { + jtt = (JPEGTablesTag) t; + break; } } - if (d instanceof TreeElement) { - if (((TreeElement) d).isLeaf()) { - tlsList.add((ScriptPack) ((TreeElement) d).getItem()); + List images = new ArrayList<>(); + List shapes = new ArrayList<>(); + List movies = new ArrayList<>(); + List sounds = new ArrayList<>(); + List texts = new ArrayList<>(); + List actionNodes = new ArrayList<>(); + List binaryData = new ArrayList<>(); + for (Object d : sel) { + if (d instanceof TagNode) { + TagNode n = (TagNode) d; + if (n.getSwf() != swf) { + continue; + } + if (getTagType(n.tag) == TagType.IMAGE) { + images.add((Tag) n.tag); + } + if (getTagType(n.tag) == TagType.SHAPE) { + shapes.add((Tag) n.tag); + } + if (getTagType(n.tag) == TagType.AS) { + actionNodes.add(n); + } + if (getTagType(n.tag) == TagType.MOVIE) { + movies.add((Tag) n.tag); + } + if (getTagType(n.tag) == TagType.SOUND) { + sounds.add((Tag) n.tag); + } + if (getTagType(n.tag) == TagType.BINARY_DATA) { + binaryData.add((Tag) n.tag); + } + if (getTagType(n.tag) == TagType.TEXT) { + texts.add((Tag) n.tag); + } + } + if (d instanceof TreeElement) { + if (((TreeElement) d).isLeaf()) { + TreeElement treeElement = (TreeElement) d; + if (treeElement.getSwf() == swf) { + tlsList.add((ScriptPack) treeElement.getItem()); + } + } } } - } - ret.addAll(swf.exportImages(handler, selFile + File.separator + "images", images)); - ret.addAll(SWF.exportShapes(handler, selFile + File.separator + "shapes", shapes)); - ret.addAll(swf.exportTexts(handler, selFile + File.separator + "texts", texts, isFormatted)); - ret.addAll(swf.exportMovies(handler, selFile + File.separator + "movies", movies)); - ret.addAll(swf.exportSounds(handler, selFile + File.separator + "sounds", sounds, isMp3OrWav, isMp3OrWav)); - ret.addAll(SWF.exportBinaryData(handler, selFile + File.separator + "binaryData", binaryData)); - if (abcPanel != null) { - for (int i = 0; i < tlsList.size(); i++) { - ScriptPack tls = tlsList.get(i); - Main.startWork(translate("work.exporting") + " " + (i + 1) + "/" + tlsList.size() + " " + tls.getPath() + " ..."); - ret.add(tls.export(selFile, abcList, exportMode, Configuration.parallelSpeedUp.get())); - } - } else { - List allNodes = new ArrayList<>(); - TagNode asn = getASTagNode(tagTree); - if (asn != null) { - allNodes.add(asn); - TagNode.setExport(allNodes, false); - TagNode.setExport(actionNodes, true); - ret.addAll(TagNode.exportNodeAS(swf.tags, handler, allNodes, selFile, exportMode, null)); + ret.addAll(swf.exportImages(handler, selFile + File.separator + "images", images)); + ret.addAll(SWF.exportShapes(handler, selFile + File.separator + "shapes", shapes)); + ret.addAll(swf.exportTexts(handler, selFile + File.separator + "texts", texts, isFormatted)); + ret.addAll(swf.exportMovies(handler, selFile + File.separator + "movies", movies)); + ret.addAll(swf.exportSounds(handler, selFile + File.separator + "sounds", sounds, isMp3OrWav, isMp3OrWav)); + ret.addAll(SWF.exportBinaryData(handler, selFile + File.separator + "binaryData", binaryData)); + List abcList = abcLists.get(swf); + if (abcPanel != null) { + for (int i = 0; i < tlsList.size(); i++) { + ScriptPack tls = tlsList.get(i); + Main.startWork(translate("work.exporting") + " " + (i + 1) + "/" + tlsList.size() + " " + tls.getPath() + " ..."); + ret.add(tls.export(selFile, abcList, exportMode, Configuration.parallelSpeedUp.get())); + } + } else { + List allNodes = new ArrayList<>(); + List asNodes = getASTagNode(tagTree); + for (TagNode asn : asNodes) { + allNodes.add(asn); + TagNode.setExport(allNodes, false); + TagNode.setExport(actionNodes, true); + ret.addAll(TagNode.exportNodeAS(swf.tags, handler, allNodes, selFile, exportMode, null)); + } } } return ret; } public SWF getCurrentSwf() { - return swfs == null || swfs.isEmpty() ? null : swfs.get(0); + if (swfs == null || swfs.isEmpty()) { + return null; + } + + TreeNode treeNode = (TreeNode) tagTree.getLastSelectedPathComponent(); + if (treeNode == null) { + return null; + } + + return treeNode.getSwf(); } private void clearCache() { @@ -1523,7 +1617,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } if (documentClass != null) { showDetail(DETAILCARDAS3NAVIGATOR); - showCard(CARDACTIONSCRIPTPANEL); + showCard(CARDACTIONSCRIPT3PANEL); abcPanel.hilightScript(documentClass); } } @@ -1554,7 +1648,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T @Override public void run() { showDetail(DETAILCARDAS3NAVIGATOR); - showCard(CARDACTIONSCRIPTPANEL); + showCard(CARDACTIONSCRIPT3PANEL); } }); } else { @@ -1597,12 +1691,13 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T public void renameOneIdentifier(final SWF swf) { if (swf.fileAttributes.actionScript3) { final int multiName = abcPanel.decompiledTextArea.getMultinameUnderCursor(); + final List abcList = abcLists.get(swf); if (multiName > 0) { new CancellableWorker() { @Override public Void doInBackground() throws Exception { Main.startWork(translate("work.renaming") + "..."); - renameMultiname(multiName); + renameMultiname(abcList, multiName); return null; } @@ -1648,7 +1743,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T if (!selDir.endsWith(File.separator)) { selDir += File.separator; } - String fileName = (new File(Main.file).getName()); + String fileName = (new File(swf.file).getName()); fileName = fileName.substring(0, fileName.length() - 4) + ".fla"; fc.setSelectedFile(new File(selDir + fileName)); FileFilter fla = new FileFilter() { @@ -1697,9 +1792,9 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T Helper.freeMem(); try { if (compressed) { - swf.exportFla(errorHandler, selfile.getAbsolutePath(), new File(Main.file).getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get()); + swf.exportFla(errorHandler, selfile.getAbsolutePath(), new File(swf.file).getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get()); } else { - swf.exportXfl(errorHandler, selfile.getAbsolutePath(), new File(Main.file).getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get()); + swf.exportXfl(errorHandler, selfile.getAbsolutePath(), new File(swf.file).getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get()); } } catch (IOException ex) { View.showMessageDialog(null, translate("error.export") + ": " + ex.getClass().getName() + " " + ex.getLocalizedMessage(), translate("error"), JOptionPane.ERROR_MESSAGE); @@ -1716,7 +1811,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } } - public void export(final SWF swf, final boolean onlySel) { + public void export(final boolean onlySel) { final ExportDialog export = new ExportDialog(); export.setVisible(true); if (!export.cancelled) { @@ -1733,12 +1828,13 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T final ExportMode exportMode = ExportMode.get(export.getOption(ExportDialog.OPTION_ACTIONSCRIPT)); final boolean isMp3OrWav = export.getOption(ExportDialog.OPTION_SOUNDS) == 0; final boolean isFormatted = export.getOption(ExportDialog.OPTION_TEXTS) == 1; + final SWF swf = getCurrentSwf(); new CancellableWorker() { @Override public Void doInBackground() throws Exception { try { if (onlySel) { - exportSelection(swf, errorHandler, selFile, export); + exportSelection(errorHandler, selFile, export); } else { swf.exportImages(errorHandler, selFile + File.separator + "images"); swf.exportShapes(errorHandler, selFile + File.separator + "shapes"); @@ -2092,7 +2188,10 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } } break; - + case ACTION_CLOSE_SWF: + { + close(getCurrentSwf()); + } } if (Main.isWorking()) { return; @@ -2101,7 +2200,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T switch (e.getActionCommand()) { case MainFrameRibbon.ACTION_EXPORT_SEL: - export(getCurrentSwf(), true); + export(true); break; } } @@ -2139,7 +2238,10 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T @Override public void valueChanged(TreeSelectionEvent e) { - setEditText(false); + TreeNode treeNode = (TreeNode) e.getPath().getLastPathComponent(); + SWF swf = treeNode.getSwf(); + updateUi(swf); + setEditText(false, false); reload(false); } @@ -2183,6 +2285,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T oldValue = tagObj; if (tagObj instanceof ScriptPack) { final ScriptPack scriptLeaf = (ScriptPack) tagObj; + final List abcList = abcLists.get(scriptLeaf.abc.swf); if (setSourceWorker != null) { setSourceWorker.cancel(true); } @@ -2233,7 +2336,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } showDetail(DETAILCARDAS3NAVIGATOR); - showCard(CARDACTIONSCRIPTPANEL); + showCard(CARDACTIONSCRIPT3PANEL); return; } else { showDetail(DETAILCARDEMPTYPANEL); @@ -2464,6 +2567,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } else { if (tagObj instanceof DefineBitsTag) { + JPEGTablesTag jtt = jtts.get(swf); if (jtt != null) { sos2.writeTag(jtt); } @@ -2728,8 +2832,19 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T tagTree.setModel(new TagTreeModel(this, swfs, abcPanel)); + expandSwfRoots(); expandTreeNodes(tagTree, expandedNodes); } + + public void expandSwfRoots() { + TreeModel model = tagTree.getModel(); + Object node = model.getRoot(); + int childCount = model.getChildCount(node); + for (int j = 0; j < childCount; j++) { + Object child = model.getChild(node, j); + tagTree.expandPath(new TreePath(new Object[] {node, child})); + } + } private List> getExpandedNodes(JTree tree) { List> expandedNodes = new ArrayList<>(); @@ -2785,17 +2900,29 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } public void setEditText(boolean edit) { + setEditText(edit, true); + } + + public void setEditText(boolean edit, boolean reload) { textValue.setEditable(edit); textSaveButton.setVisible(edit); textEditButton.setVisible(!edit); textCancelButton.setVisible(edit); - if (!edit) { + if (!edit && reload) { reload(true); } } + private boolean isFreeing; + + @Override + public boolean isFreeing() { + return isFreeing; + } + @Override public void free() { + isFreeing = true; Helper.emptyObject(mainRibbon); Helper.emptyObject(statusPanel); Helper.emptyObject(this); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java index 0d8e3dff3..59fac6b17 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java @@ -17,8 +17,10 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.ApplicationInfo; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.console.ContextMenuTools; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.helpers.Cache; import com.jpexs.process.ProcessTools; import java.awt.BorderLayout; @@ -110,12 +112,27 @@ public class MainFrameRibbon implements ActionListener { private JCheckBox miCacheDisk; private JCheckBox miGotoMainClassOnStartup; private JCommandButton saveCommandButton; + private JCommandButton saveasCommandButton; + private JCommandButton exportAllCommandButton; + private JCommandButton exportFlaCommandButton; + private JCommandButton exportSelectionCommandButton; - public MainFrameRibbon(MainFrame mainFrame, JRibbon ribbon, boolean swfLoaded, boolean hasAbc, boolean externalFlashPlayerUnavailable) { + private JCommandButton reloadCommandButton; + private JCommandButton renameinvalidCommandButton; + private JCommandButton globalrenameCommandButton; + private JCommandButton deobfuscationCommandButton; + private JCommandButton searchCommandButton; + private JCommandButton gotoDocumentClassCommandButton; + + RibbonApplicationMenuEntryPrimary exportFlaMenu; + RibbonApplicationMenuEntryPrimary exportAllMenu; + RibbonApplicationMenuEntryPrimary exportSelMenu; + + public MainFrameRibbon(MainFrame mainFrame, JRibbon ribbon, boolean externalFlashPlayerUnavailable) { this.mainFrame = mainFrame; - ribbon.addTask(createFileRibbonTask(swfLoaded)); - ribbon.addTask(createToolsRibbonTask(swfLoaded, hasAbc)); + ribbon.addTask(createFileRibbonTask()); + ribbon.addTask(createToolsRibbonTask()); ribbon.addTask(createSettingsRibbonTask()); ribbon.addTask(createHelpRibbonTask()); @@ -123,9 +140,9 @@ public class MainFrameRibbon implements ActionListener { ribbon.addTask(createDebugRibbonTask()); } - ribbon.setApplicationMenu(createMainMenu(swfLoaded)); + ribbon.setApplicationMenu(createMainMenu()); - createMenuBar(hasAbc, externalFlashPlayerUnavailable); + createMenuBar(externalFlashPlayerUnavailable); } public boolean isInternalFlashViewerSelected() { @@ -155,7 +172,7 @@ public class MainFrameRibbon implements ActionListener { return title; } - private void createMenuBar(boolean hasAbc, boolean externalFlashPlayerUnavailable) { + private void createMenuBar(boolean externalFlashPlayerUnavailable) { JMenuBar menuBar = new JMenuBar(); JMenu menuFile = new JMenu(translate("menu.file")); @@ -325,16 +342,16 @@ public class MainFrameRibbon implements ActionListener { //setJMenuBar(menuBar); - if (hasAbc) { - menuTools.add(miGotoDocumentClass); - } + //if (hasAbc) { + menuTools.add(miGotoDocumentClass); + //} } - private RibbonApplicationMenu createMainMenu(boolean swfLoaded) { + private RibbonApplicationMenu createMainMenu() { RibbonApplicationMenu mainMenu = new RibbonApplicationMenu(); - RibbonApplicationMenuEntryPrimary exportFlaMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("exportfla32"), translate("menu.file.export.fla"), new ActionRedirector(this, ACTION_EXPORT_FLA), JCommandButton.CommandButtonKind.ACTION_ONLY); - RibbonApplicationMenuEntryPrimary exportAllMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("export32"), translate("menu.file.export.all"), new ActionRedirector(this, ACTION_EXPORT), JCommandButton.CommandButtonKind.ACTION_ONLY); - RibbonApplicationMenuEntryPrimary exportSelMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("exportsel32"), translate("menu.file.export.selection"), new ActionRedirector(this, ACTION_EXPORT_SEL), JCommandButton.CommandButtonKind.ACTION_ONLY); + exportFlaMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("exportfla32"), translate("menu.file.export.fla"), new ActionRedirector(this, ACTION_EXPORT_FLA), JCommandButton.CommandButtonKind.ACTION_ONLY); + exportAllMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("export32"), translate("menu.file.export.all"), new ActionRedirector(this, ACTION_EXPORT), JCommandButton.CommandButtonKind.ACTION_ONLY); + exportSelMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("exportsel32"), translate("menu.file.export.selection"), new ActionRedirector(this, ACTION_EXPORT_SEL), JCommandButton.CommandButtonKind.ACTION_ONLY); RibbonApplicationMenuEntryPrimary checkUpdatesMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("update32"), translate("menu.help.checkupdates"), new ActionRedirector(this, ACTION_CHECK_UPDATES), JCommandButton.CommandButtonKind.ACTION_ONLY); RibbonApplicationMenuEntryPrimary aboutMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("about32"), translate("menu.help.about"), new ActionRedirector(this, ACTION_ABOUT), JCommandButton.CommandButtonKind.ACTION_ONLY); RibbonApplicationMenuEntryPrimary openFileMenu = new RibbonApplicationMenuEntryPrimary(View.getResizableIcon("open32"), translate("menu.file.open"), new ActionRedirector(this, ACTION_OPEN), JCommandButton.CommandButtonKind.ACTION_AND_POPUP_MAIN_ACTION); @@ -356,7 +373,7 @@ public class MainFrameRibbon implements ActionListener { @Override public void actionPerformed(ActionEvent ae) { RecentFilesButton source = (RecentFilesButton) ae.getSource(); - if (Main.openFile(source.fileName) == OpenFileResult.NOT_FOUND) { + if (Main.openFile(source.fileName, null) == 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); } @@ -386,12 +403,6 @@ public class MainFrameRibbon implements ActionListener { mainMenu.addFooterEntry(exitMenu); mainMenu.addMenuSeparator(); - if (!swfLoaded) { - exportAllMenu.setEnabled(false); - exportFlaMenu.setEnabled(false); - exportSelMenu.setEnabled(false); - } - return mainMenu; } @@ -402,58 +413,49 @@ public class MainFrameRibbon implements ActionListener { return resizePolicies; } - private RibbonTask createFileRibbonTask(boolean swfLoaded) { + private RibbonTask createFileRibbonTask() { 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")); + 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")); + 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")); + 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")); + 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")); + 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) { + private RibbonTask createToolsRibbonTask() { //----------------------------------------- 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")); + 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")); + 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")); @@ -476,31 +478,17 @@ public class MainFrameRibbon implements ActionListener { 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")); + 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")); + 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")); + 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); } @@ -594,12 +582,36 @@ public class MainFrameRibbon implements ActionListener { return new RibbonTask("Debug", debugBand); } + public void updateComponets(SWF swf, List abcList) { + boolean swfLoaded = swf != null; + boolean hasAbc = swfLoaded && abcList != null && !abcList.isEmpty(); + + exportAllMenu.setEnabled(swfLoaded); + exportFlaMenu.setEnabled(swfLoaded); + exportSelMenu.setEnabled(swfLoaded); + + saveCommandButton.setEnabled(swfLoaded); + saveasCommandButton.setEnabled(swfLoaded); + exportAllCommandButton.setEnabled(swfLoaded); + exportFlaCommandButton.setEnabled(swfLoaded); + exportSelectionCommandButton.setEnabled(swfLoaded); + reloadCommandButton.setEnabled(swfLoaded); + + renameinvalidCommandButton.setEnabled(swfLoaded); + globalrenameCommandButton.setEnabled(swfLoaded); + deobfuscationCommandButton.setEnabled(swfLoaded); + searchCommandButton.setEnabled(swfLoaded); + + gotoDocumentClassCommandButton.setEnabled(hasAbc); + deobfuscationCommandButton.setEnabled(hasAbc); + } + @Override public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { case ACTION_RELOAD: if (View.showConfirmDialog(null, translate("message.confirm.reload"), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { - Main.reloadSWF(); + Main.reloadSWFs(); } break; case ACTION_ADVANCED_SETTINGS: @@ -706,16 +718,18 @@ public class MainFrameRibbon implements ActionListener { break; case ACTION_SAVE: try { - Main.saveFile(Main.file); + SWF swf = mainFrame.getCurrentSwf(); + Main.saveFile(swf, swf.file); } catch (IOException ex) { Logger.getLogger(MainFrameRibbon.class.getName()).log(Level.SEVERE, null, ex); View.showMessageDialog(null, translate("error.file.save"), translate("error"), JOptionPane.ERROR_MESSAGE); } break; case ACTION_SAVE_AS: - if (Main.saveFileDialog()) { - mainFrame.setTitle(ApplicationInfo.applicationVerName + (Configuration.displayFileName.get() ? " - " + Main.getFileTitle() : "")); - saveCommandButton.setEnabled(!Main.readOnly); + SWF swf = mainFrame.getCurrentSwf(); + if (Main.saveFileDialog(swf)) { + mainFrame.setTitle(ApplicationInfo.applicationVerName + (Configuration.displayFileName.get() ? " - " + swf.getFileTitle() : "")); + saveCommandButton.setEnabled(mainFrame.getCurrentSwf() != null); } break; case ACTION_OPEN: @@ -727,7 +741,7 @@ public class MainFrameRibbon implements ActionListener { case ACTION_EXPORT_SEL: case ACTION_EXPORT: boolean onlySel = e.getActionCommand().endsWith("SEL"); - mainFrame.export(mainFrame.getCurrentSwf(), onlySel); + mainFrame.export(onlySel); break; case ACTION_CHECK_UPDATES: if (!Main.checkForUpdates()) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/SWFRoot.java b/trunk/src/com/jpexs/decompiler/flash/gui/SWFRoot.java index e172c40a1..6d1f470af 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/SWFRoot.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/SWFRoot.java @@ -17,18 +17,23 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.TagNode; +import java.util.List; /** * * @author JPEXS */ -public class SWFRoot { +public class SWFRoot implements TreeNode { private SWF swf; private String name; + public List list; - public SWFRoot(SWF swf, String name) { + public SWFRoot(SWF swf, String name, List list) { + this.swf = swf; this.name = name; + this.list = list; } public SWF getSwf() { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/SWFSourceInfo.java b/trunk/src/com/jpexs/decompiler/flash/gui/SWFSourceInfo.java new file mode 100644 index 000000000..1d5066d6b --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/gui/SWFSourceInfo.java @@ -0,0 +1,49 @@ +/* + * 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 java.io.InputStream; + +/** + * + * @author JPEXS + */ +public class SWFSourceInfo { + + private InputStream inputStream; + private String file; + private String fileTitle; + + public SWFSourceInfo(InputStream inputStream, String file, String fileTitle) { + this.inputStream = inputStream; + this.file = file; + this.fileTitle = fileTitle; + } + + public InputStream getInputStream() { + return inputStream; + } + + public String getFile() { + return file; + } + + public String getFileTitle() { + return fileTitle; + } + +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java b/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java index 6e6ad5962..c7db1509d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java @@ -38,18 +38,21 @@ import javax.swing.tree.TreePath; public class TagTreeModel implements TreeModel { - private SWFRoot root; - private List list = new ArrayList<>(); + private TagTreeRoot root = new TagTreeRoot(); + private List swfs; private MainFrame mainFrame; public TagTreeModel(MainFrame mainFrame, List swfs, ABCPanel abcPanel) { this.mainFrame = mainFrame; - SWF swf = swfs.get(0); // todo honfika: add multiple swfs - this.root = new SWFRoot(swf, new File(Main.file).getName()); + this.swfs = new ArrayList<>(); + for (SWF swf : swfs) { + List objs = new ArrayList<>(); + objs.addAll(swf.tags); + List list = createTagList(objs, null, abcPanel, swf); - List objs = new ArrayList<>(); - objs.addAll(swf.tags); - this.list = createTagList(objs, null, abcPanel); + SWFRoot swfRoot = new SWFRoot(swf, new File(swf.file).getName(), list); + this.swfs.add(swfRoot); + } } private String translate(String key) { @@ -63,7 +66,7 @@ public class TagTreeModel implements TreeModel { TagType ttype = MainFrame.getTagType(o); if (ttype == TagType.SHOW_FRAME && type == TagType.FRAME) { frameCnt++; - ret.add(new TagNode(new FrameNode(o.getSwf(), frameCnt, parent, display))); + ret.add(new TagNode(new FrameNode(o.getSwf(), frameCnt, parent, display), o.getSwf())); } else if (type == ttype) { ret.add(new TagNode(o)); } @@ -71,7 +74,7 @@ public class TagTreeModel implements TreeModel { return ret; } - private List createTagList(List list, Object parent, ABCPanel abcPanel) { + private List createTagList(List list, Object parent, ABCPanel abcPanel, SWF swf) { List ret = new ArrayList<>(); List frames = getTagNodesWithType(list, TagType.FRAME, parent, true); List shapes = getTagNodesWithType(list, TagType.SHAPE, parent, true); @@ -102,7 +105,7 @@ public class TagTreeModel implements TreeModel { } List exportAssetsTags = new ArrayList<>(); - for (Object t : list) { + for (ContainerItem t : list) { if (t instanceof ExportAssetsTag) { exportAssetsTags.add((ExportAssetsTag) t); } @@ -114,49 +117,49 @@ public class TagTreeModel implements TreeModel { TagNode tti = new TagNode(t); if (((Container) t).getItemCount() > 0) { List subItems = ((Container) t).getSubItems(); - tti.subItems = createTagList(subItems, t, abcPanel); + tti.subItems = createTagList(subItems, t, abcPanel, t.getSwf()); } //ret.add(tti); } } actionScript = SWF.createASTagList(list, null); - TagNode textsNode = new TagNode(translate("node.texts")); + TagNode textsNode = new TagNode(translate("node.texts"), swf); textsNode.subItems.addAll(texts); - TagNode imagesNode = new TagNode(translate("node.images")); + TagNode imagesNode = new TagNode(translate("node.images"), swf); imagesNode.subItems.addAll(images); - TagNode moviesNode = new TagNode(translate("node.movies")); + TagNode moviesNode = new TagNode(translate("node.movies"), swf); moviesNode.subItems.addAll(movies); - TagNode soundsNode = new TagNode(translate("node.sounds")); + TagNode soundsNode = new TagNode(translate("node.sounds"), swf); soundsNode.subItems.addAll(sounds); - TagNode binaryDataNode = new TagNode(translate("node.binaryData")); + TagNode binaryDataNode = new TagNode(translate("node.binaryData"), swf); binaryDataNode.subItems.addAll(binaryData); - TagNode fontsNode = new TagNode(translate("node.fonts")); + TagNode fontsNode = new TagNode(translate("node.fonts"), swf); fontsNode.subItems.addAll(fonts); - TagNode spritesNode = new TagNode(translate("node.sprites")); + TagNode spritesNode = new TagNode(translate("node.sprites"), swf); spritesNode.subItems.addAll(sprites); - TagNode shapesNode = new TagNode(translate("node.shapes")); + TagNode shapesNode = new TagNode(translate("node.shapes"), swf); shapesNode.subItems.addAll(shapes); - TagNode morphShapesNode = new TagNode(translate("node.morphshapes")); + TagNode morphShapesNode = new TagNode(translate("node.morphshapes"), swf); morphShapesNode.subItems.addAll(morphShapes); - TagNode buttonsNode = new TagNode(translate("node.buttons")); + TagNode buttonsNode = new TagNode(translate("node.buttons"), swf); buttonsNode.subItems.addAll(buttons); - TagNode framesNode = new TagNode(translate("node.frames")); + TagNode framesNode = new TagNode(translate("node.frames"), swf); framesNode.subItems.addAll(frames); - TagNode actionScriptNode = new TagNode(translate("node.scripts")); + TagNode actionScriptNode = new TagNode(translate("node.scripts"), swf); actionScriptNode.mark = "scripts"; actionScriptNode.subItems.addAll(actionScript); @@ -243,17 +246,13 @@ public class TagTreeModel implements TreeModel { return tp; } - public List getNodeList() { - return list; - } - @Override public Object getRoot() { return root; } @Override - public Object getChild(Object parent, int index) { + public TreeNode getChild(Object parent, int index) { if (parent instanceof TagNode) { if (((TagNode) parent).tag instanceof ClassesListTreeModel) { ClassesListTreeModel clt = (ClassesListTreeModel) ((TagNode) parent).tag; @@ -263,29 +262,29 @@ public class TagTreeModel implements TreeModel { return ((TreeElement) parent).getChild(index); } if (parent == root) { - return list.get(index); - } else { - return ((TagNode) parent).subItems.get(index); + return swfs.get(index); + } else if (parent instanceof SWFRoot) { + return ((SWFRoot) parent).list.get(index); } + return ((TagNode) parent).subItems.get(index); } @Override public int getChildCount(Object parent) { if (parent == root) { - return list.size(); - } else { - if (parent instanceof TagNode) { - if (((TagNode) parent).tag instanceof ClassesListTreeModel) { - ClassesListTreeModel clt = (ClassesListTreeModel) ((TagNode) parent).tag; - return clt.getChildCount(clt.getRoot()); - } - return ((TagNode) parent).subItems.size(); - } else if (parent instanceof TreeElement) { - return ((TreeElement) parent).getChildCount(); + return swfs.size(); + } else if (parent instanceof TagNode) { + if (((TagNode) parent).tag instanceof ClassesListTreeModel) { + ClassesListTreeModel clt = (ClassesListTreeModel) ((TagNode) parent).tag; + return clt.getChildCount(clt.getRoot()); } - return 0; - + return ((TagNode) parent).subItems.size(); + } else if (parent instanceof TreeElement) { + return ((TreeElement) parent).getChildCount(); + } else if (parent instanceof SWFRoot) { + return ((SWFRoot) parent).list.size(); } + return 0; } @Override @@ -306,27 +305,16 @@ public class TagTreeModel implements TreeModel { } } if (parent == root) { - for (int t = 0; t < list.size(); t++) { - if (list.get(t) == child) { - return t; - } - } - return -1; - } else { - if (parent instanceof TagNode) { - List subTags = ((TagNode) parent).subItems; - for (int t = 0; t < subTags.size(); t++) { - if (subTags.get(t) == child) { - return t; - } - } - } - if (parent instanceof TreeElement) { - return ((TreeElement) parent).getIndexOfChild((TreeElement) child); - } - - return -1; + return swfs.indexOf(child); + } else if (parent instanceof TagNode) { + List subTags = ((TagNode) parent).subItems; + return subTags.indexOf(child); + } else if (parent instanceof TreeElement) { + return ((TreeElement) parent).getIndexOfChild((TreeElement) child); + } else if (parent instanceof SWFRoot) { + return ((SWFRoot) parent).list.indexOf(child); } + return -1; } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeRoot.java b/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeRoot.java new file mode 100644 index 000000000..3485bfeb9 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeRoot.java @@ -0,0 +1,29 @@ +/* + * 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; + +/** + * + * @author JPEXS + */ +public class TagTreeRoot { + + @Override + public String toString() { + return "root"; + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/TreeNode.java b/trunk/src/com/jpexs/decompiler/flash/gui/TreeNode.java new file mode 100644 index 000000000..dfa94686b --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/gui/TreeNode.java @@ -0,0 +1,28 @@ +/* + * 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.SWF; + +/** + * + * @author JPEXS + */ +public interface TreeNode { + + public SWF getSwf(); +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 916110efe..c1b39ac96 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -39,6 +39,7 @@ import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.gui.HeaderLabel; import com.jpexs.decompiler.flash.gui.Main; +import com.jpexs.decompiler.flash.gui.MainFrame; import com.jpexs.decompiler.flash.gui.MyTextField; import com.jpexs.decompiler.flash.gui.TagTreeModel; import com.jpexs.decompiler.flash.gui.View; @@ -79,10 +80,12 @@ import jsyntaxpane.actions.DocumentSearchData; public class ABCPanel extends JPanel implements ItemListener, ActionListener, Freed { + private MainFrame mainFrame; public TraitsList navigator; public ClassesListTree classTree; public ABC abc; public List list; + public SWF swf; public JComboBox abcComboBox; public int listIndex = -1; public DecompiledEditorPane decompiledTextArea; @@ -265,9 +268,22 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr //colModel.getColumn(0).setMaxWidth(50); } + @SuppressWarnings("unchecked") + public void setSwf(List list, SWF swf) { + this.list = list; + this.swf = swf; + switchAbc(0); // todo honika: do we need this? + abcComboBox.setModel(new ABCComboBoxModel(list)); + if (list.size() > 0) { + this.abc = list.get(0).getABC(); + } + + navigator.setABC(list, abc); + } + public void switchAbc(int index) { listIndex = index; - classTree.setDoABCTags(list); + classTree.setDoABCTags(list, swf); if (index != -1) { this.abc = list.get(index).getABC(); @@ -294,34 +310,32 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr } + private boolean isFreeing; + + @Override + public boolean isFreeing() { + return isFreeing; + } + @Override public void free() { + isFreeing = true; Helper.emptyObject(this); } @SuppressWarnings("unchecked") - public ABCPanel(List list, SWF swf) { + public ABCPanel(MainFrame mainFrame) { DefaultSyntaxKit.initKit(); - this.list = list; - if (list.size() > 0) { - this.abc = list.get(0).getABC(); - } + this.mainFrame = mainFrame; setLayout(new BorderLayout()); - - - - - decompiledTextArea = new DecompiledEditorPane(this); - searchPanel = new JPanel(new FlowLayout()); decompiledScrollPane = new JScrollPane(decompiledTextArea); - JPanel iconDecPanel = new JPanel(); iconDecPanel.setLayout(new BoxLayout(iconDecPanel, BoxLayout.Y_AXIS)); JPanel iconsPanel = new JPanel(); @@ -370,10 +384,9 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr JPanel pan2 = new JPanel(); pan2.setLayout(new BorderLayout()); - pan2.add((abcComboBox = new JComboBox(new ABCComboBoxModel(list))), BorderLayout.NORTH); + pan2.add((abcComboBox = new JComboBox(new ABCComboBoxModel(new ArrayList()))), BorderLayout.NORTH); navigator = new TraitsList(this); - navigator.setABC(list, abc); navPanel = new JPanel(new BorderLayout()); @@ -421,7 +434,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr JPanel treePanel = new JPanel(); treePanel.setLayout(new BorderLayout()); - treePanel.add(new JScrollPane(classTree = new ClassesListTree(list, this, swf)), BorderLayout.CENTER); + treePanel.add(new JScrollPane(classTree = new ClassesListTree(this)), BorderLayout.CENTER); JPanel filterPanel = new JPanel(); filterPanel.setLayout(new BorderLayout()); filterPanel.add(filterField, BorderLayout.CENTER); @@ -488,7 +501,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr } constantTable.setAutoCreateRowSorter(true); - final List inlist = list; final ABCPanel t = this; constantTable.addMouseListener(new MouseAdapter() { @Override @@ -501,7 +513,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr } int multinameIndex = constantTable.convertRowIndexToModel(rowIndex); if (multinameIndex > 0) { - UsageFrame usageFrame = new UsageFrame(inlist, abc, multinameIndex, t); + UsageFrame usageFrame = new UsageFrame(t.list, abc, multinameIndex, t); usageFrame.setVisible(true); } } @@ -562,13 +574,13 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr } public void hilightScript(ScriptPack pack) { - TagTreeModel ttm = (TagTreeModel) Main.mainFrame.tagTree.getModel(); + TagTreeModel ttm = (TagTreeModel) mainFrame.tagTree.getModel(); final TreePath tp = ttm.getTagPath(pack); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - Main.mainFrame.tagTree.setSelectionPath(tp); - Main.mainFrame.tagTree.scrollPathToVisible(tp); + mainFrame.tagTree.setSelectionPath(tp); + mainFrame.tagTree.scrollPathToVisible(tp); } }); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTree.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTree.java index a58c61b41..12deb4747 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTree.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTree.java @@ -51,12 +51,8 @@ public final class ClassesListTree extends JTree implements TreeSelectionListene scrollPathToVisible(treePath); } - public ClassesListTree(List list, ABCPanel abcPanel, SWF swf) { - this.abcList = list; - this.swf = swf; - this.treeList = getTreeList(list); + public ClassesListTree(ABCPanel abcPanel) { this.abcPanel = abcPanel; - setModel(new ClassesListTreeModel(this.treeList)); addTreeSelectionListener(this); DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer(); ClassLoader cldr = this.getClass().getClassLoader(); @@ -99,19 +95,15 @@ public final class ClassesListTree extends JTree implements TreeSelectionListene return selectedScripts; } - public List> getTreeList(List list) { - - return swf.getAS3Packs(); - } - - public void setDoABCTags(List list) { + public void setDoABCTags(List list, SWF swf) { this.abcList = list; - this.treeList = getTreeList(list); - setModel(new ClassesListTreeModel(this.treeList)); + this.treeList = swf.getAS3Packs(); + this.swf = swf; + setModel(new ClassesListTreeModel(this.treeList, swf)); } public void applyFilter(String filter) { - setModel(new ClassesListTreeModel(this.treeList, filter)); + setModel(new ClassesListTreeModel(this.treeList, swf, filter)); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java index 580eadc2b..e00aad414 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java @@ -16,11 +16,13 @@ */ package com.jpexs.decompiler.flash.gui.abc; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.ClassPath; 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.gui.AppStrings; +import com.jpexs.decompiler.flash.gui.TreeNode; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import java.util.List; import javax.swing.event.TreeModelListener; @@ -77,18 +79,19 @@ class ClassIndexVisitor implements TreeVisitor { public class ClassesListTreeModel implements TreeModel { - private Tree classTree = new Tree(); + private Tree classTree; private List> list; public List> getList() { return list; } - public ClassesListTreeModel(List> list) { - this(list, null); + public ClassesListTreeModel(List> list, SWF swf) { + this(list, swf, null); } - public ClassesListTreeModel(List> list, String filter) { + public ClassesListTreeModel(List> list, SWF swf, String filter) { + classTree = new Tree(swf); for (MyEntry item : list) { if (filter != null) { if (!filter.isEmpty()) { @@ -125,7 +128,7 @@ public class ClassesListTreeModel implements TreeModel { } @Override - public Object getChild(Object parent, int index) { + public TreeNode getChild(Object parent, int index) { TreeElement pte = (TreeElement) parent; TreeElement te = pte.getChild(index); return te; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java index 18b49fbce..2108fb6a3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java @@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.gui.HeaderLabel; import com.jpexs.decompiler.flash.gui.View; -import static com.jpexs.decompiler.flash.gui.abc.DeobfuscationDialog.ACTION_OK; import com.jpexs.helpers.CancellableWorker; import java.awt.BorderLayout; import java.awt.CardLayout; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/Tree.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/Tree.java index 027a3fa82..8e8242153 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/Tree.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/Tree.java @@ -16,11 +16,16 @@ */ package com.jpexs.decompiler.flash.gui.abc; +import com.jpexs.decompiler.flash.SWF; import java.util.StringTokenizer; public class Tree { - private final TreeElement ROOT = new TreeElement("", "", null, null); + private final TreeElement ROOT; + + public Tree(SWF swf) { + ROOT = new TreeElement(swf, "", "", null, null); + } public void add(String name, String path, Object item) { StringTokenizer st = new StringTokenizer(path, "."); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/TreeElement.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/TreeElement.java index 014345745..b3d658e19 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/TreeElement.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/TreeElement.java @@ -16,10 +16,12 @@ */ package com.jpexs.decompiler.flash.gui.abc; +import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.gui.TreeNode; import java.util.*; import javax.swing.tree.TreePath; -public class TreeElement { +public class TreeElement implements TreeNode { private SortedMap branches; private SortedMap leafs; @@ -27,8 +29,10 @@ public class TreeElement { private String path; private Object item; private TreeElement parent; + private SWF swf; - public TreeElement(String name, String path, Object item, TreeElement parent) { + public TreeElement(SWF swf, String name, String path, Object item, TreeElement parent) { + this.swf = swf; this.name = name; this.path = path; this.item = item; @@ -37,6 +41,10 @@ public class TreeElement { leafs = new TreeMap<>(); } + public SWF getSwf() { + return swf; + } + public TreeElement getParent() { return parent; } @@ -70,14 +78,14 @@ public class TreeElement { TreeElement getBranch(String pathElement) { TreeElement branch = branches.get(pathElement); if (branch == null) { - branch = new TreeElement(pathElement, path + "." + pathElement, null, this); + branch = new TreeElement(swf, pathElement, path + "." + pathElement, null, this); branches.put(pathElement, branch); } return branch; } void addLeaf(String pathElement, Object item) { - TreeElement child = new TreeElement(pathElement, path + "." + pathElement, item, this); + TreeElement child = new TreeElement(swf, pathElement, path + "." + pathElement, item, this); leafs.put(pathElement, child); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java index 6fbff8172..10a1ce75c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java @@ -23,7 +23,6 @@ import com.jpexs.decompiler.flash.abc.usages.MultinameUsage; import com.jpexs.decompiler.flash.abc.usages.TraitMultinameUsage; import com.jpexs.decompiler.flash.gui.AppFrame; import com.jpexs.decompiler.flash.gui.View; -import static com.jpexs.decompiler.flash.gui.abc.NewTraitDialog.ACTION_OK; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.awt.BorderLayout; import java.awt.Color; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index 6fd77f1a0..b7bfe2b37 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.gui.GraphFrame; import com.jpexs.decompiler.flash.gui.HeaderLabel; import com.jpexs.decompiler.flash.gui.Main; +import com.jpexs.decompiler.flash.gui.MainFrame; import com.jpexs.decompiler.flash.gui.TagTreeModel; import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane; @@ -93,6 +94,7 @@ public class ActionPanel extends JPanel implements ActionListener { static final String ACTION_EDIT_DECOMPILED = "EDITDECOMPILED"; static final String ACTION_CANCEL_DECOMPILED = "CANCELDECOMPILED"; + private MainFrame mainFrame; public LineMarkedEditorPane editor; public LineMarkedEditorPane decompiledEditor; public List list; @@ -220,7 +222,7 @@ public class ActionPanel extends JPanel implements ActionListener { if ((txt != null) && (!txt.isEmpty())) { searchIgnoreCase = ignoreCase; searchRegexp = regexp; - List list = SWF.createASTagList(Main.swf.tags, null); + List list = SWF.createASTagList(mainFrame.getCurrentSwf().tags, null); Map asms = getASMs("", list); found = new ArrayList<>(); Pattern pat = null; @@ -423,8 +425,9 @@ public class ActionPanel extends JPanel implements ActionListener { public void hilightOffset(long offset) { } - public ActionPanel() { + public ActionPanel(MainFrame mainFrame) { DefaultSyntaxKit.initKit(); + this.mainFrame = mainFrame; editor = new LineMarkedEditorPane(); editor.setEditable(false); decompiledEditor = new LineMarkedEditorPane(); @@ -811,10 +814,10 @@ public class ActionPanel extends JPanel implements ActionListener { public void updateSearchPos() { searchPos.setText((foundPos + 1) + "/" + found.size()); setSource(found.get(foundPos), true); - TagTreeModel ttm = (TagTreeModel) Main.mainFrame.tagTree.getModel(); + TagTreeModel ttm = (TagTreeModel) mainFrame.tagTree.getModel(); TreePath tp = ttm.getTagPath(found.get(foundPos)); - Main.mainFrame.tagTree.setSelectionPath(tp); - Main.mainFrame.tagTree.scrollPathToVisible(tp); + mainFrame.tagTree.setSelectionPath(tp); + mainFrame.tagTree.scrollPathToVisible(tp); decompiledEditor.setCaretPosition(0); java.util.Timer t = new java.util.Timer(); SwingUtilities.invokeLater(new Runnable() { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 499b0f435..67733ad76 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -379,3 +379,4 @@ menu.recentFiles = Recent files #after version 1.7.4 work.restoringControlFlow.complete = Control flow restored message.confirm.recentFileNotFound = File not found. Do you want to remove it from the recent file list? +contextmenu.closeSwf = Close SWF diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties index 80ca4c0f7..41cdccedd 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties @@ -379,3 +379,4 @@ menu.recentFiles = El\u0151zm\u00e9nyek #after version 1.7.4 work.restoringControlFlow.complete = Vez\u00e9rl\u00e9si-folyam helyre\u00e1ll\u00edt\u00e1s befejez\u0151d\u00f6tt message.confirm.recentFileNotFound = F\u00e1jl nem tal\u00e1lhat\u00f3. Szeretn\u00e9 elt\u00e1vol\u00edtani az el\u0151zm\u00e9nyek k\u00f6z\u00fcl? +contextmenu.closeSwf = SWF bez\u00e1r\u00e1sa diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java index 279e064dd..9d6c46cd6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.gui.proxy; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.gui.AppFrame; import com.jpexs.decompiler.flash.gui.Main; +import com.jpexs.decompiler.flash.gui.MainFrame; import com.jpexs.decompiler.flash.gui.View; import com.jpexs.proxy.CatchedListener; import com.jpexs.proxy.ReplacedListener; @@ -54,6 +55,7 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe static final String ACTION_RENAME = "RENAME"; static final String ACTION_REMOVE = "REMOVE"; + private MainFrame mainFrame; private JList swfList; private SWFListModel listModel; private JButton switchButton = new JButton(translate("proxy.start")); @@ -86,8 +88,9 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe * Constructor */ @SuppressWarnings("unchecked") - public ProxyFrame() { + public ProxyFrame(final MainFrame mainFrame) { + this.mainFrame = mainFrame; listModel = new SWFListModel(Configuration.getReplacements()); swfList = new JList(listModel); swfList.addMouseListener(this); @@ -152,8 +155,8 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe public void windowClosing(WindowEvent e) { setVisible(false); Main.removeTrayIcon(); - if (Main.mainFrame != null) { - if (Main.mainFrame.isVisible()) { + if (mainFrame != null) { + if (mainFrame.isVisible()) { return; } } @@ -177,8 +180,7 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe private void open() { if (swfList.getSelectedIndex() > -1) { Replacement r = (Replacement) listModel.getElementAt(swfList.getSelectedIndex()); - Main.fileTitle = r.urlPattern; - Main.openFile(r.targetFile); + Main.openFile(r.targetFile, r.urlPattern); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/Freed.java b/trunk/src/com/jpexs/decompiler/flash/helpers/Freed.java index b49093e92..78bafa4d1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/helpers/Freed.java +++ b/trunk/src/com/jpexs/decompiler/flash/helpers/Freed.java @@ -22,5 +22,6 @@ package com.jpexs.decompiler.flash.helpers; */ public interface Freed { + public boolean isFreeing(); public void free(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java index 738d2cf38..88fc4a9a9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java @@ -75,7 +75,7 @@ public class DoABCDefineTag extends Tag implements ABCContainerTag { SWFInputStream sis = new SWFInputStream(is, version); flags = sis.readUI32(); name = sis.readString(); - abc = new ABC(is); + abc = new ABC(is, swf); } /** diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoABCTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoABCTag.java index f763e66af..805a3b650 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoABCTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoABCTag.java @@ -61,7 +61,7 @@ public class DoABCTag extends Tag implements ABCContainerTag { public DoABCTag(SWF swf, byte[] data, int version, long pos) throws IOException { super(swf, ID, "DoABC", data, pos); InputStream is = new ByteArrayInputStream(data); - abc = new ABC(is); + abc = new ABC(is, swf); } /** diff --git a/trunk/src/com/jpexs/helpers/Helper.java b/trunk/src/com/jpexs/helpers/Helper.java index 3e1bc30f3..f651ab95a 100644 --- a/trunk/src/com/jpexs/helpers/Helper.java +++ b/trunk/src/com/jpexs/helpers/Helper.java @@ -508,7 +508,10 @@ public class Helper { } } if (v instanceof Freed) { - ((Freed) v).free(); + Freed freed = ((Freed) v); + if (!freed.isFreeing()) { + ((Freed) v).free(); + } } f.set(obj, null); }