List of usage examples for javax.swing.tree DefaultTreeModel DefaultTreeModel
@ConstructorProperties({ "root" }) public DefaultTreeModel(TreeNode root)
From source file:de.quadrillenschule.azocamsyncd.gui.ExploreWifiSDPanel.java
public void updateTree() { Enumeration<TreePath> storeExpand = remotejTree .getExpandedDescendants(new TreePath(remotejTree.getModel().getRoot())); rootNode.removeAllChildren();/*w ww. ja v a2 s.com*/ createNodes(rootNode); if (dtm == null) { dtm = new DefaultTreeModel(rootNode); remotejTree.setModel(dtm); } dtm.nodeStructureChanged(rootNode); if (storeExpand != null) { while (storeExpand.hasMoreElements()) { TreePath t = storeExpand.nextElement(); remotejTree.expandPath(t); remotejTree.setSelectionPath(t); } } }
From source file:de.tor.tribes.ui.views.DSWorkbenchSelectionFrame.java
private void buildTree() { mRoot = new SelectionTreeRootNode("Auswahl"); if (treeMode) { //tree view //add all villages HashMap<Ally, AllyNode> allyNodes = new HashMap<>(); HashMap<Tribe, TribeNode> tribeNodes = new HashMap<>(); HashMap<Tribe, HashMap<Tag, TagNode>> tagNodes = new HashMap<>(); List<Village> used = new LinkedList<>(); for (Village v : treeData) { Tribe t = v.getTribe();/*from w w w . j a va 2s.c om*/ if (t == null) { t = Barbarians.getSingleton(); } Ally a = t.getAlly(); if (a == null) { a = NoAlly.getSingleton(); } AllyNode aNode = allyNodes.get(a); if (aNode == null) { //new ally aNode = new AllyNode(a); allyNodes.put(a, aNode); mRoot.add(aNode); } TribeNode tNode = tribeNodes.get(t); if (tNode == null) { //new tribe tNode = new TribeNode(t); tribeNodes.put(t, tNode); aNode.add(tNode); } boolean hasTag = false; for (Tag tag : TagManager.getSingleton().getTags(v)) { hasTag = true; HashMap<Tag, TagNode> nodes = tagNodes.get(t); if (nodes == null) { nodes = new HashMap<>(); tagNodes.put(t, nodes); } TagNode tagNode = nodes.get(tag); if (tagNode == null) { //new tribe tagNode = new TagNode(tag); nodes.put(tag, tagNode); tNode.add(tagNode); } tagNode.add(new VillageNode(v)); } if (!hasTag) { //only add directly if not added to any tag node tNode.add(new VillageNode(v)); } used.add(v); } } else { //simple view for (Village v : treeData) { mRoot.add(new VillageNode(v)); } } jSelectionTree.setModel(new DefaultTreeModel(mRoot)); }
From source file:ca.sqlpower.architect.swingui.enterprise.SecurityPanel.java
private void refreshTree() { tree.setModel(new DefaultTreeModel(rootNode)); usersNode.removeAllChildren();//w w w . j a va2s . c o m for (User user : securityWorkspace.getChildren(User.class)) { usersNode.add(new DefaultMutableTreeNode(user)); } groupsNode.removeAllChildren(); for (Group group : securityWorkspace.getChildren(Group.class)) { groupsNode.add(new DefaultMutableTreeNode(group)); } tree.expandPath(new TreePath(usersNode.getPath())); tree.expandPath(new TreePath(groupsNode.getPath())); }
From source file:edu.clemson.cs.nestbed.client.gui.ConfigManagerFrame.java
private void buildProgramTreeNodes() throws RemoteException { List<Program> programList; SortedTreeNode root;/*from ww w. j a v a 2 s.c o m*/ programList = programManager.getProgramList(project.getID()); root = new SortedTreeNode("root", new TreeComparator()); for (Program i : programList) { Map<String, SortedTreeNode> moduleMap; SortedTreeNode programNode; SortedTreeNode messagesNode; SortedTreeNode symbolsNode; List<ProgramMessageSymbol> programMsgSymbolList; List<ProgramSymbol> programSymbolList; programMsgSymbolList = progMsgSymManager.getProgramMessageSymbols(i.getID()); programNode = new SortedTreeNode(i, new TreeComparator()); messagesNode = new SortedTreeNode("Messages", new TreeComparator()); for (ProgramMessageSymbol j : programMsgSymbolList) { SortedTreeNode programMessageNode = new SortedTreeNode(j); messagesNode.add(programMessageNode); } programNode.add(messagesNode); symbolsNode = new SortedTreeNode("Symbols", new TreeComparator()); moduleMap = new HashMap<String, SortedTreeNode>(); programSymbolList = programSymbolManager.getProgramSymbols(i.getID()); for (ProgramSymbol j : programSymbolList) { SortedTreeNode moduleSymbolNode = moduleMap.get(j.getModule()); SortedTreeNode programSymbolNode = new SortedTreeNode(j); if (moduleSymbolNode == null) { String moduleName = j.getModule(); moduleSymbolNode = new SortedTreeNode(moduleName, new TreeComparator()); moduleMap.put(moduleName, moduleSymbolNode); } moduleSymbolNode.add(programSymbolNode); } for (SortedTreeNode j : moduleMap.values()) { symbolsNode.add(j); } programNode.add(symbolsNode); root.add(programNode); } programTree.setModel(new DefaultTreeModel(root)); }
From source file:org.jfree.chart.demo.SuperDemo.java
private TreeModel createTreeModel() { DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("JFreeChart"); defaultmutabletreenode.add(createAreaChartsNode()); defaultmutabletreenode.add(createBarChartsNode()); defaultmutabletreenode.add(createCombinedAxisChartsNode()); defaultmutabletreenode.add(createFinancialChartsNode()); defaultmutabletreenode.add(createGanttChartsNode()); defaultmutabletreenode.add(createLineChartsNode()); defaultmutabletreenode.add(createMeterChartsNode()); defaultmutabletreenode.add(createMultipleAxisChartsNode()); defaultmutabletreenode.add(createOverlaidChartsNode()); defaultmutabletreenode.add(createPieChartsNode()); defaultmutabletreenode.add(createStatisticalChartsNode()); defaultmutabletreenode.add(createTimeSeriesChartsNode()); defaultmutabletreenode.add(createXYChartsNode()); defaultmutabletreenode.add(createMiscellaneousChartsNode()); defaultmutabletreenode.add(createExperimentalNode()); return new DefaultTreeModel(defaultmutabletreenode); }
From source file:com.clough.android.adbv.view.MainFrame.java
private void refreshDatabase() { inputQuery = ""; invalidateInputOutput();/* w w w . ja v a 2s . co m*/ new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { try { Thread.sleep(100); } catch (InterruptedException ex) { } try { String tableNames = MainFrame.this.ioManager.getTableNames(); tableNameJSONArray = new JSONArray(tableNames); } catch (IOManagerException ex) { showDeviceDisconnectedDialog(); } return null; } @Override protected void done() { closeProgressDialog(); } }.execute(); showProgressDialog(true, 0, "Waiting for table list"); tableInfoTree.removeAll(); tableInfoTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); final DefaultMutableTreeNode databaseDMTN = new DefaultMutableTreeNode(databaseName); tableInfoTree.setModel(new DefaultTreeModel(databaseDMTN)); new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { try { Thread.sleep(100); } catch (InterruptedException ex) { } try { tables = new String[tableNameJSONArray.length()]; queries = new String[tableNameJSONArray.length()]; columns = new String[tableNameJSONArray.length()][]; columnInfos = new String[tableNameJSONArray.length()][][]; for (int i = 0; i < tableNameJSONArray.length(); i++) { tables[i] = tableNameJSONArray.getJSONObject(i).getString("name"); DefaultMutableTreeNode tableDMTN = new DefaultMutableTreeNode(tables[i]); databaseDMTN.add(tableDMTN); queries[i] = tableNameJSONArray.getJSONObject(i).getString("sql"); String tableColumnInfo = MainFrame.this.ioManager.getTableColumnInfo(tables[i]); JSONArray columnJSONArray = new JSONArray(tableColumnInfo); columns[i] = new String[columnJSONArray.length()]; columnInfos[i] = new String[columnJSONArray.length()][]; for (int j = 0; j < columnJSONArray.length(); j++) { JSONObject columnJSONObject = columnJSONArray.getJSONObject(j); columns[i][j] = columnJSONObject.getString("name"); columnInfos[i][j] = new String[4]; DefaultMutableTreeNode columnDMTN = new DefaultMutableTreeNode(columns[i][j]); columnInfos[i][j][0] = "Column ID : " + String.valueOf(columnJSONObject.getInt("cid")); columnDMTN.add(new DefaultMutableTreeNode(columnInfos[i][j][0])); columnInfos[i][j][1] = "Type : " + columnJSONObject.getString("type"); columnDMTN.add(new DefaultMutableTreeNode(columnInfos[i][j][1])); columnInfos[i][j][2] = "Def value : " + String.valueOf(columnJSONObject.getString("dflt_value")); columnDMTN.add(new DefaultMutableTreeNode(columnInfos[i][j][2])); columnInfos[i][j][3] = "Not NULL : " + String.valueOf((columnJSONObject.getInt("notnull") == 1)); columnDMTN.add(new DefaultMutableTreeNode(columnInfos[i][j][3])); tableDMTN.add(columnDMTN); } databaseDMTN.add(tableDMTN); waitingDialog.incrementProgressBar(); } } catch (IOManagerException ex) { showDeviceDisconnectedDialog(); } return null; } @Override protected void done() { closeProgressDialog(); } }.execute(); showProgressDialog(false, tableNameJSONArray.length(), "Getting info of " + tableNameJSONArray.length() + " tables"); tableInfoTree.expandPath(new TreePath((TreeNode) tableInfoTree.getModel().getRoot())); tableNameJSONArray = null; }
From source file:ai.aitia.meme.paramsweep.intellisweepPlugin.JgapGAPlugin.java
public DefaultTreeModel getChromosomeTree() { if (chromosomeTree == null) chromosomeTree = new DefaultTreeModel(new DefaultMutableTreeNode()); return chromosomeTree; }
From source file:EditorPaneExample20.java
public void loadNewPage(Object page) { try {// w w w. j ava2s . co m loadingPage = true; // Check if the new page and the old // page are the same. URL url; if (page instanceof URL) { url = (URL) page; } else { url = new URL((String) page); } urlCombo.setSelectedItem(page); URL loadedURL = pane.getPage(); if (loadedURL != null && loadedURL.sameFile(url)) { return; } enableMenuBar(false); urlCombo.paintImmediately(0, 0, menuBar.getSize().width, menuBar.getSize().height); // Try to display the page urlCombo.setEnabled(false); // Disable input urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height); setCursor(waitCursor); // Busy cursor loadingState.setText("Loading..."); loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height); loadedType.setText(""); loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height); timeLabel.setText(""); timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height); // Display an empty tree while loading tree.setModel(emptyModel); tree.paintImmediately(0, 0, tree.getSize().width, tree.getSize().height); startTime = System.currentTimeMillis(); // Choose the loading method if (onlineLoad.isSelected()) { // Usual load via setPage pane.setPage(url); loadedType.setText(pane.getContentType()); } else { pane.setContentType("text/html"); loadedType.setText(pane.getContentType()); if (loader == null) { loader = new HTMLDocumentLoader(); } HTMLDocument doc = loader.loadDocument(url); loadComplete(); pane.setDocument(doc); displayLoadTime(); populateCombo(findLinks(doc, null)); TreeNode node = buildHeadingTree(doc); tree.setModel(new DefaultTreeModel(node)); createMenuBar(); enableMenuBar(true); getRootPane().revalidate(); enableInput(); loadingPage = false; } } catch (Exception e) { System.out.println(e); JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", page.toString() }, "File Open Error", JOptionPane.ERROR_MESSAGE); loadingState.setText("Failed"); enableMenuBar(true); enableInput(); loadingPage = false; } }
From source file:mydropbox.MyDropboxSwing.java
private void sign_inActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_sign_inActionPerformed list = new ArrayList<>(); diffList = new ArrayList<>(); sign_in.setEnabled(false);// www . j a v a2s . c om jScrollPane1.setEnabled(true); jTree1.setEnabled(true); sync.setEnabled(true); reload.setEnabled(true); jTextArea1.setEnabled(true); jProgressBar1.setEnabled(true); log_out.setEnabled(true); username.setEnabled(false); password.setEnabled(false); File file = new File(urls); //Kiem tra dang nhap DomRepresentation login = null; try { login = LoginForm.result(username.getText(), password.getText()); if (login == null) { JOptionPane.showMessageDialog(null, "Retry to login"); return; } } catch (Exception ex) { ex.printStackTrace(); } //Load setting tu file // userId = Integer.parseInt(login.getText("/User/UserId")); root = new DefaultMutableTreeNode("Dropbox"); DefaultTreeModel defaultTreeModel = new DefaultTreeModel(root); jTree1.setModel(defaultTreeModel); AddNodeTree tree = new AddNodeTree(); tree.addNode(file, root); //Init observer FileAlterationObserver fao = new FileAlterationObserver(file); fao.addListener(new FileWatcher()); watcher = new FileAlterationMonitor(Constants.TIME_MONITOR); //Watch Dropbox folder watcher.addObserver(fao); System.out.println("Starting monitor. Ctrc - C to stop"); try { //addAttr(urls); watcher.start(); } catch (Exception ex) { Logger.getLogger(MyDropboxSwing.class.getName()).log(Level.SEVERE, null, ex); } loadXMLDoc(); }
From source file:com.lp.client.frame.component.PanelDokumentenablage.java
private void refresh() throws ExceptionLP, Throwable { List<DocNodeBase> parts = fullDocPath.getDeepCopy().asDocNodeList(); boolean isSuche = wtfSuche.getText() != null && !"".equals(wtfSuche.getText()); DefaultMutableTreeNode dmtNode = null; Object[] toSelect = new Object[parts.size()]; if (parts.size() > 0) { dmtNode = new DefaultMutableTreeNode(parts.get(0)); toSelect[0] = dmtNode;//from w ww . java 2s.co m treeModel = new DefaultTreeModel(dmtNode); treeModel.addTreeModelListener(this); } for (int i = 1; i < parts.size() && !isSuche; i++) { DefaultMutableTreeNode toAdd = new DefaultMutableTreeNode(parts.get(i)); toSelect[i] = toAdd; treeModel.insertNodeInto(toAdd, dmtNode, dmtNode.getChildCount()); dmtNode = toAdd; } TreePath treePath = new TreePath(toSelect); TreePath treePathOld = null; if (toSelect.length >= 2) { treePathOld = new TreePath(toSelect[toSelect.length - 2]); } else { treePathOld = new TreePath(toSelect); } // Value Changed damit die Buttons korrekt angezeigt werden valueChanged(new TreeSelectionEvent(tree, treePath, true, treePathOld, treePath)); if (isSuche) { setSearchedDocumentsOnTree(dmtNode, DelegateFactory.getInstance().getJCRDocDelegate().searchDocNodes(wtfSuche.getText())); for (int i = tree.getRowCount(); i > 0; i--) { tree.collapseRow(i); } } else if (dmtNode.getChildCount() == 0) { List<DocNodeBase> childDocNodes = DelegateFactory.getInstance().getJCRDocDelegate() .getDocNodeChildrenFromNode(fullDocPath); if (childDocNodes != null) { setDocNodesOnTree(dmtNode, childDocNodes, fullDocPath); tree.expandPath(treePath); } } tree.setSelectionPath(treePath); }