diff options
| author | 2019-02-24 12:43:41 -0800 | |
|---|---|---|
| committer | 2019-02-24 22:43:41 +0200 | |
| commit | ad49f6d08133253b5e2e54cc13fe3a54d85bf8d6 (patch) | |
| tree | 81feffbf613a13d386eddb98a8df901e8b19e303 /src/main/java/cuchaz/enigma/gui | |
| parent | Fix name duplication checking not occurring on root classes (diff) | |
| download | enigma-fork-ad49f6d08133253b5e2e54cc13fe3a54d85bf8d6.tar.gz enigma-fork-ad49f6d08133253b5e2e54cc13fe3a54d85bf8d6.tar.xz enigma-fork-ad49f6d08133253b5e2e54cc13fe3a54d85bf8d6.zip | |
Adds a red highlight for overridden methods in method inheritance tree gui (#112)
* Make implemented method nodes in inheritance ui more obvious
Signed-off-by: liach <liach@users.noreply.github.com>
* Make the text green and italic instead
Signed-off-by: liach <liach@users.noreply.github.com>
* Update again for the new tree gen
Also tweaked new tree gen to show only useful branch nodes
Signed-off-by: liach <liach@users.noreply.github.com>
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui')
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/Gui.java | 14 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/MethodTreeCellRenderer.java | 40 |
2 files changed, 47 insertions, 7 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java index c419aae..a604323 100644 --- a/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/src/main/java/cuchaz/enigma/gui/Gui.java | |||
| @@ -38,10 +38,7 @@ import de.sciss.syntaxpane.DefaultSyntaxKit; | |||
| 38 | import javax.swing.*; | 38 | import javax.swing.*; |
| 39 | import javax.swing.text.BadLocationException; | 39 | import javax.swing.text.BadLocationException; |
| 40 | import javax.swing.text.Highlighter; | 40 | import javax.swing.text.Highlighter; |
| 41 | import javax.swing.tree.DefaultMutableTreeNode; | 41 | import javax.swing.tree.*; |
| 42 | import javax.swing.tree.DefaultTreeModel; | ||
| 43 | import javax.swing.tree.TreeNode; | ||
| 44 | import javax.swing.tree.TreePath; | ||
| 45 | import java.awt.*; | 42 | import java.awt.*; |
| 46 | import java.awt.event.*; | 43 | import java.awt.event.*; |
| 47 | import java.nio.file.Path; | 44 | import java.nio.file.Path; |
| @@ -153,7 +150,7 @@ public class Gui { | |||
| 153 | inheritanceTree.addMouseListener(new MouseAdapter() { | 150 | inheritanceTree.addMouseListener(new MouseAdapter() { |
| 154 | @Override | 151 | @Override |
| 155 | public void mouseClicked(MouseEvent event) { | 152 | public void mouseClicked(MouseEvent event) { |
| 156 | if (event.getClickCount() == 2) { | 153 | if (event.getClickCount() >= 2) { |
| 157 | // get the selected node | 154 | // get the selected node |
| 158 | TreePath path = inheritanceTree.getSelectionPath(); | 155 | TreePath path = inheritanceTree.getSelectionPath(); |
| 159 | if (path == null) { | 156 | if (path == null) { |
| @@ -173,6 +170,9 @@ public class Gui { | |||
| 173 | } | 170 | } |
| 174 | } | 171 | } |
| 175 | }); | 172 | }); |
| 173 | TreeCellRenderer cellRenderer = inheritanceTree.getCellRenderer(); | ||
| 174 | inheritanceTree.setCellRenderer(new MethodTreeCellRenderer((DefaultTreeCellRenderer) cellRenderer)); | ||
| 175 | |||
| 176 | JPanel inheritancePanel = new JPanel(); | 176 | JPanel inheritancePanel = new JPanel(); |
| 177 | inheritancePanel.setLayout(new BorderLayout()); | 177 | inheritancePanel.setLayout(new BorderLayout()); |
| 178 | inheritancePanel.add(new JScrollPane(inheritanceTree)); | 178 | inheritancePanel.add(new JScrollPane(inheritanceTree)); |
| @@ -183,7 +183,7 @@ public class Gui { | |||
| 183 | implementationsTree.addMouseListener(new MouseAdapter() { | 183 | implementationsTree.addMouseListener(new MouseAdapter() { |
| 184 | @Override | 184 | @Override |
| 185 | public void mouseClicked(MouseEvent event) { | 185 | public void mouseClicked(MouseEvent event) { |
| 186 | if (event.getClickCount() == 2) { | 186 | if (event.getClickCount() >= 2) { |
| 187 | // get the selected node | 187 | // get the selected node |
| 188 | TreePath path = implementationsTree.getSelectionPath(); | 188 | TreePath path = implementationsTree.getSelectionPath(); |
| 189 | if (path == null) { | 189 | if (path == null) { |
| @@ -212,7 +212,7 @@ public class Gui { | |||
| 212 | @SuppressWarnings("unchecked") | 212 | @SuppressWarnings("unchecked") |
| 213 | @Override | 213 | @Override |
| 214 | public void mouseClicked(MouseEvent event) { | 214 | public void mouseClicked(MouseEvent event) { |
| 215 | if (event.getClickCount() == 2) { | 215 | if (event.getClickCount() >= 2) { |
| 216 | // get the selected node | 216 | // get the selected node |
| 217 | TreePath path = callsTree.getSelectionPath(); | 217 | TreePath path = callsTree.getSelectionPath(); |
| 218 | if (path == null) { | 218 | if (path == null) { |
diff --git a/src/main/java/cuchaz/enigma/gui/MethodTreeCellRenderer.java b/src/main/java/cuchaz/enigma/gui/MethodTreeCellRenderer.java new file mode 100644 index 0000000..c78ead2 --- /dev/null +++ b/src/main/java/cuchaz/enigma/gui/MethodTreeCellRenderer.java | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.html | ||
| 7 | * <p> | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | |||
| 12 | package cuchaz.enigma.gui; | ||
| 13 | |||
| 14 | import cuchaz.enigma.analysis.MethodInheritanceTreeNode; | ||
| 15 | |||
| 16 | import javax.swing.*; | ||
| 17 | import javax.swing.tree.TreeCellRenderer; | ||
| 18 | import java.awt.*; | ||
| 19 | |||
| 20 | class MethodTreeCellRenderer implements TreeCellRenderer { | ||
| 21 | |||
| 22 | private final TreeCellRenderer parent; | ||
| 23 | |||
| 24 | MethodTreeCellRenderer(TreeCellRenderer parent) { | ||
| 25 | this.parent = parent; | ||
| 26 | } | ||
| 27 | |||
| 28 | @Override | ||
| 29 | public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { | ||
| 30 | Component ret = parent.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); | ||
| 31 | if (value instanceof MethodInheritanceTreeNode && ((MethodInheritanceTreeNode) value).isImplemented()) { | ||
| 32 | ret.setForeground(Color.BLACK); | ||
| 33 | ret.setFont(ret.getFont().deriveFont(Font.PLAIN)); | ||
| 34 | } else { | ||
| 35 | ret.setForeground(Color.GRAY); | ||
| 36 | ret.setFont(ret.getFont().deriveFont(Font.ITALIC)); | ||
| 37 | } | ||
| 38 | return ret; | ||
| 39 | } | ||
| 40 | } | ||