show some basic tag info

This commit is contained in:
2015-05-16 15:15:27 +02:00
parent 3632c466e1
commit 7d2c0122f7
11 changed files with 494 additions and 264 deletions
@@ -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 <http://www.gnu.org/licenses/>.
*/
@@ -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);
}
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<JRibbonApplicationMenuButton> 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 <http://www.gnu.org/licenses/>.
*/
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<JRibbonApplicationMenuButton> 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;
}
}
@@ -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<Integer> 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);
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<Integer> 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 <http://www.gnu.org/licenses/>.
*/
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<TagInfo.TagInfoItem> 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<TagInfo.TagInfoItem> 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) {
}
}
}
@@ -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
@@ -529,7 +529,7 @@ public class TagTreeContextMenu extends JPopupMenu {
for (TreeItem item : items) {
Set<Tag> copiedTags = new HashSet<>();
Set<Tag> newTags = new HashSet<>();
LinkedHashSet<Integer> needed = new LinkedHashSet<>();
Set<Integer> needed = new LinkedHashSet<>();
Map<Integer, Integer> changedCharacterIds = new HashMap<>();
Tag tag = (Tag) item;