diff options
Diffstat (limited to 'enigma-swing/src/main/java')
| -rw-r--r-- | enigma-swing/src/main/java/cuchaz/enigma/gui/panels/StructurePanel.java | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/StructurePanel.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/StructurePanel.java index 0ca2714..868edcf 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/StructurePanel.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/StructurePanel.java | |||
| @@ -10,23 +10,19 @@ import cuchaz.enigma.translation.representation.entry.ParentedEntry; | |||
| 10 | import cuchaz.enigma.utils.I18n; | 10 | import cuchaz.enigma.utils.I18n; |
| 11 | 11 | ||
| 12 | import javax.swing.*; | 12 | import javax.swing.*; |
| 13 | import javax.swing.tree.TreeCellRenderer; | 13 | import javax.swing.tree.DefaultTreeCellRenderer; |
| 14 | import javax.swing.tree.TreePath; | 14 | import javax.swing.tree.TreePath; |
| 15 | import java.awt.*; | 15 | import java.awt.*; |
| 16 | import java.awt.event.MouseAdapter; | 16 | import java.awt.event.MouseAdapter; |
| 17 | import java.awt.event.MouseEvent; | 17 | import java.awt.event.MouseEvent; |
| 18 | 18 | ||
| 19 | public class StructurePanel extends JPanel { | 19 | public class StructurePanel extends JPanel { |
| 20 | private final Gui gui; | ||
| 21 | |||
| 22 | private JPanel sortingPanel; | 20 | private JPanel sortingPanel; |
| 23 | private JCheckBox hideDeobfuscated; | 21 | private JCheckBox hideDeobfuscated; |
| 24 | 22 | ||
| 25 | private JTree structureTree; | 23 | private JTree structureTree; |
| 26 | 24 | ||
| 27 | public StructurePanel(Gui gui) { | 25 | public StructurePanel(Gui gui) { |
| 28 | this.gui = gui; | ||
| 29 | |||
| 30 | this.sortingPanel = new JPanel(); | 26 | this.sortingPanel = new JPanel(); |
| 31 | this.hideDeobfuscated = new JCheckBox(I18n.translate("info_panel.tree.structure.hide_deobfuscated")); | 27 | this.hideDeobfuscated = new JCheckBox(I18n.translate("info_panel.tree.structure.hide_deobfuscated")); |
| 32 | this.hideDeobfuscated.addActionListener(event -> gui.showStructure(gui.getActiveEditor())); | 28 | this.hideDeobfuscated.addActionListener(event -> gui.showStructure(gui.getActiveEditor())); |
| @@ -63,6 +59,9 @@ public class StructurePanel extends JPanel { | |||
| 63 | return this.sortingPanel; | 59 | return this.sortingPanel; |
| 64 | } | 60 | } |
| 65 | 61 | ||
| 62 | /** | ||
| 63 | * Returns whether the "Hide Deobfuscated" option of this structure panel is selected. | ||
| 64 | */ | ||
| 66 | public boolean shouldHideDeobfuscated() { | 65 | public boolean shouldHideDeobfuscated() { |
| 67 | return this.hideDeobfuscated.isSelected(); | 66 | return this.hideDeobfuscated.isSelected(); |
| 68 | } | 67 | } |
| @@ -75,28 +74,24 @@ public class StructurePanel extends JPanel { | |||
| 75 | this.hideDeobfuscated.setText(I18n.translate("info_panel.tree.structure.hide_deobfuscated")); | 74 | this.hideDeobfuscated.setText(I18n.translate("info_panel.tree.structure.hide_deobfuscated")); |
| 76 | } | 75 | } |
| 77 | 76 | ||
| 78 | class StructureTreeCellRenderer implements TreeCellRenderer { | 77 | class StructureTreeCellRenderer extends DefaultTreeCellRenderer { |
| 79 | private JLabel label; | ||
| 80 | |||
| 81 | public StructureTreeCellRenderer() { | ||
| 82 | this.label = new JLabel(); | ||
| 83 | } | ||
| 84 | 78 | ||
| 85 | @Override | 79 | @Override |
| 86 | public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { | 80 | public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { |
| 81 | JComponent c = (JComponent) super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); | ||
| 87 | ParentedEntry entry = ((StructureTreeNode) value).getEntry(); | 82 | ParentedEntry entry = ((StructureTreeNode) value).getEntry(); |
| 88 | 83 | ||
| 89 | if (entry instanceof ClassEntry) { | 84 | if (entry instanceof ClassEntry) { |
| 90 | this.label.setIcon(GuiUtil.CLASS_ICON); | 85 | this.setIcon(GuiUtil.CLASS_ICON); |
| 91 | } else if (entry instanceof MethodEntry) { | 86 | } else if (entry instanceof MethodEntry) { |
| 92 | this.label.setIcon(((MethodEntry) entry).isConstructor() ? GuiUtil.CONSTRUCTOR_ICON : GuiUtil.METHOD_ICON); | 87 | this.setIcon(((MethodEntry) entry).isConstructor() ? GuiUtil.CONSTRUCTOR_ICON : GuiUtil.METHOD_ICON); |
| 93 | } else if (entry instanceof FieldEntry) { | 88 | } else if (entry instanceof FieldEntry) { |
| 94 | this.label.setIcon(GuiUtil.FIELD_ICON); | 89 | this.setIcon(GuiUtil.FIELD_ICON); |
| 95 | } | 90 | } |
| 96 | 91 | ||
| 97 | this.label.setText(value.toString()); | 92 | this.setText(value.toString()); |
| 98 | 93 | ||
| 99 | return this.label; | 94 | return c; |
| 100 | } | 95 | } |
| 101 | } | 96 | } |
| 102 | } | 97 | } |