javax.swing.event.TreeSelectionEvent Java Examples
The following examples show how to use
javax.swing.event.TreeSelectionEvent.
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: ElementTreePanel.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Called whenever the value of the selection changes. * @param e the event that characterizes the change. */ public void valueChanged(TreeSelectionEvent e) { if (!updatingSelection && tree.getSelectionCount() == 1) { TreePath selPath = tree.getSelectionPath(); Object lastPathComponent = selPath.getLastPathComponent(); if (!(lastPathComponent instanceof DefaultMutableTreeNode)) { Element selElement = (Element) lastPathComponent; updatingSelection = true; try { getEditor().select(selElement.getStartOffset(), selElement.getEndOffset()); } finally { updatingSelection = false; } } } }
Example #2
Source File: ClusterTreeVisualization.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
@Override public void valueChanged(TreeSelectionEvent e) { TreePath[] paths = getSelectionPaths(); // If only one item has been selected, then change the text in the // description area if (paths == null) { return; } if (paths.length == 1) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) paths[0].getLastPathComponent(); if (!node.getAllowsChildren()) { ClusterTreeLeaf leaf = (ClusterTreeLeaf) node.getUserObject(); ObjectVisualizer viz = ObjectVisualizerService.getVisualizerForObject(clusterModel); viz.startVisualization(leaf.getId()); } } }
Example #3
Source File: ImageTreePanel.java From moa with GNU General Public License v3.0 | 6 votes |
@Override public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node == null) { return; } Object nodeInfo = node.getUserObject(); if (node.isLeaf()) { ImageChart chart = (ImageChart) nodeInfo; ImagePanel chPanel = new ImagePanel(chart.getChart()); chPanel.setMouseWheelEnabled(true); chPanel.setMouseZoomable(true); chPanel.repaint(); this.imgPanel.removeAll(); this.imgPanel.add(chPanel); this.imgPanel.updateUI(); } }
Example #4
Source File: ElementTreePanel.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Called whenever the value of the selection changes. * @param e the event that characterizes the change. */ public void valueChanged(TreeSelectionEvent e) { if (!updatingSelection && tree.getSelectionCount() == 1) { TreePath selPath = tree.getSelectionPath(); Object lastPathComponent = selPath.getLastPathComponent(); if (!(lastPathComponent instanceof DefaultMutableTreeNode)) { Element selElement = (Element) lastPathComponent; updatingSelection = true; try { getEditor().select(selElement.getStartOffset(), selElement.getEndOffset()); } finally { updatingSelection = false; } } } }
Example #5
Source File: JSplitPaneClassFile.java From freeinternals with Apache License 2.0 | 6 votes |
private void jTreeClassFileSelectionChanged(final TreeSelectionEvent evt) { Object obj = evt.getPath().getLastPathComponent(); if (obj instanceof DefaultMutableTreeNode) { final DefaultMutableTreeNode objDmtn = (DefaultMutableTreeNode) obj; obj = objDmtn.getUserObject(); if (obj instanceof JTreeNodeFileComponent) { final JTreeNodeFileComponent objTncc = (JTreeNodeFileComponent) obj; // Select the bytes of this data this.binaryViewer.setSelection(objTncc.getStartPos(), objTncc.getLength()); // clear opcode values; this.opcode.setText(null); // Get the code bytes if (AttributeCode.ATTRIBUTE_CODE_NODE.equals(objTncc.getText())) { final byte[] data = this.classFile.getClassByteArray(objTncc.getStartPos(), objTncc.getLength()); this.generateOpcodeParseResult(data); } } } }
Example #6
Source File: ClassMemberList.java From Cafebabe with GNU General Public License v3.0 | 6 votes |
public ClassMemberList() { MethodEditorPanel editor = new MethodEditorPanel(this); this.setRootVisible(false); this.setShowsRootHandles(false); this.setFocusable(false); this.setCellRenderer(new MethodListCellRenderer()); this.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { MethodListNode node = (MethodListNode) getLastSelectedPathComponent(); if (node != null && node.getMethod() != null) { Cafebabe.gui.smallEditorPanel.setViewportView(editor); editor.editMethod(node.getMethod()); } } }); this.model = new DefaultTreeModel(root = new MethodListNode(null, null)); this.setModel(model); this.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); }
Example #7
Source File: UiInspectorAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getNewLeadSelectionPath(); if (path == null) { onComponentChanged((Component)null); return; } Object component = path.getLastPathComponent(); if (component instanceof ComponentNode) { Component c = ((ComponentNode)component).getComponent(); onComponentChanged(c); } if (component instanceof ClickInfoNode) { onComponentChanged(((ClickInfoNode)component).getInfo()); } }
Example #8
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 #9
Source File: Overview.java From pdfxtk with Apache License 2.0 | 6 votes |
ThreadPane(String name_, int tabIdx_) { name = name_; tabIdx = tabIdx_; setLayout(new BorderLayout()); setName(name + " (" + msgCount + ")"); jtree.setRootVisible(false); jtree.setShowsRootHandles(true); jtree.setCellRenderer(new TreeRenderer()); jtree.setScrollsOnExpand(true); jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); jtree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { if(e.getNewLeadSelectionPath() == null) return; if(e.getNewLeadSelectionPath().getLastPathComponent() instanceof LogMessageNode) { LogMessage m = ((LogMessageNode)e.getNewLeadSelectionPath().getLastPathComponent()).m; info.setText(Const.LOG_STRINGS[m.priority] + " from " + m.thread + " @ " + new Date(m.time).toString() + "\n" + m.message + "\n" + m.getException()); } } }); add(new JScrollPane(jtree), BorderLayout.CENTER); }
Example #10
Source File: TreeToolbarDecorator.java From consulo with Apache License 2.0 | 6 votes |
TreeToolbarDecorator(JTree tree, @Nullable final ElementProducer<?> producer) { myTree = tree; myProducer = producer; myAddActionEnabled = myRemoveActionEnabled = myUpActionEnabled = myDownActionEnabled = myTree.getModel() instanceof EditableTreeModel; if (myTree.getModel() instanceof EditableTreeModel) { createDefaultTreeActions(); } myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { updateButtons(); } }); myTree.addPropertyChangeListener("enabled", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { updateButtons(); } }); }
Example #11
Source File: TreeDemo.java From OpenDA with GNU Lesser General Public License v3.0 | 6 votes |
/** Required by TreeSelectionListener interface. */ public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node == null) return; Object nodeInfo = node.getUserObject(); if (node.isLeaf()) { BookInfo book = (BookInfo)nodeInfo; displayURL(book.bookURL); if (DEBUG) { System.out.print(book.bookURL + ": \n "); } } else { displayURL(helpURL); } if (DEBUG) { System.out.println(nodeInfo.toString()); } }
Example #12
Source File: CompoundDemoFrame.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void valueChanged(TreeSelectionEvent e) { final TreePath treePath = e.getNewLeadSelectionPath(); if (treePath == null) { setSelectedHandler(null); } else { final Object o = treePath.getLastPathComponent(); if (o instanceof DemoHandlerTreeNode) { DemoHandlerTreeNode handlerNode = (DemoHandlerTreeNode) o; DemoHandler handler = handlerNode.getHandler(); setSelectedHandler(handler); } else { setSelectedHandler(null); } } }
Example #13
Source File: TreeIconDemo.java From marathonv5 with Apache License 2.0 | 6 votes |
/** Required by TreeSelectionListener interface. */ public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node == null) return; Object nodeInfo = node.getUserObject(); if (node.isLeaf()) { BookInfo book = (BookInfo) nodeInfo; displayURL(book.bookURL); if (DEBUG) { System.out.print(book.bookURL + ": \n "); } } else { displayURL(helpURL); } if (DEBUG) { System.out.println(nodeInfo.toString()); } }
Example #14
Source File: JPanelForTree.java From freeinternals with Apache License 2.0 | 6 votes |
/** * Create a panel tool bar to contain a {@code JTree} object. * * @param jTree The tree to be contained * @param frame The parent window */ public JPanelForTree(final JTree jTree, final JFrame frame) { if (jTree == null) { throw new IllegalArgumentException("[tree] cannot be null."); } this.tree = jTree; this.topLevelFrame = frame; this.tree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(final javax.swing.event.TreeSelectionEvent evt) { treeSelectionChanged(evt); } }); this.toolbar = new JToolBar(); this.toolbarbtnDetails = new JButton("Details"); this.initToolbar(); this.layoutComponents(); }
Example #15
Source File: CamoChoiceDialog.java From megamek with GNU General Public License v2.0 | 6 votes |
@Override public void valueChanged(TreeSelectionEvent ev) { if (ev.getSource().equals(treeCategories)) { TreePath[] paths = treeCategories.getSelectionPaths(); // If nothing is selected, there's nothing to populate the table with. if (null == paths) { return; } for (TreePath path : paths) { Object[] values = path.getPath(); String category = ""; for (int i = 1; i < values.length; i++) { if (values[i] != null) { String name = (String) ((DefaultMutableTreeNode) values[i]) .getUserObject(); category += name; if (!name.equals(IPlayer.NO_CAMO) && !name.equals(IPlayer.ROOT_CAMO)) { category += "/"; } } } fillTable(category); } } }
Example #16
Source File: AbstractTableView.java From ramus with GNU General Public License v3.0 | 6 votes |
protected void createInnerComponent() { panel.removeAll(); Attribute[] attributes = getAttributes(); RootCreater rootCreater = getRootCreater(); component = new RowTreeTableComponent(engine, qualifier, accessRules, rootCreater, attributes, framework); rowSet = component.getRowSet(); table = component.getTable(); table.getTreeSelectionModel().addTreeSelectionListener( new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { refreshActions(); } }); refreshActions(); panel.add(component, BorderLayout.CENTER); panel.revalidate(); panel.repaint(); }
Example #17
Source File: ElementSelectionListener.java From niftyeditor with Apache License 2.0 | 6 votes |
@Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getNewLeadSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); if (!node.isRoot()) { try { SelectCommand command = CommandProcessor.getInstance().getCommand(SelectCommand.class); command.setElement((GElement) node.getUserObject()); CommandProcessor.getInstance().excuteCommand(command); } catch (Exception ex) { Logger.getLogger(ElementSelectionListener.class.getName()).log(Level.SEVERE, null, ex); } } final JTree temp = (JTree) e.getSource(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { temp.updateUI(); } }); } }
Example #18
Source File: ObjectSelector.java From jaamsim with Apache License 2.0 | 6 votes |
@Override public void valueChanged( TreeSelectionEvent e ) { JTree tree = (JTree) e.getSource(); DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent(); if(node == null) { // This occurs when we set no selected entity (null) and then // force the tree to have a null selected node return; } Object userObj = node.getUserObject(); if (userObj instanceof Entity) { FrameBox.setSelectedEntity((Entity)userObj, false); } else { FrameBox.setSelectedEntity(null, false); } }
Example #19
Source File: ElementTreePanel.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Called whenever the value of the selection changes. * @param e the event that characterizes the change. */ public void valueChanged(TreeSelectionEvent e) { if (!updatingSelection && tree.getSelectionCount() == 1) { TreePath selPath = tree.getSelectionPath(); Object lastPathComponent = selPath.getLastPathComponent(); if (!(lastPathComponent instanceof DefaultMutableTreeNode)) { Element selElement = (Element) lastPathComponent; updatingSelection = true; try { getEditor().select(selElement.getStartOffset(), selElement.getEndOffset()); } finally { updatingSelection = false; } } } }
Example #20
Source File: TreeView.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void valueChanged(TreeSelectionEvent ev) { TreePath[] paths = tree.getSelectionPaths(); if (paths == null) { // part of bugfix #37279, if DnD is active then is useless select a nearby node if (ExplorerDnDManager.getDefault().isDnDActive()) { return; } callSelectionChanged(new Node[0]); } else { // we need to force no changes to nodes hierarchy => // we are requesting read request, but it is not necessary // to execute the next action immediatelly, so postReadRequest // should be enough readAccessPaths = paths; Children.MUTEX.postReadRequest(this); } }
Example #21
Source File: PathsCustomizer.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void valueChanged(TreeSelectionEvent e) { if (e.isAddedPath()) { otherTreeSelectionModel.clearSelection(); } int idx = treeModel.getIndexOfChild(treeModel.getRoot(), e.getPath().getLastPathComponent()); if (idx >= 0) { if (otherListModel != null) { idx += otherListModel.getSize() + 1; } if (e.isAddedPath()) { list.setSelectionInterval(idx, idx); } else { list.removeSelectionInterval(idx, idx); } } else { list.clearSelection(); } }
Example #22
Source File: PathsCustomizer.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void valueChanged(TreeSelectionEvent e) { if (e.isAddedPath()) { otherTreeSelectionModel.clearSelection(); } int idx = treeModel.getIndexOfChild(treeModel.getRoot(), e.getPath().getLastPathComponent()); if (idx >= 0) { if (otherListModel != null) { idx += otherListModel.getSize() + 1; } if (e.isAddedPath()) { list.setSelectionInterval(idx, idx); } else { list.removeSelectionInterval(idx, idx); } } else { list.clearSelection(); } }
Example #23
Source File: RangeAxisConfigPanel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
@Override public void valueChanged(TreeSelectionEvent e) { TreePath newLeadSelectionPath = e.getNewLeadSelectionPath(); if (newLeadSelectionPath == null) { selectedRangeAxisConfig = null; return; } Object lastPathComponent = newLeadSelectionPath.getLastPathComponent(); if (lastPathComponent instanceof RangeAxisConfigTreeNode) { RangeAxisConfig selectedConfig = ((RangeAxisConfigTreeNode) lastPathComponent).getUserObject(); selectedRangeAxisConfig = selectedConfig; adaptGUI(); } else { selectedRangeAxisConfig = null; } }
Example #24
Source File: ClassTree.java From JByteMod-Beta with GNU General Public License v2.0 | 6 votes |
public ClassTree(JByteMod jam) { this.jbm = jam; this.setRootVisible(false); this.setShowsRootHandles(true); this.setCellRenderer(new TreeCellRenderer()); this.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { SortedTreeNode node = (SortedTreeNode) ClassTree.this.getLastSelectedPathComponent(); if (node == null) return; if (node.getCn() != null && node.getMn() != null) { jam.selectMethod(node.getCn(), node.getMn()); } else if (node.getCn() != null) { jam.selectClass(node.getCn()); } else { } } }); this.model = new DefaultTreeModel(new SortedTreeNode("")); this.setModel(model); this.setTransferHandler(new JarDropHandler(this, 0)); this.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); }
Example #25
Source File: ElementTreePanel.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Called whenever the value of the selection changes. * @param e the event that characterizes the change. */ public void valueChanged(TreeSelectionEvent e) { if (!updatingSelection && tree.getSelectionCount() == 1) { TreePath selPath = tree.getSelectionPath(); Object lastPathComponent = selPath.getLastPathComponent(); if (!(lastPathComponent instanceof DefaultMutableTreeNode)) { Element selElement = (Element) lastPathComponent; updatingSelection = true; try { getEditor().select(selElement.getStartOffset(), selElement.getEndOffset()); } finally { updatingSelection = false; } } } }
Example #26
Source File: AbstractTreeSelectionDependentPanel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@Override public void valueChanged(TreeSelectionEvent e) { TreePath newLeadSelectionPath = e.getNewLeadSelectionPath(); if (newLeadSelectionPath == null) { return; } Object lastPathComponent = newLeadSelectionPath.getLastPathComponent(); if (lastPathComponent instanceof ValueSourceTreeNode) { valueSourceNode = (ValueSourceTreeNode) lastPathComponent; // get the selected PVC ValueSource selectedValueSource = valueSourceNode.getUserObject(); if (selectedValueSource == currentValueSource) { return; } // change current PlotValueConfig currentValueSource = selectedValueSource; adaptGUI(); } else { currentValueSource = null; valueSourceNode = null; } }
Example #27
Source File: DirectoryChooserModuleTreeView.java From consulo with Apache License 2.0 | 5 votes |
@Override public void onSelectionChange(final Runnable runnable) { myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { runnable.run(); } }); }
Example #28
Source File: LayerManager.java From Spade with GNU General Public License v3.0 | 5 votes |
@Override public void valueChanged(TreeSelectionEvent e) { if(Spade.getDocument() == null) return; if(e.getNewLeadSelectionPath() == null) { Spade.getDocument().setCurrent(Spade.getDocument().getRoot()); controls.setVisible(false); return; } Layer l = (Layer) e.getNewLeadSelectionPath().getLastPathComponent(); if(l == null) { Spade.getDocument().setCurrent(Spade.getDocument().getRoot()); controls.setVisible(false); } else { Layer current = Spade.getDocument().getCurrent(); if(Spade.getDocument().setCurrent(l) && current != null) { if(current.getImage().isMaskEnabled()) { boolean[] mask = current.getImage().copyMask(); current.addChange(new ClearMaskChange()); if(Spade.main.currentTool instanceof SelectionTool) { l.addChange(new SetMaskChange(mask)); } } } controls.setVisible(true); lsettings.updateIfVisible(l); } }
Example #29
Source File: DBBrowserTree.java From nextreports-designer with Apache License 2.0 | 5 votes |
/** * TreeSelectionListener - sets selected node */ public void valueChanged(TreeSelectionEvent evt) { selectedTreePath = evt.getNewLeadSelectionPath(); if (selectedTreePath == null) { selectedNode = null; return; } selectedNode = (DBBrowserNode) selectedTreePath.getLastPathComponent(); }
Example #30
Source File: MethodsCountPanel.java From android-classyshark with Apache License 2.0 | 5 votes |
private void setup() { this.setLayout(new BorderLayout()); treeModel = new DefaultTreeModel(new DefaultMutableTreeNode(null)); jTree = new JTree(treeModel); jTree.setRootVisible(false); jTree.setCellRenderer(new CellRenderer()); theme.applyTo(jTree); DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) jTree.getCellRenderer(); cellRenderer.setFont(new Font("Monospaced", Font.PLAIN, 20)); jTree.setCellRenderer(cellRenderer); jTree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { Object selection = jTree.getLastSelectedPathComponent(); DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode)selection; ClassNode node = (ClassNode) defaultMutableTreeNode.getUserObject(); viewerController.onSelectedMethodCount(node); } }); JScrollPane jScrollPane = new JScrollPane(jTree); this.setBorder(new EmptyBorder(0,0,0,0)); this.add(jScrollPane, BorderLayout.CENTER); theme.applyTo(jScrollPane); jTree.setDragEnabled(true); jTree.setTransferHandler(new FileTransferHandler(viewerController)); }