Java Code Examples for javax.swing.event.TreeSelectionEvent#getPaths()
The following examples show how to use
javax.swing.event.TreeSelectionEvent#getPaths() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MemberChooser.java From consulo with Apache License 2.0 | 6 votes |
@Override public void valueChanged(TreeSelectionEvent e) { TreePath[] paths = e.getPaths(); if (paths == null) return; for (int i = 0; i < paths.length; i++) { Object node = paths[i].getLastPathComponent(); if (node instanceof MemberNode) { final MemberNode memberNode = (MemberNode)node; if (e.isAddedPath(i)) { if (!mySelectedNodes.contains(memberNode)) { mySelectedNodes.add(memberNode); } } else { mySelectedNodes.remove(memberNode); } } } mySelectedElements = new LinkedHashSet<T>(); for (MemberNode selectedNode : mySelectedNodes) { mySelectedElements.add((T)selectedNode.getDelegate()); } }
Example 2
Source File: JPlotterPanel.java From opensim-gui with Apache License 2.0 | 5 votes |
private void getCurrentTreeSelection(TreeSelectionEvent e) { TreePath[] selectedPaths = e.getPaths(); for(int i=0;i<selectedPaths.length;i++){ if (e.isAddedPath(i)){ selectedPathsVector.add(selectedPaths[i]); } else { //Removed selectedPathsVector.remove(selectedPaths[i]); } } }
Example 3
Source File: LiteralChooser.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void valueChanged(TreeSelectionEvent e) { // System.out.println("select event ----------"); TreePath[] paths = e.getPaths(); if (paths == null) return; for (int i = 0; i < paths.length; i++) { Object node = paths[i].getLastPathComponent(); if (node instanceof CheckedTreeNode) { Object userObject = ((DefaultMutableTreeNode) node).getUserObject(); if (userObject instanceof LiteralChooserObject) { LiteralChooserObject literalObject = (LiteralChooserObject) userObject; String text = literalObject.getText(); // System.out.println("selected " + text); if ( e.isAddedPath(paths[i]) ) { if ( selectedElements.contains(text) ) { selectedElements.remove(text); } else { selectedElements.add(text); } // System.out.println("added path: "+text); CheckedTreeNode checkedNode = (CheckedTreeNode) node; checkedNode.setChecked(!checkedNode.isChecked()); // toggle } } } } }
Example 4
Source File: FileChooserDialogImpl.java From consulo with Apache License 2.0 | 5 votes |
public void valueChanged(TreeSelectionEvent e) { TreePath[] paths = e.getPaths(); boolean enabled = true; for (TreePath treePath : paths) { if (e.isAddedPath(treePath)) { VirtualFile file = FileSystemTreeImpl.getVirtualFile(treePath); if (file == null || !myChooserDescriptor.isFileSelectable(file)) enabled = false; } } setOKActionEnabled(enabled); }
Example 5
Source File: ExcitationEditorJPanel.java From opensim-gui with Apache License 2.0 | 4 votes |
public void valueChanged(TreeSelectionEvent e) { TreePath[] selectedPaths = e.getPaths(); somethingSelected=false; for(int i=0;i<selectedPaths.length;i++){ ExcitationObject eo = null; ExcitationColumnJPanel eCol = null; TreeNode lastNode=(TreeNode)selectedPaths[i].getLastPathComponent(); if (((DefaultMutableTreeNode)lastNode).getUserObject() instanceof ExcitationObject){ eo = (ExcitationObject) ((DefaultMutableTreeNode)lastNode).getUserObject(); } else if (((DefaultMutableTreeNode)lastNode).getUserObject() instanceof ExcitationColumnJPanel){ eCol = (ExcitationColumnJPanel) ((DefaultMutableTreeNode)lastNode).getUserObject(); } if (e.isAddedPath(i)){ if (eo != null){ selectedPathsVector.add(selectedPaths[i]); eo.markSelected(true); somethingSelected=true; } else if (eCol != null) { selectedColumnsVector.add(selectedPaths[i]); } } else { //Removed if (eo != null){ selectedPathsVector.remove(selectedPaths[i]); eo.markSelected(false); } else if (eCol != null) { selectedColumnsVector.remove(selectedPaths[i]); } } } // Enable buttons to move only if (somethingSelected) jMoveUpButton.setEnabled(somethingSelected); jMoveDownButton.setEnabled(somethingSelected); jDeleteButton.setEnabled(somethingSelected); // Same for Export and Simpify //SimplfyExcitationsButton.setEnabled(somethingSelected); ExportExcitationsButton.setEnabled(somethingSelected); }