List of usage examples for javax.swing JTree JTree
@ConstructorProperties({ "model" }) public JTree(TreeModel newModel)
JTree
which displays the root node -- the tree is created using the specified data model. From source file:edu.harvard.i2b2.query.ui.ConceptTreePanel.java
/** * This method is called from within the constructor to initialize the form. *///w w w .j a v a2 s .c om 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(); jHintLabel = 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.setDragEnabled(true); 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, 10)); 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)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jClearButton.setMargin(new java.awt.Insets(-10, -15, -10, -20)); } 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.setMargin(new java.awt.Insets(-10, -15, -10,-20)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); // jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); jConstrainButton.setMargin(new java.awt.Insets(-10, -15, -10, -20)); } 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(2, 2, 2, 2)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jOccurrenceButton.setMargin(new java.awt.Insets(-10, -10, -10, -10)); } jOccurrenceButton.setIconTextGap(0); jOccurrenceButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jOccurrenceButtonActionPerformed(evt); } }); jOccurrenceButton.setBounds(40, 20, 90, 21); add(jOccurrenceButton); // jExcludeButton.setMnemonic('E'); jExcludeButton.setText("Exclude"); jExcludeButton.setToolTipText("Exclude all items in group"); jExcludeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jExcludeButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jExcludeButton.setMargin(new java.awt.Insets(-10, -15, -10, -20)); jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); } 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); 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); jNameLabel.setTransferHandler(new GroupLabelTextHandler()); jNameLabel.addMouseListener(new DragMouseAdapter()); jNameLabel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseMoved(java.awt.event.MouseEvent evt) { jNameLabelMouseMoved(evt); // System.out.println("mouse x: "+evt.getX()+" y: "+evt. // getY()); // System.out.println("name label x: "+jNameLabel.getX()+ // " width: "+ // jNameLabel.getWidth()+" y: " // +jNameLabel.getY()+" height "+jNameLabel.getHeight()); } }); jNameLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseExited(java.awt.event.MouseEvent evt) { jNameLabelMouseExited(evt); } }); 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, 120); // jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new // java.awt.Color(0, 0, 0))); // jTree1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() // { // public void mouseMoved(java.awt.event.MouseEvent evt) { // jScrollPane1MouseMoved(evt); // } // @Override // public void mouseDragged(MouseEvent e) { // jScrollPane1MouseMoved(e); // } // }); // jTree1.addMouseListener(new java.awt.event.MouseAdapter() { // public void mouseExited(java.awt.event.MouseEvent evt) { // jScrollPane1MouseExited(evt); // } // @Override // public void mouseEntered(MouseEvent e) { // jScrollPane1MouseEntered(e); // } // }); jHintLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jHintLabel.setText( "<html><center>Drag terms from Navigate, <br>" + "<left>Find and Workplace into this group"); // jHintLabel.getFont(); jHintLabel.setFont(new Font("SansSerif", Font.PLAIN, 9)); // jHintLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jHintLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jHintLabel.setVerticalAlignment(javax.swing.SwingConstants.CENTER); // jHintLabel.setBackground(Color.WHITE); // jHintLabel.setForeground(Color.WHITE); add(jHintLabel); jHintLabel.setBounds(0, 120, 180, 30); }
From source file:net.jradius.client.gui.JRadiusSimulator.java
/** * This method initializes attributeTree * // www . ja va 2 s. com * @return javax.swing.JTree */ private JTree getAttributeTree() { if (attributeTree == null) { DefaultMutableTreeNode top = new DefaultMutableTreeNode("Attribute Dictionary"); createAttributeTreeNodes(top); attributeTree = new JTree(top); } return attributeTree; }
From source file:it.imtech.metadata.MetaUtility.java
/** * Aggiunge il pannello delle classificazioni all'interfaccia dei metadati * * @param innerPanel Pannello sul quale aggiungere i metadati * @param kv Valori dei metadati/*from w w w . j ava 2 s . com*/ */ private void addClassification(JPanel innerPanel, Integer kv, final String sequence, final String panelname) throws Exception { try { ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); DefaultMutableTreeNode hierarchy = new DefaultMutableTreeNode("root"); selected = null; String selectedPath = ""; String link = selectedClassificationList.get(panelname + "---" + sequence); recursiveOefosTreeviewBuild(hierarchy, oefos.get(link), sequence, panelname); DefaultTreeModel model = new DefaultTreeModel(hierarchy); final JTree tree = new JTree(model); tree.setRootVisible(false); if (selected != null) { TreePath selpath = new TreePath(selected.getPath()); tree.setSelectionPath(selpath); Object[] nodes = selpath.getPath(); for (int i = 1; i < nodes.length; i++) { selectedPath += nodes[i].toString(); selectedPath += (i != nodes.length - 1) ? "/" : ""; } } tree.setName("MID_" + Integer.toString(kv) + "---" + sequence); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { try { setOEFOS(tree, sequence, panelname); } catch (Exception ex) { logger.error(ex.getMessage()); } } }); javax.swing.JScrollPane tree_scroller = new javax.swing.JScrollPane(); tree_scroller .setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); tree_scroller.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); tree_scroller.setViewportView(tree); tree_scroller.setBorder(null); innerPanel.add(tree_scroller, "wrap, width 100:800:800"); JPanel iPanel = new JPanel(new MigLayout()); iPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Utility.getBundleString("choose2", bundle), TitledBorder.LEFT, TitledBorder.TOP)); JLabel label = new JLabel(); label.setName("classification_path" + "---" + sequence); label.setText(selectedPath); iPanel.add(label, "wrap, growx, height 30:30:30"); innerPanel.add(iPanel, "wrap, width 100:800:800"); findLastClassification(panelname); } catch (Exception ex) { logger.error(ex.getMessage()); throw new Exception("Exception in addClassification: " + ex.getStackTrace() + "\n"); } }
From source file:edu.harvard.i2b2.query.ui.GroupPanel.java
/** * This method is called from within the constructor to initialize the form. *///from w w w . j av a2 s . c om 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(); jHintLabel = new javax.swing.JLabel(); jTimingComboBox = new javax.swing.JComboBox(); // jAnyvisitToggleButton = new javax.swing.JToggleButton(); // jSamevisitToggleButton = new javax.swing.JToggleButton(); 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.setDragEnabled(true); 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, 10)); 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)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jClearButton.setMargin(new java.awt.Insets(-10, -15, -10, -20)); } 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.setMargin(new java.awt.Insets(-10, -15, -10,-20)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); // jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); jConstrainButton.setMargin(new java.awt.Insets(-10, -15, -10, -20)); } 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(2, 2, 2, 2)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jOccurrenceButton.setMargin(new java.awt.Insets(-10, -10, -10, -10)); } jOccurrenceButton.setIconTextGap(0); jOccurrenceButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jOccurrenceButtonActionPerformed(evt); } }); jOccurrenceButton.setBounds(40, 20, 90, 21); add(jOccurrenceButton); // jExcludeButton.setMnemonic('E'); jExcludeButton.setText("Exclude"); jExcludeButton.setToolTipText("Exclude all items in group"); jExcludeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jExcludeButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jExcludeButton.setMargin(new java.awt.Insets(-10, -15, -10, -20)); jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); } 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); 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); jNameLabel.setTransferHandler(new GroupLabelTextHandler()); jNameLabel.addMouseListener(new DragMouseAdapter()); jNameLabel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseMoved(java.awt.event.MouseEvent evt) { jNameLabelMouseMoved(evt); // System.out.println("mouse x: "+evt.getX()+" y: "+evt. // getY()); // System.out.println("name label x: "+jNameLabel.getX()+ // " width: "+ // jNameLabel.getWidth()+" y: " // +jNameLabel.getY()+" height "+jNameLabel.getHeight()); } }); jNameLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseExited(java.awt.event.MouseEvent evt) { jNameLabelMouseExited(evt); } }); /* * jAnyvisitToggleButton.setText("Any Visit"); * add(jAnyvisitToggleButton); jAnyvisitToggleButton.setBounds(0, 40, * 89, 20); * * jSamevisitToggleButton.setText("Same Visit"); * add(jSamevisitToggleButton); jSamevisitToggleButton.setBounds(90, 40, * 88, 20); * * ButtonGroup group = new ButtonGroup(); * group.add(jAnyvisitToggleButton); group.add(jSamevisitToggleButton); * jAnyvisitToggleButton.setSelected(true); */ 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, 60, 180, 120); // jScrollPane1.setBounds(0, 60, 190, 270); // jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new // java.awt.Color(0, 0, 0))); // jTree1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() // { // public void mouseMoved(java.awt.event.MouseEvent evt) { // jScrollPane1MouseMoved(evt); // } // @Override // public void mouseDragged(MouseEvent e) { // jScrollPane1MouseMoved(e); // } // }); // jTree1.addMouseListener(new java.awt.event.MouseAdapter() { // public void mouseExited(java.awt.event.MouseEvent evt) { // jScrollPane1MouseExited(evt); // } // @Override // public void mouseEntered(MouseEvent e) { // jScrollPane1MouseEntered(e); // } // }); jHintLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jHintLabel.setText( "<html><center>Drag terms from Navigate, <br>" + "<left>Find and Workplace into this group"); // jHintLabel.getFont(); jHintLabel.setFont(new Font("SansSerif", Font.PLAIN, 9)); // jHintLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jHintLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jHintLabel.setVerticalAlignment(javax.swing.SwingConstants.CENTER); // jHintLabel.setBackground(Color.WHITE); // jHintLabel.setForeground(Color.WHITE); add(jHintLabel); jHintLabel.setBounds(0, 120, 180, 30); jTimingComboBox.setModel(new javax.swing.DefaultComboBoxModel( new String[] { "Treat Independently", "Occurs in Same Encounter", "Items instance will be same" })); jTimingComboBox.setAlignmentX(5.0F); ListCellRenderer renderer = new DefaultListCellRenderer(); ((JLabel) renderer).setHorizontalAlignment(SwingConstants.CENTER); jTimingComboBox.setRenderer(renderer); // jTimingComboBox.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); add(jTimingComboBox); jTimingComboBox.setBounds(1, 40, 177, 20); jTimingComboBox.setEnabled(false); }
From source file:com.monead.semantic.workbench.SemanticWorkbench.java
/** * Setup all the components// w ww.j a v a2s .co m */ private void setupControls() { LOGGER.debug("setupControls"); reasoningLevel = new JComboBox(); for (ReasonerSelection reasoner : ReasonerSelection.values()) { reasoningLevel.addItem(reasoner); } reasoningLevel.setSelectedIndex(reasoningLevel.getItemCount() - 1); reasoningLevel.setToolTipText(((ReasonerSelection) reasoningLevel.getSelectedItem()).description()); reasoningLevel.addActionListener(new ReasonerConfigurationChange()); language = new JComboBox(); language.addItem("Auto"); for (String lang : FORMATS) { language.addItem(lang); } language.setSelectedIndex(0); assertedTripleCount = new JLabel(NOT_APPLICABLE_DISPLAY); assertedTripleCount.setHorizontalAlignment(JLabel.CENTER); inferredTripleCount = new JLabel(NOT_APPLICABLE_DISPLAY); inferredTripleCount.setHorizontalAlignment(JLabel.CENTER); runInferencing = new JButton("Create Model"); runInferencing.setToolTipText( "Creates an ontology model using the provieed assertions " + "and the selected reasoning level"); runInferencing.addActionListener(new ReasonerListener()); runSparql = new JButton("Run Query"); runSparql.addActionListener(new SparqlListener()); sparqlServerInfo = new JLabel("Shutdown"); sparqlServerInfo.setHorizontalAlignment(SwingConstants.CENTER); sparqlServerInfo.setBorder(BorderFactory.createTitledBorder("SPARQL Server Status")); proxyInfo = new JLabel("Disabled"); proxyInfo.setHorizontalAlignment(SwingConstants.CENTER); proxyInfo.setBorder(BorderFactory.createTitledBorder("Proxy Status")); assertionsInput = new JTextArea(10, 50); assertionsInput.addKeyListener(new UserInputListener()); assertionsInput.addCaretListener(new TextAreaCaratListener()); inferredTriples = new JTextArea(10, 50); inferredTriples.setEditable(false); // SPARQL Input sparqlInput = new JTextArea(10, 50); sparqlInput.addKeyListener(new UserInputListener()); sparqlInput.addCaretListener(new TextAreaCaratListener()); // User id and password for accessing secured SPARQL endpoints sparqlServiceUserId = new JTextField(10); sparqlServicePassword = new JPasswordField(10); // SPARQL service URLs sparqlServiceUrl = new JComboBox(); sparqlServiceUrl.setEditable(true); sparqlServiceUrl.addActionListener(new SparqlModelChoiceListener()); sparqlServiceUrl.getEditor().getEditorComponent().addKeyListener(new UserInputListener()); // Default graph if required defaultGraphUri = new JTextField(); defaultGraphUri.setColumns(20); // Move through query history previousQuery = new JButton("Previous"); previousQuery.addActionListener(new SparqlHistoryPreviousListener()); nextQuery = new JButton("Next"); nextQuery.addActionListener(new SparqlHistoryNextListener()); // A basic default query sparqlInput.setText("select ?s ?p ?o where { ?s ?p ?o } limit 100"); // Results table // sparqlResultsTable = new JTable(new SparqlTableModel()); sparqlResultsTable = new JTable(); // TODO Allow configuration to switch auto-resizing on/off (e.g. horizontal // scrolling) sparqlResultsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); sparqlResultsTable.setAutoCreateRowSorter(true); // Determine whether alternate tree icons exist if (ImageLibrary.instance().getImageIcon(ImageLibrary.ICON_TREE_CLASS) != null) { replaceTreeImages = true; } LOGGER.debug("Tree renderer, specialized icons available? " + replaceTreeImages); // Create the tree UI with a default model ontModelTree = new JTree(new DefaultTreeModel(new DefaultMutableTreeNode("No Tree Generated"))); ontModelTree.addMouseListener(new OntologyModelTreeMouseListener()); if (replaceTreeImages) { ToolTipManager.sharedInstance().registerComponent(ontModelTree); ontModelTree.setCellRenderer(new OntologyTreeCellRenderer()); } // Status label status = new JLabel("Initializing"); }
From source file:src.gui.ItSIMPLE.java
/** * @return the planTreeFramePanel//from www.ja va 2 s. c o m */ private ItFramePanel getPlanTreeFramePanel() { if (planTreeFramePanel == null) { planTreeFramePanel = new ItFramePanel(":: Problem Selection", ItFramePanel.NO_MINIMIZE_MAXIMIZE); ItTreeNode root = new ItTreeNode("Projects"); root.setIcon(new ImageIcon("resources/images/projects.png")); problemsPlanTreeModel = new DefaultTreeModel(root); problemsPlanTree = new JTree(problemsPlanTreeModel); problemsPlanTree.setShowsRootHandles(true); problemsPlanTree.setCellRenderer(new ItTreeCellRenderer()); problemsPlanTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); problemsPlanTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() { public void valueChanged(javax.swing.event.TreeSelectionEvent e) { ItTreeNode selectedNode = (ItTreeNode) problemsPlanTree.getLastSelectedPathComponent(); if (selectedNode != null && selectedNode.getLevel() == 3) { planAnalysisFramePanel .setTitle(":: Plan Analysis - Problem: " + selectedNode.getUserObject()); solveProblemButton.setEnabled(true); setPlannerButton.setEnabled(true); addPlanActionButton.setEnabled(true); importPlanButton.setEnabled(true); planListModel.clear(); xmlPlan = null; //clean up reference of plans from database cleanupPlanDatabaseReference(); String pddlVersion = pddlButtonsGroup.getSelection().getActionCommand(); Element problem = selectedNode.getData(); Element domainProject = problem.getDocument().getRootElement(); Element xpddlDomain = ToXPDDL.XMLToXPDDLDomain(domainProject, pddlVersion, null); XMLUtilities.printXML(xpddlDomain); //fill the combo box with the existing available planners plannersComboBox.removeAllItems(); plannersList.clear(); plannerSuggestion.initialPlannerSelection(xpddlDomain, itPlanners); //List<?> planners = itPlanners.getChild("planners").getChildren("planner"); plannersComboBox.addItem("-- Supported Planners --"); plannersList.add(null); // Supported Planners fillPlannersComboBox(plannerSuggestion.getSuggestedPlanners()); plannersComboBox.addItem("All Supported Planners"); plannersList.add("allSupportedPlanners"); plannersComboBox.addItem(null); plannersList.add(null); plannersComboBox.addItem("-- Discarded Planners --"); plannersList.add(null); // Discarded Planners fillPlannersComboBox(plannerSuggestion.getDiscardedPlanners()); plannersComboBox.addItem(null); plannersList.add(null); plannersComboBox.addItem("All Planners"); plannersList.add("allPlanners"); //This item specify/represent the planners that are seceyed/enable for run all plannersComboBox.addItem("My Favorite Planners"); plannersList.add("myFavoritePlanners"); //plannersComboBox.addItem("All Selected Planners"); //plannersList.add("allSelectedPlanners"); CheckBoxNode variablesPlanTreeRoot = (CheckBoxNode) variablesPlanTreeModel.getRoot(); // delete old tree nodes if (variablesPlanTreeRoot.getChildCount() > 0) { variablesPlanTreeRoot = new CheckBoxNode("Objects"); variablesPlanTreeRoot.setIcon(new ImageIcon("resources/images/projects.png")); variablesPlanTreeModel.setRoot(variablesPlanTreeRoot); variablesPlanTreeModel.reload(); } //planningProblems domain List<?> objects = problem.getParentElement().getParentElement().getChild("elements") .getChild("objects").getChildren("object"); for (Iterator<?> iter = objects.iterator(); iter.hasNext();) { Element object = (Element) iter.next(); CheckBoxNode objectNode = new CheckBoxNode(object.getChildText("name"), object, null, null); objectNode.setIcon(new ImageIcon("resources/images/object.png")); //CheckBoxNode statesNode = new CheckBoxNode("States"); //statesNode.setIcon(new ImageIcon("resources/images/state.png")); //variablesPlanTreeModel.insertNodeInto(statesNode, objectNode, objectNode.getChildCount()); // add a node for each object attribute // get the object class Element objectClass = null; try { XPath path = new JDOMXPath("project/elements/classes/class[@id='" + object.getChildText("class") + "']"); objectClass = (Element) path.selectSingleNode(object.getDocument()); } catch (JaxenException e1) { e1.printStackTrace(); } // get the parent classes List<?> parents = XMLUtilities.getClassAscendents(objectClass); // prepares a list of attributes node List<CheckBoxNode> attributes = new ArrayList<CheckBoxNode>(); for (Iterator<?> iterator = objectClass.getChild("attributes").getChildren("attribute") .iterator(); iterator.hasNext();) { Element attribute = (Element) iterator.next(); if (attribute.getChild("parameters").getChildren().size() == 0) {// not parameterized attributes CheckBoxNode attributeNode = new CheckBoxNode(attribute.getChildText("name"), attribute, null, null); attributeNode.setIcon(new ImageIcon("resources/images/attribute.png")); attributes.add(attributeNode); //variablesPlanTreeModel.insertNodeInto(attributeNode, attributesNode, attributesNode.getChildCount()); } } for (Iterator<?> iterator = parents.iterator(); iterator.hasNext();) { Element parentClass = (Element) iterator.next(); for (Iterator<?> iter2 = parentClass.getChild("attributes").getChildren("attribute") .iterator(); iter2.hasNext();) { Element attribute = (Element) iter2.next(); if (attribute.getChild("parameters").getChildren().size() == 0) {// not parameterized attributes CheckBoxNode attributeNode = new CheckBoxNode( attribute.getChildText("name"), attribute, null, null); attributeNode.setIcon(new ImageIcon("resources/images/attribute.png")); attributes.add(attributeNode); //variablesPlanTreeModel.insertNodeInto(attributeNode, attributesNode, attributesNode.getChildCount()); } } } // only add attributes node if the object has attributes if (attributes.size() > 0) { CheckBoxNode attributesNode = new CheckBoxNode("Attributes"); attributesNode.setIcon(new ImageIcon("resources/images/attribute.png")); variablesPlanTreeModel.insertNodeInto(attributesNode, objectNode, objectNode.getChildCount()); for (Iterator<CheckBoxNode> iterator = attributes.iterator(); iterator.hasNext();) { CheckBoxNode attributeNode = iterator.next(); variablesPlanTreeModel.insertNodeInto(attributeNode, attributesNode, attributesNode.getChildCount()); } } // if the object node is not a leaf, add it to the tree if (!objectNode.isLeaf()) { variablesPlanTreeModel.insertNodeInto(objectNode, variablesPlanTreeRoot, variablesPlanTreeRoot.getChildCount()); } } variablesPlanTree.expandRow(0); } else { //clear the depending areas planAnalysisFramePanel.setTitle(":: Plan Analysis"); //setPlannerButton.setEnabled(false); setPlannerButton.setEnabled(true); addPlanActionButton.setEnabled(false); importPlanButton.setEnabled(false); planListModel.clear(); xmlPlan = null; //clean up reference of plans from database cleanupPlanDatabaseReference(); //fill the combo box with all planners plannersComboBox.removeAllItems(); plannersList.clear(); List<?> planners = itPlanners.getChild("planners").getChildren("planner"); fillPlannersComboBox(planners); plannersComboBox.addItem("All Planners"); plannersList.add("allPlanners"); //This item specify/represent the planners that are seceyed/enable for run all plannersComboBox.addItem("My Favorite Planners"); plannersList.add("myFavoritePlanners"); //plannersComboBox.addItem("All Selected Planners"); //plannersList.add("allSelectedPlanners"); //clear the variables tree, whether necessary CheckBoxNode variablesPlanTreeRoot = (CheckBoxNode) variablesPlanTreeModel.getRoot(); if (variablesPlanTreeRoot.getChildCount() > 0) { CheckBoxNode root = new CheckBoxNode("Objects"); root.setIcon(new ImageIcon("resources/images/projects.png")); variablesPlanTreeModel.setRoot(root); variablesPlanTreeModel.reload(); } } } }); CheckBoxNode variablesTreeRoot = new CheckBoxNode("Objects"); variablesTreeRoot.setIcon(new ImageIcon("resources/images/projects.png")); variablesPlanTreeModel = new DefaultTreeModel(variablesTreeRoot); variablesPlanTree = new JTree(variablesPlanTreeModel); variablesPlanTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); variablesPlanTree.setShowsRootHandles(true); variablesPlanTree.setCellRenderer(new CheckBoxNodeRenderer()); variablesPlanTree.setCellEditor(new CheckBoxNodeEditor(variablesPlanTree)); variablesPlanTree.setEditable(true); ItTreeNode selectionTreeRoot = new ItTreeNode("Selections"); selectionTreeRoot.setIcon(new ImageIcon("resources/images/projects.png")); selectedVariablesPlanTreeModel = new DefaultTreeModel(selectionTreeRoot); selectedVariablesPlanTree = new JTree(selectedVariablesPlanTreeModel); selectedVariablesPlanTree.getSelectionModel() .setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); // get the selected nodes in variables plan tree and add it to selectedVariablesPlanTree variablesPlanTree.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { TreePath path = variablesPlanTree.getPathForLocation(e.getX(), e.getY()); if (path != null) { ItTreeNode root = new ItTreeNode("Selections"); root.setIcon(new ImageIcon("resources/images/projects.png")); // get checked nodes Object[] checked = CheckBoxNode .getCheckedNodes((CheckBoxNode) variablesPlanTree.getModel().getRoot()); for (int i = 0; i < checked.length; i++) { CheckBoxNode node = (CheckBoxNode) checked[i]; if (node.getUserObject().toString().equals("States") || node.getLevel() == 3) { CheckBoxNode objectNode = (node.getLevel() == 3) ? (CheckBoxNode) node.getParent().getParent() : (CheckBoxNode) node.getParent(); String nodeName = (node.getLevel() == 3) ? objectNode.getData().getChildText("name") + "." + node.getData().getChildText("name") : "States of " + objectNode.getData().getChildText("name"); ImageIcon icon = new ImageIcon( (node.getLevel() == 3) ? "resources/images/attribute.png" : "resources/images/state.png"); ItTreeNode newNode = new ItTreeNode(nodeName, node.getData(), null, null); newNode.setIcon(icon); root.add(newNode); } } selectedVariablesPlanTreeModel.setRoot(root); selectedVariablesPlanTreeModel.reload(); selectedVariablesPlanTree.expandRow(0); } } public void mouseEntered(MouseEvent arg0) { } public void mouseExited(MouseEvent arg0) { } public void mousePressed(MouseEvent arg0) { } public void mouseReleased(MouseEvent arg0) { } }); selectedVariablesPlanTree.setShowsRootHandles(true); selectedVariablesPlanTree.setCellRenderer(new ItTreeCellRenderer()); // create a main pane JPanel mainTreePanel = new JPanel(new BorderLayout()); //The below approach of put variable selection and problems all together // has confused user, so we decided to put variable selection inside the Variable tracking panel // tabbed panes with jtrees //planTreeTabbedPane = new JTabbedPane(); //planTreeTabbedPane.addTab("Problems", new JScrollPane(problemsPlanTree)); //planTreeTabbedPane.addTab("Variables", new JScrollPane(variablesPlanTree)); //planTreeTabbedPane.addTab("Selected", new JScrollPane(selectedVariablesPlanTree)); //mainTreePanel.add(planTreeTabbedPane, BorderLayout.CENTER); // mainTreePanel.add(new JScrollPane(problemsPlanTree), BorderLayout.CENTER); // tool panel JPanel toolsPanel = new JPanel(new BorderLayout()); JPanel topPanel = new JPanel(); JPanel bottonPanel = new JPanel(); // combobox with planners plannersComboBox = new JComboBox(); // add to the panel //toolsPanel.add(plannersComboBox); topPanel.add(plannersComboBox, BorderLayout.CENTER); // solve problem button solveProblemButton = new JButton("Solve", new ImageIcon("resources/images/engine.png")); //solveProblemButton.setEnabled(false); solveProblemButton.setActionCommand("solve"); solveProblemButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (solveProblemButton.getActionCommand().equals("solve")) { ItTreeNode selectedNode = (ItTreeNode) problemsPlanTree.getLastSelectedPathComponent(); if (selectedNode != null) { stopRunningPlanners = false; forceFinish = false; //Verify selectedNode and solve problems skipPlannerProblemButton.setEnabled(true); solve(selectedNode); } } else { if (currentThread.isAlive()) { stopRunningPlanners = true; forceFinish = true; exe.destroyProcess(); try { // waits for the thread to return currentThread.join(2000);// 2 seconds time-out } catch (InterruptedException e1) { e1.printStackTrace(); } if (currentThread.isAlive()) { currentThread.interrupt(); } if (plannerThread != null) { if (plannerThread.isAlive()) { plannerThread.interrupt(); } } planSimStatusBar.setText("Status: Planning process stopped."); outputEditorPane.append(">> Planning process stopped."); // changes the button action command solveProblemButton.setActionCommand("solve"); solveProblemButton.setText("Solve"); solveProblemButton.setIcon(new ImageIcon("resources/images/engine.png")); //changes the Skip Button skipPlannerProblemButton.setEnabled(false); } hideSimProgressBar(); simTimeSpent.setText(""); } } }); // skip planner/problem button skipPlannerProblemButton = new JButton("Skip", new ImageIcon("resources/images/skip.png")); skipPlannerProblemButton.setVisible(false); skipPlannerProblemButton.setActionCommand("skip"); skipPlannerProblemButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { forceFinish = true; } }); // add to the panel //toolsPanel.add(solveProblemButton); /* //runAllPlannersButton = new JButton("Run All planners", new ImageIcon("resources/images/edit.png")); runAllPlannersButton = new JButton("Run all planners"); runAllPlannersButton.setToolTipText("Run all available planners"); runAllPlannersButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { ItTreeNode selectedNode = (ItTreeNode)problemsPlanTree.getLastSelectedPathComponent(); if(selectedNode != null){ Element problem = selectedNode.getData(); if(problem != null){ solveProblemWithAllPlanners(problem.getDocument().getRootElement(), problem); } } } });*/ // set planner button //setPlannerButton = new JButton("Settings"); setPlannerButton = new JButton(new ImageIcon("resources/images/edit.png")); setPlannerButton.setEnabled(false); setPlannerButton.setToolTipText("Set planner parameters"); setPlannerButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { //get selected planner /*List<?> planners = itPlanners.getChild("planners").getChildren("planner"); Element chosenPlanner = (Element)planners.get(plannersComboBox.getSelectedIndex());*/ //PlannersSettingsDialog dialog = new PlannersSettingsDialog( // ItSIMPLE.this, plannersComboBox.getSelectedIndex()); PlannersSettingsDialog dialog = new PlannersSettingsDialog(ItSIMPLE.this); dialog.setVisible(true); } }); //toolsPanel.add(setPlannerButton); topPanel.add(setPlannerButton, BorderLayout.EAST); bottonPanel.add(solveProblemButton); bottonPanel.add(skipPlannerProblemButton); //bottonPanel.add(runAllPlannersButton); toolsPanel.add(topPanel, BorderLayout.NORTH); toolsPanel.add(bottonPanel, BorderLayout.SOUTH); // add the tools panel to the main panel mainTreePanel.add(toolsPanel, BorderLayout.SOUTH); planTreeFramePanel.setContent(mainTreePanel, false); } return planTreeFramePanel; }
From source file:src.gui.ItSIMPLE.java
/** * Creates the project selection panel in the main analysis panel * @return /*from w w w .j a v a2 s . c o m*/ */ private JPanel getProjectPDDLSelectionPane() { JPanel anPanel = new JPanel(new BorderLayout()); //TOP panel Domain/problem selection ItFramePanel projectSelPanel = new ItFramePanel(":: Domain/Problem Selection", ItFramePanel.NO_MINIMIZE_MAXIMIZE); projectSelPanel.setPreferredSize(new Dimension(screenSize.width / 4 - 20, screenSize.height)); //Instanciate project selection tree ItTreeNode root = new ItTreeNode("Projects"); root.setIcon(new ImageIcon("resources/images/projects.png")); pddlTranslationTreeModel = new DefaultTreeModel(root); pddlTranslationTree = new JTree(pddlTranslationTreeModel); pddlTranslationTree.setShowsRootHandles(true); pddlTranslationTree.setCellRenderer(new ItTreeCellRenderer()); pddlTranslationTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); pddlTranslationTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() { public void valueChanged(javax.swing.event.TreeSelectionEvent e) { ItTreeNode selectedNode = (ItTreeNode) pddlTranslationTree.getLastSelectedPathComponent(); //if(selectedNode != null && selectedNode.getLevel() == 3){ //} //else{ //} } }); // create a main pane for putting the tree inside JPanel mainTreePanel = new JPanel(new BorderLayout()); mainTreePanel.add(new JScrollPane(pddlTranslationTree), BorderLayout.CENTER); //Translate button translateDomainProblemButton = new JButton("Translate", new ImageIcon("resources/images/play.png")); //solveProblemButton.setEnabled(false); translateDomainProblemButton.setActionCommand("translate"); translateDomainProblemButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ItTreeNode selectedNode = (ItTreeNode) pddlTranslationTree.getLastSelectedPathComponent(); if (selectedNode != null) { if (selectedNode.getLevel() == 2 && selectedNode.getData().getName().equals("domain")) { Element domain = selectedNode.getData(); translateDomainToPddl(domain); } else if (selectedNode.getLevel() == 3 && selectedNode.getData().getName().equals("problem")) { Element problem = selectedNode.getData(); translateProblemToPddl(problem); } else { JOptionPane.showMessageDialog(ItSIMPLE.this, "<html>Please chose a domain or problem node (from a UML project)<br> in the Domain/Problem Selection tree.</html>"); } } } }); mainTreePanel.add(translateDomainProblemButton, BorderLayout.SOUTH); projectSelPanel.setContent(mainTreePanel, false); //projectSelPanel.setParentSplitPane(petriEditorSplitPane); anPanel.add(projectSelPanel, BorderLayout.CENTER); //BOTTOM panels (pddl version settings) ItFramePanel pddlSettingFramePanel = new ItFramePanel(":: PDDL Version Settings", ItFramePanel.NO_MINIMIZE_MAXIMIZE); //pddlSettingPanel.setPreferredSize(new Dimension(screenSize.width/4 - 20, screenSize.height)); JPanel bottonPanel = new JPanel(new BorderLayout()); bottonPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); bottonPanel.add(getPddlVersionSettingsPanel(), BorderLayout.CENTER); pddlSettingFramePanel.setContent(bottonPanel, false); anPanel.add(pddlSettingFramePanel, BorderLayout.SOUTH); return anPanel; }
From source file:src.gui.ItSIMPLE.java
/** * Creates the project selection panel in the main analysis panel * @return //from w ww .j a va2 s . co m */ private JPanel getProjectAnalysisSelectionPane() { JPanel anPanel = new JPanel(new BorderLayout()); ItFramePanel projectSelPanel = new ItFramePanel(":: Project Selection", ItFramePanel.NO_MINIMIZE_MAXIMIZE); projectSelPanel.setPreferredSize(new Dimension(screenSize.width / 4 - 20, screenSize.height)); //Instanciate project selectio tree ItTreeNode root = new ItTreeNode("Projects"); root.setIcon(new ImageIcon("resources/images/projects.png")); projectAnalysisTreeModel = new DefaultTreeModel(root); projectAnalysisTree = new JTree(projectAnalysisTreeModel); projectAnalysisTree.setShowsRootHandles(true); projectAnalysisTree.setCellRenderer(new ItTreeCellRenderer()); projectAnalysisTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); projectAnalysisTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() { public void valueChanged(javax.swing.event.TreeSelectionEvent e) { ItTreeNode selectedNode = (ItTreeNode) projectAnalysisTree.getLastSelectedPathComponent(); //if(selectedNode != null && selectedNode.getLevel() == 3){ //} //else{ //} } }); // create a main pane for putting the tree inside JPanel mainTreePanel = new JPanel(new BorderLayout()); mainTreePanel.add(new JScrollPane(projectAnalysisTree), BorderLayout.CENTER); projectSelPanel.setContent(mainTreePanel, false); //projectSelPanel.setParentSplitPane(petriEditorSplitPane); anPanel.add(projectSelPanel, BorderLayout.CENTER); return anPanel; }
From source file:net.sourceforge.squirrel_sql.client.gui.HelpViewerWindow.java
/** * Create a tree each node being a link to a document. * /* ww w .j a v a2 s . c om*/ * @return The contents tree. */ private JScrollPane createContentsTree() throws IOException { // i18n[HelpViewerWindow.help=Help] final FolderNode root = new FolderNode(s_stringMgr.getString("HelpViewerWindow.help")); _tree = new JTree(new DefaultTreeModel(root)); _tree.setShowsRootHandles(true); _tree.addTreeSelectionListener(new ObjectTreeSelectionListener()); // Renderer for tree. DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer(); SquirrelResources rsrc = _app.getResources(); renderer.setLeafIcon(rsrc.getIcon(SquirrelResources.IImageNames.HELP_TOPIC)); renderer.setOpenIcon(rsrc.getIcon(SquirrelResources.IImageNames.HELP_TOC_OPEN)); renderer.setClosedIcon(rsrc.getIcon(SquirrelResources.IImageNames.HELP_TOC_CLOSED)); _tree.setCellRenderer(renderer); // First put the Welcome to SQuirreL node. FileWrapper file = applicationFiles.getWelcomeFile(); try { // i18n[HelpViewerWindow.welcome=Welcome] DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.welcome"), file); root.add(dn); _nodes.put(dn.getURL().toString(), dn); } catch (MalformedURLException ex) { // i18n[HelpViewerWindow.error.loadwelcomefile=Error retrieving Welcome file URL for {0}] String msg = s_stringMgr.getString("HelpViewerWindow.error.loadwelcomefile", file.getAbsolutePath()); s_log.error(msg, ex); } // Add Help, Licence and Change Log nodes to the tree. // i18n[HelpViewerWindow.help=Help] final FolderNode helpRoot = new FolderNode(s_stringMgr.getString("HelpViewerWindow.help")); root.add(helpRoot); _nodes.put(helpRoot.getURL().toString(), helpRoot); // i18n[HelpViewerWindow.licences=Licences] final FolderNode licenceRoot = new FolderNode(s_stringMgr.getString("HelpViewerWindow.licences")); root.add(licenceRoot); _nodes.put(licenceRoot.getURL().toString(), licenceRoot); // i18n[HelpViewerWindow.changelogs=Change Logs] final FolderNode changeLogRoot = new FolderNode(s_stringMgr.getString("HelpViewerWindow.changelogs")); root.add(changeLogRoot); _nodes.put(changeLogRoot.getURL().toString(), changeLogRoot); // Add SQuirreL help to the Help node. file = applicationFiles.getQuickStartGuideFile(); try { // i18n[HelpViewerWindow.squirrel=SQuirreL] DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.squirrel"), file); helpRoot.add(dn); _homeURL = dn.getURL(); _nodes.put(_homeURL.toString(), dn); } catch (MalformedURLException ex) { // i18n[HelpViewerWindow.error.loadwelcomefile=Error retrieving Help file URL for {0}] String msg = s_stringMgr.getString("HelpViewerWindow.error.loadhelpfile", file.getAbsolutePath()); s_log.error(msg, ex); } // Add SQuirreL Licence to the Licence node. file = applicationFiles.getLicenceFile(); try { // i18n[HelpViewerWindow.squirrel=SQuirreL] DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.squirrel"), file); licenceRoot.add(dn); _nodes.put(dn.getURL().toString(), dn); } catch (MalformedURLException ex) { // i18n[HelpViewerWindow.error.loadlicencefile=Error retrieving Licence file URL for {0}] String msg = s_stringMgr.getString("HelpViewerWindow.error.loadlicencefile", file.getAbsolutePath()); s_log.error(msg, ex); } // Add SQuirreL Change Log to the Licence node. file = applicationFiles.getChangeLogFile(); try { // i18n[HelpViewerWindow.squirrel=SQuirreL] DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.squirrel"), file); changeLogRoot.add(dn); _nodes.put(dn.getURL().toString(), dn); } catch (MalformedURLException ex) { // i18n[HelpViewerWindow.error.loadchangelogfile=Error retrieving Change Log file URL for {0}] String msg = s_stringMgr.getString("HelpViewerWindow.error.loadchangelogfile", file.getAbsolutePath()); s_log.error(msg, ex); } // Add plugin help, licence and change log documents to the tree. PluginInfo[] pi = _app.getPluginManager().getPluginInformation(); for (int i = 0; i < pi.length; ++i) { try { final FileWrapper dir = pi[i].getPlugin().getPluginAppSettingsFolder(); final String title = pi[i].getDescriptiveName(); // Help document. try { final String fn = pi[i].getHelpFileName(); if (fn != null && fn.length() > 0) { DocumentNode dn = new DocumentNode(title, fileWrapperFactory.create(dir, fn)); helpRoot.add(dn); _nodes.put(dn.getURL().toString(), dn); } } catch (IOException ex) { // i18n[HelpViewerWindow.error.loadpluginhelp=Error generating Help entry for plugin {0}] String msg = s_stringMgr.getString("HelpViewerWindow.error.loadpluginhelp", pi[i].getDescriptiveName()); s_log.error(msg, ex); } // Licence document. try { final String fn = pi[i].getLicenceFileName(); if (fn != null && fn.length() > 0) { DocumentNode dn = new DocumentNode(title, fileWrapperFactory.create(dir, fn)); licenceRoot.add(dn); _nodes.put(dn.getURL().toString(), dn); } } catch (IOException ex) { // i18n[HelpViewerWindow.error.loadpluginlicence=Error generating Licence entry for plugin {0}] String msg = s_stringMgr.getString("HelpViewerWindow.error.loadpluginlicence", pi[i].getDescriptiveName()); s_log.error(msg, ex); } try { // Change log. final String fn = pi[i].getChangeLogFileName(); if (fn != null && fn.length() > 0) { DocumentNode dn = new DocumentNode(title, fileWrapperFactory.create(dir, fn)); changeLogRoot.add(dn); _nodes.put(dn.getURL().toString(), dn); } } catch (IOException ex) { // i18n[HelpViewerWindow.error.loadchangelog=Error generating Change Log entry for plugin {0}] String msg = s_stringMgr.getString("HelpViewerWindow.error.loadchangelog", pi[i].getDescriptiveName()); s_log.error(msg, ex); } } catch (IOException ex) { // i18n[HelpViewerWindow.error.loadpluginsettings=Error retrieving app settings folder for plugin // {0}] String msg = s_stringMgr.getString("HelpViewerWindow.error.loadpluginsettings", pi[i].getDescriptiveName()); s_log.error(msg, ex); } } // FAQ. file = applicationFiles.getFAQFile(); try { // i18n[HelpViewerWindow.faq=FAQ] DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.faq"), file); root.add(dn); _nodes.put(dn.getURL().toString(), dn); } catch (MalformedURLException ex) { // i18n[HelpViewerWindow.error.loadfaqfile=Error retrieving FAQ from URL = {0}] String msg = s_stringMgr.getString("HelpViewerWindow.error.loadfaqfile", file.getAbsolutePath()); s_log.error(msg, ex); } // generate contents file. helpRoot.generateContentsFile(); licenceRoot.generateContentsFile(); changeLogRoot.generateContentsFile(); JScrollPane sp = new JScrollPane(_tree); sp.setPreferredSize(new Dimension(200, 200)); return sp; }
From source file:nl.tudelft.goal.SimpleIDE.FilePanel.java
/** * DOC/*www . j a va 2 s . com*/ * * @param mainp * the main panel, for centering dialogs. * @param state * the IDE state */ public FilePanel(JPanel mainp, IDEState state) { this.mainpanel = mainp; this.ideState = state; this.rootNode = new FileNode(NodeType.ROOT, null); this.rootNode.setAllowsChildren(true); this.projectsNode = new FileNode(NodeType.ROOT, new File("MAS Projects")); //$NON-NLS-1$ this.nullNode = new NullNode(); this.rootNode.add(this.projectsNode); this.rootNode.add(this.nullNode); this.treeModel = new DefaultTreeModel(this.rootNode, true); this.fileTree = new JTree(this.treeModel); // add the various event listeners addListeners(); // double-click should not toggle the tree this.fileTree.setToggleClickCount(-1); // set the layout setLayout(new BorderLayout()); this.fileTree.setEditable(false); // TODO: allow this. this.fileTree.setRootVisible(false); this.fileTree.setShowsRootHandles(true); this.fileTree.setCellRenderer(new IDENodeRenderer()); // include tree view in pane JScrollPane fileTreeView = new JScrollPane(this.fileTree); this.add(new JLabel("Files"), BorderLayout.NORTH); //$NON-NLS-1$ this.add(fileTreeView, BorderLayout.CENTER); this.allFiles = new FileNodeMap(); this.platform = PlatformManager.getCurrent(); }