當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。