use of javax.swing.tree.TreePath in project antlrworks by antlr.
the class AWTreePanel method scrollNodeToVisible.
public void scrollNodeToVisible(TreeNode node) {
if (node == null)
return;
tree.scrollPathToVisible(new TreePath(jTreeModel.getPathToRoot(node)));
treeGraphView.scrollNodeToVisible(node);
}
use of javax.swing.tree.TreePath in project antlrworks by antlr.
the class AWTreePanel method selectNode.
public void selectNode(TreeNode node) {
TreePath path = new TreePath(jTreeModel.getPathToRoot(node));
tree.scrollPathToVisible(path);
tree.setSelectionPath(path);
treeGraphView.highlightNode(node);
}
use of javax.swing.tree.TreePath in project languagetool by languagetool-org.
the class ConfigurationDialog method getMouseAdapter.
@NotNull
private MouseAdapter getMouseAdapter() {
return new MouseAdapter() {
private void handlePopupEvent(MouseEvent e) {
JTree tree = (JTree) e.getSource();
TreePath path = tree.getPathForLocation(e.getX(), e.getY());
if (path == null) {
return;
}
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
TreePath[] paths = tree.getSelectionPaths();
boolean isSelected = false;
if (paths != null) {
for (TreePath selectionPath : paths) {
if (selectionPath.equals(path)) {
isSelected = true;
}
}
}
if (!isSelected) {
tree.setSelectionPath(path);
}
if (node.isLeaf()) {
JPopupMenu popup = new JPopupMenu();
JMenuItem aboutRuleMenuItem = new JMenuItem(messages.getString("guiAboutRuleMenu"));
aboutRuleMenuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
RuleNode node = (RuleNode) tree.getSelectionPath().getLastPathComponent();
Rule rule = node.getRule();
Language lang = config.getLanguage();
if (lang == null) {
lang = Languages.getLanguageForLocale(Locale.getDefault());
}
Tools.showRuleInfoDialog(tree, messages.getString("guiAboutRuleTitle"), rule.getDescription(), rule, messages, lang.getShortCodeWithCountryAndVariant());
}
});
popup.add(aboutRuleMenuItem);
popup.show(tree, e.getX(), e.getY());
}
}
@Override
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) {
handlePopupEvent(e);
}
}
@Override
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
handlePopupEvent(e);
}
}
};
}
use of javax.swing.tree.TreePath in project CoreNLP by stanfordnlp.
the class FileTreeModel method treeNodeChanged.
public void treeNodeChanged(FileTreeNode n) {
TreePath t = new TreePath(makeTreePathArray(n));
//System.out.println("Tree path is: " + t);
this.fireTreeStructureChanged(t);
}
use of javax.swing.tree.TreePath in project binnavi by google.
the class CRootTagTreeNode method refreshTree.
/**
* Rebuilds the entire tree from scratch by filtering over all elements in the graph. This is
* pretty damn slow for any reasonably-sized graph, and should hence be done only rarely.
* @deprecated
*/
@Deprecated
@Override
public void refreshTree(final ITreeNode<CTag> tag) {
final List<DefaultMutableTreeNode> lastNodes = TreeHelpers.getLastExpandedNodes(m_tagsTree);
final List<Integer> lastNodeIds = new ArrayList<Integer>();
if ((tag != null) && (tag.getParent() != null)) {
lastNodeIds.add(tag.getParent().getObject().getId());
}
for (final DefaultMutableTreeNode lastNode : lastNodes) {
if (lastNode.getUserObject() instanceof Integer) {
final int tagId = (Integer) lastNode.getUserObject();
lastNodeIds.add(tagId);
}
}
deleteChildren();
createChildren();
final Enumeration<?> bfn = breadthFirstEnumeration();
while (bfn.hasMoreElements()) {
final Object node = bfn.nextElement();
int tagId = -1;
TreePath path = null;
if (node instanceof CRootTagTreeNode) {
final CRootTagTreeNode rootNode = (CRootTagTreeNode) node;
tagId = m_rootTag.getObject().getId();
path = new TreePath(rootNode.getPath());
} else if (node instanceof CTagTreeNode) {
final CTagTreeNode treeNode = (CTagTreeNode) node;
tagId = treeNode.getTag().getObject().getId();
path = new TreePath(treeNode.getPath());
} else if (node instanceof CTaggedGraphNodesContainerNode) {
final CTaggedGraphNodesContainerNode containerNode = (CTaggedGraphNodesContainerNode) node;
tagId = -containerNode.getTag().getObject().getId();
path = new TreePath(containerNode.getPath());
}
if (lastNodeIds.contains(tagId)) {
m_tagsTree.expandPath(path);
}
}
}
Aggregations