下面列出了javax.swing.event.TreeSelectionEvent#getPath() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
}
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;
}
}
@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);
}
}
@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);
}
}
@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);
}
}
@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);
}
}
@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();
}
}
}
@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();
}
}
@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("");
}
}
@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("");
}
}
@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);
}
}
@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);
}
}
}
/**
* 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() );
}
}
/**
* 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 );
}
}
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 );
}
}
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);
}
public void valueChanged(TreeSelectionEvent e) {
TreePath path = e.getPath();
Person person = personTreeModel.getPerson(path);
listModelSelection.setSelection(person);
}
public void valueChanged(TreeSelectionEvent selectionEvent) {
services.activate();
TreePath selectedPath = selectionEvent.getPath();
history.updateHistory(selectedPath);
showDetailPaneForPath(selectedPath);
}