本文整理汇总了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);
}
}
}
示例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();
}
}
}
示例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;
}
}
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例8: getSelectedNode
import javax.swing.tree.TreePath; //导入方法依赖的package包/类
private ClassNode getSelectedNode() {
TreePath path = getSelectionPath();
if (path != null) {
return (ClassNode) path.getLastPathComponent();
} else {
return null;
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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());
}
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
}