From 8ba6648c51e73fd889393101dbfece89af4b81ac Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Tue, 12 May 2015 13:09:04 +0200 Subject: [PATCH] #871 Show the needed character ids --- .../jpexs/decompiler/flash/gui/MainPanel.java | 33 +++++++++----- .../decompiler/flash/gui/TagInfoPanel.java | 44 +++++++++++++++++++ .../decompiler/flash/gui/abc/ABCPanel.java | 4 ++ 3 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 639ec3aec..6998dd253 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -256,6 +256,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se private static final String DETAILCARDAS3NAVIGATOR = "Traits list"; + private static final String DETAILCARDTAGINFO = "Tag information"; + private static final String DETAILCARDEMPTYPANEL = "Empty card"; private static final String SPLIT_PANE1 = "SPLITPANE1"; @@ -286,6 +288,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se private final JPanel treePanel; + private final TagInfoPanel tagInfoPanel; + private TreePanelMode treePanelMode; private CancellableWorker setSourceWorker; @@ -413,11 +417,13 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se detailPanel = new JPanel(); detailPanel.setLayout(new CardLayout()); + JPanel whitePanel = new JPanel(); whitePanel.setBackground(Color.white); detailPanel.add(whitePanel, DETAILCARDEMPTYPANEL); - CardLayout cl2 = (CardLayout) (detailPanel.getLayout()); - cl2.show(detailPanel, DETAILCARDEMPTYPANEL); + + tagInfoPanel = new TagInfoPanel(); + detailPanel.add(tagInfoPanel, DETAILCARDTAGINFO); UIManager.getDefaults().put("TreeUI", BasicTreeUI.class.getName()); tagTree = new TagTree(null, this); @@ -2794,14 +2800,6 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se previewPanel.setImageReplaceButtonVisible(false); - /*if (treeItem instanceof Tag) { - Tag tag = (Tag) treeItem; - Set needed = new HashSet<>(); - tag.getNeededCharactersDeep(needed); - String neededStr = Helper.joinStrings(needed, ", "); - // todo: it would be usefule to show this information on the UI - System.out.println("Needed characters: " + neededStr); - }*/ boolean internalViewer = isInternalFlashViewerSelected(); if (treeItem instanceof ScriptPack) { @@ -2850,7 +2848,20 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se return; } - showDetail(DETAILCARDEMPTYPANEL); + if (treeItem instanceof Tag) { + Tag tag = (Tag) treeItem; + Set needed = new HashSet<>(); + tag.getNeededCharactersDeep(needed); + if (needed.size() > 0) { + tagInfoPanel.setNeededCharacters(needed); + showDetail(DETAILCARDTAGINFO); + } else { + showDetail(DETAILCARDEMPTYPANEL); + } + } else { + showDetail(DETAILCARDEMPTYPANEL); + } + if (treeItem instanceof HeaderItem) { headerPanel.load(((HeaderItem) treeItem).getSwf()); showCard(CARDHEADER); diff --git a/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java b/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java new file mode 100644 index 000000000..8d6d17106 --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java @@ -0,0 +1,44 @@ +/* + * 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); + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index da24a8a63..d4e2210ba 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -111,6 +111,10 @@ import jsyntaxpane.SyntaxDocument; import jsyntaxpane.Token; import jsyntaxpane.TokenType; +/** + * + * @author JPEXS + */ public class ABCPanel extends JPanel implements ItemListener, SearchListener, Freed, TagEditorPanel { private MainPanel mainPanel;