javax.swing.event.TreeSelectionEvent#getPath()源码实例Demo

下面列出了javax.swing.event.TreeSelectionEvent#getPath() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: ProfilerTreeTable.java
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;
    }
}
 
源代码2 项目: visualvm   文件: ProfilerTreeTable.java
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;
    }
}
 
源代码3 项目: binnavi   文件: CDialogUpdater.java
@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);
  }
}
 
源代码4 项目: gameserver   文件: GuildManagePanel.java
@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);
	}
}
 
源代码5 项目: gameserver   文件: UserManagePanel.java
@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);
	}
}
 
源代码6 项目: gameserver   文件: UserManagePanel.java
@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();
		}
	}
}
 
源代码8 项目: freecol   文件: DifficultyDialog.java
@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();
    }
}
 
源代码9 项目: openjdk-jdk9   文件: GUIBrowser.java
@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("");
    }
}
 
源代码10 项目: binnavi   文件: PathfindingDialog.java
@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("");
  }
}
 
源代码11 项目: gameserver   文件: UserManagePanel.java
@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);
	}
}
 
源代码12 项目: snap-desktop   文件: LayerManagerForm.java
@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);
        }
    }
}
 
源代码13 项目: pentaho-reporting   文件: ConfigEditorPane.java
/**
 * 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() );
  }
}
 
源代码14 项目: pentaho-reporting   文件: ParameterDialog.java
/**
 * 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 );
  }
}
 
源代码16 项目: LoboBrowser   文件: PreferencesDialog.java
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);
}
 
源代码17 项目: blog   文件: TreeListModelSelectionAdapter.java
public void valueChanged(TreeSelectionEvent e) {
	TreePath path = e.getPath();
	Person person = personTreeModel.getPerson(path);
	listModelSelection.setSelection(person);

}
 
源代码18 项目: ApkToolPlus   文件: BrowserComponent.java
public void valueChanged(TreeSelectionEvent selectionEvent) {

        services.activate();

        TreePath selectedPath = selectionEvent.getPath();

        history.updateHistory(selectedPath);
        showDetailPaneForPath(selectedPath);

    }