List of usage examples for javax.swing.tree DefaultMutableTreeNode getUserObject
public Object getUserObject()
From source file:display.containers.FileManager.java
@Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; File file = (File) node.getUserObject(); label.setIcon(fileSystemView.getSystemIcon(file)); label.setText(fileSystemView.getSystemDisplayName(file)); label.setToolTipText(file.getPath()); if (selected) { label.setBackground(backgroundSelectionColor); label.setForeground(textSelectionColor); } else {/*from ww w . j a v a 2 s .c o m*/ label.setBackground(backgroundNonSelectionColor); label.setForeground(textNonSelectionColor); } return label; }
From source file:com.lp.client.frame.component.PanelDokumentenablage.java
@Override public void treeExpanded(TreeExpansionEvent event) { if (treeInProgress) return;// w ww .j a va 2 s . c o m setBusy(true); DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent(); DefaultMutableTreeNode firstChild = (DefaultMutableTreeNode) node.getFirstChild(); TreePath selectionPath = tree.getSelectionPath(); if (MUST_LOAD_CHILDREN.equals(firstChild.getUserObject())) { node.removeAllChildren(); DocPath expandPath = new DocPath(); for (Object obj : node.getUserObjectPath()) { try { expandPath.add((DocNodeBase) obj); } catch (ClassCastException ex) { expandPath.add(new DocNodeLiteral(obj.toString())); } } List<DocNodeBase> childList; try { childList = DelegateFactory.getInstance().getJCRDocDelegate() .getDocNodeChildrenFromNode(expandPath); setDocNodesOnTree(node, childList, expandPath); } catch (Throwable e) { treeModel.insertNodeInto(new DefaultMutableTreeNode(e), node, 0); } tree.expandPath(new TreePath(node.getPath())); tree.setSelectionPath(selectionPath); } setBusy(false); }
From source file:com.lp.client.frame.component.PanelDokumentenablage.java
private void addNotExistingNodes(DocPath pathToAdd, DefaultMutableTreeNode top) { if (pathToAdd == null || pathToAdd.size() == 0) { treeModel.insertNodeInto(new DefaultMutableTreeNode(MUST_LOAD_CHILDREN), top, 0); return;/*from w w w . j a v a 2 s .c o m*/ } boolean exists = false; DefaultMutableTreeNode node = null; for (int i = 0; i < top.getChildCount(); i++) { node = (DefaultMutableTreeNode) top.getChildAt(i); if (pathToAdd.asDocNodeList().get(0).toString().equals(node.getUserObject().toString())) { exists = true; break; } } if (!exists) { node = new DefaultMutableTreeNode(pathToAdd.asDocNodeList().get(0)); treeModel.insertNodeInto(node, top, top.getChildCount()); } DocPath subPath = pathToAdd.getDeepCopy(); subPath.asDocNodeList().remove(0); addNotExistingNodes(subPath, node); }
From source file:com.pironet.tda.SunJDKParser.java
private void updateChildCount(DefaultMutableTreeNode threadOrMonitorNode, boolean isThreadNode) { int count = 0; for (Enumeration e = threadOrMonitorNode.depthFirstEnumeration(); e.hasMoreElements();) { Object element = e.nextElement(); ThreadInfo mi = (ThreadInfo) (((DefaultMutableTreeNode) element).getUserObject()); if (mi.getName().startsWith("Thread")) { count++;/*ww w.j a v a 2 s. c o m*/ } } ThreadInfo mi = (ThreadInfo) threadOrMonitorNode.getUserObject(); if (ThreadDumpInfo.areALotOfWaiting(count)) { mi.setALotOfWaiting(true); } if (isThreadNode) { count--; } mi.setChildCount(count); if (count > 1) { mi.setName(mi.getName() + ": " + count + " Blocked threads"); } else if (count == 1) { mi.setName(mi.getName() + ": " + count + " Blocked thread"); } // Recurse for (Enumeration e = threadOrMonitorNode.children(); e.hasMoreElements();) { updateChildCount((DefaultMutableTreeNode) e.nextElement(), !isThreadNode); } }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java
/** * @return//w w w.j ava 2s . co m */ protected FormViewDef getViewDefFromSelection() { if (tree != null && tree.getSelectionModel() != null && tree.getSelectionModel().getSelectionPath() != null) { TreePath path = tree.getSelectionModel().getSelectionPath(); for (int i = 0; i < path.getPathCount(); i++) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getPathComponent(i); if (node.getUserObject() instanceof FormViewDef) { return (FormViewDef) node.getUserObject(); } } } return null; }
From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * /*from w ww.j a v a2s. c o m*/ */ private void editContainer() { if (checkForChanges()) { DefaultMutableTreeNode node = getSelectedTreeNode(); if (node != null && node.getUserObject() instanceof Container) { Container container = (Container) node.getUserObject(); createOrEditContainer(container, null); model.nodeChanged(node); } } }
From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * /*from w w w .ja v a 2 s.co m*/ */ private void viewContainer() { DefaultMutableTreeNode node = getSelectedTreeNode(); if (node != null && node.getUserObject() instanceof Container) { String title = DBTableIdMgr.getInstance().getTitleForId(Container.getClassTableId()); ViewBasedDisplayDialog dlg = new ViewBasedDisplayDialog((Frame) UIRegistry.getTopWindow(), null, "Container", null, title, "Close", null, null, false, MultiView.HIDE_SAVE_BTN); dlg.setWhichBtns(CustomDialog.OK_BTN); dlg.getMultiView().getCurrentViewAsFormViewObj().setDataObj(node.getUserObject()); UIHelper.centerAndShow(dlg); } }
From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * //from ww w. j a v a 2 s . c o m */ private void editColObj() { if (checkForChanges()) { DefaultMutableTreeNode node = getSelectedTreeNode(); if (node != null && node.getUserObject() instanceof CollectionObject) { CollectionObject co = editColObj((CollectionObject) node.getUserObject()); if (co != null) { node.setUserObject(co); } } } }
From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * @param doAssociated//ww w . j av a 2 s . c o m */ private void viewColObj() { Object dataObj = null; DefaultMutableTreeNode node = getSelectedTreeNode(); if (node != null) { if (node.getUserObject() instanceof Container) { Container cn = (Container) node.getUserObject(); dataObj = cn.getCollectionObject(); } else if (node.getUserObject() instanceof CollectionObject) { dataObj = node.getUserObject(); } } if (dataObj != null) { String title = DBTableIdMgr.getInstance().getTitleForId(CollectionObject.getClassTableId()); ViewBasedDisplayDialog dlg = new ViewBasedDisplayDialog((Frame) UIRegistry.getTopWindow(), null, "CollectionObject", null, title, "Close", null, null, false, MultiView.HIDE_SAVE_BTN); dlg.setWhichBtns(CustomDialog.OK_BTN); dlg.getMultiView().getCurrentViewAsFormViewObj().setDataObj(dataObj); UIHelper.centerAndShow(dlg); } }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java
/** * /*from w ww.j a v a2 s .co m*/ */ protected void treeSelected() { TreePath treePath = tree.getSelectionModel().getSelectionPath(); if (treePath == null) { selectedRow = null; selectedCell = null; return; } DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent(); Object nodeObj = node.getUserObject(); if (nodeObj instanceof FormRow) { if (nodeObj == selectedRow) { return; } selectedRow = (FormRow) nodeObj; selectedCell = null; } else if (nodeObj instanceof FormCell) { if (nodeObj == selectedCell) { return; } selectedCell = (FormCell) nodeObj; DefaultMutableTreeNode rowNode = (DefaultMutableTreeNode) node.getParent(); selectedRow = (FormRow) rowNode.getUserObject(); } else { selectedRow = null; selectedCell = null; } if (treePath != null) { updateUIControls(); if (treePath.getPathCount() == 1) { panel.loadView("ViewDefProps", null); //$NON-NLS-1$ panel.setData(selectedViewDef); return; } if (selectedCell != null) { int col = 0; for (FormCellIFace fc : selectedRow.getCells()) { if (fc == nodeObj) { break; } col++; } showPropertiesPanel((FormCell) nodeObj, formViewDef.getClassName(), (formViewDef.getRows().size() * 2) - 1, formViewDef.getRowDefItem().getNumItems(), selectedRow.getRowNumber(), (selectedRow.getCells().size() * 2) - 1, formViewDef.getColumnDefItem().getNumItems(), col); } } }