From 7d2c0122f78b600b36e522190fae04720c2f0aab Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sat, 16 May 2015 15:15:27 +0200 Subject: [PATCH] show some basic tag info --- .../flash/importers/SwfXmlImporter.java | 4 +- .../com/jpexs/decompiler/flash/tags/Tag.java | 55 ++- .../jpexs/decompiler/flash/tags/TagInfo.java | 50 ++- .../decompiler/flash/tags/TagTypeInfo.java | 48 +++ .../decompiler/flash/tags/base/ImageTag.java | 9 + .../decompiler/flash/gui/AppRibbonFrame.java | 9 +- .../decompiler/flash/gui/MainFrameRibbon.java | 370 +++++++++--------- .../jpexs/decompiler/flash/gui/MainPanel.java | 11 +- .../decompiler/flash/gui/TagInfoPanel.java | 187 ++++++--- .../flash/gui/locales/MainFrame.properties | 13 + .../flash/gui/tagtree/TagTreeContextMenu.java | 2 +- 11 files changed, 494 insertions(+), 264 deletions(-) create mode 100644 libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/TagTypeInfo.java diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/SwfXmlImporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/SwfXmlImporter.java index 50b753fdf..2dc4ff7cb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/SwfXmlImporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/SwfXmlImporter.java @@ -36,7 +36,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.tags.Tag; -import com.jpexs.decompiler.flash.tags.TagInfo; +import com.jpexs.decompiler.flash.tags.TagTypeInfo; import com.jpexs.decompiler.flash.types.ALPHABITMAPDATA; import com.jpexs.decompiler.flash.types.ALPHACOLORMAPDATA; import com.jpexs.decompiler.flash.types.ARGB; @@ -241,7 +241,7 @@ public class SwfXmlImporter { private Object createObject(String type, SWF swf, Tag tag) throws NoSuchMethodException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (swfTags == null) { Map tags = new HashMap<>(); - Map knownTags = Tag.getKnownClasses(); + Map knownTags = Tag.getKnownClasses(); for (Integer key : knownTags.keySet()) { Class cls = knownTags.get(key).getCls(); if (!ReflectionTools.canInstantiate(cls)) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java index 7af8c82e0..4384ddfa2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java @@ -19,6 +19,8 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.tags.base.BoundedTag; +import com.jpexs.decompiler.flash.tags.base.CharacterIdTag; import com.jpexs.decompiler.flash.tags.base.Exportable; import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont; @@ -32,8 +34,10 @@ import com.jpexs.decompiler.flash.tags.gfx.DefineSubImage; import com.jpexs.decompiler.flash.tags.gfx.ExporterInfo; import com.jpexs.decompiler.flash.tags.gfx.FontTextureInfo; import com.jpexs.decompiler.flash.timeline.Timelined; +import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.helpers.ByteArrayRange; +import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.Serializable; @@ -161,9 +165,9 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable { private volatile static Integer[] knownTagIds; - private volatile static Map knownTagInfosById; + private volatile static Map knownTagInfosById; - private volatile static Map knownTagInfosByName; + private volatile static Map knownTagInfosByName; private volatile static List requiredTagIds; @@ -180,12 +184,12 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable { return knownTagIds; } - public static Map getKnownClasses() { + public static Map getKnownClasses() { if (knownTagInfosById == null) { synchronized (lockObject) { if (knownTagInfosById == null) { - Map map = new HashMap<>(); - Map map2 = new HashMap<>(); + Map map = new HashMap<>(); + Map map2 = new HashMap<>(); addTagInfo(map, map2, CSMTextSettingsTag.ID, CSMTextSettingsTag.class, CSMTextSettingsTag.NAME); addTagInfo(map, map2, DebugIDTag.ID, DebugIDTag.class, DebugIDTag.NAME); addTagInfo(map, map2, DefineBinaryDataTag.ID, DefineBinaryDataTag.class, DefineBinaryDataTag.NAME); @@ -273,7 +277,7 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable { return knownTagInfosById; } - public static Map getKnownClassesByName() { + public static Map getKnownClassesByName() { // map is filled together with knownTagInfosById if (knownTagInfosByName == null) { getKnownClasses(); @@ -282,9 +286,9 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable { return knownTagInfosByName; } - private static void addTagInfo(Map map, Map map2, int id, Class cls, String name) { - map.put(id, new TagInfo(id, cls, name)); - map2.put(name, new TagInfo(id, cls, name)); + private static void addTagInfo(Map map, Map map2, int id, Class cls, String name) { + map.put(id, new TagTypeInfo(id, cls, name)); + map2.put(name, new TagTypeInfo(id, cls, name)); } public static List getRequiredTags() { @@ -561,4 +565,37 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable { } } } + + public void getTagInfo(TagInfo tagInfo) { + + tagInfo.addInfo("general", "tagType", String.format("%s (%d)", tagName, id)); + if (this instanceof CharacterIdTag) { + CharacterIdTag characterIdTag = (CharacterIdTag) this; + tagInfo.addInfo("general", "characterId", characterIdTag.getCharacterId()); + } + + if (originalRange != null) { + int pos = originalRange.getPos(); + int length = originalRange.getLength(); + tagInfo.addInfo("general", "offset", String.format("%d (0x%x)", pos, pos)); + tagInfo.addInfo("general", "length", String.format("%d (0x%x)", length, length)); + } + + if (this instanceof BoundedTag) { + BoundedTag boundedIdTag = (BoundedTag) this; + RECT bounds = boundedIdTag.getRect(); + tagInfo.addInfo("general", "bounds", + String.format("(%.2f, %.2f)[%.2f x %.2f]", bounds.Xmin / SWF.unitDivisor, + bounds.Ymin / SWF.unitDivisor, + bounds.getWidth() / SWF.unitDivisor, + bounds.getHeight() / SWF.unitDivisor)); + } + + Set needed = new LinkedHashSet<>(); + getNeededCharactersDeep(needed); + + if (needed.size() > 0) { + tagInfo.addInfo("general", "neededCharacters", Helper.joinStrings(needed, ", ")); + } + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/TagInfo.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/TagInfo.java index d640c588f..db2572897 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/TagInfo.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/TagInfo.java @@ -16,33 +16,55 @@ */ package com.jpexs.decompiler.flash.tags; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + /** * * @author JPEXS */ public class TagInfo { - private final int id; + private final Map> infos = new LinkedHashMap<>(); - private final Class cls; + public void addInfo(String categoryName, String name, Object value) { + categoryName = "general"; // temporary add everything to general catagory + List category = infos.get(categoryName); + if (category == null) { + category = new ArrayList<>(); + infos.put(categoryName, category); + } - private final String name; - - public TagInfo(int id, Class cls, String name) { - this.id = id; - this.cls = cls; - this.name = name; + category.add(new TagInfoItem(name, value)); } - public int getId() { - return id; + public Map> getInfos() { + return infos; } - public Class getCls() { - return cls; + public boolean isEmpty() { + return infos.isEmpty(); } - public String getName() { - return name; + public class TagInfoItem { + + private final String name; + + private final Object value; + + public TagInfoItem(String name, Object value) { + this.name = name; + this.value = value; + } + + public String getName() { + return name; + } + + public Object getValue() { + return value; + } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/TagTypeInfo.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/TagTypeInfo.java new file mode 100644 index 000000000..183153fec --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/TagTypeInfo.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2010-2015 JPEXS, All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + */ +package com.jpexs.decompiler.flash.tags; + +/** + * + * @author JPEXS + */ +public class TagTypeInfo { + + private final int id; + + private final Class cls; + + private final String name; + + public TagTypeInfo(int id, Class cls, String name) { + this.id = id; + this.cls = cls; + this.name = name; + } + + public int getId() { + return id; + } + + public Class getCls() { + return cls; + } + + public String getName() { + return name; + } +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java index ba4374f34..bdb66f278 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java @@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter; import com.jpexs.decompiler.flash.exporters.shape.CanvasShapeExporter; import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter; +import com.jpexs.decompiler.flash.tags.TagInfo; import com.jpexs.decompiler.flash.tags.enums.ImageFormat; import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.ColorTransform; @@ -264,6 +265,14 @@ public abstract class ImageTag extends CharacterTag implements DrawableTag { cachedImage = null; } + @Override + public void getTagInfo(TagInfo tagInfo) { + super.getTagInfo(tagInfo); + SerializableImage image = getImage(); + tagInfo.addInfo("general", "width", image.getWidth()); + tagInfo.addInfo("general", "height", image.getHeight()); + } + @Override public int getCharacterId() { return characterID; diff --git a/src/com/jpexs/decompiler/flash/gui/AppRibbonFrame.java b/src/com/jpexs/decompiler/flash/gui/AppRibbonFrame.java index e007e47d4..e5d59e4e2 100644 --- a/src/com/jpexs/decompiler/flash/gui/AppRibbonFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/AppRibbonFrame.java @@ -1,16 +1,16 @@ /* * Copyright (C) 2010-2015 JPEXS - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -23,7 +23,7 @@ import org.pushingpixels.flamingo.api.ribbon.JRibbonFrame; * * @author JPEXS */ -public abstract class AppRibbonFrame extends JRibbonFrame { +public abstract class AppRibbonFrame extends JRibbonFrame implements MainFrame { private final ResourceBundle resourceBundle; @@ -35,6 +35,7 @@ public abstract class AppRibbonFrame extends JRibbonFrame { } } + @Override public String translate(String key) { return resourceBundle.getString(key); } diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java index 555d52d9b..0534ba5db 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java @@ -1,185 +1,185 @@ -/* - * Copyright (C) 2010-2015 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.gui; - -import com.jpexs.decompiler.flash.configuration.Configuration; -import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel; -import com.jpexs.decompiler.flash.treeitems.SWFList; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Window; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.event.WindowStateListener; -import java.io.File; -import java.util.List; -import javax.swing.JFrame; -import javax.swing.tree.TreePath; -import org.pushingpixels.flamingo.api.ribbon.JRibbon; -import org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationMenuButton; - -/** - * - * @author JPEXS - */ -public final class MainFrameRibbon extends AppRibbonFrame implements MainFrame { - - private final MainPanel panel; - - private final MainFrameMenu mainMenu; - - public MainFrameRibbon() { - super(); - - FlashPlayerPanel flashPanel = null; - try { - flashPanel = new FlashPlayerPanel(this); - } catch (FlashUnsupportedException fue) { - } - - Container cnt = getContentPane(); - cnt.setLayout(new BorderLayout()); - JRibbon ribbon = getRibbon(); - cnt.add(ribbon, BorderLayout.NORTH); - - boolean externalFlashPlayerUnavailable = flashPanel == null; - mainMenu = new MainFrameRibbonMenu(this, ribbon, externalFlashPlayerUnavailable); - - panel = new MainPanel(this, mainMenu, flashPanel); - panel.setBackground(Color.yellow); - cnt.add(panel, BorderLayout.CENTER); - - int w = Configuration.guiWindowWidth.get(); - int h = Configuration.guiWindowHeight.get(); - Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); - if (w > dim.width) { - w = dim.width; - } - if (h > dim.height) { - h = dim.height; - } - setSize(w, h); - - boolean maximizedHorizontal = Configuration.guiWindowMaximizedHorizontal.get(); - boolean maximizedVertical = Configuration.guiWindowMaximizedVertical.get(); - - int state = 0; - if (maximizedHorizontal) { - state |= JFrame.MAXIMIZED_HORIZ; - } - if (maximizedVertical) { - state |= JFrame.MAXIMIZED_VERT; - } - setExtendedState(state); - - View.setWindowIcon(this); - addWindowStateListener(new WindowStateListener() { - @Override - public void windowStateChanged(WindowEvent e) { - int state = e.getNewState(); - Configuration.guiWindowMaximizedHorizontal.set((state & JFrame.MAXIMIZED_HORIZ) == JFrame.MAXIMIZED_HORIZ); - Configuration.guiWindowMaximizedVertical.set((state & JFrame.MAXIMIZED_VERT) == JFrame.MAXIMIZED_VERT); - } - }); - addComponentListener(new ComponentAdapter() { - @Override - public void componentResized(ComponentEvent e) { - int state = getExtendedState(); - if ((state & JFrame.MAXIMIZED_HORIZ) == 0) { - Configuration.guiWindowWidth.set(getWidth()); - } - if ((state & JFrame.MAXIMIZED_VERT) == 0) { - Configuration.guiWindowHeight.set(getHeight()); - } - } - }); - - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - if (Configuration.saveSessionOnExit.get()) { - StringBuilder sb = new StringBuilder(); - for (SWFList swf : panel.getSwfs()) { - String file = swf.sourceInfo.getFile(); - if (file != null) { - sb.append(file); - sb.append(File.pathSeparator); - } - } - - TreePath path = panel.tagTree.getLeadSelectionPath(); - if (path != null) { - boolean first = true; - for (Object p : path.getPath()) { - if (!first) { - sb.append("|"); - } - - first = false; - sb.append(p.toString()); - } - } - - Configuration.lastSessionData.set(sb.toString()); - } - - boolean closeResult = panel.closeAll(); - if (closeResult) { - Main.exit(); - } - } - }); - - View.centerScreen(this); - - } - - private static void getApplicationMenuButtons(Component comp, List ret) { - if (comp instanceof JRibbonApplicationMenuButton) { - ret.add((JRibbonApplicationMenuButton) comp); - return; - } - if (comp instanceof Container) { - Container cont = (Container) comp; - for (int i = 0; i < cont.getComponentCount(); i++) { - getApplicationMenuButtons(cont.getComponent(i), ret); - } - } - } - - @Override - public void setVisible(boolean b) { - super.setVisible(b); - panel.setVisible(b); - } - - @Override - public MainPanel getPanel() { - return panel; - } - - @Override - public Window getWindow() { - return this; - } -} +/* + * Copyright (C) 2010-2015 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui; + +import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel; +import com.jpexs.decompiler.flash.treeitems.SWFList; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Window; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.WindowStateListener; +import java.io.File; +import java.util.List; +import javax.swing.JFrame; +import javax.swing.tree.TreePath; +import org.pushingpixels.flamingo.api.ribbon.JRibbon; +import org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationMenuButton; + +/** + * + * @author JPEXS + */ +public final class MainFrameRibbon extends AppRibbonFrame { + + private final MainPanel panel; + + private final MainFrameMenu mainMenu; + + public MainFrameRibbon() { + super(); + + FlashPlayerPanel flashPanel = null; + try { + flashPanel = new FlashPlayerPanel(this); + } catch (FlashUnsupportedException fue) { + } + + Container cnt = getContentPane(); + cnt.setLayout(new BorderLayout()); + JRibbon ribbon = getRibbon(); + cnt.add(ribbon, BorderLayout.NORTH); + + boolean externalFlashPlayerUnavailable = flashPanel == null; + mainMenu = new MainFrameRibbonMenu(this, ribbon, externalFlashPlayerUnavailable); + + panel = new MainPanel(this, mainMenu, flashPanel); + panel.setBackground(Color.yellow); + cnt.add(panel, BorderLayout.CENTER); + + int w = Configuration.guiWindowWidth.get(); + int h = Configuration.guiWindowHeight.get(); + Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); + if (w > dim.width) { + w = dim.width; + } + if (h > dim.height) { + h = dim.height; + } + setSize(w, h); + + boolean maximizedHorizontal = Configuration.guiWindowMaximizedHorizontal.get(); + boolean maximizedVertical = Configuration.guiWindowMaximizedVertical.get(); + + int state = 0; + if (maximizedHorizontal) { + state |= JFrame.MAXIMIZED_HORIZ; + } + if (maximizedVertical) { + state |= JFrame.MAXIMIZED_VERT; + } + setExtendedState(state); + + View.setWindowIcon(this); + addWindowStateListener(new WindowStateListener() { + @Override + public void windowStateChanged(WindowEvent e) { + int state = e.getNewState(); + Configuration.guiWindowMaximizedHorizontal.set((state & JFrame.MAXIMIZED_HORIZ) == JFrame.MAXIMIZED_HORIZ); + Configuration.guiWindowMaximizedVertical.set((state & JFrame.MAXIMIZED_VERT) == JFrame.MAXIMIZED_VERT); + } + }); + addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + int state = getExtendedState(); + if ((state & JFrame.MAXIMIZED_HORIZ) == 0) { + Configuration.guiWindowWidth.set(getWidth()); + } + if ((state & JFrame.MAXIMIZED_VERT) == 0) { + Configuration.guiWindowHeight.set(getHeight()); + } + } + }); + + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + if (Configuration.saveSessionOnExit.get()) { + StringBuilder sb = new StringBuilder(); + for (SWFList swf : panel.getSwfs()) { + String file = swf.sourceInfo.getFile(); + if (file != null) { + sb.append(file); + sb.append(File.pathSeparator); + } + } + + TreePath path = panel.tagTree.getLeadSelectionPath(); + if (path != null) { + boolean first = true; + for (Object p : path.getPath()) { + if (!first) { + sb.append("|"); + } + + first = false; + sb.append(p.toString()); + } + } + + Configuration.lastSessionData.set(sb.toString()); + } + + boolean closeResult = panel.closeAll(); + if (closeResult) { + Main.exit(); + } + } + }); + + View.centerScreen(this); + + } + + private static void getApplicationMenuButtons(Component comp, List ret) { + if (comp instanceof JRibbonApplicationMenuButton) { + ret.add((JRibbonApplicationMenuButton) comp); + return; + } + if (comp instanceof Container) { + Container cont = (Container) comp; + for (int i = 0; i < cont.getComponentCount(); i++) { + getApplicationMenuButtons(cont.getComponent(i), ret); + } + } + } + + @Override + public void setVisible(boolean b) { + super.setVisible(b); + panel.setVisible(b); + } + + @Override + public MainPanel getPanel() { + return panel; + } + + @Override + public Window getWindow() { + return this; + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 9e766ce54..444350c89 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -100,6 +100,7 @@ import com.jpexs.decompiler.flash.tags.DoInitActionTag; import com.jpexs.decompiler.flash.tags.FileAttributesTag; import com.jpexs.decompiler.flash.tags.MetadataTag; import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.tags.TagInfo; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.ButtonTag; @@ -424,7 +425,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se whitePanel.setBackground(Color.white); detailPanel.add(whitePanel, DETAILCARDEMPTYPANEL); - tagInfoPanel = new TagInfoPanel(); + tagInfoPanel = new TagInfoPanel(this); detailPanel.add(tagInfoPanel, DETAILCARDTAGINFO); UIManager.getDefaults().put("TreeUI", BasicTreeUI.class.getName()); @@ -2881,10 +2882,10 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (treeItem instanceof Tag) { Tag tag = (Tag) treeItem; - Set needed = new HashSet<>(); - tag.getNeededCharactersDeep(needed); - if (needed.size() > 0) { - tagInfoPanel.setNeededCharacters(needed); + TagInfo tagInfo = new TagInfo(); + tag.getTagInfo(tagInfo); + if (!tagInfo.isEmpty()) { + tagInfoPanel.setTagInfos(tagInfo); showDetail(DETAILCARDTAGINFO); } else { showDetail(DETAILCARDEMPTYPANEL); diff --git a/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java b/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java index 8d6d17106..4f92c74e0 100644 --- a/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java @@ -1,44 +1,143 @@ -/* - * Copyright (C) 2010-2015 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.gui; - -import com.jpexs.helpers.Helper; -import java.util.Set; -import javax.swing.JLabel; -import javax.swing.JPanel; - -/** - * - * @author JPEXS - */ -public class TagInfoPanel extends JPanel { - - private final JLabel neededCharactersLabel; - - public TagInfoPanel() { - neededCharactersLabel = new JLabel(); - add(new JLabel("Needed characters:")); - add(neededCharactersLabel); - - // todo: add other information - } - - public void setNeededCharacters(Set needed) { - String neededStr = Helper.joinStrings(needed, ", "); - neededCharactersLabel.setText(neededStr); - } -} +/* + * Copyright (C) 2010-2015 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui; + +import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.tags.TagInfo; +import java.awt.BorderLayout; +import java.awt.Color; +import java.util.List; +import java.util.MissingResourceException; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.event.TableModelListener; +import javax.swing.table.TableModel; + +/** + * + * @author JPEXS + */ +public class TagInfoPanel extends JPanel { + + private final MainPanel mainPanel; + + private final JTable infoTable = new JTable(); + + private TagInfo tagInfo = new TagInfo(); + + public TagInfoPanel(MainPanel mainPanel) { + this.mainPanel = mainPanel; + infoTable.setModel(new InfoTableModel("general")); + setLayout(new BorderLayout()); + infoTable.setAutoCreateRowSorter(true); + add(new JScrollPane(infoTable), BorderLayout.CENTER); + } + + public void setTagInfos(TagInfo tagInfo) { + this.tagInfo = tagInfo; + infoTable.setBackground(Color.WHITE); + infoTable.setModel(new InfoTableModel("general")); + } + + private class InfoTableModel implements TableModel { + + private final String categoryName; + + public InfoTableModel(String categoryName) { + this.categoryName = categoryName; + } + + @Override + public int getRowCount() { + List category = tagInfo.getInfos().get(categoryName); + if (category != null) { + return category.size(); + } + + return 0; + } + + @Override + public int getColumnCount() { + return 2; + } + + @Override + public String getColumnName(int columnIndex) { + switch (columnIndex) { + case 0: + return mainPanel.translate("tagInfo.header.name"); + case 1: + return mainPanel.translate("tagInfo.header.value"); + } + + return null; + } + + @Override + public Class getColumnClass(int columnIndex) { + return String.class; + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + List category = tagInfo.getInfos().get(categoryName); + if (category != null) { + TagInfo.TagInfoItem item = category.get(rowIndex); + + switch (columnIndex) { + case 0: + String name = item.getName(); + String key = "tagInfo." + name; + try { + name = mainPanel.translate(key); + } catch (MissingResourceException mes) { + if (Configuration.debugMode.get()) { + Logger.getLogger(TagInfoPanel.class.getName()).log(Level.WARNING, "Resource not found: {0}", key); + } + } + + return name; + case 1: + return item.getValue(); + } + } + + return null; + } + + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } + + @Override + public void addTableModelListener(TableModelListener l) { + } + + @Override + public void removeTableModelListener(TableModelListener l) { + } + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 3f5bd64ee..03f5205da 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -589,3 +589,16 @@ button.resolveConstants = Resolve constants button.viewConstants = View Constants work.exported = Exported button.replaceAlphaChannel = Replace alpha channel... + +tagInfo.header.name = Name +tagInfo.header.value = Value +tagInfo.tagType = Tag Type +tagInfo.characterId = Character Id +tagInfo.offset = Offset +tagInfo.length = Length +tagInfo.bounds = Bounds +tagInfo.width = Width +tagInfo.height = Height +tagInfo.neededCharacters = Needed Characters + + diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index e660f8f66..30b08258e 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -529,7 +529,7 @@ public class TagTreeContextMenu extends JPopupMenu { for (TreeItem item : items) { Set copiedTags = new HashSet<>(); Set newTags = new HashSet<>(); - LinkedHashSet needed = new LinkedHashSet<>(); + Set needed = new LinkedHashSet<>(); Map changedCharacterIds = new HashMap<>(); Tag tag = (Tag) item;