Java Code Examples for javax.swing.event.TreeSelectionEvent#getPath()
The following examples show how to use
javax.swing.event.TreeSelectionEvent#getPath() .
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: ProfilerTreeTable.java From visualvm with GNU General Public License v2.0 | 6 votes |
public void valueChanged(TreeSelectionEvent e) { if (internal) return; TreePath selected = e.getPath(); // NOTE: workaround to not break scrollRectToVisible() when there's // an expanded node above the selection. // Can be detected by e.getPath() != tree.getSelectionPath(). if (!Objects.equals(selected, tree.getSelectionPath())) return; int row = selected == null ? -1 : tree.getRowForPath(selected); try { internal = true; if (row != -1) selectRow(row, !tree.isChangingModel()); else clearSelection(); } finally { internal = false; } }
Example 2
Source File: CDialogUpdater.java From binnavi with Apache License 2.0 | 6 votes |
@Override public void valueChanged(final TreeSelectionEvent event) { final TreePath path = event.getPath(); if (path == null) { m_addConditionButton.setEnabled(false); updateDefineConditionPanel((JCriteriumTreeNode) m_jtree.getModel().getRoot()); } else { final JCriteriumTreeNode selectedNode = (JCriteriumTreeNode) path.getLastPathComponent(); boolean enable = selectedNode.allowAppend(CConditionCriterium.class); if (!enable && selectedNode.getLevel() > 0) { final JCriteriumTreeNode parentNode = (JCriteriumTreeNode) selectedNode.getParent(); if (parentNode.getLevel() != 0 && !(parentNode.getCriterium() instanceof CNotCriterium) && !(selectedNode.getCriterium() instanceof CNotCriterium)) { enable = true; } } m_addConditionButton.setEnabled(enable); updateDefineConditionPanel(selectedNode); } }
Example 3
Source File: SelectSettlersFolderDialog.java From settlers-remake with MIT License | 6 votes |
@Override public void valueChanged(TreeSelectionEvent event) { TreePath path = event.getPath(); pathPanel.setPath(path.getPath()); Object lastPathComponent = path.getLastPathComponent(); if (lastPathComponent instanceof FilesystemTreeNode) { FilesystemTreeNode fileSystemTreeNode = (FilesystemTreeNode) lastPathComponent; if (!fileSystemTreeNode.wasExpanded()) { fileSystemTreeNode.setWasExpanded(true); tree.expandPath(path); } if (fileSystemTreeNode.isSettlersFolder()) { foundPanel.setFolder(fileSystemTreeNode.getFile().getAbsolutePath()); } else { foundPanel.resetFolder(); } } }
Example 4
Source File: GuildManagePanel.java From gameserver with Apache License 2.0 | 6 votes |
@Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getPath(); if ( path.getPathCount() > 1 ) { DBObjectTreeTableNode node = (DBObjectTreeTableNode)path.getPath()[1]; Object nodeKey = node.getKey(); if ( nodeKey instanceof UserId ) { UserId userId = (UserId)node.getKey(); User user = ((MongoUserManager)(UserManager.getInstance())). constructUserObject((DBObject)node.getUserObject()); if ( userId != null ) { delGuildAction.setEnabled(true); return; } } } else { delGuildAction.setEnabled(false); } }
Example 5
Source File: ProfilerTreeTable.java From netbeans with Apache License 2.0 | 6 votes |
public void valueChanged(TreeSelectionEvent e) { if (internal) return; TreePath selected = e.getPath(); // NOTE: workaround to not break scrollRectToVisible() when there's // an expanded node above the selection. // Can be detected by e.getPath() != tree.getSelectionPath(). if (!Objects.equals(selected, tree.getSelectionPath())) return; int row = selected == null ? -1 : tree.getRowForPath(selected); try { internal = true; if (row != -1) selectRow(row, !tree.isChangingModel()); else clearSelection(); } finally { internal = false; } }
Example 6
Source File: UserManagePanel.java From gameserver with Apache License 2.0 | 6 votes |
@Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getPath(); if ( path.getPathCount() > 1 ) { DBObjectTreeTableNode node = (DBObjectTreeTableNode)path.getPath()[1]; Object nodeKey = node.getKey(); if ( nodeKey instanceof String ) { node = (DBObjectTreeTableNode)path.getPath()[1]; String accountIdStr = node.getKey().toString(); Account account = (Account)MongoUtil.constructObject( (DBObject)node.getUserObject()); loginStatusAction.setAccount(account); loginStatusAction.setEnabled(true); deleteAccountButton.setEnabled(true); } } else { loginStatusAction.setEnabled(false); deleteAccountButton.setEnabled(false); } }
Example 7
Source File: UserManagePanel.java From gameserver with Apache License 2.0 | 6 votes |
@Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getPath(); if ( path.getPathCount() > 1 ) { DBObjectTreeTableNode node = (DBObjectTreeTableNode)path.getPath()[1]; Object nodeKey = node.getKey(); if ( nodeKey instanceof String ) { node = (DBObjectTreeTableNode)path.getPath()[1]; String accountIdStr = node.getKey().toString(); GuildMember account = (GuildMember)MongoUtil.constructObject( (DBObject)node.getUserObject()); saveGuildMemberAction.setEnabled(true); deleteGuildMemberAction.setEnabled(true); } } else { saveGuildMemberAction.setEnabled(false); deleteGuildMemberAction.setEnabled(false); } }
Example 8
Source File: UserManagePanel.java From gameserver with Apache License 2.0 | 5 votes |
@Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getPath(); if ( path.getPathCount() > 1 ) { DBObjectTreeTableNode node = (DBObjectTreeTableNode)path.getPath()[1]; Object nodeKey = node.getKey(); if ( nodeKey instanceof UserId ) { UserId userId = (UserId)node.getKey(); User user = ((MongoUserManager)(UserManager.getInstance())). constructUserObject((DBObject)node.getUserObject()); if ( userId != null ) { bagAction.setUser(user); bagAction.setEnabled(true); delAction.setUserId(userId); delAction.setEnabled(true); sendGiftAction.setUserId(userId); sendGiftAction.setEnabled(true); loginStatusAction.setEnabled(false); deleteAccountButton.setEnabled(false); chargeAction.setUserId(userId); chargeAction.setEnabled(true); pushAction.setUser(user); pushAction.setEnabled(true); return; } } } else { bagAction.setEnabled(false); delAction.setEnabled(false); sendGiftAction.setEnabled(false); loginStatusAction.setEnabled(false); } }
Example 9
Source File: ExpressionChooserDialog.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public void valueChanged( final TreeSelectionEvent e ) { final TreePath path = e.getPath(); if ( path == null ) { addAction.setEnabled( false ); return; } final Object o = path.getLastPathComponent(); if ( o instanceof ExpressionMetaData ) { addAction.setEnabled( true ); } else { addAction.setEnabled( false ); } }
Example 10
Source File: ParameterDialog.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Called whenever the value of the selection changes. * * @param e the event that characterizes the change. */ public void valueChanged( final TreeSelectionEvent e ) { if ( e.getPath() == null ) { return; } final Object o = e.getPath().getLastPathComponent(); if ( o instanceof String ) { queryComboBoxModel.setSelectedItem( o ); } }
Example 11
Source File: ConfigEditorPane.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Called whenever the value of the selection changes. * * @param e the event that characterizes the change. */ public void valueChanged( final TreeSelectionEvent e ) { if ( configuration == null ) { throw new IllegalStateException( "Need a configuration" ); } final TreePath path = e.getPath(); final Object lastPathElement = path.getLastPathComponent(); if ( lastPathElement instanceof ConfigTreeModuleNode ) { final ConfigTreeModuleNode node = (ConfigTreeModuleNode) lastPathElement; final ConfigEditorPanel detailEditorPane = getDetailEditorPane(); detailEditorPane.store(); detailEditorPane.editModule( node.getModule(), configuration, node.getAssignedKeys() ); } }
Example 12
Source File: LayerManagerForm.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
@Override public void valueChanged(TreeSelectionEvent event) { if (!adjusting) { TreePath path = event.getPath(); Layer layer = getLayer(path); if (layer.getParent() != null) { boolean pathSelected = ((TreeSelectionModel) event.getSource()).isPathSelected(path); layer.setVisible(pathSelected); } } }
Example 13
Source File: PathfindingDialog.java From binnavi with Apache License 2.0 | 5 votes |
@Override public void valueChanged(final TreeSelectionEvent event) { // The tree selection changed. Update the assembler code // depending on the new node selection. final TreePath path = event.getPath(); if (path == null) { return; } final Object selectedNode = path.getLastPathComponent(); // Every selectable node in the tree is either of type FunctionTreeContainerNode // or of type FunctionTreeFunctionNode. Only nodes of the first // type contain assembler code that is displayed. if (selectedNode instanceof FunctionTreeBlockNode) { final FunctionTreeBlockNode blockNode = (FunctionTreeBlockNode) selectedNode; final BasicBlock basicBlock = blockNode.getBasicBlock(); // Generate the assembler code string for the instructions of // the selected basic block and show them in the text field. final StringBuilder text = new StringBuilder(""); for (final Instruction instruction : basicBlock.getInstructions()) { text.append(instruction.toString() + "\n"); } m_field.setText(text.toString()); m_field.setCaretPosition(0); } else { // Do not show anything if a function node is selected. m_field.setText(""); } }
Example 14
Source File: GUIBrowser.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public void valueChanged(TreeSelectionEvent e) { if (e.getPath() != null && e.getPath().getLastPathComponent() instanceof ComponentNode) { area.setText("toString(): " + ((ComponentNode) e.getPath().getLastPathComponent()). getToString()); } else { area.setText(""); } }
Example 15
Source File: DifficultyDialog.java From freecol with GNU General Public License v2.0 | 5 votes |
@Override public void valueChanged(TreeSelectionEvent event) { TreePath path = event.getPath(); if (path.getPathCount() >= 2) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getPathComponent(1); this.selected = (OptionGroup)node.getUserObject(); } }
Example 16
Source File: PreferencesDialog.java From LoboBrowser with MIT License | 4 votes |
public void valueChanged(final TreeSelectionEvent e) { final TreePath path = e.getPath(); final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); final SettingsInfo si = node == null ? null : (SettingsInfo) node.getUserObject(); updatePreferencesPanel(si); }
Example 17
Source File: TreeListModelSelectionAdapter.java From blog with Apache License 2.0 | 4 votes |
public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getPath(); Person person = personTreeModel.getPerson(path); listModelSelection.setSelection(person); }
Example 18
Source File: BrowserComponent.java From ApkToolPlus with Apache License 2.0 | 3 votes |
public void valueChanged(TreeSelectionEvent selectionEvent) { services.activate(); TreePath selectedPath = selectionEvent.getPath(); history.updateHistory(selectedPath); showDetailPaneForPath(selectedPath); }