List of usage examples for javax.swing.tree DefaultMutableTreeNode removeAllChildren
public void removeAllChildren()
From source file:com.SE.myPlayer.MusicPlayerGUI.java
private void treeReferesh() { DefaultTreeModel myModel = (DefaultTreeModel) folder_Playlist_Tree.getModel(); DefaultMutableTreeNode root = (DefaultMutableTreeNode) myModel.getRoot(); root.removeAllChildren(); DefaultMutableTreeNode library = new DefaultMutableTreeNode("library"); DefaultMutableTreeNode playlist = new DefaultMutableTreeNode("playlist"); myModel.insertNodeInto(library, root, root.getChildCount()); myModel.insertNodeInto(playlist, root, root.getChildCount()); try {/*from w w w.j a v a 2 s .c om*/ con = db.getCon(); stmt = con.createStatement(); String node; ResultSet rs = stmt.executeQuery("select pn_name from playlist_name"); while (rs.next()) { node = rs.getString(1); DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(node); myModel.insertNodeInto(newNode, playlist, playlist.getChildCount()); } if (con != null) { stmt.close(); con.close(); } } catch (SQLException e) { System.out.println("Error in Stmt " + e); } myModel.reload(); folder_Playlist_Tree.setModel(myModel); }
From source file:GUI.MainWindow.java
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed System.out.println("New Test Selected, Clear the tree and GUI"); // Clear the tree DefaultTreeModel dtm = ((DefaultTreeModel) this.VulnTree.getModel()); DefaultMutableTreeNode root = (DefaultMutableTreeNode) dtm.getRoot(); root.removeAllChildren(); dtm.reload();// w ww. j av a2s. c o m // Clear the GUI clearGUI(); // Clear save file this.save_file = null; }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
private void addSubParametersToTree(final SubmodelInfo sInfo, final JTree tree, final DefaultMutableTreeNode node) { try {//from w w w. j a v a2s.com final List<ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?>> subparameters = ParameterTreeUtils .fetchSubparameters(currentModelHandler, sInfo); final List<ParameterInfo> convertedSubparameters = new ArrayList<ParameterInfo>(subparameters.size()); for (ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?> parameterInfo : subparameters) { final ParameterInfo converted = InfoConverter.parameterInfo2ParameterInfo(parameterInfo); converted.setRuns(0); convertedSubparameters.add(converted); } Collections.sort(convertedSubparameters); final DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel(); if (node.getChildCount() > 0) { node.removeAllChildren(); treeModel.nodeStructureChanged(node); } for (final ParameterInfo pInfo : convertedSubparameters) { final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode( new ParameterInATree(pInfo, currentModelHandler.getModelClass())); treeModel.insertNodeInto(newNode, node, node.getChildCount()); if (pInfo instanceof SubmodelInfo) { final SubmodelInfo ssInfo = (SubmodelInfo) pInfo; if (ssInfo.getActualType() != null) addSubParametersToTree(ssInfo, tree, newNode); } } //tree.expandPath(new TreePath(treeModel.getPathToRoot(node))); } catch (final ModelInformationException e) { sInfo.setActualType(null, null); JOptionPane.showMessageDialog(wizard, new JLabel(e.getMessage()), "Error while analyizing model", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); submodelTypeBox.setSelectedIndex(0); } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
public void expandFileSystemTree(TreePath currentPath) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) currentPath.getLastPathComponent(); FileSystemObject fso = (FileSystemObject) node.getUserObject(); if ((fso.getChildren() != null) && (fso.getChildren().size() == 1) && (fso.getChildren().get(0).getIsPlaceholder())) { // LOG.debug("Before load children"); fso.loadChildren(false);//from w w w . ja v a2 s .co m // LOG.debug("After load children"); DepositTreeModel model = (DepositTreeModel) theFileSystemTree.getModel(); // LOG.debug("Before remove children"); node.removeAllChildren(); // LOG.debug("Before reload node"); model.reload(node); // LOG.debug("Before add children"); addChildFiles(node, fso.getChildren(), model, null, null); // LOG.debug("Before expand path"); theFileSystemTree.expandPath(currentPath); } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
public void refreshFileList() { ArrayList<DefaultMutableTreeNode> clipboard = getClipboardCopy(); for (DefaultMutableTreeNode node : clipboard) { if (node.getUserObject() instanceof FileSystemObject) { node.removeAllChildren(); FileSystemObject fso = (FileSystemObject) node.getUserObject(); fso.loadChildren(false);/*from w w w. j av a 2 s . c om*/ DepositTreeModel model = (DepositTreeModel) theFileSystemTree.getModel(); addChildFiles(node, fso.getChildren(), model, null, theFileSystemTree); } } }
From source file:org.apache.jetspeed.portlets.site.PortalSiteManager.java
private DefaultMutableTreeNode retrieveFolders(String folderPath, DefaultMutableTreeNode rootNode, boolean cleanBeforeRetrieve) { try {// w ww . j ava2 s . co m Link link; Folder folder; DefaultMutableTreeNode tmpNode; Page page; Folder rootfolder = getServiceLocator().getPageManager().getFolder(folderPath); if (rootNode == null) { rootNode = new DefaultMutableTreeNode(new SiteTreeNode(rootfolder, true)); } if (cleanBeforeRetrieve) { rootNode.removeAllChildren(); } Iterator folders = rootfolder.getFolders().iterator(); while (folders.hasNext()) { folder = (Folder) folders.next(); if (rootfolder.getPath().equals("/_user")) { if (folder.getName().startsWith("template")) { rootNode.add(new DefaultMutableTreeNode(new SiteTreeNode(folder))); } } else { rootNode.add(new DefaultMutableTreeNode(new SiteTreeNode(folder))); } } Iterator pages = rootfolder.getPages().iterator(); while (pages.hasNext()) { page = (Page) pages.next(); tmpNode = new DefaultMutableTreeNode(new SiteTreeNode(page)); tmpNode.setAllowsChildren(false); rootNode.add(tmpNode); } Iterator links = rootfolder.getLinks().iterator(); while (links.hasNext()) { link = (Link) links.next(); tmpNode = new DefaultMutableTreeNode(new SiteTreeNode(link)); tmpNode.setAllowsChildren(false); rootNode.add(tmpNode); } } catch (Exception e) { log.error("Failed to retrieve folders ", e); } return rootNode; }
From source file:org.codinjutsu.tools.jenkins.view.BrowserPanel.java
public void handleEmptyConfiguration() { JenkinsWidget.getInstance(project).updateStatusIcon(BuildStatusAggregator.EMPTY); //FIXME could be handled elsehwere DefaultTreeModel model = (DefaultTreeModel) jobTree.getModel(); DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); root.removeAllChildren(); model.nodeStructureChanged(root);/*from ww w.j a v a 2 s . com*/ jobTree.setRootVisible(false); jenkins.update(Jenkins.byDefault()); currentSelectedView = null; setJobsUnavailable(); }
From source file:org.codinjutsu.tools.jenkins.view.BrowserPanel.java
private void fillJobTree(final BuildStatusVisitor buildStatusVisitor) { final List<Job> jobList = jenkins.getJobs(); if (jobList.isEmpty()) { return;//from w w w .j a v a 2s. c o m } DefaultTreeModel model = (DefaultTreeModel) jobTree.getModel(); final DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) model.getRoot(); rootNode.removeAllChildren(); for (Job job : jobList) { DefaultMutableTreeNode jobNode = new DefaultMutableTreeNode(job); rootNode.add(jobNode); visit(job, buildStatusVisitor); } watch(); setSortedByStatus(sortedByBuildStatus); jobTree.setRootVisible(true); }
From source file:org.kepler.objectmanager.cache.LocalRepositoryManager.java
/** * Refresh the folder model for the specified local repository. * //from w w w.j a va 2 s . com * @param repo */ public void refreshFolderModelForRepo(LocalRepository repo) { if (isDebugging) log.debug("refreshFolderModelForRepo(" + repo.toString() + ")"); String repoName = getLocalRepositories().get(repo); if (repoName == null) { log.warn("Error: not a local repository: " + repo); return; } TreeModel tm = getFolderModel(repoName); if (tm == null) { tm = new DefaultTreeModel(new DefaultMutableTreeNode(repo)); _folderModel.put(repoName, tm); } DefaultMutableTreeNode root = (DefaultMutableTreeNode) tm.getRoot(); root.removeAllChildren(); for (File dir : repo.getDirectories()) { findKarsRecursive(dir, 20, root); } }
From source file:org.kepler.objectmanager.cache.LocalRepositoryManager.java
public void refreshFolderModelForFolder(File folder) { // find the corresponding TreeNode DefaultMutableTreeNode dmtn = getFolderModelNode(folder); if (dmtn == null) { return;//from w w w. j a v a 2s . c o m } // remove the children of that TreeNode dmtn.removeAllChildren(); // rebuild the children of the TreeNode findKarsRecursive(folder, 20, dmtn); }