diff --git a/trunk/src/com/jpexs/decompiler/flash/FrameNode.java b/trunk/src/com/jpexs/decompiler/flash/FrameNode.java index 54f7e209d..b47f0f0ab 100644 --- a/trunk/src/com/jpexs/decompiler/flash/FrameNode.java +++ b/trunk/src/com/jpexs/decompiler/flash/FrameNode.java @@ -16,11 +16,13 @@ */ package com.jpexs.decompiler.flash; +import com.jpexs.decompiler.flash.gui.abc.TreeElementItem; + /** * * @author JPEXS */ -public class FrameNode { +public class FrameNode implements TreeElementItem { private SWF swf; private int frame; diff --git a/trunk/src/com/jpexs/decompiler/flash/PackageNode.java b/trunk/src/com/jpexs/decompiler/flash/PackageNode.java index 998541bcc..f06f8dbd5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/PackageNode.java +++ b/trunk/src/com/jpexs/decompiler/flash/PackageNode.java @@ -16,11 +16,13 @@ */ package com.jpexs.decompiler.flash; +import com.jpexs.decompiler.flash.gui.abc.TreeElementItem; + /** * * @author JPEXS */ -public class PackageNode { +public class PackageNode implements TreeElementItem { public String packageName; diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index b73a1b5e3..afed5026e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -55,6 +55,7 @@ import com.jpexs.decompiler.flash.flv.AUDIODATA; import com.jpexs.decompiler.flash.flv.FLVOutputStream; import com.jpexs.decompiler.flash.flv.FLVTAG; import com.jpexs.decompiler.flash.flv.VIDEODATA; +import com.jpexs.decompiler.flash.gui.SWFSourceInfo; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; @@ -66,6 +67,7 @@ import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag; import com.jpexs.decompiler.flash.tags.DoInitActionTag; import com.jpexs.decompiler.flash.tags.ExportAssetsTag; import com.jpexs.decompiler.flash.tags.FileAttributesTag; +import com.jpexs.decompiler.flash.tags.JPEGTablesTag; import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag; import com.jpexs.decompiler.flash.tags.ShowFrameTag; import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag; @@ -204,9 +206,13 @@ public final class SWF { */ public boolean gfx = false; + public SWFSourceInfo sourceInfo; public String file; public String fileTitle; - + public HashMap characters; + public List abcList; + public JPEGTablesTag jtt; + /** * Gets all tags with specified id * @@ -815,13 +821,13 @@ public final class SWF { frame++; frames.add(tti); } else if (t instanceof ASMSource) { - TagNode tti = new TagNode(t); + TagNode tti = new TagNode(t, t.getSwf()); //ret.add(tti); addNode = tti; } else if (t instanceof Container) { if (((Container) t).getItemCount() > 0) { - TagNode tti = new TagNode(t); + TagNode tti = new TagNode(t, t.getSwf()); List subItems = ((Container) t).getSubItems(); tti.subItems = createASTagList(subItems, t); diff --git a/trunk/src/com/jpexs/decompiler/flash/StringNode.java b/trunk/src/com/jpexs/decompiler/flash/StringNode.java new file mode 100644 index 000000000..e5e151ab5 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/StringNode.java @@ -0,0 +1,37 @@ +/* + * 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; + +import com.jpexs.decompiler.flash.gui.abc.TreeElementItem; + +/** + * + * @author JPEXS + */ +public class StringNode implements TreeElementItem { + + private String str; + + public StringNode(String str) { + this.str = str; + } + + @Override + public String toString() { + return str; + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/TagNode.java b/trunk/src/com/jpexs/decompiler/flash/TagNode.java index d22aec591..a5a159803 100644 --- a/trunk/src/com/jpexs/decompiler/flash/TagNode.java +++ b/trunk/src/com/jpexs/decompiler/flash/TagNode.java @@ -19,6 +19,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.gui.abc.TreeElementItem; import com.jpexs.decompiler.flash.helpers.FileTextWriter; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG3Tag; @@ -69,7 +70,7 @@ import java.util.logging.Logger; public class TagNode implements TreeNode { public List subItems; - public Object tag; + public TreeElementItem tag; private SWF swf; public boolean export = false; public String mark; @@ -83,11 +84,11 @@ public class TagNode implements TreeNode { return ret; } - public TagNode(ContainerItem containerItem) { - this(containerItem, containerItem.getSwf()); + public TagNode(Tag tag) { + this(tag, tag.getSwf()); } - public TagNode(Object tag, SWF swf) { + public TagNode(TreeElementItem tag, SWF swf) { this.swf = swf; this.tag = tag; this.subItems = new ArrayList<>(); @@ -125,12 +126,12 @@ public class TagNode implements TreeNode { || (t instanceof DefineFont2Tag) || (t instanceof DefineFont3Tag) || (t instanceof DefineFont4Tag)) { - fonts.add(new TagNode(t)); + fonts.add(new TagNode(t, t.getSwf())); } if ((t instanceof DefineTextTag) || (t instanceof DefineText2Tag) || (t instanceof DefineEditTextTag)) { - texts.add(new TagNode(t)); + texts.add(new TagNode(t, t.getSwf())); } if ((t instanceof DefineBitsTag) @@ -139,27 +140,27 @@ public class TagNode implements TreeNode { || (t instanceof DefineBitsJPEG4Tag) || (t instanceof DefineBitsLosslessTag) || (t instanceof DefineBitsLossless2Tag)) { - images.add(new TagNode(t)); + images.add(new TagNode(t, t.getSwf())); } if ((t instanceof DefineShapeTag) || (t instanceof DefineShape2Tag) || (t instanceof DefineShape3Tag) || (t instanceof DefineShape4Tag)) { - shapes.add(new TagNode(t)); + shapes.add(new TagNode(t, t.getSwf())); } if ((t instanceof DefineMorphShapeTag) || (t instanceof DefineMorphShape2Tag)) { - morphShapes.add(new TagNode(t)); + morphShapes.add(new TagNode(t, t.getSwf())); } if (t instanceof DefineSpriteTag) { - sprites.add(new TagNode(t)); + sprites.add(new TagNode(t, t.getSwf())); } if ((t instanceof DefineButtonTag) || (t instanceof DefineButton2Tag)) { - buttons.add(new TagNode(t)); + buttons.add(new TagNode(t, t.getSwf())); } if (t instanceof ShowFrameTag) { - TagNode tti = new TagNode("frame" + frame, t.getSwf()); + TagNode tti = new TagNode(new StringNode("frame" + frame), t.getSwf()); /* for (int r = ret.size() - 1; r >= 0; r--) { if (!(ret.get(r).tag instanceof DefineSpriteTag)) { @@ -180,7 +181,7 @@ public class TagNode implements TreeNode { ret.add(tti); } else */ if (t instanceof Container) { - TagNode tti = new TagNode(t); + TagNode tti = new TagNode(t, t.getSwf()); if (((Container) t).getItemCount() > 0) { List subItems = ((Container) t).getSubItems(); tti.subItems = createTagList(subItems, t.getSwf()); @@ -189,29 +190,29 @@ public class TagNode implements TreeNode { } } - TagNode textsNode = new TagNode("texts", swf); + TagNode textsNode = new TagNode(new StringNode("texts"), swf); textsNode.subItems.addAll(texts); - TagNode imagesNode = new TagNode("images", swf); + TagNode imagesNode = new TagNode(new StringNode("images"), swf); imagesNode.subItems.addAll(images); - TagNode fontsNode = new TagNode("fonts", swf); + TagNode fontsNode = new TagNode(new StringNode("fonts"), swf); fontsNode.subItems.addAll(fonts); - TagNode spritesNode = new TagNode("sprites", swf); + TagNode spritesNode = new TagNode(new StringNode("sprites"), swf); spritesNode.subItems.addAll(sprites); - TagNode shapesNode = new TagNode("shapes", swf); + TagNode shapesNode = new TagNode(new StringNode("shapes"), swf); shapesNode.subItems.addAll(shapes); - TagNode morphShapesNode = new TagNode("morphshapes", swf); + TagNode morphShapesNode = new TagNode(new StringNode("morphshapes"), swf); morphShapesNode.subItems.addAll(morphShapes); - TagNode buttonsNode = new TagNode("buttons", swf); + TagNode buttonsNode = new TagNode(new StringNode("buttons"), swf); buttonsNode.subItems.addAll(buttons); - TagNode framesNode = new TagNode("frames", swf); + TagNode framesNode = new TagNode(new StringNode("frames"), swf); framesNode.subItems.addAll(frames); ret.add(shapesNode); ret.add(morphShapesNode);; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java b/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java index 9501083b9..2235b2966 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.gui.abc.TreeElementItem; import com.jpexs.decompiler.flash.helpers.FileTextWriter; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; @@ -44,7 +45,7 @@ import java.util.logging.Logger; * * @author JPEXS */ -public class ScriptPack { +public class ScriptPack implements TreeElementItem { public ABC abc; public int scriptIndex; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index 99f2e83e5..8fc1e678a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -40,8 +40,8 @@ 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.List; import java.util.Locale; import java.util.logging.ConsoleHandler; import java.util.logging.FileHandler; @@ -185,19 +185,22 @@ public class Main { } public static SWF parseSWF(String file) throws Exception { - return parseSWF(new FileInputStream(file), file, null); + SWFSourceInfo sourceInfo = new SWFSourceInfo(new FileInputStream(file), file, null); + return parseSWF(sourceInfo); } - public static SWF parseSWF(InputStream fis, String file, String fileTitle) throws Exception { + public static SWF parseSWF(SWFSourceInfo sourceInfo) throws Exception { SWF locswf; + InputStream fis = sourceInfo.getInputStream(); locswf = new SWF(fis, new ProgressListener() { @Override public void progress(int p) { startWork(AppStrings.translate("work.reading.swf"), p); } }, Configuration.parallelSpeedUp.get()); - locswf.file = file; - locswf.fileTitle = fileTitle; + locswf.sourceInfo = sourceInfo; + locswf.file = sourceInfo.getFile(); + locswf.fileTitle = sourceInfo.getFileTitle(); locswf.addEventListener(new EventListener() { @Override public void handleEvent(String event, Object data) { @@ -251,7 +254,7 @@ public class Main { try { Main.startWork(AppStrings.translate("work.reading.swf") + "..."); InputStream inputStream = sourceInfo.getInputStream(); - swf = parseSWF(inputStream, sourceInfo.getFile(), sourceInfo.getFileTitle()); + swf = parseSWF(sourceInfo); if (inputStream instanceof FileInputStream) { inputStream.close(); } @@ -350,6 +353,10 @@ public class Main { loadFromCacheFrame.setVisible(false); loadFromCacheFrame = null; } + if (mainFrame != null) { + mainFrame.setVisible(false); + mainFrame = null; + } reloadSWFs(); } @@ -372,6 +379,7 @@ public class Main { public static OpenFileResult openFile(SWFSourceInfo sourceInfo) { if (mainFrame != null && !Configuration.openMultiple.get()) { + sourceInfos.clear(); mainFrame.closeAll(); mainFrame.setVisible(false); Cache.clearAll(); @@ -399,6 +407,11 @@ public class Main { return openFile(sourceInfo); } + public static void closeFile(SWF swf) { + sourceInfos.remove(swf.sourceInfo); + mainFrame.close(swf); + } + public static boolean saveFileDialog(SWF swf) { JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(Configuration.lastSaveDir.get())); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index 6f4b5c1a2..e28491154 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -36,6 +36,7 @@ import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel; import com.jpexs.decompiler.flash.gui.abc.DeobfuscationDialog; import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane; import com.jpexs.decompiler.flash.gui.abc.TreeElement; +import com.jpexs.decompiler.flash.gui.abc.TreeElementItem; import com.jpexs.decompiler.flash.gui.action.ActionPanel; import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel; import com.jpexs.decompiler.flash.gui.player.PlayerControls; @@ -151,7 +152,6 @@ 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; @@ -226,7 +226,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T 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 CARDACTIONSCRIPT3PANEL = "ActionScript3 card"; private static final String DETAILCARDAS3NAVIGATOR = "Traits list"; private static final String DETAILCARDEMPTYPANEL = "Empty card"; private static final String CARDTEXTPANEL = "Text card"; @@ -234,9 +234,6 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T private static final String FLASH_VIEWER_CARD = "FLASHVIEWER"; private static final String INTERNAL_VIEWER_CARD = "INTERNALVIEWER"; private LineMarkedEditorPane textValue; - private Map jtts; - private HashMap characters; - private Map> abcLists; private JSplitPane splitPane1; private JSplitPane splitPane2; private boolean splitsInited = false; @@ -256,6 +253,8 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T private JPanel viewerCards; private AbortRetryIgnoreHandler errorHandler = new GuiAbortRetryIgnoreHandler(); private CancellableWorker setSourceWorker; + public TreeNode oldValue; + private File tempFile; private static final String ACTION_SELECT_COLOR = "SELECTCOLOR"; private static final String ACTION_REPLACE_IMAGE = "REPLACEIMAGE"; @@ -453,8 +452,6 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T public MainFrame() { super(); - abcLists = new HashMap<>(); - try { flashPanel = new FlashPlayerPanel(this); } catch (FlashUnsupportedException fue) { @@ -692,8 +689,6 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T statusPanel = new MainFrameStatusPanel(this); cnt.add(statusPanel, BorderLayout.SOUTH); - jtts = new HashMap<>(); - characters = new HashMap<>(); JPanel textTopPanel = new JPanel(new BorderLayout()); textValue = new LineMarkedEditorPane(); textTopPanel.add(new JScrollPane(textValue), BorderLayout.CENTER); @@ -880,8 +875,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T welcomePanel = createWelcomePanel(); - actionPanel = null; - abcPanel = null; + cnt.add(welcomePanel, BorderLayout.CENTER); //splitPane1.setDividerLocation(0.5); splitPane1.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() { @@ -930,15 +924,17 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T getActionScript3(objs, abcList); swfs.add(swf); - abcLists.put(swf, abcList); + swf.abcList = abcList; + + boolean hasAbc = !abcList.isEmpty(); - if (!abcList.isEmpty()) { + if (hasAbc) { if (abcPanel == null) { abcPanel = new ABCPanel(this); - abcPanel.setSwf(abcList, swf); displayPanel.add(abcPanel, CARDACTIONSCRIPT3PANEL); detailPanel.add(abcPanel.tabbedPane, DETAILCARDAS3NAVIGATOR); } + abcPanel.setSwf(abcList, swf); } else { if (actionPanel == null) { actionPanel = new ActionPanel(this); @@ -946,19 +942,22 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } } - tagTree.setModel(new TagTreeModel(this, swfs, abcPanel)); + tagTree.setModel(new TagTreeModel(this, swfs, hasAbc ? abcPanel : null)); expandSwfRoots(); for (Tag t : swf.tags) { if (t instanceof JPEGTablesTag) { - jtts.put(swf, (JPEGTablesTag) t); + swf.jtt = (JPEGTablesTag) t; } } List list2 = new ArrayList<>(); list2.addAll(swf.tags); - parseCharacters(list2); + swf.characters = new HashMap<>(); + parseCharacters(swf, list2); + showDetail(DETAILCARDEMPTYPANEL); + showCard(CARDEMPTYPANEL); updateUi(swf); } @@ -966,9 +965,11 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T setTitle(ApplicationInfo.applicationVerName + (Configuration.displayFileName.get() ? " - " + swf.getFileTitle() : "")); - List abcList = abcLists.get(swf); + List abcList = swf.abcList; - if (abcList != null && !abcList.isEmpty()) { + boolean hasAbc = !abcList.isEmpty(); + + if (hasAbc) { abcPanel.setSwf(abcList, swf); } @@ -1000,15 +1001,23 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T public void closeAll() { swfs.clear(); - abcLists.clear(); - jtts.clear(); + oldValue = null; + if (abcPanel != null) { + abcPanel.clearSwf(); + } + if (actionPanel != null) { + actionPanel.clearSource(); + } updateUi(); } public void close(SWF swf) { swfs.remove(swf); - abcLists.remove(swf); - jtts.remove(swf); + if (abcPanel != null && abcPanel.swf == swf) { + abcPanel.clearSwf(); + } + actionPanel.clearSource(); + oldValue = null; updateUi(); } @@ -1162,13 +1171,13 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } } - private void parseCharacters(List list) { + private void parseCharacters(SWF swf, List list) { for (ContainerItem t : list) { if (t instanceof CharacterTag) { - characters.put(((CharacterTag) t).getCharacterId(), (CharacterTag) t); + swf.characters.put(((CharacterTag) t).getCharacterId(), (CharacterTag) t); } if (t instanceof Container) { - parseCharacters(((Container) t).getSubItems()); + parseCharacters(swf, ((Container) t).getSubItems()); } } } @@ -1555,7 +1564,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T 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); + List abcList = swf.abcList; if (abcPanel != null) { for (int i = 0; i < tlsList.size(); i++) { ScriptPack tls = tlsList.get(i); @@ -1691,7 +1700,7 @@ 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); + final List abcList = swf.abcList; if (multiName > 0) { new CancellableWorker() { @Override @@ -2190,7 +2199,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T break; case ACTION_CLOSE_SWF: { - close(getCurrentSwf()); + Main.closeFile(getCurrentSwf()); } } if (Main.isWorking()) { @@ -2233,14 +2242,16 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T CardLayout cl = (CardLayout) (displayPanel.getLayout()); cl.show(displayPanel, card); } - public Object oldValue; - private File tempFile; @Override public void valueChanged(TreeSelectionEvent e) { TreeNode treeNode = (TreeNode) e.getPath().getLastPathComponent(); SWF swf = treeNode.getSwf(); - updateUi(swf); + if (swfs.contains(swf)) { + updateUi(swf); + } else { + updateUi(); + } setEditText(false, false); reload(false); } @@ -2261,31 +2272,34 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } public void reload(boolean forceReload) { - Object tagObj = tagTree.getLastSelectedPathComponent(); - if (tagObj == null) { + TreeNode treeNode = (TreeNode) tagTree.getLastSelectedPathComponent(); + if (treeNode == null) { return; } - if (tagObj instanceof TagNode) { - tagObj = ((TagNode) tagObj).tag; - } - if (tagObj instanceof TreeElement) { - tagObj = ((TreeElement) tagObj).getItem(); - } - - if (!forceReload && (tagObj == oldValue)) { + if (!forceReload && (treeNode == oldValue)) { return; } + oldValue = treeNode; + + TreeElementItem tagObj = null; + if (treeNode instanceof TagNode) { + tagObj = ((TagNode) treeNode).tag; + } + if (treeNode instanceof TreeElement) { + tagObj = ((TreeElement) treeNode).getItem(); + } + + if (flashPanel != null) { flashPanel.specialPlayback = false; } swfPreviewPanel.stop(); stopFlashPlayer(); - oldValue = tagObj; if (tagObj instanceof ScriptPack) { final ScriptPack scriptLeaf = (ScriptPack) tagObj; - final List abcList = abcLists.get(scriptLeaf.abc.swf); + final List abcList = scriptLeaf.abc.swf.abcList; if (setSourceWorker != null) { setSourceWorker.cancel(true); } @@ -2343,8 +2357,8 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } - if ((tagObj instanceof SWFRoot)) { - SWFRoot swfRoot = (SWFRoot) tagObj; + if (treeNode instanceof SWFRoot) { + SWFRoot swfRoot = (SWFRoot) treeNode; SWF swf = swfRoot.getSwf(); if (mainRibbon.isInternalFlashViewerSelected()) { showCard(CARDSWFPREVIEWPANEL); @@ -2393,11 +2407,11 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } else if ((tagObj instanceof DrawableTag) && (!(tagObj instanceof TextTag)) && (!(tagObj instanceof FontTag)) && (mainRibbon.isInternalFlashViewerSelected())) { Tag tag = (Tag) tagObj; showCard(CARDDRAWPREVIEWPANEL); - previewImagePanel.setDrawable((DrawableTag) tag, tag.getSwf(), characters, 50/*FIXME*/); + previewImagePanel.setDrawable((DrawableTag) tag, tag.getSwf(), tag.getSwf().characters, 50/*FIXME*/); } else if ((tagObj instanceof FontTag) && (mainRibbon.isInternalFlashViewerSelected())) { Tag tag = (Tag) tagObj; showCard(CARDFLASHPANEL); - previewImagePanel.setDrawable((DrawableTag) tag, tag.getSwf(), characters, 50/*FIXME*/); + previewImagePanel.setDrawable((DrawableTag) tag, tag.getSwf(), tag.getSwf().characters, 50/*FIXME*/); showFontTag((FontTag) tagObj); } else if (tagObj instanceof FrameNode && ((FrameNode) tagObj).isDisplayed() && (mainRibbon.isInternalFlashViewerSelected())) { showCard(CARDDRAWPREVIEWPANEL); @@ -2410,10 +2424,10 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T if (fn.getParent() instanceof DefineSpriteTag) { controlTags = ((DefineSpriteTag) fn.getParent()).subTags; containerId = ((DefineSpriteTag) fn.getParent()).spriteId; - rect = ((DefineSpriteTag) fn.getParent()).getRect(characters, new Stack()); + rect = ((DefineSpriteTag) fn.getParent()).getRect(swf.characters, new Stack()); totalFrameCount = ((DefineSpriteTag) fn.getParent()).frameCount; } - previewImagePanel.setImage(SWF.frameToImage(containerId, ((FrameNode) tagObj).getFrame() - 1, swf.tags, controlTags, rect, totalFrameCount, new Stack())); + previewImagePanel.setImage(SWF.frameToImage(containerId, fn.getFrame() - 1, swf.tags, controlTags, rect, totalFrameCount, new Stack())); } else if (((tagObj instanceof FrameNode) && ((FrameNode) tagObj).isDisplayed()) || ((tagObj instanceof CharacterTag) || (tagObj instanceof FontTag)) && (tagObj instanceof Tag)) { ((CardLayout) viewerCards.getLayout()).show(viewerCards, FLASH_VIEWER_CARD); createAndShowTempSwf(tagObj); @@ -2528,10 +2542,10 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T break; } Tag t = (Tag) o; - Set needed = t.getDeepNeededCharacters(characters, new ArrayList()); + Set needed = t.getDeepNeededCharacters(swf.characters, new ArrayList()); for (int n : needed) { if (!doneCharacters.contains(n)) { - sos2.writeTag(classicTag(characters.get(n))); + sos2.writeTag(classicTag(swf.characters.get(n))); doneCharacters.add(n); } } @@ -2551,7 +2565,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } mat = (MATRIX) Helper.deepCopy(mat); if (parent instanceof BoundedTag) { - RECT r = ((BoundedTag) parent).getRect(characters, new Stack()); + RECT r = ((BoundedTag) parent).getRect(swf.characters, new Stack()); mat.translateX = mat.translateX + width / 2 - r.getWidth() / 2; mat.translateY = mat.translateY + height / 2 - r.getHeight() / 2; } else { @@ -2567,15 +2581,15 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T } else { if (tagObj instanceof DefineBitsTag) { - JPEGTablesTag jtt = jtts.get(swf); + JPEGTablesTag jtt = swf.jtt; if (jtt != null) { sos2.writeTag(jtt); } } else if (tagObj instanceof AloneTag) { } else { - Set needed = ((Tag) tagObj).getDeepNeededCharacters(characters, new ArrayList()); + Set needed = ((Tag) tagObj).getDeepNeededCharacters(swf.characters, new ArrayList()); for (int n : needed) { - sos2.writeTag(classicTag(characters.get(n))); + sos2.writeTag(classicTag(swf.characters.get(n))); } } @@ -2592,7 +2606,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T mat.translateX = 0; mat.translateY = 0; if (tagObj instanceof BoundedTag) { - RECT r = ((BoundedTag) tagObj).getRect(characters, new Stack()); + RECT r = ((BoundedTag) tagObj).getRect(swf.characters, new Stack()); mat.translateX = -r.Xmin; mat.translateY = -r.Ymin; mat.translateX = mat.translateX + width / 2 - r.getWidth() / 2; @@ -2816,7 +2830,7 @@ public final class MainFrame extends AppRibbonFrame implements ActionListener, T private void showFontTag(FontTag ft) { if (mainRibbon.isInternalFlashViewerSelected() /*|| ft instanceof GFxDefineCompactedFont*/) { ((CardLayout) viewerCards.getLayout()).show(viewerCards, INTERNAL_VIEWER_CARD); - internelViewerPanel.setDrawable(ft, ft.getSwf(), characters, 1); + internelViewerPanel.setDrawable(ft, ft.getSwf(), ft.getSwf().characters, 1); } else { ((CardLayout) viewerCards.getLayout()).show(viewerCards, FLASH_VIEWER_CARD); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java b/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java index c7db1509d..f543fe8a8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.FrameNode; import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.StringNode; import com.jpexs.decompiler.flash.TagNode; import com.jpexs.decompiler.flash.gui.abc.ABCPanel; import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel; @@ -68,7 +69,7 @@ public class TagTreeModel implements TreeModel { frameCnt++; ret.add(new TagNode(new FrameNode(o.getSwf(), frameCnt, parent, display), o.getSwf())); } else if (type == ttype) { - ret.add(new TagNode(o)); + ret.add(new TagNode(o, o.getSwf())); } } return ret; @@ -114,7 +115,7 @@ public class TagTreeModel implements TreeModel { ret.add(tti); } else */ if (t instanceof Container) { - TagNode tti = new TagNode(t); + TagNode tti = new TagNode(t, t.getSwf()); if (((Container) t).getItemCount() > 0) { List subItems = ((Container) t).getSubItems(); tti.subItems = createTagList(subItems, t, abcPanel, t.getSwf()); @@ -124,42 +125,42 @@ public class TagTreeModel implements TreeModel { } actionScript = SWF.createASTagList(list, null); - TagNode textsNode = new TagNode(translate("node.texts"), swf); + TagNode textsNode = new TagNode(new StringNode(translate("node.texts")), swf); textsNode.subItems.addAll(texts); - TagNode imagesNode = new TagNode(translate("node.images"), swf); + TagNode imagesNode = new TagNode(new StringNode(translate("node.images")), swf); imagesNode.subItems.addAll(images); - TagNode moviesNode = new TagNode(translate("node.movies"), swf); + TagNode moviesNode = new TagNode(new StringNode(translate("node.movies")), swf); moviesNode.subItems.addAll(movies); - TagNode soundsNode = new TagNode(translate("node.sounds"), swf); + TagNode soundsNode = new TagNode(new StringNode(translate("node.sounds")), swf); soundsNode.subItems.addAll(sounds); - TagNode binaryDataNode = new TagNode(translate("node.binaryData"), swf); + TagNode binaryDataNode = new TagNode(new StringNode(translate("node.binaryData")), swf); binaryDataNode.subItems.addAll(binaryData); - TagNode fontsNode = new TagNode(translate("node.fonts"), swf); + TagNode fontsNode = new TagNode(new StringNode(translate("node.fonts")), swf); fontsNode.subItems.addAll(fonts); - TagNode spritesNode = new TagNode(translate("node.sprites"), swf); + TagNode spritesNode = new TagNode(new StringNode(translate("node.sprites")), swf); spritesNode.subItems.addAll(sprites); - TagNode shapesNode = new TagNode(translate("node.shapes"), swf); + TagNode shapesNode = new TagNode(new StringNode(translate("node.shapes")), swf); shapesNode.subItems.addAll(shapes); - TagNode morphShapesNode = new TagNode(translate("node.morphshapes"), swf); + TagNode morphShapesNode = new TagNode(new StringNode(translate("node.morphshapes")), swf); morphShapesNode.subItems.addAll(morphShapes); - TagNode buttonsNode = new TagNode(translate("node.buttons"), swf); + TagNode buttonsNode = new TagNode(new StringNode(translate("node.buttons")), swf); buttonsNode.subItems.addAll(buttons); - TagNode framesNode = new TagNode(translate("node.frames"), swf); + TagNode framesNode = new TagNode(new StringNode(translate("node.frames")), swf); framesNode.subItems.addAll(frames); - TagNode actionScriptNode = new TagNode(translate("node.scripts"), swf); + TagNode actionScriptNode = new TagNode(new StringNode(translate("node.scripts")), swf); actionScriptNode.mark = "scripts"; actionScriptNode.subItems.addAll(actionScript); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCComboBoxModel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCComboBoxModel.java index 9d4459484..3d9de1963 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCComboBoxModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCComboBoxModel.java @@ -22,11 +22,11 @@ import java.util.List; import javax.swing.ComboBoxModel; import javax.swing.event.ListDataListener; -public class ABCComboBoxModel implements ComboBoxModel { +public class ABCComboBoxModel implements ComboBoxModel { public List list; public int itemIndex = 0; - public static final String ROOT = " - all - "; + public static final ABCContainerTag ROOT = new RootABCContainerTag(); public ABCComboBoxModel(List list) { this.list = list; @@ -39,7 +39,7 @@ public class ABCComboBoxModel implements ComboBoxModel { } @Override - public Object getElementAt(int index) { + public ABCContainerTag getElementAt(int index) { if (index == 0) { return ROOT; } @@ -64,7 +64,7 @@ public class ABCComboBoxModel implements ComboBoxModel { } @Override - public Object getSelectedItem() { + public ABCContainerTag getSelectedItem() { return getElementAt(itemIndex); } } 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 c1b39ac96..8ce9e2585 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -268,10 +268,22 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr //colModel.getColumn(0).setMaxWidth(50); } + @SuppressWarnings("unchecked") + public void clearSwf() { + this.list = null; + this.swf = null; + this.abc = null; + constantTable.setModel(new DefaultTableModel()); + classTree.clearDoABCTags(); + abcComboBox.setModel(new ABCComboBoxModel(new ArrayList())); + navigator.clearABC(); + } + @SuppressWarnings("unchecked") public void setSwf(List list, SWF swf) { this.list = list; this.swf = swf; + listIndex = -1; switchAbc(0); // todo honika: do we need this? abcComboBox.setModel(new ABCComboBoxModel(list)); if (list.size() > 0) { 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 12deb4747..2ba41f681 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTree.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTree.java @@ -95,6 +95,13 @@ public final class ClassesListTree extends JTree implements TreeSelectionListene return selectedScripts; } + public void clearDoABCTags() { + this.abcList = null; + this.treeList = null; + this.swf = null; + setModel(null); + } + public void setDoABCTags(List list, SWF swf) { this.abcList = list; this.treeList = swf.getAS3Packs(); @@ -106,6 +113,11 @@ public final class ClassesListTree extends JTree implements TreeSelectionListene setModel(new ClassesListTreeModel(this.treeList, swf, filter)); } + @Override + public ClassesListTreeModel getModel() { + return (ClassesListTreeModel) super.getModel(); + } + @Override public void valueChanged(TreeSelectionEvent e) { if (Main.isWorking()) { 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 e00aad414..285f784c3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java @@ -77,7 +77,7 @@ class ClassIndexVisitor implements TreeVisitor { } } -public class ClassesListTreeModel implements TreeModel { +public class ClassesListTreeModel implements TreeModel, TreeElementItem { private Tree classTree; private List> list; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/RootABCContainerTag.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/RootABCContainerTag.java new file mode 100644 index 000000000..a98126f35 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/RootABCContainerTag.java @@ -0,0 +1,46 @@ +/* + * 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.abc; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; + +/** + * + * @author JPEXS + */ +public class RootABCContainerTag implements ABCContainerTag { + + @Override + public ABC getABC() { + return null; + } + + @Override + public int compareTo(ABCContainerTag t) { + if (t instanceof RootABCContainerTag) { + return 0; + } + return -1; + } + + @Override + public String toString() { + return " - all - "; + } + +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitsList.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitsList.java index f86703565..af38ea6b3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitsList.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitsList.java @@ -55,6 +55,13 @@ public class TraitsList extends JList implements ListSelectionListener { setBackground(Color.white); } + @SuppressWarnings("unchecked") + public void clearABC() { + this.abc = null; + this.abcTags = null; + setModel(new DefaultListModel()); + } + @SuppressWarnings("unchecked") public void setABC(List abcTags, ABC abc) { this.abc = abc; 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 8e8242153..1bbd646b3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/Tree.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/Tree.java @@ -27,7 +27,7 @@ public class Tree { ROOT = new TreeElement(swf, "", "", null, null); } - public void add(String name, String path, Object item) { + public void add(String name, String path, TreeElementItem item) { StringTokenizer st = new StringTokenizer(path, "."); TreeElement parent = ROOT; while (st.hasMoreTokens()) { 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 b3d658e19..86a7d8919 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/TreeElement.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/TreeElement.java @@ -27,11 +27,11 @@ public class TreeElement implements TreeNode { private SortedMap leafs; private String name; private String path; - private Object item; + private TreeElementItem item; private TreeElement parent; private SWF swf; - public TreeElement(SWF swf, String name, String path, Object item, TreeElement parent) { + public TreeElement(SWF swf, String name, String path, TreeElementItem item, TreeElement parent) { this.swf = swf; this.name = name; this.path = path; @@ -66,7 +66,7 @@ public class TreeElement implements TreeNode { return new TreePath(pathList.toArray()); } - public Object getItem() { + public TreeElementItem getItem() { return item; } @@ -84,7 +84,7 @@ public class TreeElement implements TreeNode { return branch; } - void addLeaf(String pathElement, Object item) { + void addLeaf(String pathElement, TreeElementItem item) { 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/TreeElementItem.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/TreeElementItem.java new file mode 100644 index 000000000..e78f5e9df --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/TreeElementItem.java @@ -0,0 +1,25 @@ +/* + * 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.abc; + +/** + * + * @author JPEXS + */ +public interface TreeElementItem { + +} 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 b7bfe2b37..16723f55f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -38,7 +38,6 @@ import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane; import com.jpexs.decompiler.flash.helpers.HilightedText; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; -import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -97,7 +96,6 @@ public class ActionPanel extends JPanel implements ActionListener { private MainFrame mainFrame; public LineMarkedEditorPane editor; public LineMarkedEditorPane decompiledEditor; - public List list; public JSplitPane splitPane; public JButton saveButton = new JButton(AppStrings.translate("button.save"), View.getIcon("save16")); public JButton editButton = new JButton(AppStrings.translate("button.edit"), View.getIcon("edit16")); @@ -134,6 +132,18 @@ public class ActionPanel extends JPanel implements ActionListener { private Cache cache = Cache.getInstance(true); private CancellableWorker setSourceWorker; + public void clearSource() { + lastCode = null; + lastASM = null; + lastDecompiled = null; + found = new ArrayList<>(); + foundPos = 0; + src = null; + srcWithHex = null; + srcNoHex = null; + srcHexOnly = null; + } + public void clearCache() { cache.clear(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/ContainerItem.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/ContainerItem.java index 0b28be16a..e0e8ceab2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/ContainerItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/ContainerItem.java @@ -17,13 +17,14 @@ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.gui.abc.TreeElementItem; /** * Object which contains other objects * * @author JPEXS */ -public interface ContainerItem { +public interface ContainerItem extends TreeElementItem { SWF getSwf(); }