List of usage examples for javax.swing.tree DefaultTreeModel DefaultTreeModel
@ConstructorProperties({ "root" }) public DefaultTreeModel(TreeNode root)
From source file:de.tor.tribes.ui.windows.DSWorkbenchSplashScreen.java
protected HIDE_RESULT hideSplash() { try {/*from w w w . j a v a 2s . c om*/ if (!new File(".").canWrite()) { try { throw new IOException( "Failed to access installation directory " + new File(".").getAbsolutePath()); } catch (Exception e) { showFatalError(e); return HIDE_RESULT.ERROR; } } File f = new File("./servers"); if (!f.exists() && !f.mkdir()) { try { throw new IOException( "Failed to create server directory at location " + new File(".").getAbsolutePath()); } catch (Exception e) { showFatalError(e); return HIDE_RESULT.ERROR; } } ProfileManager.getSingleton().loadProfiles(); if (ProfileManager.getSingleton().getProfiles().length == 0) { logger.debug("Starting first start wizard"); //first start wizard if (!new File("./hfsw").exists()) { logger.debug(" - Initializing first start wizard"); Map result = new HashMap<>(); try { WizardPanelProvider provider = new FirstStartWizard(); Wizard wizard = provider.createWizard(); logger.debug(" - Showing wizard"); result = (Map) WizardDisplayer.showWizard(wizard); logger.debug("Wizard finished with result " + result); } catch (Throwable t) { logger.error("Wizard exception", t); result = null; } logger.debug(" - Wizard has finished"); if (result == null) { logger.warn(" - Wizard returned no result. Startup will fail."); JOptionPaneHelper.showWarningBox(self, "Du musst die grundlegenden Einstellungen zumindest einmalig durchfhren,\n" + "um DS Workbench verwenden zu knnen. Bitte starte DS Workbench neu.", "Abbruch"); return HIDE_RESULT.ERROR; } else { logger.debug("Wizard result: " + result); } logger.debug("- First start wizard finished"); GlobalOptions.addProperty("proxySet", result.get("proxySet").toString()); GlobalOptions.addProperty("proxyHost", result.get("proxyHost").toString()); GlobalOptions.addProperty("proxyPort", result.get("proxyPort").toString()); GlobalOptions.addProperty("proxyType", result.get("proxyType").toString()); GlobalOptions.addProperty("proxyUser", result.get("proxyUser").toString()); GlobalOptions.addProperty("proxyPassword", result.get("proxyPassword").toString()); GlobalOptions.addProperty("default.server", result.get("server").toString()); GlobalOptions.addProperty("default.player", result.get("tribe.id").toString()); logger.debug("Creating initial profile"); UserProfile p = UserProfile.create(GlobalOptions.getProperty("default.server"), result.get("tribe.name").toString()); GlobalOptions.setSelectedProfile(p); GlobalOptions.addProperty("selected.profile", Long.toString(p.getProfileId())); logger.debug(" - Disabling first start wizard"); FileUtils.touch(new File("./hfsw")); GlobalOptions.saveProperties(); } } //load properties, cursors, skins, world decoration logger.debug("Adding startup listeners"); DataHolder.getSingleton().addDataHolderListener(this); DataHolder.getSingleton().addDataHolderListener(DSWorkbenchSettingsDialog.getSingleton()); GlobalOptions.addDataHolderListener(this); } catch (Exception e) { logger.error("Failed to initialize global options", e); showFatalError(e); return HIDE_RESULT.ERROR; } logger.debug("Starting profile selection"); boolean settingsRestored = false; ServerManager.loadServerList(DSWorkbenchSettingsDialog.getSingleton().getWebProxy()); try { //open profile selection if (ProfileManager.getSingleton().getProfiles().length == 0) { logger.debug("No profile exists, SettingsDialog will handle this"); //no profile found...this is handles by the settings validation } else if (ProfileManager.getSingleton().getProfiles().length == 1) { logger.debug("One profile exists. Using it..."); //only one single profile was found, use it UserProfile profile = ProfileManager.getSingleton().getProfiles()[0]; String server = profile.getServerId(); GlobalOptions.setSelectedServer(server); GlobalOptions.setSelectedProfile(profile); GlobalOptions.addProperty("default.server", server); GlobalOptions.addProperty("selected.profile", Long.toString(profile.getProfileId())); } else { logger.debug("More than one profiles exist. Showing selection dialog"); File f = new File("./servers"); List<String> servers = new LinkedList<>(); for (File server : f.listFiles()) { servers.add(server.getName()); } //sort server names Collections.sort(servers, new Comparator<String>() { @Override public int compare(String o1, String o2) { if (o1.length() < o2.length()) { return -1; } else if (o1.length() > o2.length()) { return 1; } return o1.compareTo(o2); } }); List<Object> path = new LinkedList<>(); DefaultMutableTreeNode root = new DefaultMutableTreeNode("Profile"); long selectedProfile = GlobalOptions.getProperties().getLong("selected.profile"); path.add(root); for (String server : servers) { DefaultMutableTreeNode serverNode = new DefaultMutableTreeNode(server); boolean profileAdded = false; for (UserProfile profile : ProfileManager.getSingleton().getProfiles(server)) { DefaultMutableTreeNode profileNode = new DefaultMutableTreeNode(profile); if (profile.getProfileId() == selectedProfile) { path.add(serverNode); path.add(profileNode); } serverNode.add(profileNode); profileAdded = true; } if (profileAdded) { root.add(serverNode); } } jTree1.setModel(new DefaultTreeModel(root)); jTree1.setSelectionPath(new TreePath(path.toArray())); jTree1.scrollPathToVisible(new TreePath(path.toArray())); jTree1.setCellRenderer(new ProfileTreeNodeRenderer()); jProfileDialog.setVisible(true); } logger.debug("Profile selection finished"); //check settings DSWorkbenchSettingsDialog.getSingleton().restoreProperties(); settingsRestored = true; if (!DSWorkbenchSettingsDialog.getSingleton().checkSettings()) { logger.debug("Settings check in settings dialog failed"); logger.info("Reading user settings returned error(s)"); DSWorkbenchSettingsDialog.getSingleton().setBlocking(true); DSWorkbenchSettingsDialog.getSingleton().setVisible(true); } } catch (Exception e) { logger.warn("Failed to open profile manager", e); } if (!settingsRestored) { DSWorkbenchSettingsDialog.getSingleton().restoreProperties(); } // <editor-fold defaultstate="collapsed" desc=" Check for data updates "> logger.debug("Checking for application updates"); boolean checkForUpdates = GlobalOptions.getProperties().getBoolean("check.updates.on.startup"); try { if (!DataHolder.getSingleton().loadData(checkForUpdates)) { throw new Exception("loadData() returned 'false'. See log for more details."); } } catch (Exception e) { logger.error("Failed to load server data", e); showFatalError(e); return HIDE_RESULT.ERROR; } // </editor-fold> try { logger.debug("Initializing application window"); DSWorkbenchMainFrame.getSingleton().init(); logger.info("Showing application window"); DSWorkbenchMainFrame.getSingleton().setVisible(true); //check for version updates logger.info("Checking for DS Workbench update."); UpdateInfo info = GithubVersionCheck.getUpdateInformation(); switch (info.getStatus()) { case UPDATE_AVAILABLE: NotifierFrame.doNotification( "Eine neue DS Workbench Version ist verfgbar. Klick den grnen Punkt oben links, um auf die Download Seite zu gelangen. ", NotifierFrame.NOTIFY_UPDATE); default: logger.info("No update available or update check failed."); } try { ReportServer.getSingleton().start(GlobalOptions.getProperties().getInt("report.server.port")); } catch (Exception e) { logger.error("Failed to start report server", e); } // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem "> if (!Constants.DEBUG) { GlobalOptions.getHelpBroker().enableHelpKey(DSWorkbenchSimulatorFrame.getSingleton().getRootPane(), "pages.astar", GlobalOptions.getHelpBroker().getHelpSet()); GlobalOptions.getHelpBroker().enableHelpKey(DSWorkbenchMainFrame.getSingleton().getRootPane(), "index", GlobalOptions.getHelpBroker().getHelpSet()); } // </editor-fold> // <editor-fold defaultstate="collapsed" desc=" Init A*Star Servers "> ServerManager.giveSimulatorServerList(); // </editor-fold> t.stopRunning(); setVisible(false); GlobalOptions.removeDataHolderListener(this); return HIDE_RESULT.SUCCESS; } catch (Throwable th) { logger.fatal("Fatal error while running DS Workbench", th); showFatalError(th); return HIDE_RESULT.ERROR; } }
From source file:de.erdesignerng.visual.common.OutlineComponent.java
private void initialize() { tree = new DefaultTree(); tree.setCellRenderer(new OutlineTreeCellRenderer()); tree.addMouseListener(new OutlineMouseListener()); tree.addTreeSelectionListener(new OutlineSelectionListener()); tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode(TreeGroupingElement.MODEL))); setLayout(new BorderLayout()); add(tree.getScrollPane(), BorderLayout.CENTER); filterField = new DefaultTextField(); filterField.setColumns(255);// w w w . jav a 2 s . c o m filterField.addKeyListener(new OutlineKeyAdapter()); DefaultButton disableFilterButton = new DefaultButton(); disableFilterButton.setIcon(IconFactory.getCancelIcon()); disableFilterButton.setMaximumSize(new Dimension(21, 21)); disableFilterButton.setMinimumSize(new Dimension(21, 21)); disableFilterButton.setPreferredSize(new Dimension(21, 21)); disableFilterButton.addActionListener(new OutlineDisableFilterActionListener()); JPanel theFilterPanel = new JPanel(); theFilterPanel.setLayout(new BorderLayout()); theFilterPanel.add(filterField, BorderLayout.CENTER); theFilterPanel.add(disableFilterButton, BorderLayout.EAST); add(theFilterPanel, BorderLayout.NORTH); tree.addTreeExpansionListener(new OutlineTreeExpansionListener()); }
From source file:ai.aitia.meme.paramsweep.intellisweepPlugin.JgapGAPlugin.java
private void addParameter(final ParameterOrGene parameterOrGene) { if (chromosomeTree == null) { chromosomeTree = new DefaultTreeModel(new DefaultMutableTreeNode()); genes = null;/* ww w . j av a 2s . c om*/ } final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(parameterOrGene); final DefaultMutableTreeNode root = (DefaultMutableTreeNode) chromosomeTree.getRoot(); chromosomeTree.insertNodeInto(newNode, root, root.getChildCount()); if (listeners != null) { for (final ModelListener listener : listeners) listener.parameterAdded(); } }
From source file:com.orthancserver.SelectImageDialog.java
public boolean ShowModal() { final DefaultTreeModel model = new DefaultTreeModel(root_); root_.LoadChildren(model);// www . jav a2 s. com tree_.setRootVisible(false); tree_.setShowsRootHandles(true); tree_.setModel(model); isSuccess_ = false; setVisible(true); return isSuccess_; }
From source file:com.tascape.qa.th.android.driver.App.java
private TreeModel getModel(WindowHierarchy wh) { DefaultMutableTreeNode rootNode = createNode(wh.root); DefaultTreeModel treeModel = new DefaultTreeModel(rootNode); return treeModel; }
From source file:ai.aitia.meme.paramsweep.intellisweepPlugin.JgapGAPlugin.java
private void removeAllParameters() { if (chromosomeTree == null) chromosomeTree = new DefaultTreeModel(new DefaultMutableTreeNode()); else/*from ww w .j a va 2s .c om*/ chromosomeTree.setRoot(new DefaultMutableTreeNode()); genes = null; if (listeners != null) { for (final ModelListener listener : listeners) listener.parametersRemoved(); } }
From source file:edu.harvard.i2b2.query.QueryConceptTreePanel.java
/** This method is called from within the constructor to * initialize the form./*from w w w .j ava2 s .com*/ */ private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); jClearButton = new javax.swing.JButton(); jConstrainButton = new javax.swing.JButton(); jExcludeButton = new javax.swing.JButton(); jOccurrenceButton = new javax.swing.JButton(); jNameLabel = new javax.swing.JLabel(); setLayout(null); QueryConceptTreeNodeData tmpData = new QueryConceptTreeNodeData(); tmpData.name("working ......"); tmpData.tooltip("A root node"); tmpData.visualAttribute("FAO"); top = new DefaultMutableTreeNode(tmpData); //top = new DefaultMutableTreeNode("Root Node"); treeModel = new DefaultTreeModel(top); //treeModel.addTreeModelListener(new MyTreeModelListener()); jTree1 = new JTree(treeModel); jTree1.setEditable(true); //jTree1.getSelectionModel().setSelectionMode // (TreeSelectionModel.SINGLE_TREE_SELECTION); //jTree1.setShowsRootHandles(true); //JScrollPane treeView = new JScrollPane(jTree1); jTree1.setRootVisible(false); jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); jTree1.setCellRenderer(new MyRenderer()); ToolTipManager.sharedInstance().registerComponent(jTree1); setBorder(javax.swing.BorderFactory.createEtchedBorder()); add(jScrollPane1); //jScrollPane1.setBounds(0, 40, 180, 200); jClearButton.setFont(new java.awt.Font("Tahoma", 1, 11)); jClearButton.setText("X"); jClearButton.setToolTipText("Clear all items from panel"); jClearButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jClearButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); jClearButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); jClearButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jClearButtonActionPerformed(evt); } }); add(jClearButton); jClearButton.setBounds(160, 0, 18, 20); jConstrainButton.setText("Dates"); jConstrainButton.setToolTipText("Constrain group by dates"); jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); jConstrainButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jConstrainButtonActionPerformed(evt); } }); add(jConstrainButton); jConstrainButton.setBounds(0, 20, 40, 21); jOccurrenceButton.setText("Occurs > 0x"); jOccurrenceButton.setToolTipText("Set occurrence times"); jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jOccurrenceButton.setMargin(new java.awt.Insets(6, 6, 6, 6)); jOccurrenceButton.setIconTextGap(0); jOccurrenceButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jOccurrenceButtonActionPerformed(evt); } }); add(jOccurrenceButton); jOccurrenceButton.setBounds(40, 20, 90, 21); //jExcludeButton.setMnemonic('E'); jExcludeButton.setText("Exclude"); jExcludeButton.setToolTipText("Exclude all items in group"); jExcludeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jExcludeButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); jExcludeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jExcludeButtonActionPerformed(evt); } }); add(jExcludeButton); jExcludeButton.setBounds(130, 20, 48, 21); jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jNameLabel.setText("Group 1"); jNameLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jNameLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); add(jNameLabel); jNameLabel.setBounds(0, 0, 160, 20); jTree1.addTreeExpansionListener(this); jTree1.setTransferHandler(new TextHandler()); add(jScrollPane1); jScrollPane1.setViewportView(jTree1); //jTree1.setToolTipText("Double click on a folder to view the items inside"); //jScrollPane1.getViewport().setToolTipText("Double click on a folder to view the items inside"); jScrollPane1.setBounds(0, 40, 180, 160); }
From source file:uk.co.petertribble.jangle.SnmpTreePanel.java
private void buildUI() { for (SnmpObject sno : oidList) { model.addElement(sno);/*from www . j a v a 2 s . c o m*/ } /* * We create a SnmpTreeNode for each element in the list and add it to * a Hash with the name as the key. Then we walk the list - if a node * has a parent, we add it to the parent, else we need to create * intermediate nodes to fill in the tree. */ // root node SnmpTreeNode rootNode = new SnmpTreeNode("SNMP"); // real nodes Map<String, SnmpTreeNode> m = new HashMap<String, SnmpTreeNode>(); // intermediate nodes Map<String, SnmpTreeNode> m2 = new HashMap<String, SnmpTreeNode>(); for (SnmpObject sno : oidList) { m.put(sno.toString(), new SnmpTreeNode(sno)); } for (SnmpObject sno : oidList) { String s = sno.toString(); SnmpTreeNode mynode = m.get(s); String parent = SnmpUtil.getParentOID(s); while (parent != null) { if (m.containsKey(parent)) { /* * If there's a parent node, add this as a child. * This almost never happens. */ m.get(parent).add(mynode); mynode = m.get(parent); } else if (m2.containsKey(parent)) { /* * If we've already created a parent node, add this node * to that. */ m2.get(parent).add(mynode); mynode = m2.get(parent); } else { /* * Need to create a new node */ SnmpTreeNode pnode = new SnmpTreeNode(parent); pnode.add(mynode); m2.put(parent, pnode); mynode = pnode; } parent = SnmpUtil.getParentOID(parent); } rootNode.add(mynode); } if (stree == null) { stree = new JTree(rootNode); stree.addTreeSelectionListener(this); jtpl.add(SnmpResources.getString("SNMP.TREE.TEXT"), new JScrollPane(stree)); } else { stree.setModel(new DefaultTreeModel(rootNode)); } }
From source file:wsattacker.plugin.intelligentdos.ui.dialog.Result_NB.java
private TreeModel createModel() { DefaultMutableTreeNode root = new DefaultMutableTreeNode("root"); Set<String> dosAttackNameSet = new HashSet<String>(); Set<Position> elementSet = new HashSet<Position>(); for (SuccessfulAttack sa : attacks) { dosAttackNameSet.add(sa.getDoSAttack().getName()); elementSet.add(sa.getPosition()); }/*from w w w . j a v a 2 s . c o m*/ for (String dosAttackName : dosAttackNameSet) { DefaultMutableTreeNode dn = new DefaultMutableTreeNode(dosAttackName); root.add(dn); // for (Position position : elementSet) { DefaultMutableTreeNode el = new DefaultMutableTreeNode(position); boolean some = false; for (SuccessfulAttack sa : attacks) { if (sa.getDoSAttack().getName().equals(dosAttackName) && sa.getPosition().equals(position)) { DefaultMutableTreeNode attackNode = new DefaultMutableTreeNode(sa); el.add(attackNode); some = true; } } if (some) { dn.add(el); } } } return new DefaultTreeModel(root); }
From source file:dotaSoundEditor.Controls.EditorPanel.java
protected TreeModel buildSoundListTree(TreeModel scriptTree) { TreeNode rootNode = (TreeNode) scriptTree.getRoot(); int childCount = rootNode.getChildCount(); TreeModel soundListTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode("root")); ArrayList<String> wavePathsList = new ArrayList<>(); for (int i = 0; i < childCount; i++) { String nodeValue = scriptTree.getChild(rootNode, i).toString(); if (nodeValue.trim().startsWith("//")) { continue; }//from w w w . j a v a2s . com wavePathsList = getWavePathsAsList((TreeNode) scriptTree.getChild(rootNode, i)); DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(nodeValue); for (String s : wavePathsList) { DefaultMutableTreeNode tempNode = new DefaultMutableTreeNode(s); newNode.add(tempNode); } ((DefaultMutableTreeNode) soundListTreeModel.getRoot()).add(newNode); } return soundListTreeModel; }