List of usage examples for javax.swing.tree DefaultMutableTreeNode getUserObject
public Object getUserObject()
From source file:gdt.jgui.entity.JEntityDigestDisplay.java
private void instantiateComponentNode(DefaultMutableTreeNode facetComponentNode) { try {/*w ww . j a v a 2s .c o m*/ String facetComponentLocator$ = (String) facetComponentNode.getUserObject(); Properties locator = Locator.toProperties(facetComponentLocator$); Entigrator entigrator = console.getEntigrator(entihome$); String facetClass$ = locator.getProperty(BaseHandler.HANDLER_CLASS); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); JFacetOpenItem facetOpenItem = (JFacetOpenItem) JConsoleHandler.getHandlerInstance(entigrator, facetClass$); // System.out.println("EntityDigestDisplay:instantiateComponentNode:facetOpenItem="+facetOpenItem.getClass().getName()); String facetOpenItemLocator$ = facetOpenItem.getLocator(); facetOpenItemLocator$ = Locator.append(facetComponentLocator$, Entigrator.ENTIHOME, entihome$); facetOpenItemLocator$ = Locator.append(facetComponentLocator$, EntityHandler.ENTITY_KEY, entityKey$); facetOpenItem.instantiate(console, facetOpenItemLocator$); DefaultMutableTreeNode[] na = facetOpenItem.getDigest(); if (na == null) return; String nodeLocator$; for (DefaultMutableTreeNode aNa : na) { nodeLocator$ = (String) aNa.getUserObject(); nodeLocator$ = Locator.append(nodeLocator$, NODE_NUMBER, String.valueOf(nodeNumber++)); nodeLocator$ = Locator.append(nodeLocator$, COMPONENT_KEY, entityKey$); aNa.setUserObject(nodeLocator$); facetComponentNode.add(aNa); setSubnodesNumbers(aNa); } } catch (Exception e) { Logger.getLogger(getClass().getName()).severe(e.toString()); } }
From source file:gdt.jgui.entity.JEntityDigestDisplay.java
private void instantiateFacetNode(DefaultMutableTreeNode facetNode) { try {/* w w w .j a v a2s . com*/ String facetNodeLocator$ = (String) facetNode.getUserObject(); Properties locator = Locator.toProperties(facetNodeLocator$); Entigrator entigrator = console.getEntigrator(entihome$); String facetClass$ = locator.getProperty(BaseHandler.HANDLER_CLASS); // System.out.println("EntityDigestDisplay:instantiateFacetNode:facet class="+facetClass$); JFacetOpenItem facetOpenItem = (JFacetOpenItem) JConsoleHandler.getHandlerInstance(entigrator, facetClass$); FacetHandler facetHandler = facetOpenItem.getFacetHandler(); // System.out.println("EntityDigestDisplay:instantiateFacetNode:facet handler="+facetHandler.getClassName()); Sack entity = entigrator.getEntityAtKey(entityKey$); String entityLocator$ = EntityHandler.getEntityLocator(entigrator, entity); // System.out.println("EntityDigestDisplay:instantiateFacetNode:entity locator="+entityLocator$); DefaultMutableTreeNode facetComponentNode; if (facetHandler.isApplied(entigrator, entityLocator$)) { // System.out.println("EntityDigestDisplay:instantiateFacetNode:entity locator="+entityLocator$); entityLocator$ = Locator.append(entityLocator$, Locator.LOCATOR_TYPE, LOCATOR_FACET_COMPONENT); entityLocator$ = Locator.append(entityLocator$, BaseHandler.HANDLER_CLASS, facetClass$); entityLocator$ = Locator.append(entityLocator$, NODE_TYPE, NODE_TYPE_FACET_OWNER); entityLocator$ = Locator.append(entityLocator$, NODE_NUMBER, String.valueOf(nodeNumber++)); facetComponentNode = new DefaultMutableTreeNode(); facetComponentNode.setUserObject(entityLocator$); instantiateComponentNode(facetComponentNode); facetNode.add(facetComponentNode); } String[] sa = entigrator.ent_listComponents(entity); if (sa != null) { Sack component; for (String aSa : sa) { component = entigrator.getEntityAtKey(aSa); if (component == null) continue; entityLocator$ = EntityHandler.getEntityLocator(entigrator, component); if (facetHandler.isApplied(entigrator, entityLocator$)) { entityLocator$ = Locator.append(entityLocator$, Locator.LOCATOR_TYPE, LOCATOR_FACET_COMPONENT); entityLocator$ = Locator.append(entityLocator$, BaseHandler.HANDLER_CLASS, facetClass$); facetComponentNode = new DefaultMutableTreeNode(); facetComponentNode.setUserObject(entityLocator$); instantiateComponentNode(facetComponentNode); facetNode.add(facetComponentNode); } } } } catch (Exception e) { Logger.getLogger(getClass().getName()).severe(e.toString()); } }
From source file:com.ssn.listener.SSNHiveAlbumSelectionListner.java
@Override public void valueChanged(TreeSelectionEvent e) { iT = 0;//from www. j a v a 2 s. c om dT = 0; DefaultMutableTreeNode node = treeHelper.getTreeNode(e.getPath()); List hiveFiles = new ArrayList(); if (this.form.getHiveTree() != null) { this.form.getHiveTree().clearSelection(); } this.form.setCursor(new Cursor(Cursor.WAIT_CURSOR)); SSNFileNode fnode = null; try { if (((SSNIconData) node.getUserObject()).getObject() instanceof SSNFileNode) { fnode = (SSNFileNode) ((SSNIconData) node.getUserObject()).getObject(); } } catch (ClassCastException ee) { logger.error(ee); this.form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } getAlbumMedia(form.getHomeModel().getLoggedInUserAccessToken(), 1, fileTree.hiveAlbumMap.get(fnode.getFile().getName())); /** * ******* * */ if (fnode != null) { if (fileTree.m_display.getText() != null && !fileTree.m_display.getText().equals("viewAllAlbums") && !fileTree.m_display.getText().equals("instagramMedia") && !fileTree.m_display.getText().equals("tagUnTaggedMedia")) { fileTree.m_display.setText(fnode.getFile().getAbsolutePath()); } if (fnode.getFile().isDirectory()) { this.fileTree.setSelectedFolder(fnode.getFile().getName()); getSSNMediaFolderProperties(fnode.getFile().getPath()); File[] file = fnode.getFile().listFiles(); for (File f : file) { if (f.isFile()) { hiveFiles.add(f.getName()); } else { } } } if (hiveFiles != null && hiveFiles.size() > 0) { createCompontents(fnode.getFile().getAbsolutePath(), form, true); } else { createCompontents(fnode.getFile().getAbsolutePath(), form, false); } } else { SSNHelper.toggleDeleteAndShareImages(false, form); String path = SSNHelper.getSsnHiveDirPath(); path = SSNHelper.getSsnTempDirPath(); form.getFileNamesToBeDeleted().clear(); getSSNMediaFolderProperties(path); if (fileTree.m_display.getText() != null && !fileTree.m_display.getText().equals("viewAllAlbums") && !fileTree.m_display.getText().equals("instagramMedia") && !fileTree.m_display.getText().equals("tagUnTaggedMedia")) { fileTree.m_display.setText(path); } getForm().ssnFileExplorer.m_tree.setSelectionRow(1); long size = FileUtils.sizeOfDirectory(new File(path)); if (size > 0) { File file1 = new File(path); if (fileTree.m_display.getText() != null && !fileTree.m_display.getText().equals("viewAllAlbums") && !fileTree.m_display.getText().equals("instagramMedia") && !fileTree.m_display.getText().equals("tagUnTaggedMedia")) { fileTree.m_display.setText(file1.getAbsolutePath()); } //just copied from above if block if (file1.isDirectory()) { this.form.setCurrentSelectedFile(null); fileTree.setSelectedFolder(file1.getName()); File[] file = file1.listFiles(); for (File f : file) { if (f.isFile()) { hiveFiles.add(f.getName()); } else { } } } if (hiveFiles != null && hiveFiles.size() > 0) { createCompontents(file1.getAbsolutePath(), form, true); } else { createCompontents(file1.getAbsolutePath(), form, false); } } else { // show welcome screen addWelcomeIcons(); } this.form.getSsnHomeCenterMainPanel().revalidate(); this.form.getSsnHomeCenterMainPanel().repaint(); this.form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } this.form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); }
From source file:gdt.jgui.entity.JEntityDigestDisplay.java
private void setSubnodesNumbers(DefaultMutableTreeNode node) { try {//ww w . j a v a 2s. co m Enumeration en = node.preorderEnumeration(); DefaultMutableTreeNode child; String locator$; while (en.hasMoreElements()) { child = (DefaultMutableTreeNode) en.nextElement(); locator$ = (String) child.getUserObject(); locator$ = Locator.append(locator$, NODE_NUMBER, String.valueOf(nodeNumber++)); child.setUserObject(locator$); } } catch (Exception e) { Logger.getLogger(getClass().getName()).severe(e.toString()); } }
From source file:net.sf.jhylafax.addressbook.AddressBook.java
public ContactCollection getSelectedContactCollection() { DefaultMutableTreeNode node = (DefaultMutableTreeNode) addressBookTree.getSelectionPath() .getLastPathComponent();/*from w ww .ja v a 2 s . co m*/ return (ContactCollection) node.getUserObject(); }
From source file:com.jaspersoft.ireport.designer.data.fieldsproviders.BeanInspectorPanel.java
private void jTree1MouseClicked1(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTree1MouseClicked1 if (evt.getClickCount() == 2 && evt.getButton() == MouseEvent.BUTTON1) { DefaultMutableTreeNode tn = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); if (tn.getChildCount() > 0) return; /*if (!jTree1.isCollapsed( jTree1.getSelectionPath() )) {/*w w w. ja v a 2 s .com*/ jTree1.collapsePath( jTree1.getSelectionPath() ); return; } * */ if (tn.getUserObject() instanceof TreeJRField) { TreeJRField jrf = (TreeJRField) tn.getUserObject(); if (!jrf.getObj().isPrimitive() && !jrf.getObj().getName().startsWith("java.lang.")) { exploreBean(tn, jrf.getObj().getName(), isPathOnDescription() ? Misc.nvl(jrf.getField().getDescription(), "") : Misc.nvl(jrf.getField().getName(), "")); } } } }
From source file:fxts.stations.ui.help.ContentTree.java
/** * Returns node containing the specified url. * * @param aParent parent node//from w ww . j a va 2 s .co m * @param aUrl specified url * * @return node containing specified url */ public DefaultMutableTreeNode findNodeByUrl(DefaultMutableTreeNode aParent, String aUrl) { DefaultMutableTreeNode node; DefaultMutableTreeNode result; NodeInfo info; if (!aParent.getAllowsChildren()) { return null; } for (Enumeration enumeration = aParent.children(); enumeration.hasMoreElements();) { node = (DefaultMutableTreeNode) enumeration.nextElement(); info = (NodeInfo) node.getUserObject(); if (aUrl.equals(info.getUrl())) { return node; } else { result = findNodeByUrl(node, aUrl); if (result != null) { return result; } } } return null; }
From source file:de.erdesignerng.visual.common.OutlineComponent.java
/** * Set the currently selected item./*from www .ja v a2 s.c om*/ * * @param aSelection the selection */ public void setSelectedItem(ModelItem aSelection) { TreePath theSelected = tree.getSelectionPath(); if (theSelected != null) { DefaultMutableTreeNode theNode = (DefaultMutableTreeNode) theSelected.getLastPathComponent(); if (theNode.getUserObject().equals(aSelection)) { // The object is already selected, so keep the selection return; } } DefaultMutableTreeNode theNode = userObjectMap.get(aSelection); if (theNode != null) { TreePath thePath = new TreePath(theNode.getPath()); tree.setSelectionPath(thePath); tree.scrollPathToVisible(thePath); } else { tree.clearSelection(); } tree.invalidate(); tree.repaint(); }
From source file:de.erdesignerng.visual.common.OutlineComponent.java
/** * Create the PopupMenu actions correlating to a specific tree node. * * @param aNode - the node/* w w w .j a v a 2 s. c om*/ * @param aMenu - the menu to add the actions to * @param aRecursive - recursive */ private void initializeActionsFor(final DefaultMutableTreeNode aNode, JPopupMenu aMenu, boolean aRecursive) { Object theUserObject = aNode.getUserObject(); if (!aRecursive) { JMenuItem theExpandAllItem = new JMenuItem(); theExpandAllItem.setText(getResourceHelper().getFormattedText(ERDesignerBundle.EXPANDALL)); theExpandAllItem .addActionListener(e -> expandOrCollapseAllChildrenOfNode(new TreePath(aNode.getPath()), true)); aMenu.add(theExpandAllItem); JMenuItem theCollapseAllItem = new JMenuItem(); theCollapseAllItem.setText(getResourceHelper().getFormattedText(ERDesignerBundle.COLLAPSEALL)); theCollapseAllItem.addActionListener( e -> expandOrCollapseAllChildrenOfNode(new TreePath(aNode.getPath()), false)); aMenu.add(theCollapseAllItem); aMenu.addSeparator(); } List<ModelItem> theItemList = new ArrayList<>(); if (theUserObject instanceof ModelItem) { theItemList.add((ModelItem) theUserObject); ContextMenuFactory.addActionsToMenu(ERDesignerComponent.getDefault().getEditor(), aMenu, theItemList); } if (aNode.getParent() != null) { initializeActionsFor((DefaultMutableTreeNode) aNode.getParent(), aMenu, true); } }
From source file:uk.co.markfrimston.tasktree.TaskTree.java
protected void addChildElementsFromTasks(Document doc, Element parent, DefaultMutableTreeNode treeNode, int indent) { for (int i = 0; i < treeNode.getChildCount(); i++) { DefaultMutableTreeNode treeChild = (DefaultMutableTreeNode) treeNode.getChildAt(i); String indentText = "\n"; for (int j = 0; j < indent + 1; j++) { indentText += "\t"; }// ww w . j a va 2s . c o m parent.appendChild(doc.createTextNode(indentText)); Element childEl = doc.createElement("task"); childEl.setAttribute("label", (String) treeChild.getUserObject()); parent.appendChild(childEl); addChildElementsFromTasks(doc, childEl, treeChild, indent + 1); } if (treeNode.getChildCount() > 0) { String indentText = "\n"; for (int i = 0; i < indent; i++) { indentText += "\t"; } parent.appendChild(doc.createTextNode(indentText)); } }