下面列出了javax.swing.event.TreeSelectionEvent#getNewLeadSelectionPath() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void valueChanged(TreeSelectionEvent aEvent) {
TreePath thePath = aEvent.getNewLeadSelectionPath();
if (thePath != null) {
DefaultMutableTreeNode theNode = (DefaultMutableTreeNode) thePath
.getLastPathComponent();
if (theNode != null) {
Object theUserObject = theNode.getUserObject();
if (theUserObject instanceof UsedBy) {
theUserObject = ((UsedBy) theUserObject).ref;
}
if (theUserObject instanceof ModelItem) {
SQLComponent.getDefault().displaySQLFor(
new ModelItem[]{(ModelItem) theUserObject});
ERDesignerComponent.getDefault().setSelectedObject(
(ModelItem) theUserObject);
} else {
SQLComponent.getDefault().resetDisplay();
}
}
}
}
@Override
public void valueChanged(TreeSelectionEvent e) {
TreePath selected = e.getNewLeadSelectionPath();
if (selected == null)
return;
DefaultMutableTreeNode node = (DefaultMutableTreeNode) selected.getLastPathComponent();
text.setText(getText(node));
try {
String hash = ((NodeInfo) node.getUserObject()).getHash();
if (hash != null) {
data.setText(fdq.getSomeData(hash, 10000));
} else {
data.setText("");
}
} catch (IOException e1) {
log.error("Could not get data from FileDataQuery.", e1);
}
}
@Override
public void valueChanged(TreeSelectionEvent e) {
TreePath newLeadSelectionPath = e.getNewLeadSelectionPath();
if (newLeadSelectionPath == null) {
return;
}
Object lastPathComponent = newLeadSelectionPath.getLastPathComponent();
if (lastPathComponent instanceof ValueSourceTreeNode) {
ValueSourceTreeNode valueSourceNode = (ValueSourceTreeNode) lastPathComponent;
// get the selected PVC
ValueSource selectedValueSource = valueSourceNode.getUserObject();
if (selectedValueSource == currentValueSource) {
return;
}
// change current PlotValueConfig
currentValueSource = selectedValueSource;
} else {
currentValueSource = null;
}
}
@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;
}
}
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);
}
}
}
@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());
}
}
public void valueChanged(TreeSelectionEvent evt)
{
final TreePath selPath = evt.getNewLeadSelectionPath();
if (selPath != null)
{
StringBuffer buf = new StringBuffer();
Object[] fullPath = selPath.getPath();
for (int i = 0; i < fullPath.length; ++i)
{
if (fullPath[i] instanceof ObjectTreeNode)
{
ObjectTreeNode node = (ObjectTreeNode)fullPath[i];
buf.append('/').append(node.toString());
}
}
//JASON: have a main application status bar setStatusBarMessage(buf.toString());
}
}
public void valueChanged(TreeSelectionEvent evt)
{
final TreePath selPath = evt.getNewLeadSelectionPath();
if (selPath != null)
{
StringBuffer buf = new StringBuffer();
Object[] fullPath = selPath.getPath();
for (int i = 0; i < fullPath.length; ++i)
{
if (fullPath[i] instanceof ObjectTreeNode)
{
ObjectTreeNode node = (ObjectTreeNode)fullPath[i];
buf.append('/').append(node.toString());
}
}
setStatusBarMessage(buf.toString());
}
}
@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();
}
});
}
}
/**
* TreeSelectionListener - sets selected node
*/
public void valueChanged(TreeSelectionEvent evt) {
selectedTreePath = evt.getNewLeadSelectionPath();
if (selectedTreePath == null) {
selectedNode = null;
return;
}
selectedNode = (DBBrowserNode) selectedTreePath.getLastPathComponent();
}
/************ imple of TreeSelectionListener *******/
@Override
public void valueChanged(TreeSelectionEvent e) {
showPopupCompletion = false;
FileSystemView fsv = fileChooser.getFileSystemView();
JTree tree = (JTree) e.getSource();
TreePath path = tree.getSelectionPath();
TreePath curSel = e.getNewLeadSelectionPath();
curSelPath = (curSel != null) ? new WeakReference<TreePath>(curSel) : null;
if(path != null) {
DirectoryNode node = (DirectoryNode)path.getLastPathComponent();
File file = node.getFile();
if(file != null) {
setSelected(getSelectedNodes(tree.getSelectionPaths()));
newFolderAction.setEnabled(false);
if(!node.isLeaf()) {
newFolderAction.enable(file);
setDirectorySelected(true);
}
}
}
}
@Override
public void valueChanged(TreeSelectionEvent e) {
TreePath path = e.getNewLeadSelectionPath();
if (listener != null) {
listener.selectionChanged(new Event(path));
}
}
private void handleTreeSelectionEvent(TreeSelectionEvent e) {
final TreePath selectionPath = e.getNewLeadSelectionPath();
if (selectionPath != null) {
ApplicationManager.getApplication().invokeLater(() -> selectPath(selectionPath, false));
}
activeOutlines.setValue(getOutlinesSelectedInTree());
}
private void handleTreeSelectionEvent(TreeSelectionEvent e) {
final TreePath selectionPath = e.getNewLeadSelectionPath();
if (selectionPath != null) {
ApplicationManager.getApplication().invokeLater(() -> selectPath(selectionPath, false));
}
activeOutlines.setValue(getOutlinesSelectedInTree());
}
@Override
public void valueChanged(TreeSelectionEvent e) {
TreePath newLeadSelectionPath = e.getNewLeadSelectionPath();
if (newLeadSelectionPath != null) {
if (newLeadSelectionPath.getLastPathComponent() instanceof DimensionConfigTreeNode) {
adaptGUI();
}
}
}
public void valueChanged(TreeSelectionEvent evt)
{
final TreePath path = evt.getNewLeadSelectionPath();
if (path != null)
{
Object lastComp = path.getLastPathComponent();
if (lastComp instanceof DocumentNode)
{
setSelectedDocument(((DocumentNode) lastComp).getURL());
}
}
}
public void valueChanged(final TreeSelectionEvent treeselectionevent) {
final TreePath path = treeselectionevent.getNewLeadSelectionPath();
if (path != null) {
final DomTreeNode domNode = (DomTreeNode) path.getLastPathComponent();
final Node node = domNode.getNode();
if ((node.getNodeType() == Node.TEXT_NODE) || (node.getNodeType() == Node.COMMENT_NODE)) {
this.textArea.setText(node.getNodeValue());
} else {
this.textArea.setText("");
this.appendNode(0, node);
}
this.textArea.setCaretPosition(0);
}
}
@Override
public void valueChanged(TreeSelectionEvent event) {
if (selectedView != null) {
selectedView.setSelected(false);
}
if (event.getNewLeadSelectionPath() == null) {
selectedView = null;
return;
}
DefaultMutableTreeNode newNode = (DefaultMutableTreeNode) event.getNewLeadSelectionPath().getLastPathComponent();
View newView = (View) newNode.getUserObject();
newView.setSelected(true);
selectedView = newView;
updateImage(false);
}
@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);
}
}
@Override
public void valueChanged(TreeSelectionEvent e) {
currentPath = e.getNewLeadSelectionPath();
pathParser.parse(currentPath);
}