Skip to content

Commit 812e373

Browse files
committed
use named edge for FakeTreeNodes
Previously if you had a DM node `code : integer` selected, that's how the text would be populated in the project search box. We don't want the ` : integer` part. To get rid of it, we add special handling for `FakeTreeNode` nodes, of which these are an instance, and just get the edge name if the edge exists. See #57.
1 parent c707d16 commit 812e373

File tree

1 file changed

+20
-5
lines changed
  • src/main/java/edu/umich/soar/visualsoar/dialogs/find

1 file changed

+20
-5
lines changed

src/main/java/edu/umich/soar/visualsoar/dialogs/find/Util.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package edu.umich.soar.visualsoar.dialogs.find;
22

33
import edu.umich.soar.visualsoar.datamap.DataMapTree;
4+
import edu.umich.soar.visualsoar.datamap.FakeTreeNode;
45
import edu.umich.soar.visualsoar.mainframe.feedback.FeedbackList;
56
import edu.umich.soar.visualsoar.mainframe.feedback.FeedbackListEntry;
67
import edu.umich.soar.visualsoar.operatorwindow.OperatorWindow;
@@ -25,11 +26,7 @@ static String getSelectedText() {
2526
initialText = editorPane.getSelectedText();
2627
} else if (focusedComponent instanceof JTree) {
2728
// covers both OperatorWindow and DataMapTree
28-
JTree tree = (JTree) focusedComponent;
29-
TreePath path = tree.getSelectionPath();
30-
if (path != null) {
31-
initialText = path.getLastPathComponent().toString();
32-
}
29+
initialText = getJtreeTextSelection((JTree) focusedComponent);
3330
} else if (focusedComponent instanceof FeedbackList) {
3431
FeedbackList fbList = (FeedbackList) focusedComponent;
3532
FeedbackListEntry entry = fbList.getSelectedValue();
@@ -42,4 +39,22 @@ static String getSelectedText() {
4239
}
4340
return initialText;
4441
}
42+
43+
private static String getJtreeTextSelection(JTree jTree) {
44+
String initialText = null;
45+
TreePath path = jTree.getSelectionPath();
46+
if (path != null) {
47+
Object lastPathComponent = path.getLastPathComponent();
48+
if (lastPathComponent instanceof FakeTreeNode) {
49+
FakeTreeNode ftn = (FakeTreeNode) lastPathComponent;
50+
if (ftn.getEdge() != null) {
51+
initialText = ftn.getEdge().getName();
52+
}
53+
}
54+
if (initialText == null) {
55+
initialText = path.getLastPathComponent().toString();
56+
}
57+
}
58+
return initialText;
59+
}
4560
}

0 commit comments

Comments
 (0)