List of usage examples for javax.swing.tree TreeSelectionModel SINGLE_TREE_SELECTION
int SINGLE_TREE_SELECTION
To view the source code for javax.swing.tree TreeSelectionModel SINGLE_TREE_SELECTION.
Click Source Link
From source file:edu.harvard.i2b2.query.ui.GroupPanel.java
/** * This method is called from within the constructor to initialize the form. *//*w w w .j av a2 s.co m*/ 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:src.gui.ItSIMPLE.java
/** * This method initializes tree/*from w ww . java2s .c o m*/ * * @return javax.swing.JTree */ private ItTree getProjectsTree() { if (projectsTree == null) { treeRoot = new ItTreeNode("itSIMPLE Projects"); treeRoot.setIcon(new ImageIcon("resources/images/projects.png")); projectsTree = new ItTree(treeRoot); projectsTree.setCellRenderer(new ItTreeCellRenderer()); projectsTree.setShowsRootHandles(true); projectsTree.setVisible(true); projectsTree.setEditable(false); projectsTree.add(getTreePopupMenu()); projectsTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() { public void valueChanged(javax.swing.event.TreeSelectionEvent e) { ItTreeNode selectedNode = (ItTreeNode) projectsTree.getLastSelectedPathComponent(); if (treeRoot.getChildCount() == 1) { saveMenuItem.setEnabled(true); saveAsMenuItem.setEnabled(true); } else { saveMenuItem.setEnabled(false); saveAsMenuItem.setEnabled(false); } if (selectedNode != null) { if (selectedNode != treeRoot) { saveMenuItem.setEnabled(true); saveAsMenuItem.setEnabled(true); Element selected = selectedNode.getData(); if (selected.getName().equals("repositoryDiagram")) { setDiagramRespository(selected); setTypeDiagram(0); } if (selected.getName().equals("objectDiagram")) { setObjectDiagram(selected); setTypeDiagram(1); } if (selected != null) { propertiesPane.showProperties(selectedNode, projectsTree); } else { propertiesPane.setNoSelection(); } } else { propertiesPane.setNoSelection(); } } } }); projectsTree.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent e) { if (e.getClickCount() == 2) { TreePath path = projectsTree.getPathForLocation(e.getX(), e.getY()); if (path != null && projectsTree.getLastSelectedPathComponent() != projectsTree.getModel() .getRoot()) { ItTreeNode selectedNode = (ItTreeNode) projectsTree.getLastSelectedPathComponent(); String projectType = selectedNode.getData().getDocument().getRootElement().getName(); //check if this is a UML project if (projectType.equals("project")) { //Diagrams if (selectedNode.getLevel() == 2) { if (!selectedNode.getData().getName().equals("problem") && !selectedNode.getData().getName().equals("domain")) { openDiagramAction.actionPerformed(null); } } //Planning Problems else if (selectedNode.getData().getName().equals("objectDiagram") || selectedNode.getData().getName().equals("repositoryDiagram")) { openDiagramAction.actionPerformed(null); } } //check if this is a PDDL project else if (projectType.equals("pddlproject")) { //open pddl text for edit } } } } public void mouseReleased(java.awt.event.MouseEvent e) {// this is for Windows if (e.isPopupTrigger()) { TreePath path = projectsTree.getPathForLocation(e.getX(), e.getY()); if (path != null) { projectsTree.setSelectionPath(path); getTreePopupMenu().show(projectsTree, e.getX(), e.getY()); } } } public void mousePressed(java.awt.event.MouseEvent e) {// this is for Linux if (e.isPopupTrigger()) { TreePath path = projectsTree.getPathForLocation(e.getX(), e.getY()); if (path != null) { projectsTree.setSelectionPath(path); getTreePopupMenu().show(projectsTree, e.getX(), e.getY()); } } } }); projectsTree.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (projectsTree.getLastSelectedPathComponent() != projectsTree.getModel().getRoot()) { ItTreeNode selectedNode = (ItTreeNode) projectsTree.getLastSelectedPathComponent(); if ((selectedNode.getLevel() == 2 && !selectedNode.getData().getName().equals("domain")) || selectedNode.getData().getName().equals("repositoryDiagram") || selectedNode.getData().getName().equals("objectDiagram")) { openDiagramAction.actionPerformed(null); } } } } }); projectsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); } return projectsTree; }
From source file:src.gui.ItSIMPLE.java
/** * @return the planTreeFramePanel//from ww w . j av a2 s . co 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 .ja 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 w w . ja v a2 s.c o 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.pmd.util.designer.Designer.java
private JComponent createASTPanel() { astTreeWidget.setCellRenderer(createNoImageTreeCellRenderer()); TreeSelectionModel model = astTreeWidget.getSelectionModel(); model.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); model.addTreeSelectionListener(new SymbolTableListener()); model.addTreeSelectionListener(new CodeHighlightListener()); return new JScrollPane(astTreeWidget); }
From source file:net.team2xh.crt.gui.entities.EntityTree.java
public EntityTree() { setLayout(new BorderLayout()); add(tree, BorderLayout.CENTER); add(properties, BorderLayout.PAGE_END); tree.getVerticalScrollBar().setUnitIncrement(16); tree.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setPopupAllowed(false);//from w w w .j a va2 s.c o m // ((JViewport) tree.getComponent(0)).getComponent(0).setForeground(Color.white); }
From source file:org.apache.jmeter.visualizers.ViewResultsFullVisualizer.java
private synchronized Component createLeftPanel() { SampleResult rootSampleResult = new SampleResult(); rootSampleResult.setSampleLabel("Root"); rootSampleResult.setSuccessful(true); root = new SearchableTreeNode(rootSampleResult, null); treeModel = new DefaultTreeModel(root); jTree = new JTree(treeModel); jTree.setCellRenderer(new ResultsNodeRenderer()); jTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); jTree.addTreeSelectionListener(this); jTree.setRootVisible(false);/*from w w w . java2s.c om*/ jTree.setShowsRootHandles(true); JScrollPane treePane = new JScrollPane(jTree); treePane.setPreferredSize(new Dimension(200, 300)); VerticalPanel leftPane = new VerticalPanel(); leftPane.add(treePane, BorderLayout.CENTER); leftPane.add(createComboRender(), BorderLayout.NORTH); autoScrollCB = new JCheckBox(JMeterUtils.getResString("view_results_autoscroll")); // $NON-NLS-1$ autoScrollCB.setSelected(false); autoScrollCB.addItemListener(this); leftPane.add(autoScrollCB, BorderLayout.SOUTH); return leftPane; }
From source file:org.feistymeow.dragdrop.dragdrop_tree_test.java
public dragdrop_tree_test(String startPath) { super("dragdrop_test"); // create the tree, configure it to show our hashtable nodes, and put it in // a scroll pane. larch = new DraggableDroppableTree(startPath); DefaultTreeModel treeModel = (DefaultTreeModel) larch.getModel(); larch.setCellRenderer(new CustomCellRenderer()); TreeSelectionModel selmod = new DefaultTreeSelectionModel(); selmod.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); larch.setSelectionModel(selmod);/*from www . ja v a 2 s. c om*/ larch.addTreeSelectionListener(this); JScrollPane listScrollPane = new JScrollPane(larch); // get the files that live in the specified directory. String dirName = startPath + "/"; // make sure we think of it as a // directory. String filelist[] = new File(dirName).list(); MutableTreeNode root_node = (MutableTreeNode) treeModel.getRoot(); if (root_node == null) { logger.error("something is not right about tree. has null root."); System.exit(1); } // load up the tree with the files in the directory they passed. for (int i = 0; i < filelist.length; i++) { String thisFileSt = dirName + filelist[i]; File thisFile = new File(thisFileSt); // skip directories for now. if (thisFile.isDirectory()) continue; // skip dot files. if (filelist[i].startsWith(".")) continue; try { // need to trap exceptions from the URI/URL functions. DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(makeNode(thisFile.getName(), thisFile.toURI().toURL().toString(), thisFile.getAbsolutePath())); treeModel.insertNodeInto(newNode, root_node, root_node.getChildCount()); } catch (java.net.MalformedURLException e) { logger.warn("caught an exception while trying to process path: " + thisFile.getAbsolutePath()); } } // set our status bar to have the current path info. fileName = new JTextField(50); // select the root. larch.setSelectionPath(larch.getPathForRow(0)); // pop out all the nodes. larch.expandAll(); // Create a panel that uses FlowLayout (the default). JPanel buttonPane = new JPanel(); buttonPane.add(fileName); Container contentPane = getContentPane(); contentPane.add(listScrollPane, BorderLayout.CENTER); contentPane.add(buttonPane, BorderLayout.NORTH); }
From source file:org.fhaes.gui.AnalysisResultsPanel.java
/** * Set up the AnalysisResults GUI//from w w w .ja va 2 s.co m */ private void initGUI() { setLayout(new BorderLayout(0, 0)); if (Platform.isOSX()) setBackground(MainWindow.MAC_BACKGROUND_COLOR); ImageIcon iconMultipleTables = Builder.getImageIcon("multipletables16.png"); ImageIcon iconTable = Builder.getImageIcon("table16.png"); // ImageIcon iconChart = Builder.getImageIcon("chart16.png"); // Categories rootNode = new FHAESCategoryTreeNode("FHAES analysis results"); categoryGeneral = new FHAESCategoryTreeNode("Descriptive summaries", Builder.getImageIcon("interval16.png")); categoryInterval = new FHAESCategoryTreeNode("Interval analysis", Builder.getImageIcon("interval16.png")); categorySeasonality = new FHAESCategoryTreeNode("Seasonality", Builder.getImageIcon("seasonality16.png")); categoryBinarySummaryMatrices = new FHAESCategoryTreeNode("Binary summary matrices", Builder.getImageIcon("matrix16.png")); categoryBinaryMatrices = new FHAESCategoryTreeNode("Binary comparison matrices", Builder.getImageIcon("matrix16.png")); categorySimMatrices = new FHAESCategoryTreeNode("Similarity matrices", Builder.getImageIcon("matrix16.png")); categoryDisSimMatrices = new FHAESCategoryTreeNode("Dissimilarity matrices", Builder.getImageIcon("matrix16.png")); // Menu actions // Results itemJaccard = new FHAESResultTreeNode(FHAESResult.JACCARD_SIMILARITY_MATRIX, iconMultipleTables); itemJaccard.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(SJACFile, new CSVFileFilter()); } }); itemCohen = new FHAESResultTreeNode(FHAESResult.COHEN_SIMILARITITY_MATRIX, iconMultipleTables); itemCohen.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(SCOHFile, new CSVFileFilter()); } }); itemJaccardD = new FHAESResultTreeNode(FHAESResult.JACCARD_SIMILARITY_MATRIX_D, iconMultipleTables); itemJaccardD.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(DSJACFile, new CSVFileFilter()); } }); itemCohenD = new FHAESResultTreeNode(FHAESResult.COHEN_SIMILARITITY_MATRIX_D, iconMultipleTables); itemCohenD.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(DSCOHFile, new CSVFileFilter()); } }); itemIntervalSummary = new FHAESResultTreeNode(FHAESResult.INTERVAL_SUMMARY, iconMultipleTables); itemIntervalSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(intervalsSummaryFile, new CSVFileFilter()); } }); itemExceedence = new FHAESResultTreeNode(FHAESResult.INTERVAL_EXCEEDENCE_TABLE, iconMultipleTables); itemExceedence.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(intervalsExceedenceFile, new CSVFileFilter()); } }); itemSeasonalitySummary = new FHAESResultTreeNode(FHAESResult.SEASONALITY_SUMMARY, iconMultipleTables); itemSeasonalitySummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(seasonalitySummaryFile, new CSVFileFilter()); } }); itemBin00 = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_00, iconMultipleTables); itemBin00.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(bin00File, new CSVFileFilter()); } }); itemBin01 = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_01, iconMultipleTables); itemBin01.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(bin01File, new CSVFileFilter()); } }); itemBin10 = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_10, iconMultipleTables); itemBin10.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(bin10File, new CSVFileFilter()); } }); itemBin11 = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_11, iconMultipleTables); itemBin11.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(bin11File, new CSVFileFilter()); } }); itemBinSum = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_SUM, iconMultipleTables); itemBinSum.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(binSumFile, new CSVFileFilter()); } }); itemBinSiteSummary = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_SITE, iconMultipleTables); itemBinSiteSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(siteSummaryFile, new CSVFileFilter()); } }); itemBinSiteSummary.addAction(new FHAESAction("Export to shapefile", "formatshp.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { new ShapeFileDialog(App.mainFrame, fhm); } }); itemBinTreeSummary = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_TREE, iconMultipleTables); itemBinTreeSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(treeSummaryFile, new CSVFileFilter()); } }); itemNTP = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_NTP, iconMultipleTables); itemNTP.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(NTPFile, new CSVFileFilter()); } }); this.itemGeneralSummary = new FHAESResultTreeNode(FHAESResult.GENERAL_SUMMARY, iconMultipleTables); itemGeneralSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(generalSummaryFile, new CSVFileFilter()); } }); this.itemSingleFileSummary = new FHAESResultTreeNode(FHAESResult.SINGLE_FILE_SUMMARY, iconTable); itemSingleFileSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(singleFileSummaryFile, new CSVFileFilter()); } }); this.itemSingleEventSummary = new FHAESResultTreeNode(FHAESResult.SINGLE_EVENT_SUMMARY, iconTable); itemSingleEventSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { saveFileToDisk(singleEventSummaryFile, new CSVFileFilter()); } }); // Add results to categories categoryGeneral.add(itemGeneralSummary); categoryGeneral.add(itemSingleFileSummary); categoryGeneral.add(itemSingleEventSummary); categorySimMatrices.add(itemJaccard); categorySimMatrices.add(itemCohen); categoryDisSimMatrices.add(itemJaccardD); categoryDisSimMatrices.add(itemCohenD); categoryInterval.add(itemIntervalSummary); categoryInterval.add(itemExceedence); categorySeasonality.add(itemSeasonalitySummary); categoryBinaryMatrices.add(itemBin11); categoryBinaryMatrices.add(itemBin01); categoryBinaryMatrices.add(itemBin10); categoryBinaryMatrices.add(itemBin00); categoryBinaryMatrices.add(itemBinSum); categoryBinarySummaryMatrices.add(itemBinSiteSummary); categoryBinarySummaryMatrices.add(itemBinTreeSummary); categoryBinarySummaryMatrices.add(itemNTP); // Add categories to root of tree rootNode.add(categoryGeneral); rootNode.add(categoryInterval); rootNode.add(categorySeasonality); rootNode.add(categoryBinarySummaryMatrices); rootNode.add(categoryBinaryMatrices); rootNode.add(categorySimMatrices); rootNode.add(categoryDisSimMatrices); treeModel = new DefaultTreeModel(rootNode); splitPane = new JSplitPane(); if (Platform.isOSX()) splitPane.setBackground(MainWindow.MAC_BACKGROUND_COLOR); splitPane.setResizeWeight(0.9); add(splitPane, BorderLayout.CENTER); JPanel panelTree = new JPanel(); splitPane.setRightComponent(panelTree); panelTree.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); panelTree.setLayout(new BorderLayout(0, 0)); // Build tree treeResults = new JTree(); panelTree.add(treeResults); treeResults.setModel(treeModel); treeResults.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); treeResults.setCellRenderer(new FHAESResultTreeRenderer()); pickResultPanel = new PickResultPanel(); runAnalysisPanel = new RunAnalysisPanel(); cards = new JPanel(); cl = new CardLayout(); cards.setLayout(cl); cards.add(pickResultPanel, PICKRESULTPANEL); cards.add(runAnalysisPanel, RUNANALYSIS); cards.add(emptyPanel, EMPTYPANEL); splitPane.setLeftComponent(cards); cl.show(cards, RUNANALYSIS); splitPaneResult = new JSplitPane(); splitPaneResult.setOneTouchExpandable(true); splitPaneResult.setOrientation(JSplitPane.VERTICAL_SPLIT); cards.add(splitPaneResult, RESULTSPANEL); panelResult = new JPanel(); panelResult.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panelResult.setLayout(new BorderLayout(0, 0)); goldFishPanel = new GoldFishPanel(); splitPaneResult.setRightComponent(goldFishPanel); // Build table scrollPane = new JScrollPane(); panelResult.add(scrollPane); table = new JXTable(); adapter = new JTableSpreadsheetByRowAdapter(table); table.setModel(new DefaultTableModel()); table.setHorizontalScrollEnabled(true); scrollPane.setViewportView(table); splitPaneResult.setLeftComponent(panelResult); // OSX Style hack if (Platform.isOSX()) panelResult.setBackground(MainWindow.MAC_BACKGROUND_COLOR); if (Platform.isOSX()) scrollPane.setBackground(MainWindow.MAC_BACKGROUND_COLOR); // Expand all nodes for (int i = 0; i < treeResults.getRowCount(); i++) { treeResults.expandRow(i); } treeResults.addTreeSelectionListener(this); treeResults.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { int x = e.getX(); int y = e.getY(); JTree tree = (JTree) e.getSource(); TreePath path = tree.getPathForLocation(x, y); if (path == null) return; if (!tree.isEnabled()) return; tree.setSelectionPath(path); Component mc = e.getComponent(); if (path != null && path.getLastPathComponent() instanceof FHAESResultTreeNode) { FHAESResultTreeNode node = (FHAESResultTreeNode) path.getLastPathComponent(); if (!node.isEnabled()) return; FHAESResultPopupMenu popupMenu = new FHAESResultPopupMenu(node.getArrayOfActions()); popupMenu.show(mc, e.getX(), e.getY()); } } } @Override public void mouseEntered(MouseEvent arg0) { } @Override public void mouseExited(MouseEvent arg0) { } @Override public void mousePressed(MouseEvent arg0) { } @Override public void mouseReleased(MouseEvent arg0) { } }); this.splitPaneResult.setDividerLocation(10000); this.splitPaneResult.setDividerSize(3); this.splitPaneResult.setResizeWeight(1); }