List of usage examples for javax.swing.tree DefaultTreeModel DefaultTreeModel
@ConstructorProperties({ "root" }) public DefaultTreeModel(TreeNode root)
From source file:org.languagetool.gui.ConfigurationDialog.java
@NotNull private DefaultTreeModel getTreeModel(DefaultMutableTreeNode rootNode) { DefaultTreeModel treeModel = new DefaultTreeModel(rootNode); treeModel.addTreeModelListener(new TreeModelListener() { @Override//ww w. j a v a 2s. c om public void treeNodesChanged(TreeModelEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getTreePath().getLastPathComponent(); int index = e.getChildIndices()[0]; node = (DefaultMutableTreeNode) node.getChildAt(index); if (node instanceof RuleNode) { RuleNode o = (RuleNode) node; if (o.getRule().isDefaultOff() || o.getRule().getCategory().isDefaultOff()) { if (o.isEnabled()) { config.getEnabledRuleIds().add(o.getRule().getId()); config.getDisabledRuleIds().remove(o.getRule().getId()); } else { config.getEnabledRuleIds().remove(o.getRule().getId()); config.getDisabledRuleIds().add(o.getRule().getId()); } } else { if (o.isEnabled()) { config.getDisabledRuleIds().remove(o.getRule().getId()); } else { config.getDisabledRuleIds().add(o.getRule().getId()); } } } if (node instanceof CategoryNode) { CategoryNode o = (CategoryNode) node; if (o.getCategory().isDefaultOff()) { if (o.isEnabled()) { config.getDisabledCategoryNames().remove(o.getCategory().getName()); config.getEnabledCategoryNames().add(o.getCategory().getName()); } else { config.getDisabledCategoryNames().add(o.getCategory().getName()); config.getEnabledCategoryNames().remove(o.getCategory().getName()); } } else { if (o.isEnabled()) { config.getDisabledCategoryNames().remove(o.getCategory().getName()); } else { config.getDisabledCategoryNames().add(o.getCategory().getName()); } } } } @Override public void treeNodesInserted(TreeModelEvent e) { } @Override public void treeNodesRemoved(TreeModelEvent e) { } @Override public void treeStructureChanged(TreeModelEvent e) { } }); return treeModel; }
From source file:org.lnicholls.galleon.gui.MainFrame.java
public DefaultTreeModel getAppsModel() { DefaultMutableTreeNode root = new DefaultMutableTreeNode("ROOT"); if (Galleon.getApps() != null) { Iterator iterator = Galleon.getApps().iterator(); while (iterator.hasNext()) { AppContext app = (AppContext) iterator.next(); root.add(new DefaultMutableTreeNode(getAppNode(app))); }//from w w w . j a v a 2 s . c o m } return new DefaultTreeModel(root); }
From source file:org.mbari.aved.ui.classifier.knowledgebase.ConceptTree.java
/** * Loads the JTree model using the specified <code>Concept</code> as the root * node./*from w ww .ja v a2 s . c o m*/ * * @param rootConcept Description of the Parameter */ public void loadModel(Concept rootConcept) { if (rootConcept == null) { setModel(null); } else { TreeConcept treeConcept = new TreeConcept(rootConcept); DefaultMutableTreeNode rootNode = new SortedTreeNode(treeConcept); // addChildrenNodes( rootNode, rootConcept ); // adding a boolean value as a child to this concept indicates that // the node has children that will be loaded dynamically, start off by // assuming this node has children, the rest will be taken care of in // the ConceptTreeLazyLoader rootNode.add(new DefaultMutableTreeNode(Boolean.TRUE)); treeConcept.lazyExpand(rootNode); DefaultTreeModel model = new DefaultTreeModel(rootNode); setModel(model); addTreeExpansionListener(new ConceptTreeLazyLoader(model)); } }
From source file:org.objectpocket.viewer.Viewer.java
private void updateTree() { DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("OBJECT STORES"); DefaultTreeModel treeModel = new DefaultTreeModel(rootNode); for (ObjectPocketImpl objectPocketImpl : objectPocketList) { DefaultMutableTreeNode objectPocketNode = new DefaultMutableTreeNode(objectPocketImpl.getSource()); rootNode.add(objectPocketNode);/*from w w w . j ava 2 s .c o m*/ Set<String> availableTypes = objectPocketImpl.getAvailableTypes(); for (String type : availableTypes) { DefaultMutableTreeNode typeNode = new DefaultMutableTreeNode(type); objectPocketNode.add(typeNode); } } classTree.setModel(treeModel); }
From source file:org.olivier.ihm.FramePUMLCleanerControler.java
/** * Analyser le fichier PUML et initialiser le filtre * * @param jTextAreaFichier Le contenu du fichier PUML * @param jTreeFiltre Le filtre initialiser *//*from ww w . j av a 2s .c o m*/ private void analyserFichier(JTextArea jTextAreaFichier, JTree jTreeFiltre) { lines = jTextAreaFichier.getText().split("[\\r\\n]+"); final DefaultMutableTreeNode newFilter = initaliserNodes(); // parcours de chaque ligne du fichier pour analyse for (String line : lines) { if (line.contains(">")) { break; } else { String categ = ""; String noeud = null; // recherche de la catgorie for (String categorie : categories) { if (line.contains(categorie)) { categ = categorie; noeud = line.replaceFirst(categorie, "").replaceAll(" ", ""); // ajout du noeud dans la bonne catgorie de l'arbre for (int i = 0; i < newFilter.getChildCount(); i++) { final DefaultMutableTreeNode dmtr = (DefaultMutableTreeNode) newFilter.getChildAt(i); if (dmtr.toString().equals(categ)) { final DefaultMutableTreeNode node = new DefaultMutableTreeNode(new NodeInfo(noeud)); dmtr.add(node); } } break; } } } } jTreeFiltre.setModel(new DefaultTreeModel(newFilter)); jTextAreaFichier.requestFocus(); }
From source file:org.openconcerto.erp.panel.ITreeSelection.java
private void initTree() { if (this.element == null) { this.rootNode = new ITreeSelectionNode(null); } else {//from www .j av a 2s . co m SQLRow row = this.element.getTable().getRow(element.getTable().getUndefinedID()); this.rootNode = new ITreeSelectionNode(row); } this.model = new DefaultTreeModel(this.rootNode); this.setModel(this.model); loadTree(); this.expandRow(0); setTableListener(); this.addMouseListener(this); }
From source file:org.openehealth.coms.cc.consent_applet.applet.ConsentApplet.java
/** * Requests the root of the organisations tree and it's children */// w w w . jav a2s .com private void requestTreeRoot() { try { URL url = new URL(strRelURL + "/" + privilegedServlet + "CreateConsentServiceServlet?type=treeroot"); URLConnection conn = url.openConnection(); conn.setRequestProperty("cookie", strCookie); conn.setDoInput(true); InputStream is = conn.getInputStream(); StringWriter writer = new StringWriter(); IOUtils.copy(new InputStreamReader(is, "UTF8"), writer); String s = writer.toString(); is.close(); JSONObject jso = new JSONObject(s); OIDObject root = new OIDObject(jso.getString("identifier"), jso.getString("name"), jso.getBoolean("isActive")); root.setHasChildren(jso.getBoolean("hasChildren")); LazyOIDTreeNode rootNode = new LazyOIDTreeNode(root); JSONArray jsa = jso.getJSONArray("children"); for (int i = 0; i < jsa.length(); i++) { JSONObject jsoo = (JSONObject) jsa.get(i); OIDObject oi = new OIDObject(jsoo.getString("identifier"), jsoo.getString("name"), jsoo.getBoolean("isActive")); oi.setHasChildren(jsoo.getBoolean("hasChildren")); LazyOIDTreeNode oin = new LazyOIDTreeNode(oi); rootNode.add(oin); } oidTreeModel = new DefaultTreeModel(rootNode); cap.setOIDTree(oidTreeModel, null, new OIDTreeSelectionListener()); cap.mainPanel.mp.cp.tp.orgaTree.collapseRow(1); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.openehealth.coms.cc.consent_applet.applet.ConsentApplet.java
/** * Requests all TreeNodes containing the given String in their Name-attribute * /* w ww . ja v a2 s . co m*/ * @param searchString */ private void requestSearchTree(String searchString) { if (searchString.trim().equalsIgnoreCase("")) { requestTreeRoot(); } else { try { String toBeURL = strRelURL + "/" + privilegedServlet + "CreateConsentServiceServlet?type=searchtree&searchstring=" + searchString; URL url = new URL(encodeString(toBeURL)); URLConnection conn = url.openConnection(); conn.setRequestProperty("cookie", strCookie); conn.setDoInput(true); InputStream is = conn.getInputStream(); StringWriter writer = new StringWriter(); IOUtils.copy(new InputStreamReader(is, "UTF8"), writer); String s = writer.toString(); is.close(); JSONObject jso = new JSONObject(s); OIDObject root = new OIDObject(jso.getString("identifier"), jso.getString("name"), jso.getBoolean("isActive")); root.setHasChildren(jso.getBoolean("hasChildren")); DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(root); reconstructTree(rootNode, jso); oidTreeModel = new DefaultTreeModel(rootNode); cap.setOIDTree(oidTreeModel, null, new OIDTreeSelectionListener()); int row = 0; while (row < cap.mainPanel.mp.cp.tp.orgaTree.getRowCount()) { cap.mainPanel.mp.cp.tp.orgaTree.expandRow(row); row++; } } catch (Exception e) { e.printStackTrace(); } } }
From source file:org.openehealth.coms.cc.web_frontend.consentcreator.service.ConsentCreatorService.java
/** * Returns a DefaultTreeModel containing leaf-Nodes containing the query * String in their names. /* w ww . j ava 2 s . c o m*/ * noch? * * @param query * @return */ public DefaultTreeModel getOIDTreeNodes(String query) { DefaultMutableTreeNode realRoot = (DefaultMutableTreeNode) getOIDTreeRoot(); DefaultMutableTreeNode searchRoot = (DefaultMutableTreeNode) getOIDTreeRoot().clone(); DefaultMutableTreeNode ret = consentCreatorUtilites.traverseTreeString(query.toLowerCase(), searchRoot, realRoot); return new DefaultTreeModel(searchRoot); }
From source file:org.openehealth.coms.cc.web_frontend.consentcreator.service.Shipper.java
/** * Retrieves the tree of organisations from the Provider and Organization * Registry Service./* www . j a va2 s. co m*/ * * FIXME Remove stub * * @return - null if no organisations could be obtained * @throws HL7Exception */ public DefaultTreeModel getTreeOrganisations() throws HL7Exception { OIDObject o = new OIDObject("1.2", "Organisationen", true); DefaultMutableTreeNode root = new DefaultMutableTreeNode(o); Vector<OIDObject> vOrg = getOrganisations(); if (vOrg == null) { throw new ServiceException( "Die bentigten Daten zur Darstellung der Organisationen konnten nicht abgerufen werden."); } for (int i = 0; i < vOrg.size(); i++) { consentCreatorUtilities.addNodeToModel(new DefaultMutableTreeNode(vOrg.elementAt(i)), root); } consentCreatorUtilities.sortTree(root); return new DefaultTreeModel(root); }