List of usage examples for javax.swing.tree DefaultMutableTreeNode setUserObject
public void setUserObject(Object userObject)
userObject
. From source file:com.yosanai.java.aws.console.panel.InstancesPanel.java
/** Creates new form InstancesPanel */ public InstancesPanel() { initComponents();// w w w .ja v a 2s . co m DefaultTreeModel treeModel = (DefaultTreeModel) trInstances.getModel(); DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) treeModel.getRoot(); rootNode.setAllowsChildren(true); rootNode.setUserObject("Instances"); instancesTableModel = (DefaultTableModel) tblInstances.getModel(); instanceTableModel = new ObjectEditorTableModel(); instanceTableModel.setEditable(false); instanceTableModel.setExpandAllProperties(true); trInstances.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); }
From source file:gdt.jgui.entity.JEntityStructurePanel.java
private void addChildren(DefaultMutableTreeNode parentNode) { try {//from w w w.ja v a2s . c o m String locator$ = (String) parentNode.getUserObject(); Properties locator = Locator.toProperties(locator$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); Entigrator entigrator = console.getEntigrator(entihome$); Sack parent = entigrator.getEntityAtKey(entityKey$); String[] sa = entigrator.ent_listComponents(parent); if (sa != null) { Sack child; String childLocator$; DefaultMutableTreeNode childNode; for (String aSa : sa) { child = entigrator.getEntityAtKey(aSa); childLocator$ = EntityHandler.getEntityLocator(entigrator, child); childNode = new DefaultMutableTreeNode(); childNode.setUserObject(childLocator$); parentNode.add(childNode); addChildren(childNode); } } } catch (Exception e) { Logger.getLogger(JEntityStructurePanel.class.getName()).severe(e.toString()); } }
From source file:gdt.jgui.entity.JEntityStructurePanel.java
/** * Create the context.// w ww.j a va 2s.c o m * @param console the main console. * @param locator$ the locator. * @return the structure panel. */ @Override public JContext instantiate(JMainConsole console, String locator$) { this.console = console; this.locator$ = locator$; Properties locator = Locator.toProperties(locator$); entihome$ = locator.getProperty(Entigrator.ENTIHOME); entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); entityLabel$ = locator.getProperty(EntityHandler.ENTITY_LABEL); DefaultMutableTreeNode root = new DefaultMutableTreeNode(entityLabel$); locator = new Properties(); locator.setProperty(Locator.LOCATOR_TITLE, STRUCTURE); String icon$ = Support.readHandlerIcon(null, getClass(), "tree.png"); locator.setProperty(Locator.LOCATOR_ICON, icon$); root.setUserObject(Locator.toString(locator)); DefaultMutableTreeNode parentNode = new DefaultMutableTreeNode(entityLabel$); root.add(parentNode); Entigrator entigrator = console.getEntigrator(entihome$); Sack parent = entigrator.getEntityAtKey(entityKey$); String parentLocator$ = EntityHandler.getEntityLocator(entigrator, parent); parentNode.setUserObject(parentLocator$); addChildren(parentNode); tree = new JTree(root); tree.addTreeSelectionListener(new SelectionListener()); tree.setShowsRootHandles(true); tree.setCellRenderer(new NodeRenderer()); tree.addMouseListener(new MousePopupListener()); scrollPane.getViewport().add(tree); expandTree(tree, true); return this; }
From source file:net.sf.jhylafax.addressbook.AddressBook.java
public AddressBook() { ContactModelFactory cmf = Pim.getContactModelFactory(); JHylaFAX.initializeToolkit();/* w ww. ja va 2s .c o m*/ initialize(); ContactDatabase contactDatabase = Pim.getContactDBFactory().createContactDatabase(); // initialize tree content DefaultMutableTreeNode localAddressBookTreeNode = new DefaultMutableTreeNode(); localAddressBook = new ContactCollection(contactDatabase, i18n.tr("Local Address Book")); localAddressBookTreeNode.setUserObject(localAddressBook); rootNode.add(localAddressBookTreeNode); addressBookTree.expandPath(new TreePath(rootNode)); addressBookTree.setSelectionRow(0); updateActions(); }
From source file:gdt.jgui.entity.JEntityDigestDisplay.java
private void instantiateComponentNode(DefaultMutableTreeNode facetComponentNode) { try {//from w w w . j ava 2 s. 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 setSubnodesNumbers(DefaultMutableTreeNode node) { try {/* w w w .j a va 2 s . c o 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:gdt.jgui.entity.JEntityDigestDisplay.java
/** * Create the context./* www .j a v a 2 s . c o m*/ * @param console the main console. * @param locator$ the locator. * @return the digest display. */ @Override public JContext instantiate(JMainConsole console, String locator$) { try { this.console = console; this.locator$ = locator$; Properties locator = Locator.toProperties(locator$); entihome$ = locator.getProperty(Entigrator.ENTIHOME); entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); entityLabel$ = locator.getProperty(EntityHandler.ENTITY_LABEL); String compressedSelection$ = locator.getProperty(SELECTION); if (compressedSelection$ != null) { try { byte[] ba = Base64.decodeBase64(compressedSelection$); selection$ = new String(ba, "UTF-8"); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } Entigrator entigrator = console.getEntigrator(entihome$); DefaultMutableTreeNode root = new DefaultMutableTreeNode(entityLabel$); locator = new Properties(); locator.setProperty(Locator.LOCATOR_TITLE, DIGEST); String icon$ = Support.readHandlerIcon(null, getClass(), "digest.png"); locator.setProperty(Locator.LOCATOR_ICON, icon$); locator.setProperty(NODE_TYPE, NODE_TYPE_ROOT); root.setUserObject(Locator.toString(locator)); DefaultMutableTreeNode parentNode = new DefaultMutableTreeNode(entityLabel$); root.add(parentNode); Sack parent = entigrator.getEntityAtKey(entityKey$); String parentLocator$ = EntityHandler.getEntityLocator(entigrator, parent); parentLocator$ = Locator.append(parentLocator$, NODE_TYPE, NODE_TYPE_PARENT); parentNode.setUserObject(parentLocator$); tree = new JTree(root); tree.addTreeSelectionListener(new SelectionListener()); tree.setShowsRootHandles(true); tree.setCellRenderer(new NodeRenderer()); tree.addMouseListener(new MousePopupListener()); scrollPane.getViewport().add(tree); facets = listFacetOpenItems(); DefaultMutableTreeNode[] na = getFacetOpenItems(); if (na != null) for (DefaultMutableTreeNode n : na) parentNode.add(n); expandTree(tree, true); select(); } catch (Exception e) { Logger.getLogger(getClass().getName()).severe(e.toString()); } return this; }
From source file:fr.jmmc.jmcs.logging.LogbackGui.java
/** * Generate the tree from the current edited list of Loggers *///from w w w. j a va 2 s . c om private void generateTree() { visitJulLoggers(); final GenericJTree<Logger> treeLoggers = getTreeLoggers(); final LoggerContext loggerContext = _rootLogger.getLoggerContext(); final DefaultMutableTreeNode rootNode = treeLoggers.getRootNode(); // remove complete hierarchy: rootNode.removeAllChildren(); // update the root node with the root logger (Logger[ROOT]): rootNode.setUserObject(_rootLogger); int pos; String path; DefaultMutableTreeNode parentNode; for (Logger logger : loggerContext.getLoggerList()) { // skip root logger if (logger != _rootLogger) { pos = logger.getName().lastIndexOf('.'); if (pos == -1) { // no path path = null; parentNode = null; } else { path = logger.getName().substring(0, pos); parentNode = treeLoggers.findTreeNode(loggerContext.getLogger(path)); } if (parentNode == null) { parentNode = rootNode; } if (parentNode != null) { treeLoggers.addNode(parentNode, logger); } } } // fire node structure changed : treeLoggers.fireNodeChanged(rootNode); // select root node treeLoggers.selectPath(new TreePath(rootNode.getPath())); }
From source file:gdt.jgui.entity.JEntityDigestDisplay.java
private void instantiateFacetNode(DefaultMutableTreeNode facetNode) { try {/*from ww w . j ava 2 s. c o m*/ 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:gdt.jgui.entity.index.JIndexPanel.java
private DefaultMutableTreeNode instantiateNode(Sack index, String nodeKey$) { try {/*from ww w. java 2s . c o m*/ // System.out.println("IndexPanel:instantiateNode:"+nodeKey$); String nodeLocator$ = index.getElementItemAt("index.jlocator", nodeKey$); if (nodeLocator$ == null) return null; // System.out.println("IndexPanel:instantiateNode:locator="+nodeLocator$); DefaultMutableTreeNode node = new DefaultMutableTreeNode(); node.setUserObject(nodeLocator$); Properties locator = Locator.toProperties(nodeLocator$); if (!NODE_TYPE_GROUP.equals(locator.getProperty(NODE_TYPE))) return node; String[] sa = listOrderedGroupMembers(index, nodeKey$); if (sa == null || sa.length < 1) { System.out.println("IndexPanel:instantiateNode:no member in group=" + nodeKey$); return node; } DefaultMutableTreeNode member; // System.out.println("IndexPanel:instantiateNode:members="+sa.length); for (String aSa : sa) { //nodeLocator$=index.getElementItemAt("index.jlocator", aSa); member = instantiateNode(index, aSa); if (member != null) node.add(member); } return node; } catch (Exception e) { LOGGER.severe(e.toString()); } return null; }