List of usage examples for javax.swing.tree DefaultTreeModel DefaultTreeModel
@ConstructorProperties({ "root" }) public DefaultTreeModel(TreeNode root)
From source file:edu.harvard.i2b2.query.ui.ConceptTreePanel.java
/** * This method is called from within the constructor to initialize the form. *//*from ww w . ja va 2 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:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * @param actionableTree//w w w. java 2 s .co m */ public void print(final JTree actionableTree) { /*if (true) { PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(OrientationRequested.LANDSCAPE); aset.add(new Copies(2)); aset.add(new JobName("My job", null)); // Create a print job PrinterJob pj = PrinterJob.getPrinterJob(); pj.setPrintable(this); // locate a print service that can handle the request PrintService[] services = PrinterJob.lookupPrintServices(); if (services.length > 0) { System.out.println("selected printer " + services[0].getName()); try { pj.setPrintService(services[0]); pj.pageDialog(aset); if(pj.printDialog(aset)) { pj.print(aset); } } catch (PrinterException pe) { System.err.println(pe); } } return; }*/ DefaultMutableTreeNode clonedTree = GhostActionableTree .makeDeepCopy((DefaultMutableTreeNode) actionableTree.getModel().getRoot()); GhostActionableTree printTree = new GhostActionableTree(this, new DefaultTreeModel(clonedTree)); printTree.setRowHeight(ROW_HEIGHT); //printTree.setEditable(false); //printTree.setVisibleRowCount(15); ContainerTreeRenderer renderer = new ContainerTreeRenderer(null, false, false); renderer.setBGColor(Color.WHITE); renderer.setFont(getFont().deriveFont(8.0f)); //renderer.setLeafIcon(IconManager.getIcon(CollectionObject.class.getSimpleName(), IconManager.IconSize.Std32)); //renderer.setVerticalTextPosition(SwingConstants.CENTER); printTree.setCellRenderer(renderer); for (int row = 0; row < printTree.getRowCount(); row++) { printTree.expandRow(row); } PrintablePanel p = new PrintablePanel(new BorderLayout(), printTree); p.add(printTree, BorderLayout.CENTER); PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); //PrinterResolution pr = new PrinterResolution(300, 300, PrinterResolution.DPI); //MediaPrintableArea mpa = new MediaPrintableArea(8,21, 210-16, 296-42, MediaPrintableArea.MM); //aset.add( MediaSizeName.IS); //aset.add( pr ); //aset.add( mpa ); aset.add(new Copies(1)); aset.add(OrientationRequested.PORTRAIT); aset.add(PrintQuality.HIGH); PrinterJob job = PrinterJob.getPrinterJob(); /*PageFormat pageFormat = job.defaultPage(); Paper paper = pageFormat.getPaper(); paper.setSize(pageFormat.getWidth(), pageFormat.getHeight()); paper.setImageableArea( 0, 0, pageFormat.getWidth(), pageFormat.getHeight() ); //aset.add( Fidelity.FIDELITY_TRUE ); pageFormat.setPaper(paper); Book book = new Book(); book.append(p, pageFormat, 1); job.setPageable(book);*/ job.setPrintable(p); boolean ok = job.printDialog(); if (ok) { try { job.print(aset); } catch (PrinterException ex) { ex.printStackTrace(); /* The job did not successfully complete */ } } }
From source file:it.cnr.icar.eric.client.ui.swing.graph.JBGraph.java
/** * DOCUMENT ME!//from ww w . j av a 2s .c o m * * @return DOCUMENT ME! */ public JToolBar createToolBar() { JButton button = null; JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false); //TODO: SwingBoost: Localize this TreeNode tempTreeNode = new DefaultMutableTreeNode("loading object types..."); objectTypeCombo = new it.cnr.icar.eric.client.ui.swing.TreeCombo(new DefaultTreeModel(tempTreeNode)); toolbar.add(objectTypeCombo); // use a SwingWorker to get the real model, since it might not have been initialized yet final SwingWorker worker = new SwingWorker(this) { public Object doNonUILogic() { ConceptsTreeModel objectTypesTreeModel = BusinessQueryPanel.getObjectTypesTreeModel(); return objectTypesTreeModel; } public void doUIUpdateLogic() { ConceptsTreeModel objectTypesTreeModel = (ConceptsTreeModel) get(); objectTypeCombo.setModel(objectTypesTreeModel); } }; worker.start(); // Insert URL insertUrl = getClass().getClassLoader().getResource("icons/insert.gif"); ImageIcon insertIcon = new ImageIcon(insertUrl); button = toolbar.add(new AbstractAction("", insertIcon) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { insert(new Point(10, 10)); } }); button.setText(""); //an icon-only button button.setToolTipText("Insert"); // Toggle Connect Mode URL connectUrl = getClass().getClassLoader().getResource("icons/connecton.gif"); ImageIcon connectIcon = new ImageIcon(connectUrl); button = toolbar.add(new AbstractAction("", connectIcon) { /** * */ private static final long serialVersionUID = 657528648199915209L; public void actionPerformed(ActionEvent e) { setPortsVisible(!isPortsVisible()); URL connectUrl; if (isPortsVisible()) { connectUrl = getClass().getClassLoader().getResource("icons/connecton.gif"); } else { connectUrl = getClass().getClassLoader().getResource("icons/connectoff.gif"); } ImageIcon connectIcon = new ImageIcon(connectUrl); putValue(SMALL_ICON, connectIcon); } }); button.setText(""); //an icon-only button button.setToolTipText("Toggle Connect Mode"); // Undo toolbar.addSeparator(); URL undoUrl = getClass().getClassLoader().getResource("icons/undo.gif"); ImageIcon undoIcon = new ImageIcon(undoUrl); undo = new AbstractAction("", undoIcon) { /** * */ private static final long serialVersionUID = -740055667372297781L; public void actionPerformed(ActionEvent e) { undo(); } }; undo.setEnabled(false); button = toolbar.add(undo); button.setText(""); //an icon-only button button.setToolTipText("Undo"); // Redo URL redoUrl = getClass().getClassLoader().getResource("icons/redo.gif"); ImageIcon redoIcon = new ImageIcon(redoUrl); redo = new AbstractAction("", redoIcon) { /** * */ private static final long serialVersionUID = 5021485220988522968L; public void actionPerformed(ActionEvent e) { redo(); } }; redo.setEnabled(false); button = toolbar.add(redo); button.setText(""); //an icon-only button button.setToolTipText("Redo"); // // Edit Block // toolbar.addSeparator(); Action action; URL url; // Copy action = TransferHandler.getCopyAction(); url = getClass().getClassLoader().getResource("icons/copy.gif"); action.putValue(Action.SMALL_ICON, new ImageIcon(url)); //Commented out until we can figure out how to assign new id to copied objects //button = toolbar.add(copy = new EventRedirector(action)); button.setText(""); //an icon-only button button.setToolTipText("Copy"); // Paste action = TransferHandler.getPasteAction(); url = getClass().getClassLoader().getResource("icons/paste.gif"); action.putValue(Action.SMALL_ICON, new ImageIcon(url)); //Commented out until we can figure out how to assign new id to copied objects //button = toolbar.add(paste = new EventRedirector(action)); button.setText(""); //an icon-only button button.setToolTipText("Paste"); // Cut action = TransferHandler.getCutAction(); url = getClass().getClassLoader().getResource("icons/cut.gif"); action.putValue(Action.SMALL_ICON, new ImageIcon(url)); //Commented out until we can figure out how to assign new id to copied objects //button = toolbar.add(cut = new EventRedirector(action)); button.setText(""); //an icon-only button button.setToolTipText("Cut"); // Remove URL removeUrl = getClass().getClassLoader().getResource("icons/delete.gif"); ImageIcon removeIcon = new ImageIcon(removeUrl); remove = new AbstractAction("", removeIcon) { /** * */ private static final long serialVersionUID = 6889927067487680474L; public void actionPerformed(ActionEvent e) { if (!isSelectionEmpty()) { Object[] cells = getSelectionCells(); cells = getDescendants(cells); getModel().remove(cells); //Remove entry from map of cells on the graph for (int i = 0; i < cells.length; i++) { Object cell = cells[i]; if (cell instanceof JBGraphCell) { RegistryObject ro = ((JBGraphCell) cell).getRegistryObject(); registryObjectToCellMap.remove(ro); } } } } }; remove.setEnabled(false); button = toolbar.add(remove); button.setText(""); //an icon-only button button.setToolTipText(resourceBundle.getString("menu.graphPanel.removeFromView")); // Zoom Std toolbar.addSeparator(); URL zoomUrl = getClass().getClassLoader().getResource("icons/zoom.gif"); ImageIcon zoomIcon = new ImageIcon(zoomUrl); button = toolbar.add(new AbstractAction("", zoomIcon) { /** * */ private static final long serialVersionUID = -4404610379022823602L; public void actionPerformed(ActionEvent e) { setScale(1.0); } }); button.setText(""); //an icon-only button button.setToolTipText("Zoom"); // Zoom In URL zoomInUrl = getClass().getClassLoader().getResource("icons/zoomin.gif"); ImageIcon zoomInIcon = new ImageIcon(zoomInUrl); button = toolbar.add(new AbstractAction("", zoomInIcon) { /** * */ private static final long serialVersionUID = 6782766891458235321L; public void actionPerformed(ActionEvent e) { setScale(2 * getScale()); } }); button.setText(""); //an icon-only button button.setToolTipText("Zoom In"); // Zoom Out URL zoomOutUrl = getClass().getClassLoader().getResource("icons/zoomout.gif"); ImageIcon zoomOutIcon = new ImageIcon(zoomOutUrl); button = toolbar.add(new AbstractAction("", zoomOutIcon) { /** * */ private static final long serialVersionUID = -5480242207934335070L; public void actionPerformed(ActionEvent e) { setScale(getScale() / 2); } }); button.setText(""); //an icon-only button button.setToolTipText("Zoom Out"); // Group /* toolbar.addSeparator(); URL groupUrl = getClass().getClassLoader().getResource("icons/group.gif"); ImageIcon groupIcon = new ImageIcon(groupUrl); group = new AbstractAction("", groupIcon) { public void actionPerformed(ActionEvent e) { group(getSelectionCells()); } }; group.setEnabled(false); //button = toolbar.add(group); button.setText(""); //an icon-only button button.setToolTipText("Group"); // Ungroup URL ungroupUrl = getClass().getClassLoader().getResource("icons/ungroup.gif"); ImageIcon ungroupIcon = new ImageIcon(ungroupUrl); ungroup = new AbstractAction("", ungroupIcon) { public void actionPerformed(ActionEvent e) { ungroup(getSelectionCells()); } }; ungroup.setEnabled(false); //button = toolbar.add(ungroup); button.setText(""); //an icon-only button button.setToolTipText("Ungroup"); */ // To Front toolbar.addSeparator(); URL toFrontUrl = getClass().getClassLoader().getResource("icons/tofront.gif"); ImageIcon toFrontIcon = new ImageIcon(toFrontUrl); tofront = new AbstractAction("", toFrontIcon) { /** * */ private static final long serialVersionUID = -4901428890590828561L; public void actionPerformed(ActionEvent e) { if (!isSelectionEmpty()) { toFront(getSelectionCells()); } } }; tofront.setEnabled(false); button = toolbar.add(tofront); button.setText(""); //an icon-only button button.setToolTipText("To Front"); // To Back URL toBackUrl = getClass().getClassLoader().getResource("icons/toback.gif"); ImageIcon toBackIcon = new ImageIcon(toBackUrl); toback = new AbstractAction("", toBackIcon) { /** * */ private static final long serialVersionUID = -5942025518651424307L; public void actionPerformed(ActionEvent e) { if (!isSelectionEmpty()) { toBack(getSelectionCells()); } } }; toback.setEnabled(false); button = toolbar.add(toback); button.setText(""); //an icon-only button button.setToolTipText("To Back"); return toolbar; }
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 www .jav a2 s . c o m */ 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 ww. ja v a2s . c o 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:it.isislab.dmason.util.SystemManagement.Master.thrower.DMasonMaster.java
private void initComponents() { menuBar1 = new JMenuBar(); jMenuFile = new JMenu(); //menuItemOpen = new JMenuItem(); menuItemExit = new JMenuItem(); jMenuAbout = new JMenu(); menuItemInfo = new JMenuItem(); menuItemHelp = new JMenuItem(); panelMain = new JPanel(); jPanelContainerConnection = new JPanel(); jPanelConnection = new JPanel(); jLabelAddress = new JLabel(); textFieldAddress = new JTextField(); jLabelPort = new JLabel(); textFieldPort = new JTextField(); refreshServerLabel = new JLabel(); buttonRefreshServerLabel = new JButton(); jPanelContainerSettings = new JPanel(); jPanelSetDistribution = new JPanel(); jPanelSettings = new JPanel(); jLabelHorizontal = new JLabel(); jLabelSquare = new JLabel(); jLabelMaxDistance = new JLabel(); jLabelWidth = new JLabel(); jLabelInsertSteps = new JLabel(); textFieldMaxDistance = new JTextField(); textFieldWidth = new JTextField(); jLabelHeight = new JLabel(); textFieldHeight = new JTextField(); jLabelAgents = new JLabel(); textFieldAgents = new JTextField(); textFieldColumns = new JTextField(); textFieldRows = new JTextField(); textFieldSteps = new JTextField(); jLabelChooseSimulation = new JLabel(); jComboBoxChooseSimulation = new JComboBox(); jComboBoxNumRegionXPeer = new JComboBox(); jPanelContainerTabbedPane = new JPanel(); tabbedPane2 = new JTabbedPane(); jPanelDefault = new JPanel(); jPanelSimulation = new ModelPanel(tabbedPane2); labelSimulationConfigSet = new JLabel(); labelRegionsResume = new JLabel(); labelNumOfPeerResume = new JLabel(); labelRegForPeerResume = new JLabel(); labelWriteReg = new JLabel(); labelWriteNumOfPeer = new JLabel(); labelWriteRegForPeer = new JLabel(); labelWidthRegion = new JLabel(); labelheightRegion = new JLabel(); labelDistrMode = new JLabel(); labelWriteRegWidth = new JLabel(); labelWriteRegHeight = new JLabel(); labelWriteDistrMode = new JLabel(); graphicONcheckBox2 = new JCheckBox(); jPanelSetButton = new JPanel(); buttonSetConfigDefault = new JButton(); jPanelAdvanced = new JPanel(); jPanelAdvancedMain = new JPanel(); peerInfoStatus = new JDesktopPane(); internalFrame1 = new JInternalFrame(); architectureLabel = new JTextArea(); architectureLabel.setBackground(Color.BLACK); architectureLabel.setForeground(Color.GREEN); architectureLabel.setEditable(false); advancedConfirmBut = new JLabel(); graphicONcheckBox = new JCheckBox(); jCheckBoxLoadBalancing = new JCheckBox("Load Balancing", false); jCheckBoxLoadBalancing.setEnabled(true); jCheckBoxLoadBalancing.setSelected(false); jCheckBoxMPI = new JCheckBox("Enable MPI", false); jCheckBoxMPI.setEnabled(true);//from w w w.ja va2 s.c o m jCheckBoxMPI.setSelected(false); scrollPaneTree = new JScrollPane(); tree1 = new JTree(); buttonSetConfigAdvanced = new JButton(); jLabelPlayButton = new JLabel(); jLabelPauseButton = new JLabel(); jPanelNumStep = new JPanel(); jLabelStep = new JLabel(); jLabelStep.setHorizontalAlignment(SwingConstants.LEFT); jLabelStopButton = new JLabel(); scrollPane1 = new JScrollPane(); peerInfoStatus1 = new JDesktopPane(); root = new DefaultMutableTreeNode("Simulation"); ButtonGroup b = new ButtonGroup(); ip = textFieldAddress.getText(); port = textFieldPort.getText(); menuBar1 = new JMenuBar(); jMenuFile = new JMenu(); menuItemExit = new JMenuItem(); menuNewSim = new JMenuItem(); jMenuAbout = new JMenu(); menuItemInfo = new JMenuItem(); menuItemHelp = new JMenuItem(); scrollPane3 = new JScrollPane(); scrollPane4 = new JScrollPane(); notifyArea = new JTextArea(); panelConsole = new JPanel(); buttonSetConfigDefault2 = new JButton(); jPanelSetButton2 = new JPanel(); graphicONcheckBox = new JCheckBox(); graphicONcheckBox.setEnabled(false); graphicONcheckBox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { withGui = graphicONcheckBox.isSelected(); } }); jLabelChooseSimulation = new JLabel(); jComboBoxChooseSimulation = new JComboBox(); loadSimulation(); selectedSimulation = ((SimComboEntry) jComboBoxChooseSimulation.getSelectedItem()).fullSimName; jPanelSimulation.updateHTML(selectedSimulation); jComboBoxChooseSimulation.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // Prevent executing listener's actions two times if (e.getStateChange() != ItemEvent.SELECTED) return; selectedSimulation = ((SimComboEntry) jComboBoxChooseSimulation.getSelectedItem()).fullSimName; jPanelSimulation.updateHTML(selectedSimulation); isThin = isThinSimulation(selectedSimulation); jCheckBoxLoadBalancing.setSelected(false); jCheckBoxLoadBalancing.setEnabled(!isThin); initializeDefaultLabel(); } }); /*for(int i=2;i<100;i++) jComboRegions.addItem(i);*/ buttonRefreshServerLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { connect(); } }); refreshServerLabel.addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent arg0) { if (starter.isConnected()) starter.execute("restart"); else JOptionPane.showMessageDialog(null, "Not connected to the Server!"); } @Override public void mousePressed(MouseEvent arg0) { } @Override public void mouseExited(MouseEvent arg0) { } @Override public void mouseEntered(MouseEvent arg0) { } @Override public void mouseClicked(MouseEvent arg0) { } }); jCheckBoxLoadBalancing.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (!isHorizontal) { if (jCheckBoxLoadBalancing.isSelected()) labelWriteDistrMode.setText("SQUARE BALANCED MODE"); else labelWriteDistrMode.setText("SQUARE MODE"); } if (isHorizontal) { if (jCheckBoxLoadBalancing.isSelected()) labelWriteDistrMode.setText("HORIZONTAL BALANCED MODE"); else labelWriteDistrMode.setText("HORIZONTAL MODE"); } } }); buttonSetConfigDefault2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (initializeDefaultLabel()) submitCustomizeMode(); else JOptionPane.showMessageDialog(null, "To start a simulation must fill in all fields...!"); } }); buttonSetConfigDefault.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (initializeDefaultLabel()) submitDefaultMode(); else JOptionPane.showMessageDialog(null, "To start a simulation must fill in all fields...!"); } }); advancedConfirmBut.addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent arg0) { confirm(); res -= (Integer) jComboBoxNumRegionXPeer.getSelectedItem(); withGui = graphicONcheckBox.isSelected(); jComboBoxNumRegionXPeer.removeAllItems(); graphicONcheckBox.setSelected(false); for (int i = 1; i <= res; i++) jComboBoxNumRegionXPeer.addItem(i); JOptionPane.showMessageDialog(null, "Region assigned !"); } @Override public void mousePressed(MouseEvent arg0) { } @Override public void mouseExited(MouseEvent arg0) { } @Override public void mouseEntered(MouseEvent arg0) { } @Override public void mouseClicked(MouseEvent arg0) { } }); //======== this ======== Container contentPane = getContentPane(); //======== menuBar1 ======== { { jMenuFile.setText(" File "); menuNewSim.setText("New "); menuNewSim.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { me.dispose(); me = null; DMasonMaster p = new DMasonMaster(); p.setVisible(true); } }); jMenuFile.add(menuNewSim); //---- menuItemExit ---- menuItemExit.setText("Exit"); menuItemExit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { me.dispose(); } }); jMenuFile.add(menuItemExit); } menuBar1.add(jMenuFile); menuBar1.add(getJMenuSystem()); //======== jMenuAbout ======== { jMenuAbout.setText(" ? "); //---- menuItemInfo ---- menuItemInfo.setText("Info"); menuItemInfo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, Release.PRODUCT_RELEASE, "Info", 1); } }); jMenuAbout.add(menuItemInfo); //---- menuItenHelp ---- menuItemHelp.setText("Help"); menuItemHelp.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { try { java.net.URI uri = new java.net.URI( "http://isis.dia.unisa.it/projects/it.isislab.dmason/"); try { java.awt.Desktop.getDesktop().browse(uri); } catch (IOException e) { e.printStackTrace(); } } catch (URISyntaxException e) { e.printStackTrace(); } } }); jMenuAbout.add(menuItemHelp); } menuBar1.add(jMenuAbout); } setJMenuBar(menuBar1); //======== panelMain ======== { //======== jPanelContainerConnection ======== { //======== jPanelConnection ======== { jPanelConnection.setBorder(new TitledBorder("Connection")); jPanelConnection.setPreferredSize(new Dimension(215, 125)); //---- jLabelAddress ---- jLabelAddress.setText("IP Address :"); //---- textFieldAddress ---- textFieldAddress.setText("127.0.0.1"); //---- jLabelPort ---- jLabelPort.setText("Port :"); //---- textFieldPort ---- textFieldPort.setText("61616"); //---- refreshServerLabel ---- refreshServerLabel.setIcon(new ImageIcon("resources/image/refresh.png")); //---- buttonRefreshServerLabel ---- buttonRefreshServerLabel.setText("OK"); JLabel lblStatus = new JLabel("Communication Server status :"); lblStatusIcon = new JLabel(""); lblStatusIcon.setIcon(new ImageIcon("resources/image/status-down.png")); buttonActiveMQRestart = new JButton(""); buttonActiveMQRestart.setEnabled(false); buttonActiveMQRestart.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { notifyArea.append("ActiveMQ restarting...\n"); if (csManager.restartActiveMQ()) notifyArea.append("ActiveMQ restarted!\n"); checkCommunicationServerStatus(); } }); buttonActiveMQRestart.setMinimumSize(new Dimension(24, 24)); buttonActiveMQRestart.setMaximumSize(new Dimension(24, 24)); buttonActiveMQRestart.setPreferredSize(new Dimension(24, 24)); buttonActiveMQRestart.setIcon(new ImageIcon("resources/image/LH2 - Restart.png")); buttonActiveMQStart = new JButton(""); buttonActiveMQStart.setEnabled(false); buttonActiveMQStart.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { notifyArea.append("ActiveMQ starting...\n"); if (csManager.startActiveMQ()) notifyArea.append("ActiveMQ started!\n"); checkCommunicationServerStatus(); } }); buttonActiveMQStart.setPreferredSize(new Dimension(24, 24)); buttonActiveMQStart.setMinimumSize(new Dimension(24, 24)); buttonActiveMQStart.setMaximumSize(new Dimension(24, 24)); buttonActiveMQStart.setIcon(new ImageIcon("resources/image/LH2 - Shutdown.png")); buttonActiveMQStop = new JButton(""); buttonActiveMQStop.setEnabled(false); buttonActiveMQStop.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { notifyArea.append("ActiveMQ stopping...\n"); if (csManager.stopActiveMQ()) notifyArea.append("ActiveMQ stopped!\n"); checkCommunicationServerStatus(); } }); buttonActiveMQStop.setPreferredSize(new Dimension(24, 24)); buttonActiveMQStop.setMinimumSize(new Dimension(24, 24)); buttonActiveMQStop.setMaximumSize(new Dimension(24, 24)); buttonActiveMQStop.setIcon(new ImageIcon("resources/image/LH2 - Stop.png")); btnCheckPeers = new JButton("Check Peers"); btnCheckPeers.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { checkPeers(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); GroupLayout jPanelConnectionLayout = new GroupLayout(jPanelConnection); jPanelConnectionLayout.setHorizontalGroup(jPanelConnectionLayout .createParallelGroup(Alignment.LEADING) .addGroup(jPanelConnectionLayout.createSequentialGroup().addGroup(jPanelConnectionLayout .createParallelGroup(Alignment.LEADING) .addGroup(jPanelConnectionLayout.createSequentialGroup() .addGroup(jPanelConnectionLayout.createParallelGroup(Alignment.TRAILING) .addComponent(refreshServerLabel) .addGroup(jPanelConnectionLayout.createSequentialGroup() .addComponent(buttonActiveMQStart, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(buttonActiveMQRestart, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(buttonActiveMQStop, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(111).addComponent(jLabelAddress).addGap(18) .addComponent(textFieldAddress, GroupLayout.PREFERRED_SIZE, 91, GroupLayout.PREFERRED_SIZE) .addGap(18).addComponent(jLabelPort).addGap(18) .addComponent(textFieldPort, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE) .addGap(46).addComponent(buttonRefreshServerLabel))) .addGap(51).addComponent(btnCheckPeers)) .addGroup(jPanelConnectionLayout.createSequentialGroup().addComponent(lblStatus) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(lblStatusIcon))) .addContainerGap(71, Short.MAX_VALUE))); jPanelConnectionLayout.setVerticalGroup(jPanelConnectionLayout .createParallelGroup(Alignment.TRAILING) .addGroup(jPanelConnectionLayout.createSequentialGroup().addGroup(jPanelConnectionLayout .createParallelGroup(Alignment.LEADING) .addGroup(jPanelConnectionLayout.createSequentialGroup() .addGroup(jPanelConnectionLayout.createParallelGroup(Alignment.LEADING) .addComponent(lblStatus).addComponent(lblStatusIcon)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(jPanelConnectionLayout.createParallelGroup(Alignment.LEADING) .addComponent(buttonActiveMQRestart, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(buttonActiveMQStart, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(buttonActiveMQStop, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED, 1, Short.MAX_VALUE)) .addGroup(jPanelConnectionLayout.createSequentialGroup() .addContainerGap(18, Short.MAX_VALUE).addComponent(refreshServerLabel) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(jPanelConnectionLayout.createParallelGroup(Alignment.BASELINE) .addComponent(buttonRefreshServerLabel).addComponent(jLabelPort) .addComponent(textFieldPort, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE) .addComponent(jLabelAddress) .addComponent(textFieldAddress, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE) .addComponent(btnCheckPeers)))) .addGap(10))); jPanelConnectionLayout.linkSize(SwingConstants.HORIZONTAL, new Component[] { buttonActiveMQRestart, buttonActiveMQStart, buttonActiveMQStop }); jPanelConnection.setLayout(jPanelConnectionLayout); } GroupLayout jPanelContainerConnectionLayout = new GroupLayout(jPanelContainerConnection); jPanelContainerConnection.setLayout(jPanelContainerConnectionLayout); jPanelContainerConnectionLayout .setHorizontalGroup(jPanelContainerConnectionLayout.createParallelGroup() .addGroup(jPanelContainerConnectionLayout .createSequentialGroup().addContainerGap().addComponent(jPanelConnection, GroupLayout.PREFERRED_SIZE, 829, GroupLayout.PREFERRED_SIZE) .addContainerGap(153, Short.MAX_VALUE))); jPanelContainerConnectionLayout.setVerticalGroup( jPanelContainerConnectionLayout.createParallelGroup().addComponent(jPanelConnection, GroupLayout.PREFERRED_SIZE, 71, GroupLayout.PREFERRED_SIZE)); } //======== jPanelContainerSettings ======== { GroupLayout jPanelContainerSettingsLayout = new GroupLayout(jPanelContainerSettings); jPanelContainerSettings.setLayout(jPanelContainerSettingsLayout); jPanelContainerSettingsLayout.setHorizontalGroup( jPanelContainerSettingsLayout.createParallelGroup().addGap(0, 1, Short.MAX_VALUE)); jPanelContainerSettingsLayout.setVerticalGroup( jPanelContainerSettingsLayout.createParallelGroup().addGap(0, 481, Short.MAX_VALUE)); } //======== jPanelSetDistribution ======== { jPanelSetDistribution.setBorder(new TitledBorder("Settings")); //======== jPanelSettings ======== { //jLabelHorizontal.setIcon(new ImageIcon("it.isislab.dmason/resources/image/hori.png"))); //---- jLabelSquare ---- //jLabelSquare.setIcon(new ImageIcon("it.isislab.dmason/resources/image/square.png"))); //---- jLabelMaxDistance ---- jLabelMaxDistance.setText("MAX_DISTANCE :"); //---- jLabelWidth ---- jLabelWidth.setText("WIDTH :"); //---- jLabelInsertSteps ---- jLabelInsertSteps.setText("STEPS :"); //---- textFieldMaxDistance ---- textFieldMaxDistance.setText("1"); //---- textFieldWidth ---- textFieldWidth.setText("200"); //---- jLabelHeight ---- jLabelHeight.setText("HEIGHT :"); //---- textFieldHeight ---- textFieldHeight.setText("200"); //---- jLabelAgents ---- jLabelAgents.setText("AGENTS :"); //---- textFieldAgents ---- textFieldAgents.setText("15"); //---- textFieldSteps textFieldSteps.setText("100"); MouseListener textFieldMouseListener = new MouseListener() { @Override public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent e) { initializeDefaultLabel(); } @Override public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseClicked(MouseEvent e) { // TODO Auto-generated method stub } }; textFieldAgents.addMouseListener(textFieldMouseListener); textFieldAgents.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { char v = e.getKeyChar(); if (!(Character.isDigit(v)) || v == KeyEvent.VK_BACK_SPACE) { e.consume(); } if (textFieldAgents.getText().length() > 0) initializeDefaultLabel(); } @Override public void keyReleased(KeyEvent e) { //initializeDefaultLabel(); } @Override public void keyPressed(KeyEvent e) { } }); textFieldColumns.addMouseListener(textFieldMouseListener); textFieldColumns.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { // TODO Auto-generated method stub char v = e.getKeyChar(); if (!(Character.isDigit(v)) || v == KeyEvent.VK_BACK_SPACE) { e.consume(); } if (textFieldColumns.getText().length() > 0) initializeDefaultLabel(); } @Override public void keyReleased(KeyEvent e) { // TODO Auto-generated method stub } @Override public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub } }); textFieldMaxDistance.addMouseListener(textFieldMouseListener); textFieldMaxDistance.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { char v = e.getKeyChar(); if (!(Character.isDigit(v)) || v == KeyEvent.VK_BACK_SPACE) { e.consume(); } if (textFieldMaxDistance.getText().length() > 0) initializeDefaultLabel(); } @Override public void keyReleased(KeyEvent e) { //initializeDefaultLabel(); } @Override public void keyPressed(KeyEvent e) { } }); textFieldWidth.addMouseListener(textFieldMouseListener); textFieldWidth.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { char v = e.getKeyChar(); if (!(Character.isDigit(v)) || v == KeyEvent.VK_BACK_SPACE) { e.consume(); } if (textFieldWidth.getText().length() > 0) initializeDefaultLabel(); } @Override public void keyReleased(KeyEvent e) { //initializeDefaultLabel(); } @Override public void keyPressed(KeyEvent e) { } }); textFieldRows.addMouseListener(textFieldMouseListener); textFieldRows.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { char v = e.getKeyChar(); if (!(Character.isDigit(v)) || v == KeyEvent.VK_BACK_SPACE) { e.consume(); } if (textFieldRows.getText().length() > 0) initializeDefaultLabel(); } @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { } }); textFieldHeight.addMouseListener(textFieldMouseListener); textFieldHeight.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { char v = e.getKeyChar(); if (!(Character.isDigit(v)) || v == KeyEvent.VK_BACK_SPACE) { e.consume(); } if (textFieldHeight.getText().length() > 0) initializeDefaultLabel(); } @Override public void keyReleased(KeyEvent arg0) { //initializeDefaultLabel(); } @Override public void keyPressed(KeyEvent arg0) { } }); textFieldSteps.addMouseListener(textFieldMouseListener); textFieldSteps.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { char v = e.getKeyChar(); if (!(Character.isDigit(v)) || v == KeyEvent.VK_BACK_SPACE) { e.consume(); } if (textFieldSteps.getText().length() > 0) initializeDefaultLabel(); } @Override public void keyReleased(KeyEvent e) { // TODO Auto-generated method stub } @Override public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub } }); //---- jLabelChooseSimulation ---- jLabelChooseSimulation.setText("Choose your simulation:"); //---- jComboBoxChooseSimulation ---- jComboBoxChooseSimulation.setMaximumRowCount(10); JLabel lblRows = new JLabel("ROWS :"); JLabel lblColumns = new JLabel("COLUMNS :"); textFieldRows.setText("1"); textFieldRows.setEnabled(false); textFieldRows.setColumns(10); rows = Integer.parseInt(textFieldRows.getText()); textFieldColumns.setText("2"); textFieldColumns.setEnabled(false); textFieldColumns.setColumns(10); columns = Integer.parseInt(textFieldColumns.getText()); textFieldSteps.setText("100"); textFieldSteps.setEnabled(false); textFieldSteps.setColumns(10); steps = 100; GroupLayout jPanelSettingsLayout = new GroupLayout(jPanelSettings); jPanelSettingsLayout.setHorizontalGroup(jPanelSettingsLayout .createParallelGroup(Alignment.LEADING) .addGroup(jPanelSettingsLayout.createSequentialGroup().addGap(17) .addGroup(jPanelSettingsLayout.createParallelGroup(Alignment.LEADING) .addComponent(jLabelChooseSimulation, GroupLayout.PREFERRED_SIZE, 245, GroupLayout.PREFERRED_SIZE) .addGroup(jPanelSettingsLayout.createSequentialGroup().addGap(119) .addComponent(jLabelHorizontal)) .addComponent(jComboBoxChooseSimulation, GroupLayout.PREFERRED_SIZE, 214, GroupLayout.PREFERRED_SIZE) .addGroup(jPanelSettingsLayout.createSequentialGroup() .addGroup(jPanelSettingsLayout .createParallelGroup(Alignment.TRAILING) .addGroup(Alignment.LEADING, jPanelSettingsLayout .createSequentialGroup() .addGroup(jPanelSettingsLayout .createParallelGroup(Alignment.LEADING) .addComponent(lblRows, GroupLayout.PREFERRED_SIZE, 59, GroupLayout.PREFERRED_SIZE) .addComponent(lblColumns)) .addGap(60) .addGroup(jPanelSettingsLayout .createParallelGroup(Alignment.LEADING) .addComponent(jLabelSquare) .addComponent(textFieldColumns, GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE) .addComponent(textFieldRows, GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE))) .addGroup(Alignment.LEADING, jPanelSettingsLayout .createSequentialGroup() .addGroup(jPanelSettingsLayout .createParallelGroup(Alignment.LEADING) .addComponent(jLabelMaxDistance) .addComponent(jLabelWidth) .addComponent(jLabelHeight) .addComponent(jLabelAgents) .addComponent(jLabelInsertSteps) .addGap(132)) .addGroup(jPanelSettingsLayout .createParallelGroup(Alignment.LEADING) .addComponent(textFieldAgents, GroupLayout.PREFERRED_SIZE, 94, GroupLayout.PREFERRED_SIZE) .addComponent(textFieldHeight, GroupLayout.PREFERRED_SIZE, 94, GroupLayout.PREFERRED_SIZE) .addComponent(textFieldWidth, GroupLayout.PREFERRED_SIZE, 94, GroupLayout.PREFERRED_SIZE) .addComponent(textFieldMaxDistance, GroupLayout.PREFERRED_SIZE, 94, GroupLayout.PREFERRED_SIZE) .addComponent(textFieldSteps, GroupLayout.PREFERRED_SIZE, 94, GroupLayout.PREFERRED_SIZE) .addGap(20)))) .addGap(20))))); jPanelSettingsLayout.setVerticalGroup(jPanelSettingsLayout .createParallelGroup(Alignment.LEADING) .addGroup(jPanelSettingsLayout.createSequentialGroup().addContainerGap() .addComponent(jLabelHorizontal).addGap(41) .addGroup(jPanelSettingsLayout.createParallelGroup(Alignment.LEADING) .addComponent(jLabelSquare) .addGroup(jPanelSettingsLayout.createParallelGroup(Alignment.BASELINE) .addComponent(lblRows, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE) .addComponent(textFieldRows, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanelSettingsLayout.createParallelGroup(Alignment.BASELINE) .addComponent(textFieldColumns, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lblColumns)) .addGap(18) .addGroup(jPanelSettingsLayout.createParallelGroup(Alignment.BASELINE) .addComponent(jLabelMaxDistance).addComponent(textFieldMaxDistance, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(jPanelSettingsLayout.createParallelGroup(Alignment.BASELINE) .addComponent(jLabelWidth, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE) .addComponent(textFieldWidth, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)) .addGap(10) .addGroup(jPanelSettingsLayout.createParallelGroup(Alignment.BASELINE) .addComponent(jLabelHeight, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE) .addComponent(textFieldHeight, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(jPanelSettingsLayout.createParallelGroup(Alignment.BASELINE) .addComponent(jLabelAgents).addComponent(textFieldAgents, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) //.addGap(10) .addGroup(jPanelSettingsLayout.createParallelGroup(Alignment.BASELINE) .addComponent(jLabelInsertSteps, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE) .addComponent(textFieldSteps, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)) .addGap(35).addComponent(jLabelChooseSimulation) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(jComboBoxChooseSimulation, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(52))); jPanelSettings.setLayout(jPanelSettingsLayout); } //======== jPanelContainerTabbedPane ======== { //======== tabbedPane2 ======== { //======== jPanelDefault ======== { jPanelDefault.setBorder(new EtchedBorder()); jPanelDefault.setPreferredSize(new Dimension(350, 331)); //---- labelSimulationConfigSet ---- labelSimulationConfigSet.setText("Simulation Configuration Settings"); labelSimulationConfigSet.setFont(labelSimulationConfigSet.getFont().deriveFont( labelSimulationConfigSet.getFont().getStyle() | Font.BOLD, labelSimulationConfigSet.getFont().getSize() + 8f)); //---- labelRegionsResume ---- labelRegionsResume.setText("REGIONS :"); //---- labelNumOfPeerResume ---- labelNumOfPeerResume.setText("NUMBER OF PEERS :"); //---- labelRegForPeerResume ---- labelRegForPeerResume.setText("REGIONS FOR PEER :"); //---- labelWriteReg ---- labelWriteReg.setText("text"); //---- labelWriteNumOfPeer ---- labelWriteNumOfPeer.setText("text"); //---- labelWriteRegForPeer ---- labelWriteRegForPeer.setText("text"); //---- labelWidthRegion ---- labelWidthRegion.setText("REGION WIDTH :"); //---- labelheightRegion ---- labelheightRegion.setText("REGION HEIGHT :"); //---- labelDistrMode ---- labelDistrMode.setText("DISTRIBUTION MODE :"); //---- labelWriteRegWidth ---- labelWriteRegWidth.setText("text"); //---- labelWriteRegHeight ---- labelWriteRegHeight.setText("text"); //---- labelWriteDistrMode ---- labelWriteDistrMode.setText("text"); //---- graphicONcheckBox2 ---- graphicONcheckBox2.setText("Graphic ON"); //======== jPanelSetButton ======== { //---- buttonSetConfigDefault ---- buttonSetConfigDefault.setText("Set"); { jCheckBoxLoadBalancing.setText("Load Balancing"); } GroupLayout jPanelSetButtonLayout = new GroupLayout(jPanelSetButton); jPanelSetButton.setLayout(jPanelSetButtonLayout); jPanelSetButtonLayout.setVerticalGroup(jPanelSetButtonLayout.createSequentialGroup() .addGroup(jPanelSetButtonLayout.createParallelGroup().addGroup( GroupLayout.Alignment.TRAILING, jPanelSetButtonLayout.createSequentialGroup().addComponent( jCheckBoxMPI, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))) .addGroup(jPanelSetButtonLayout.createParallelGroup() .addGroup(GroupLayout.Alignment.LEADING, jPanelSetButtonLayout.createSequentialGroup().addComponent( jCheckBoxLoadBalancing, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) .addGroup(GroupLayout.Alignment.LEADING, jPanelSetButtonLayout .createSequentialGroup() .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE) .addComponent(buttonSetConfigDefault, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))) .addContainerGap()); jPanelSetButtonLayout.setHorizontalGroup(jPanelSetButtonLayout .createSequentialGroup() .addComponent(jCheckBoxMPI, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) .addContainerGap(0, 0) .addComponent(jCheckBoxLoadBalancing, GroupLayout.PREFERRED_SIZE, 114, GroupLayout.PREFERRED_SIZE) .addGap(0, 150, Short.MAX_VALUE).addComponent(buttonSetConfigDefault, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE) .addContainerGap(0, 0)); FlowLayout lsetbutt = new FlowLayout(); lsetbutt.addLayoutComponent("", jCheckBoxMPI); lsetbutt.addLayoutComponent("", jCheckBoxLoadBalancing); lsetbutt.addLayoutComponent("", buttonSetConfigDefault); jPanelSetButton.setLayout(lsetbutt); } GroupLayout jPanelDefaultLayout = new GroupLayout(jPanelDefault); jPanelDefaultLayout.setHorizontalGroup(jPanelDefaultLayout .createParallelGroup(Alignment.LEADING) .addGroup(jPanelDefaultLayout.createSequentialGroup().addContainerGap() .addGroup(jPanelDefaultLayout.createParallelGroup(Alignment.LEADING) .addComponent(labelSimulationConfigSet, GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE) .addGroup(jPanelDefaultLayout.createSequentialGroup().addGap(6) .addGroup(jPanelDefaultLayout .createParallelGroup(Alignment.LEADING) .addGroup(jPanelDefaultLayout .createSequentialGroup() .addGroup(jPanelDefaultLayout .createParallelGroup( Alignment.LEADING) .addComponent( labelNumOfPeerResume) .addComponent( labelRegForPeerResume) .addComponent(labelWidthRegion) .addComponent(labelheightRegion) .addComponent(labelDistrMode) .addComponent( labelRegionsResume)) .addPreferredGap( ComponentPlacement.RELATED, 218, Short.MAX_VALUE) .addGroup(jPanelDefaultLayout .createParallelGroup( Alignment.LEADING) .addComponent( labelWriteNumOfPeer, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE) .addComponent(labelWriteReg) .addComponent( labelWriteRegForPeer) .addComponent( labelWriteRegWidth) .addComponent( labelWriteRegHeight) .addComponent( labelWriteDistrMode)) .addGap(118)) .addComponent(graphicONcheckBox2)))) .addGap(211)) .addGroup(jPanelDefaultLayout.createSequentialGroup() .addComponent(jPanelSetButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap(23, Short.MAX_VALUE))); jPanelDefaultLayout.setVerticalGroup(jPanelDefaultLayout .createParallelGroup(Alignment.LEADING) .addGroup(jPanelDefaultLayout.createSequentialGroup().addContainerGap() .addComponent(labelSimulationConfigSet, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) .addGap(28) .addGroup(jPanelDefaultLayout.createParallelGroup(Alignment.TRAILING) .addGroup(jPanelDefaultLayout.createSequentialGroup() .addComponent(labelRegionsResume) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(labelNumOfPeerResume) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(labelRegForPeerResume).addGap(6) .addComponent(labelWidthRegion).addGap(6) .addComponent(labelheightRegion) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(labelDistrMode)) .addGroup(jPanelDefaultLayout.createSequentialGroup() .addComponent(labelWriteReg) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(labelWriteNumOfPeer) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(labelWriteRegForPeer).addGap(6) .addComponent(labelWriteRegWidth).addGap(6) .addComponent(labelWriteRegHeight) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(labelWriteDistrMode, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE) .addGap(8))) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(graphicONcheckBox2) .addPreferredGap(ComponentPlacement.RELATED, 82, Short.MAX_VALUE) .addComponent(jPanelSetButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))); jPanelDefault.setLayout(jPanelDefaultLayout); } tabbedPane2.addTab("Default", jPanelDefault); //======== jPanelSimulation ======== tabbedPane2.addTab("Simulation", jPanelSimulation); //======== End jPanelSimulation ======== //======== jPanelAdvanced ======== { jPanelAdvanced.setBorder(new EtchedBorder()); //======== jPanelAdvancedMain ======== { //======== scrollPaneTree ======== { //---- tree1 ---- tree1.setModel(new DefaultTreeModel(root)); DefaultTreeCellRenderer render = new DefaultTreeCellRenderer(); render.setOpenIcon(new ImageIcon("resources/image/network.png")); render.setLeafIcon(new ImageIcon("esource/image/computer.gif")); render.setClosedIcon(new ImageIcon("resources/image/network.png")); tree1.setCellRenderer(render); tree1.setRowHeight(25); scrollPaneTree.setViewportView(tree1); tree1.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent arg0) { if (arg0.getPath().getLastPathComponent().equals(root)) { jComboBoxNumRegionXPeer.setEnabled(true); advancedConfirmBut.setEnabled(true); graphicONcheckBox.setEnabled(true); total = Integer.parseInt(textFieldRows.getText()) * Integer.parseInt(textFieldColumns.getText()); //(Integer)jComboRegions.getSelectedItem(); res = total; jComboBoxNumRegionXPeer.removeAllItems(); for (int i = 1; i < res; i++) jComboBoxNumRegionXPeer.addItem(i); } else clickTreeListener(); } }); } //======== peerInfoStatus ======== { peerInfoStatus.setBorder(new TitledBorder("Settings")); peerInfoStatus.setBackground(Color.lightGray); //======== peerInfoStatus1 ======== { peerInfoStatus1.setBackground(Color.lightGray); peerInfoStatus1.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); peerInfoStatus1.setBorder(null); //======== internalFrame1 ======== { internalFrame1.setVisible(true); Container internalFrame1ContentPane = internalFrame1.getContentPane(); //======== scrollPane1 ======== { //---- label8 ---- architectureLabel.setText("Architecture Information"); scrollPane1.setViewportView(architectureLabel); } GroupLayout internalFrame1ContentPaneLayout = new GroupLayout( internalFrame1ContentPane); internalFrame1ContentPane.setLayout(internalFrame1ContentPaneLayout); internalFrame1ContentPaneLayout.setHorizontalGroup( internalFrame1ContentPaneLayout.createParallelGroup() .addGroup(internalFrame1ContentPaneLayout .createSequentialGroup().addContainerGap() .addComponent(scrollPane1, GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE) .addContainerGap())); internalFrame1ContentPaneLayout.setVerticalGroup( internalFrame1ContentPaneLayout.createParallelGroup() .addGroup(internalFrame1ContentPaneLayout .createSequentialGroup().addContainerGap() .addComponent(scrollPane1, GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE) .addContainerGap())); } peerInfoStatus1.add(internalFrame1, JLayeredPane.DEFAULT_LAYER); internalFrame1.setBounds(15, 0, 365, 160); } //---- graphicONcheckBox ---- graphicONcheckBox.setText("Graphic ON"); //---- advancedConfirmBut ---- advancedConfirmBut.setIcon(new ImageIcon("resources/image/ok.png")); GroupLayout peerInfoStatusLayout = new GroupLayout(peerInfoStatus); peerInfoStatus.setLayout(peerInfoStatusLayout); peerInfoStatusLayout.setHorizontalGroup(peerInfoStatusLayout .createParallelGroup() .addGroup(peerInfoStatusLayout.createSequentialGroup() .addGroup(peerInfoStatusLayout.createParallelGroup() .addGroup(peerInfoStatusLayout.createSequentialGroup() .addGap(26, 26, 26) .addComponent(graphicONcheckBox) .addGap(73, 73, 73) .addComponent(jComboBoxNumRegionXPeer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(80, 80, 80) .addComponent(advancedConfirmBut, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)) .addGroup(peerInfoStatusLayout.createSequentialGroup() .addContainerGap().addComponent(peerInfoStatus1, GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE))) .addContainerGap())); peerInfoStatusLayout.setVerticalGroup(peerInfoStatusLayout.createParallelGroup() .addGroup(peerInfoStatusLayout.createSequentialGroup() .addComponent(peerInfoStatus1, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(peerInfoStatusLayout .createParallelGroup(GroupLayout.Alignment.TRAILING) .addGroup(GroupLayout.Alignment.LEADING, peerInfoStatusLayout .createParallelGroup( GroupLayout.Alignment.BASELINE) .addComponent(graphicONcheckBox) .addComponent(jComboBoxNumRegionXPeer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(advancedConfirmBut, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)) .addContainerGap(16, Short.MAX_VALUE))); } GroupLayout jPanelAdvancedMainLayout = new GroupLayout(jPanelAdvancedMain); jPanelAdvancedMain.setLayout(jPanelAdvancedMainLayout); jPanelAdvancedMainLayout.setHorizontalGroup(jPanelAdvancedMainLayout .createParallelGroup() .addGroup(jPanelAdvancedMainLayout.createSequentialGroup().addContainerGap() .addComponent(scrollPaneTree, GroupLayout.PREFERRED_SIZE, 207, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(peerInfoStatus, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); jPanelAdvancedMainLayout.setVerticalGroup(jPanelAdvancedMainLayout .createParallelGroup() .addGroup(GroupLayout.Alignment.TRAILING, jPanelAdvancedMainLayout .createSequentialGroup().addContainerGap() .addGroup(jPanelAdvancedMainLayout .createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(peerInfoStatus, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(scrollPaneTree, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE)) .addContainerGap())); } //======== jPanelSetButton2 ======== { //---- buttonSetConfigDefault2 ---- buttonSetConfigDefault2.setText("Set"); GroupLayout jPanelSetButton2Layout = new GroupLayout(jPanelSetButton2); jPanelSetButton2.setLayout(jPanelSetButton2Layout); jPanelSetButton2Layout.setHorizontalGroup(jPanelSetButton2Layout .createParallelGroup().addGroup(GroupLayout.Alignment.TRAILING, jPanelSetButton2Layout.createSequentialGroup() .addContainerGap(522, Short.MAX_VALUE) .addComponent(buttonSetConfigDefault2, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE) .addGap(72, 72, 72))); jPanelSetButton2Layout.setVerticalGroup(jPanelSetButton2Layout.createParallelGroup() .addGroup(GroupLayout.Alignment.TRAILING, jPanelSetButton2Layout.createSequentialGroup() .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(buttonSetConfigDefault2).addContainerGap())); } GroupLayout jPanelAdvancedLayout = new GroupLayout(jPanelAdvanced); jPanelAdvancedLayout.setHorizontalGroup(jPanelAdvancedLayout .createParallelGroup(Alignment.LEADING) .addGroup(jPanelAdvancedLayout.createSequentialGroup() .addGroup(jPanelAdvancedLayout.createParallelGroup(Alignment.LEADING) .addComponent(jPanelAdvancedMain, GroupLayout.DEFAULT_SIZE, 689, Short.MAX_VALUE) .addComponent(jPanelSetButton2, GroupLayout.PREFERRED_SIZE, 681, GroupLayout.PREFERRED_SIZE)) .addContainerGap())); jPanelAdvancedLayout.setVerticalGroup(jPanelAdvancedLayout .createParallelGroup(Alignment.TRAILING) .addGroup(jPanelAdvancedLayout.createSequentialGroup().addContainerGap() .addComponent(jPanelAdvancedMain, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18).addComponent(jPanelSetButton2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))); jPanelAdvanced.setLayout(jPanelAdvancedLayout); } tabbedPane2.addTab("Advanced", jPanelAdvanced); } //======== panelConsole ======== { //======== scrollPane3 ======== { //---- textField1 ---- notifyArea.setEditable(false); DefaultCaret caret = (DefaultCaret) notifyArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); scrollPane3.setViewportView(notifyArea); } GroupLayout panelConsoleLayout = new GroupLayout(panelConsole); panelConsole.setLayout(panelConsoleLayout); panelConsoleLayout.setHorizontalGroup(panelConsoleLayout.createParallelGroup() .addGroup(panelConsoleLayout.createParallelGroup() .addGroup(panelConsoleLayout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(scrollPane3, GroupLayout.PREFERRED_SIZE, 679, GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE))) .addGap(0, 679, Short.MAX_VALUE)); panelConsoleLayout.setVerticalGroup(panelConsoleLayout.createParallelGroup() .addGroup(panelConsoleLayout.createParallelGroup() .addGroup(panelConsoleLayout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(scrollPane3, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE))) .addGap(0, 76, Short.MAX_VALUE)); } GroupLayout jPanelContainerTabbedPaneLayout = new GroupLayout(jPanelContainerTabbedPane); jPanelContainerTabbedPaneLayout.setHorizontalGroup(jPanelContainerTabbedPaneLayout .createParallelGroup(Alignment.LEADING) .addGroup(jPanelContainerTabbedPaneLayout.createSequentialGroup().addContainerGap() .addGroup(jPanelContainerTabbedPaneLayout.createParallelGroup(Alignment.LEADING) .addComponent(tabbedPane2, GroupLayout.PREFERRED_SIZE, 686, GroupLayout.PREFERRED_SIZE) .addComponent(panelConsole, GroupLayout.DEFAULT_SIZE, 708, Short.MAX_VALUE)) .addContainerGap())); jPanelContainerTabbedPaneLayout.setVerticalGroup(jPanelContainerTabbedPaneLayout .createParallelGroup(Alignment.LEADING) .addGroup(jPanelContainerTabbedPaneLayout.createSequentialGroup().addGap(3) .addComponent(tabbedPane2, GroupLayout.PREFERRED_SIZE, 384, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelConsole, GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE))); jPanelContainerTabbedPane.setLayout(jPanelContainerTabbedPaneLayout); } { jPanelDeploying = new JPanel(); tabbedPane2.addTab("Simulation Jar", null, jPanelDeploying, null); GroupLayout jPanelDeployingLayout = new GroupLayout(jPanelDeploying); jPanelDeploying.setLayout(jPanelDeployingLayout); { jButtonLoadJar = new JButton(); jButtonLoadJar.setText("Load Jar"); jButtonLoadJar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { if (simulationFile != null) { File dest = new File(FTP_HOME + dirSeparator + SIMULATION_DIR + dirSeparator + simulationFile.getName()); try { FileUtils.copyFile(simulationFile, dest); Digester dg = new Digester(DigestAlgorithm.MD5); InputStream in = new FileInputStream(dest); Properties prop = new Properties(); try { prop.setProperty("MD5", dg.getDigest(in)); String fileName = FilenameUtils .removeExtension(simulationFile.getName()); //save properties to project root folder prop.store(new FileOutputStream(FTP_HOME + dirSeparator + SIMULATION_DIR + dirSeparator + fileName + ".hash"), null); } catch (IOException ex) { ex.printStackTrace(); } System.out.println("MD5: " + dg.getDigest(in)); loadSimulation(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }); } jPanelDeployingLayout.setVerticalGroup(jPanelDeployingLayout.createSequentialGroup() .addGap(22, 22, 22) .addGroup(jPanelDeployingLayout.createParallelGroup().addGroup( GroupLayout.Alignment.LEADING, jPanelDeployingLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jButtonLoadJar, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(getJTextFieldPathSimJar(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(getJButtonChoseSimJar(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 286, GroupLayout.PREFERRED_SIZE)); jPanelDeployingLayout .setHorizontalGroup(jPanelDeployingLayout.createSequentialGroup().addGap(22, 22, 22) .addComponent(getJTextFieldPathSimJar(), GroupLayout.PREFERRED_SIZE, 202, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(getJButtonChoseSimJar(), GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE) .addGap(24) .addComponent(jButtonLoadJar, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 155, Short.MAX_VALUE)); } jPanelRunBatchTests = new JPanel(); tabbedPane2.addTab("Run batch tests", null, jPanelRunBatchTests, null); JLabel lblSelectConfigurationFile = new JLabel("Select configuration file:"); textFieldConfigFilePath = new JTextField(); textFieldConfigFilePath.setColumns(10); JButton buttonChooseConfigFile = new JButton(); buttonChooseConfigFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { configFile = showFileChooser(); if (configFile != null) textFieldConfigFilePath.setText(configFile.getAbsolutePath()); } }); buttonChooseConfigFile.setIcon(new ImageIcon("it/isislab/dmason/resources/image/openFolder.png")); JButton buttonLoadConfig = new JButton("Start"); buttonLoadConfig.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { if (configFile.getName().contains(".xml")) { ClassLoader.getSystemClassLoader(); //File xsd = new File(xsdFilename); InputStream xsd = new FileInputStream("resources/batch/batchSchema.xsd"); if (xsd != null) { if (validateXML(configFile, xsd)) { Batch batch = loadConfigFromXML(configFile); if (batch != null) { textAreaBatchInfo.append(configFile.getName() + " loaded.\n"); if (batch.getNeededWorkers() > peers.size() || batch.getNeededWorkers() == 0) JOptionPane.showMessageDialog(DMasonMaster.this, "There are not enough workers to start the simulation"); else { textAreaBatchInfo .append("Simulation: " + batch.getSimulationName() + "\n"); textAreaBatchInfo.append( "Needed Worker: " + batch.getNeededWorkers() + "\n"); textAreaBatchInfo.append("Balance: " + batch.isBalanced() + "\n"); Set<List<EntryParam<String, Object>>> testList = generateTestsFrom( batch); textAreaBatchInfo .append("--------------------------------------\n"); textAreaBatchInfo .append("Number of experiments: " + testList.size() + "\n"); ConcurrentLinkedQueue<List<EntryParam<String, Object>>> testQueue = new ConcurrentLinkedQueue<List<EntryParam<String, Object>>>(); for (List<EntryParam<String, Object>> test : testList) testQueue.offer(test); //System.out.println("Test queue: "+testQueue.size()); try { List<List<EntryWorkerScore<Integer, String>>> workersPartition = Util .chopped(scoreList, batch.getNeededWorkers()); //System.out.println(workersPartition.toString()); testCount.set(0); totalTests = testList.size(); progressBarBatchTest.setValue(0); progressBarBatchTest.setString("0 %"); progressBarBatchTest.setStringPainted(true); batchLogger = Logger .getLogger(BatchExecutor.class.getCanonicalName()); batchStartedTime = System.currentTimeMillis(); textAreaBatchInfo.append("Batch started at: " + Util.getCurrentDateTime(batchStartedTime) + "\n"); textAreaBatchInfo .append("--------------------------------------\n"); batchLogger.debug("Started at: " + batchStartedTime); int i = 1; BatchExecutor batchExec; for (List<EntryWorkerScore<Integer, String>> workers : workersPartition) { try { batchExec = new BatchExecutor(batch.getSimulationName(), batch.isBalanced(), testQueue, master, connection, root.getChildCount(), getFPTAddress(), workers, "Batch" + i, 1, textAreaBatchInfo); batchExec.getObservable() .addObserver(DMasonMaster.this); batchExec.start(); //Thread.sleep(2000); //textAreaBatchInfo.append("Batch Executor "+i+" started\n"); i++; //not paraller simulation, I use only one batch executor if (!chckbxParallelBatch.isSelected()) break; } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } catch (Exception e3) { // TODO Auto-generated catch block e3.printStackTrace(); } } } else JOptionPane.showMessageDialog(DMasonMaster.this, "Error when loading config file"); } else JOptionPane.showMessageDialog(DMasonMaster.this, "The configuration file is not a valid file"); } else JOptionPane.showMessageDialog(DMasonMaster.this, xsdFilename + " not exists, can't validate configuration file."); } else JOptionPane.showMessageDialog(DMasonMaster.this, "The file " + configFile.getName() + "is not a configuration file."); } catch (HeadlessException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); JPanel panel = new JPanel(); panel.setBorder( new TitledBorder(null, "Batch Status", TitledBorder.LEADING, TitledBorder.TOP, null, null)); chckbxParallelBatch = new JCheckBox("Parallel Batch"); GroupLayout gl_jPanelRunBatchTests = new GroupLayout(jPanelRunBatchTests); gl_jPanelRunBatchTests.setHorizontalGroup(gl_jPanelRunBatchTests .createParallelGroup(Alignment.LEADING) .addGroup(gl_jPanelRunBatchTests.createSequentialGroup().addContainerGap() .addGroup(gl_jPanelRunBatchTests.createParallelGroup(Alignment.LEADING) .addGroup(gl_jPanelRunBatchTests.createSequentialGroup() .addComponent(lblSelectConfigurationFile, GroupLayout.PREFERRED_SIZE, 139, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(textFieldConfigFilePath, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE) .addGap(10).addComponent(buttonChooseConfigFile, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_jPanelRunBatchTests.createSequentialGroup() .addComponent(chckbxParallelBatch).addGap(18) .addComponent(buttonLoadConfig)) .addComponent(panel, GroupLayout.PREFERRED_SIZE, 666, GroupLayout.PREFERRED_SIZE)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); gl_jPanelRunBatchTests.setVerticalGroup(gl_jPanelRunBatchTests .createParallelGroup(Alignment.LEADING) .addGroup(gl_jPanelRunBatchTests.createSequentialGroup().addContainerGap() .addGroup(gl_jPanelRunBatchTests.createParallelGroup(Alignment.TRAILING) .addComponent(buttonChooseConfigFile, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE) .addComponent(textFieldConfigFilePath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lblSelectConfigurationFile)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_jPanelRunBatchTests.createParallelGroup(Alignment.BASELINE) .addComponent(chckbxParallelBatch).addComponent(buttonLoadConfig)) .addPreferredGap(ComponentPlacement.RELATED, 14, Short.MAX_VALUE) .addComponent(panel, GroupLayout.PREFERRED_SIZE, 261, GroupLayout.PREFERRED_SIZE) .addContainerGap())); progressBarBatchTest = new JProgressBar(); JLabel lblProgress = new JLabel("Progress:"); GroupLayout gl_panel = new GroupLayout(panel); gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addGroup(gl_panel .createSequentialGroup().addContainerGap() .addGroup(gl_panel.createParallelGroup(Alignment.LEADING) .addComponent(scrollPane4, GroupLayout.DEFAULT_SIZE, 641, Short.MAX_VALUE) .addGroup(gl_panel.createSequentialGroup().addComponent(lblProgress).addGap(18) .addComponent(progressBarBatchTest, GroupLayout.PREFERRED_SIZE, 169, GroupLayout.PREFERRED_SIZE))) .addContainerGap())); gl_panel.setVerticalGroup(gl_panel.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel.createSequentialGroup().addContainerGap() .addGroup(gl_panel.createParallelGroup(Alignment.LEADING).addComponent(lblProgress) .addComponent(progressBarBatchTest, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(scrollPane4, GroupLayout.PREFERRED_SIZE, 202, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); panel.setLayout(gl_panel); jPanelRunBatchTests.setLayout(gl_jPanelRunBatchTests); GroupLayout jPanelSetDistributionLayout = new GroupLayout(jPanelSetDistribution); jPanelSetDistributionLayout .setHorizontalGroup( jPanelSetDistributionLayout.createParallelGroup(Alignment.LEADING) .addGroup(jPanelSetDistributionLayout.createSequentialGroup() .addComponent(jPanelSettings, GroupLayout.PREFERRED_SIZE, 254, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(jPanelContainerTabbedPane, GroupLayout.PREFERRED_SIZE, 707, GroupLayout.PREFERRED_SIZE) .addContainerGap(21, Short.MAX_VALUE))); jPanelSetDistributionLayout.setVerticalGroup(jPanelSetDistributionLayout .createParallelGroup(Alignment.LEADING) .addGroup(jPanelSetDistributionLayout.createSequentialGroup() .addGroup(jPanelSetDistributionLayout.createParallelGroup(Alignment.LEADING) .addComponent(jPanelSettings, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jPanelContainerTabbedPane, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); jPanelSetDistribution.setLayout(jPanelSetDistributionLayout); } textAreaBatchInfo = new JTextArea(); textAreaBatchInfo.setEditable(false); DefaultCaret caret = (DefaultCaret) textAreaBatchInfo.getCaret(); caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); scrollPane4.setViewportView(textAreaBatchInfo); //---- jLabelPlayButton ---- jLabelPlayButton.setIcon(new ImageIcon("resources/image/NotStopped.png")); //---- jLabelPauseButton ---- jLabelPauseButton.setIcon(new ImageIcon("resources/image/PauseOff.png")); //---- labelStopButton ---- jLabelPlayButton.setIcon(new ImageIcon("image/NotPlaying.png")); jLabelPlayButton.addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent arg0) { } @Override public void mousePressed(MouseEvent arg0) { } @Override public void mouseExited(MouseEvent arg0) { } @Override public void mouseEntered(MouseEvent arg0) { } @Override public void mouseClicked(MouseEvent arg0) { jLabelPlayButton.setIcon(new ImageIcon("resources/image/Playing.png")); jLabelPauseButton.setIcon(new ImageIcon("resources/image/PauseOff.png")); jLabelStopButton.setIcon(new ImageIcon("resources/image/NotStopped.png")); jLabelResetButton.setIcon(new ImageIcon("resources/image/NotReload.png")); try { master.play(); } catch (Exception e) { e.printStackTrace(); } } }); //---- labelStopButton2 ---- jLabelStopButton.setIcon(new ImageIcon("resources/image/NotStopped.png")); jLabelStopButton.addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseClicked(MouseEvent e) { jLabelStopButton.setIcon(new ImageIcon("resources/image/Stopped.png")); jLabelPlayButton.setIcon(new ImageIcon("resources/image/NotPlaying.png")); jLabelPauseButton.setIcon(new ImageIcon("resources/image/PauseOff.png")); try { Address FTPAddress = getFPTAddress(); if (FTPAddress != null) { UpdateData ud = new UpdateData("", FTPAddress); master.stop(ud); } } catch (Exception e1) { e1.printStackTrace(); } } }); //---- labelPauseButton ---- jLabelPauseButton.setIcon(new ImageIcon("resources/image/PauseOff.png")); jLabelPauseButton.addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseClicked(MouseEvent e) { jLabelPauseButton.setIcon(new ImageIcon("resources/image/PauseOn.png")); jLabelStopButton.setIcon(new ImageIcon("resources/image/NotStopped.png")); jLabelPlayButton.setIcon(new ImageIcon("resources/image/NotPlaying.png")); try { master.pause(); } catch (Exception e1) { e1.printStackTrace(); } } }); //======== jPanelNumStep ======== { GroupLayout jPanelNumStepLayout = new GroupLayout(jPanelNumStep); jPanelNumStepLayout.setHorizontalGroup( jPanelNumStepLayout.createParallelGroup(Alignment.TRAILING).addGap(0, 25, Short.MAX_VALUE)); jPanelNumStepLayout.setVerticalGroup( jPanelNumStepLayout.createParallelGroup(Alignment.LEADING).addGap(0, 28, Short.MAX_VALUE)); jPanelNumStep.setLayout(jPanelNumStepLayout); jPanelNumStep.setPreferredSize(new java.awt.Dimension(89, 23)); } { jLabelResetButton = new JLabel(); jLabelResetButton.setIcon(new ImageIcon("resources/image/NotReload.png")); jLabelResetButton.setPreferredSize(new java.awt.Dimension(20, 20)); jLabelResetButton.setVisible(enableReset); } // for resetting simulation jLabelResetButton.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent arg0) { if (connected) { jLabelStopButton.setIcon(new ImageIcon("resources/image/NotStopped.png")); jLabelPlayButton.setIcon(new ImageIcon("resources/image/NotPlaying.png")); jLabelPauseButton.setIcon(new ImageIcon("resources/image/PauseOff.png")); jLabelResetButton.setIcon(new ImageIcon("resources/image/Reload.png")); //send message to workers for resetting simulation try { master.reset(); } catch (Exception e1) { e1.printStackTrace(); } //clean up topic from AcitveMQ connection.resetTopic(); setSystemSettingsEnabled(true); notifyArea.append("Simulation resetted\n"); } } @Override public void mouseEntered(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseReleased(MouseEvent arg0) { // TODO Auto-generated method stub } }); writeStepLabel = new JLabel(); writeStepLabel.setText("0"); lblTotalSteps = new JLabel("Steps:"); GroupLayout panelMainLayout = new GroupLayout(panelMain); panelMainLayout.setHorizontalGroup(panelMainLayout.createParallelGroup(Alignment.LEADING) .addGroup(panelMainLayout.createSequentialGroup() .addComponent(jPanelContainerSettings, GroupLayout.PREFERRED_SIZE, 0, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(panelMainLayout.createParallelGroup(Alignment.LEADING) .addComponent(jPanelSetDistribution, 0, 986, Short.MAX_VALUE) .addGroup(panelMainLayout.createSequentialGroup().addGap(636) .addGroup(panelMainLayout.createParallelGroup(Alignment.TRAILING) .addComponent(jLabelStep, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addGroup(panelMainLayout.createSequentialGroup() .addComponent(lblTotalSteps) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(writeStepLabel))) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(jPanelNumStep, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE) .addGroup(panelMainLayout.createParallelGroup(Alignment.LEADING) .addGroup(panelMainLayout.createSequentialGroup().addGap(24) .addComponent(jLabelPlayButton, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(jLabelPauseButton, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(jLabelStopButton, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(panelMainLayout.createSequentialGroup().addGap(116) .addComponent(jLabelResetButton, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))))) .addGap(12)) .addComponent(jPanelContainerConnection, 0, 1004, Short.MAX_VALUE)); panelMainLayout.setVerticalGroup(panelMainLayout.createParallelGroup(Alignment.LEADING) .addGroup(panelMainLayout.createSequentialGroup() .addComponent(jPanelContainerConnection, GroupLayout.PREFERRED_SIZE, 71, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(panelMainLayout.createParallelGroup(Alignment.LEADING) .addComponent(jPanelSetDistribution, GroupLayout.PREFERRED_SIZE, 518, GroupLayout.PREFERRED_SIZE) .addGroup(panelMainLayout.createSequentialGroup().addGap(29).addComponent( jPanelContainerSettings, GroupLayout.PREFERRED_SIZE, 489, GroupLayout.PREFERRED_SIZE))) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(panelMainLayout.createParallelGroup(Alignment.LEADING) .addComponent(jLabelStopButton, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabelPlayButton, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabelPauseButton, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabelResetButton, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addGroup(panelMainLayout.createParallelGroup(Alignment.BASELINE) .addComponent(writeStepLabel, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE) .addComponent(lblTotalSteps)) .addGroup(panelMainLayout.createSequentialGroup() .addComponent(jLabelStep, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(jPanelNumStep, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE))) .addContainerGap(13, Short.MAX_VALUE))); panelMain.setLayout(panelMainLayout); } GroupLayout contentPaneLayout = new GroupLayout(contentPane); contentPaneLayout.setHorizontalGroup( contentPaneLayout.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING, contentPaneLayout .createSequentialGroup().addContainerGap().addComponent(panelMain, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); contentPaneLayout.setVerticalGroup( contentPaneLayout.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING, contentPaneLayout.createSequentialGroup().addContainerGap().addComponent(panelMain, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); contentPane.setLayout(contentPaneLayout); pack(); setLocationRelativeTo(null); refreshServerLabel.setVisible(false); jButtonChoseSimJar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { simulationFile = showFileChooser(); if (simulationFile != null) jTextFieldPathSimJar.setText(simulationFile.getAbsolutePath()); } }); }
From source file:com.monead.semantic.workbench.SemanticWorkbench.java
/** * Setup all the components/* ww w . j a v a 2 s. com*/ */ 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:com.monead.semantic.workbench.SemanticWorkbench.java
/** * Clears the tree model//from w w w. j a v a2 s .c o m */ private void clearTree() { ontModelTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("No Tree Generated"))); isTreeInSyncWithModel = true; colorCodeTabs(); }
From source file:com.monead.semantic.workbench.SemanticWorkbench.java
/** * Build a tree representation of the semantic model * //from ww w.j a v a 2 s.c o m * TODO aggregate items from duplicate nodes * * TODO Consider more efficient approach that scans the model once rather than * querying for each class, individual and property collection * * @see #addClassesToTree(DefaultMutableTreeNode, String) * @see OntologyTreeCellRenderer * * @return The message to be presented on the status line */ private String createTreeFromModel() { final String messagePrefix = "Creating the tree view"; DefaultMutableTreeNode treeTopNode; DefaultMutableTreeNode classesNode; String message; int maxIndividualsPerClass; setStatus(messagePrefix); setWaitCursor(true); clearTree(); try { maxIndividualsPerClass = Integer.parseInt( properties.getProperty(ConfigurationProperty.MAX_INDIVIDUALS_PER_CLASS_IN_TREE.key(), "0")); } catch (Throwable throwable) { maxIndividualsPerClass = 0; } treeTopNode = new DefaultMutableTreeNode("Model"); // Ignore latest value since we have just released the old tree (if there // was one) MemoryWarningSystem.hasLatestAvailableTenuredGenAfterCollectionChanged(this); // Classes classesNode = new DefaultMutableTreeNode("Classes"); treeTopNode.add(classesNode); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Building list of classes in the model"); } try { addClassesToTree(classesNode, maxIndividualsPerClass, messagePrefix); // Select the tree view tab SwingUtilities.invokeLater(new Runnable() { public void run() { tabbedPane.setSelectedIndex(TAB_NUMBER_TREE_VIEW); } }); message = "Tree view of current model created"; if (maxIndividualsPerClass > 0) { message += " (individuals per class limited to " + maxIndividualsPerClass + ")"; } ontModelTree.setModel(new DefaultTreeModel(treeTopNode)); isTreeInSyncWithModel = true; colorCodeTabs(); } catch (IllegalStateException ise) { // Memory exhaustion, keep the incomplete tree SwingUtilities.invokeLater(new Runnable() { public void run() { tabbedPane.setSelectedIndex(TAB_NUMBER_TREE_VIEW); } }); message = "Insufficient memory for entire tree, partial tree view of current model created"; ontModelTree.setModel(new DefaultTreeModel(treeTopNode)); isTreeInSyncWithModel = false; colorCodeTabs(); throw ise; } catch (RuntimeException rte) { if (rte.getMessage().contains("canceled by user")) { message = rte.getMessage(); } else { throw rte; } } return message; }
From source file:src.gui.ItSIMPLE.java
/** * @return the planTreeFramePanel//from w w w. j a v a 2 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; }