当前位置: 首页>>代码示例>>Java>>正文


Java TreePath.getLastPathComponent方法代码示例

本文整理汇总了Java中javax.swing.tree.TreePath.getLastPathComponent方法的典型用法代码示例。如果您正苦于以下问题:Java TreePath.getLastPathComponent方法的具体用法?Java TreePath.getLastPathComponent怎么用?Java TreePath.getLastPathComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.tree.TreePath的用法示例。


在下文中一共展示了TreePath.getLastPathComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: valueForPathChanged

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
@Override
public void valueForPathChanged(TreePath path, Object newValue) {
    DefaultMutableTreeNode o = (DefaultMutableTreeNode) path.getLastPathComponent();
    if (o.getUserObject() instanceof HintMetadata) {
        try {
            HintMetadata hint = (HintMetadata) o.getUserObject();
            getDataObject(hint).rename((String) newValue);
            RulesManager.getInstance().reload();
            cpBased.reset();
            errorTreeModel = constructTM(Utilities.getBatchSupportedHints(cpBased).keySet(), false);
            setModel(errorTreeModel);
            if (logic != null) {
                logic.errorTreeModel = errorTreeModel;
            }
            select(getHintByName((String) newValue));
            hasNewHints = true;
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(errorTree, NbBundle.getMessage(HintsPanel.class, "ERR_CannotRename", newValue));
            errorTree.startEditingAtPath(path);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:HintsPanel.java

示例2: mouseClicked

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent evt) {
    if (evt.getButton() != MouseEvent.BUTTON1) {
        return;
    }
    TreePath path = getSelectionPath();
    if (path == null) {
        return;
    }
    Object selectedNode = path.getLastPathComponent();
    if (selectedNode instanceof MatchTreeNode
        || selectedNode instanceof RecipeTransitionTreeNode) {
        if (evt.getClickCount() == 2) {
            getActions().getApplyMatchAction()
                .execute();
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:19,代码来源:RuleTree.java

示例3: valueChanged

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
/**
 * 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;
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:ElementTreePanel.java

示例4: OntoTreeExpand

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
private void OntoTreeExpand( TreePath parent, boolean expand, Integer CurrNodeLevel, Integer Up2TreeLevel) {

    TreeNode node = (TreeNode)parent.getLastPathComponent();
    if (CurrNodeLevel >= Up2TreeLevel) {
    	return;
    }
    if (node.getChildCount() >= 0) {
        for (Enumeration<?> e=node.children(); e.hasMoreElements();) {
            TreeNode n = (TreeNode) e.nextElement();
            TreePath path = parent.pathByAddingChild(n);
            OntoTreeExpand(path, expand, CurrNodeLevel+1, Up2TreeLevel);
        }
    }    
    // Expansion or collapse must be done bottom-up
    if (expand) {
        ontoTree.expandPath(parent);
    } else {
    	ontoTree.collapsePath(parent);
    }
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:21,代码来源:OntologyTab.java

示例5: saveExpansionState

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
/**
 * Saves the currently selected paths and saves all expanded repositories and nodes.
 *
 * @param tree
 *            The related tree, containing the path(s)
 */
public void saveExpansionState(JTree tree) {

	saveSelectionPaths(tree.getSelectionPaths());

	expandedNodes = new HashSet<>();
	expandedRepositories = new HashSet<>();

	for (int i = 0; i < tree.getRowCount(); i++) {
		TreePath path = tree.getPathForRow(i);
		if (tree.isExpanded(path)) {
			Entry entry = (Entry) path.getLastPathComponent();
			String absoluteLocation = entry.getLocation().getAbsoluteLocation();
			if (entry instanceof Repository) {
				expandedRepositories.add(absoluteLocation);
			} else {
				expandedNodes.add(absoluteLocation);
			}

		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:28,代码来源:RepositoryTreeUtil.java

示例6: getSelectedPages

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
public List<ORPageInf> getSelectedPages() {
    List<ORPageInf> pages = new ArrayList<>();
    TreePath[] paths = tree.getSelectionPaths();
    if (paths != null && paths.length > 0) {
        for (TreePath path : paths) {
            if (path.getLastPathComponent() instanceof ORPageInf) {
                pages.add((ORPageInf) path.getLastPathComponent());
            }
        }
    }
    return pages;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:13,代码来源:ObjectTree.java

示例7: performFinish

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
private boolean performFinish() {
  final TreePath path = this.tree.getSelectionModel().getSelectionPath();
  if (path == null || path.getLastPathComponent() == null) {
    return false;
  }

  final String relationName = path.getLastPathComponent().toString();
  final String inRelationName = Utility.getType(relationName);

  if (this.beforeAtom == null) {
    final String name = this.textField.getText();
    if (inRelationName != null) {
      Utility.addAtomToSigType(inRelationName, name);
    }
    Utility.addAtomToSigType(relationName, name);
    final List<Notifier> notifierList = Visualization.getInstance().getNotifierList();
    final List<String> tupleList = new ArrayList<>();
    tupleList.add(name);
    for (final Notifier notifier : notifierList) {
      if (inRelationName != null) {
        notifier.addTupleNotify(relationName, inRelationName, tupleList,
            Visualization.getInstance().isLower() ? "lower" : "upper");
      } else {
        notifier.addTupleNotify(relationName, tupleList,
            Visualization.getInstance().isLower() ? "lower" : "upper");
      }
    }
  } else {
    Utility.changeAtomType(this.beforeAtom, !relationName.equals(inRelationName) ? inRelationName : relationName);
  }

  return true;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:34,代码来源:CreateAtom.java

示例8: getSelectedNode

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
private ClassNode getSelectedNode() {
    TreePath path = getSelectionPath();
    if (path != null) {
        return (ClassNode) path.getLastPathComponent();
    } else {
        return null;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:GUIBrowser.java

示例9: expandTreeRecursively

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
private static void expandTreeRecursively(JTree tree, TreePath parent) {
    tree.expandPath(parent);
    TreeNode node = (TreeNode) parent.getLastPathComponent();
    if (node.getChildCount() >= 0) {
        for (Enumeration e = node.children(); e.hasMoreElements(); ) {
            TreeNode n = (TreeNode) e.nextElement();
            TreePath path = parent.pathByAddingChild(n);
            expandTreeRecursively(tree, path);
        }
    }
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:12,代码来源:SwingUtils.java

示例10: valueForPathChanged

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
@Override
public void valueForPathChanged(TreePath path, Object newValue) {
    boolean refreshTree = false;
    if (path == null) {
        // no idea
        return;
    }
    DirectoryNode node = (DirectoryNode)path.getLastPathComponent();
    File f = node.getFile();
    File newFile = getFileChooser().getFileSystemView().createFileObject(f.getParentFile(), (String)newValue);
    
    if(f.renameTo(newFile)) {
        // fix bug #97521, #96960
        if(tree.isExpanded(path)) {
            tree.collapsePath(path);
            refreshTree = true;
        }
        
        node.setFile(newFile);
        node.removeAllChildren();
        
        ((DefaultTreeModel) tree.getModel()).nodeStructureChanged(node);
        if(refreshTree) {
            tree.expandPath(path);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:DirectoryChooserUI.java

示例11: maybeShowPopup

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
private void maybeShowPopup(MouseEvent evt) {
    if (evt.isPopupTrigger()) {
        TreePath selectedPath = getPathForLocation(evt.getX(), evt.getY());
        TreeNode selectedNode =
            selectedPath == null ? null : (TreeNode) selectedPath.getLastPathComponent();
        StateTree.this.requestFocus();
        createPopupMenu(selectedNode).show(evt.getComponent(), evt.getX(), evt.getY());
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:10,代码来源:StateTree.java

示例12: valueForPathChanged

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
@Override
public void valueForPathChanged(TreePath path, Object newValue) {
    Object o = path.getLastPathComponent();
    Row row = (Row) o;
    ((Journaled) row.getEngine()).startUserTransaction();
    row.setName(String.valueOf(newValue));
    ((Journaled) row.getEngine()).commitUserTransaction();
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:9,代码来源:TreeModel.java

示例13: createTransferable

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
@Override
public Transferable createTransferable(JComponent c) {
	JTree tree = (JTree) c;
	TreePath selectionPath = tree.getSelectionPath();
	Object lastPathComponent = selectionPath.getLastPathComponent();

	Transferable t = null;
	if (lastPathComponent instanceof ValueSourceTreeNode) {
		t = (ValueSourceTreeNode) lastPathComponent;
	} else if (lastPathComponent instanceof RangeAxisConfigTreeNode) {
		t = (RangeAxisConfigTreeNode) lastPathComponent;
	}
	return t;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:15,代码来源:PlotConfigurationTreeTransferHandler.java

示例14: canImport

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
@Override
public boolean canImport(TransferHandler.TransferSupport transferSupport) {
    if (!transferSupport.isDrop()) {
        return false;
    }
    transferSupport.setShowDropLocation(true);
    if (!transferSupport.isDataFlavorSupported(myDataFlavor)) {
        return false;
    }
    JTree tree = (JTree) transferSupport.getComponent();
    int[] selectionRows = tree.getSelectionRows();

    // Do not allow a drop on the drag source selections.
    JTree.DropLocation dropLocation = (JTree.DropLocation) transferSupport.getDropLocation();
    int dropRow = tree.getRowForPath(dropLocation.getPath());
    if (Arrays.asList(selectionRows).contains(dropRow)) {
        return false;
    }

    // Do not allow MOVE-action drops if a non-leaf node is selected unless all of its children are also selected
    if (transferSupport.getDropAction() == MOVE) {
        return haveCompleteNode(tree);
    }

    // Do not allow a non-leaf node to be copied to a level which is less than its source level.
    TreePath destinationPath = dropLocation.getPath();
    DefaultMutableTreeNode target = (DefaultMutableTreeNode) destinationPath.getLastPathComponent();
    TreePath path = tree.getPathForRow(selectionRows[0]);
    DefaultMutableTreeNode firstNode = (DefaultMutableTreeNode) path.getLastPathComponent();
    if (firstNode.getChildCount() > 0 && target.getLevel() < firstNode.getLevel()) {
        return false;
    }
    return true;
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:35,代码来源:RmlTagTreeTransferHandler.java

示例15: isPathEditable

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
@Override
public boolean isPathEditable(TreePath path)
{
	SchemaNode node = (SchemaNode) path.getLastPathComponent();

	if( node.isLocked() || node.isRoot() )
	{
		return false;
	}
	else
	{
		return isEditable();
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:15,代码来源:SchemaTree.java


注:本文中的javax.swing.tree.TreePath.getLastPathComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。