本文整理了Java中javax.swing.tree.TreePath.getParentPath()
方法的一些代码示例,展示了TreePath.getParentPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreePath.getParentPath()
方法的具体详情如下:
包路径:javax.swing.tree.TreePath
类名称:TreePath
方法名:getParentPath
暂无
代码示例来源:origin: zzz40500/GsonFormat
public boolean isPathSelected(TreePath path, boolean dig) {
if (!dig) {
return super.isPathSelected(path);
}
while (path != null && !super.isPathSelected(path)) {
path = path.getParentPath();
}
return path != null;
}
代码示例来源:origin: zzz40500/GsonFormat
private void toggleRemoveSelection(TreePath path) {
Stack stack = new Stack();
TreePath parent = path.getParentPath();
while (parent != null && !isPathSelected(parent)) {
stack.push(parent);
parent = parent.getParentPath();
}
if (parent != null) {
stack.push(parent);
} else {
super.removeSelectionPaths(new TreePath[]{path});
return;
}
while (!stack.isEmpty()) {
TreePath temp = (TreePath) stack.pop();
TreePath peekPath = stack.isEmpty() ? path : (TreePath) stack.peek();
Object node = temp.getLastPathComponent();
Object peekNode = peekPath.getLastPathComponent();
int childCount = model.getChildCount(node);
for (int i = 0; i < childCount; i++) {
Object childNode = model.getChild(node, i);
if (childNode != peekNode) {
super.addSelectionPaths(new TreePath[]{temp.pathByAddingChild(childNode)});
}
}
}
super.removeSelectionPaths(new TreePath[]{parent});
}
代码示例来源:origin: zzz40500/GsonFormat
private boolean areSiblingsSelected(TreePath path) {
TreePath parent = path.getParentPath();
if (parent == null) {
return true;
}
Object node = path.getLastPathComponent();
Object parentNode = parent.getLastPathComponent();
int childCount = model.getChildCount(parentNode);
for (int i = 0; i < childCount; i++) {
Object childNode = model.getChild(parentNode, i);
if (childNode == node) {
continue;
}
if (!isPathSelected(parent.pathByAddingChild(childNode))) {
return false;
}
}
return true;
}
代码示例来源:origin: kiegroup/optaplanner
private void expandSubtree(TreePath path, boolean expand) {
if (path == null) {
TreePath selectionPath = getSelectionPath();
path = selectionPath == null ? new TreePath(treeModel.getRoot()) : selectionPath;
}
DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) path.getLastPathComponent();
Enumeration children = currentNode.children();
while (children.hasMoreElements()) {
DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement();
TreePath expandedPath = path.pathByAddingChild(child);
expandSubtree(expandedPath, expand);
}
if (expand) {
expandPath(path);
} else if (path.getParentPath() != null) {
collapsePath(path);
}
}
代码示例来源:origin: zzz40500/GsonFormat
while (areSiblingsSelected(path)) {
temp = path;
if (path.getParentPath() == null) {
break;
path = path.getParentPath();
if (temp.getParentPath() != null) {
addSelectionPath(temp.getParentPath());
} else {
if (!isSelectionEmpty()) {
代码示例来源:origin: stackoverflow.com
TreePath parentPath = tp.getParentPath();
代码示例来源:origin: pentaho/mondrian
public Object getParentObject() {
TreePath tPath = tree.getSelectionPath();
if ((tPath != null) && (tPath.getParentPath() != null)) {
return tPath.getParentPath().getLastPathComponent();
}
return null;
}
代码示例来源:origin: apache/pdfbox
/**
* Constructs a status string from the path.
* @param path
* @return the status string.
*/
private String generatePathString(TreePath path)
{
StringBuilder pathStringBuilder = new StringBuilder();
while (path.getParentPath() != null)
{
Object object = path.getLastPathComponent();
pathStringBuilder.insert(0, "/" + getObjectName(object));
path = path.getParentPath();
}
pathStringBuilder.delete(0, 1);
return pathStringBuilder.toString();
}
代码示例来源:origin: geotools/geotools
@Override
public void valueChanged(TreeSelectionEvent e) {
TreePath path = e.getNewLeadSelectionPath();
if (path.getLastPathComponent() instanceof Name) {
Name name = (Name) path.getLastPathComponent();
ProcessFactory factory =
(ProcessFactory)
path.getParentPath().getLastPathComponent();
updateProcessDesc(factory, name);
}
}
});
代码示例来源:origin: pentaho/mondrian
public void itemStateChanged(ItemEvent e) {
tree.stopEditing();
TreePath tpath = tree.getSelectionPath();
if (tpath != null) {
TreePath parentpath = tpath.getParentPath();
if (parentpath != null) {
refreshTree(parentpath);
}
}
}
});
代码示例来源:origin: pentaho/mondrian
parentpath = tpath.getParentPath();
int objCnt = 2;
while (parentpath != null) {
treeObjs[objCnt] = po;
objCnt += 1;
parentpath = parentpath.getParentPath();
代码示例来源:origin: apache/pdfbox
private void showFont(Object selectedNode, TreePath path)
{
COSName fontName = getNodeKey(selectedNode);
COSDictionary resourceDic = (COSDictionary) getUnderneathObject(path.getParentPath().getParentPath().getLastPathComponent());
FontEncodingPaneController fontEncodingPaneController = new FontEncodingPaneController(fontName, resourceDic);
JPanel pane = fontEncodingPaneController.getPane();
if (pane == null)
{
// unsupported font type
replaceRightComponent(jScrollPane2);
return;
}
replaceRightComponent(pane);
}
代码示例来源:origin: pentaho/mondrian
protected void arrowButtonUpAction(ActionEvent evt) {
TreePath tpath = tree.getSelectionPath();
if (tpath != null) {
TreePath parentpath = tpath.getParentPath();
if (parentpath != null) {
tree.setSelectionPath(parentpath);
refreshTree(parentpath);
}
}
}
代码示例来源:origin: pentaho/mondrian
tpath.getParentPath().pathByAddingChild(
nextSibling));
} else if (prevSibling != null) {
tree.setSelectionPath(
tpath.getParentPath().pathByAddingChild(
prevSibling));
} else if (grandparentAsSibling) {
tree.setSelectionPath(tpath.getParentPath().getParentPath());
} else {
tree.setSelectionPath(tpath.getParentPath());
代码示例来源:origin: apache/pdfbox
COSName parentKey = getNodeKey(path.getParentPath().getLastPathComponent());
COSDictionary resourcesDic = null;
Object pageObj = path.getParentPath().getLastPathComponent();
COSDictionary page = (COSDictionary) getUnderneathObject(pageObj);
resourcesDic = (COSDictionary) page.getDictionaryObject(COSName.RESOURCES);
Object pageObj = path.getParentPath().getParentPath().getLastPathComponent();
COSDictionary page = (COSDictionary) getUnderneathObject(pageObj);
resourcesDic = (COSDictionary) page.getDictionaryObject(COSName.RESOURCES);
Object resourcesObj = path.getParentPath().getParentPath().getLastPathComponent();
resourcesDic = (COSDictionary) getUnderneathObject(resourcesObj);
代码示例来源:origin: apache/pdfbox
return;
if (path.getParentPath() != null
&& isFlagNode(selectedNode, path.getParentPath().getLastPathComponent()))
Object parentNode = path.getParentPath().getLastPathComponent();
showFlagPane(parentNode, selectedNode);
return;
代码示例来源:origin: pentaho/mondrian
if (tpath != null) {
Object value = tpath.getLastPathComponent();
TreePath parentpath = tpath.getParentPath();
if (parentpath != null) {
Object parent = parentpath.getLastPathComponent();
代码示例来源:origin: stackoverflow.com
path = path.getParentPath();
temp = path;
if(path.getParentPath()==null)
path = path.getParentPath();
if(temp.getParentPath()!=null)
addSelectionPath(temp.getParentPath());
TreePath parent = path.getParentPath();
TreePath parent = path.getParentPath();
parent = parent.getParentPath();
代码示例来源:origin: pentaho/mondrian
Object po = null;
TreePath parentTpath = tpath.getParentPath();
String parentName = "";
String elementName = "";
代码示例来源:origin: pentaho/mondrian
instanceof MondrianGuiDef.RelationOrJoin)
Object po = path.getParentPath().getLastPathComponent();
if (!(po instanceof MondrianGuiDef.RelationOrJoin)
&& !(po instanceof MondrianGuiDef.Closure))
内容来源于网络,如有侵权,请联系作者删除!