public void viewChange(View new_view) { Vector mbrship; if (new_view != null && (mbrship = new_view.getMembers()) != null) { tree._put(SEP, "members", mbrship); tree._put(SEP, "coordinator", mbrship.firstElement()); } }
public void redrawTree(boolean doRepaint) { displayText = false; if (argument == null) return; if (argument.isMultiRoots()) { argument.deleteDummyRoot(); argument.setMultiRoots(false); } TreeVertex root = null; Vector roots = argument.getTree().getRoots(); if (roots.size() > 1) { if (argument.getDummyRoot() == null) { argument.addDummyRoot(roots); } root = argument.getDummyRoot(); } else if (roots.size() == 1) { root = (TreeVertex) roots.firstElement(); } // if root == null, the entire tree has been erased, // so call emptyTree() to clean things up and // clear the display if (root == null) { argument.emptyTree(false); } else { calcTreeShape(root); } if (doRepaint) { repaint(); } /* if (displayFrame.getMainDiagramPanel() == this) { searchFrame.updateDisplays(false); } */ }
/** Fetches all data from underlying tree model and display it graphically */ void init() { Vector mbrship = null; addGuiNode(SEP); mbrship = tree != null && tree.getMembers() != null ? (Vector) tree.getMembers().clone() : null; if (mbrship != null) { tree._put(SEP, "members", mbrship); tree._put(SEP, "coordinator", mbrship.firstElement()); } }
/** Reaction to Add/Delete buttons. */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmdAdd.equals(cmd)) { Zone z = ((ControllerSWARM) controller).new Zone(); Vector<AbstractNetworkElement> ml = ((AbstractControllerComplex) controller).getMyMonitor().getPredecessors(); Vector<AbstractNetworkElement> cl = ((AbstractControllerComplex) controller).getMyMonitor().getSuccessors(); if (ml.size() > 0) z.bottleneck = (AbstractLinkHWC) ml.firstElement(); if (cl.size() > 0) { z.setFromOnramp((AbstractLinkHWC) cl.firstElement()); z.setToOnramp((AbstractLinkHWC) cl.firstElement()); } z.initialize(); zones.add(z); zoneTM.fireTableStructureChanged(); setUpBottleneckColumn(); setUpFromOnrampColumn(); setUpToOnrampColumn(); } if (cmdDelete.equals(cmd)) { try { int[] selected = zonetab.getSelectedRows(); if ((selected != null) && (selected.length > 0)) for (int i = 0; i < selected.length; i++) { int idx = selected[i] - i; if ((idx >= 0) && (idx < zones.size())) { zones.remove(idx); zoneTM.fireTableStructureChanged(); setUpBottleneckColumn(); setUpFromOnrampColumn(); setUpToOnrampColumn(); } } } catch (Exception ex) { } } return; }
private void browseAction() { if (selectedPath == null) { selectedPath = System.getenv("ROPE_SOURCES_DIR"); if (selectedPath != null) { File dir = new File(selectedPath); if (!dir.exists() || !dir.isDirectory()) { String message = String.format( "The sources path set in environment variable ROPE_SOURCES_DIR is not avaliable.\n%s", selectedPath); JOptionPane.showMessageDialog(null, message, "ROPE", JOptionPane.WARNING_MESSAGE); selectedPath = null; } else { System.out.println("Source folder path set from ROPE_SOURCES_DIR: " + selectedPath); } } if (selectedPath == null) { selectedPath = System.getProperty("user.dir"); System.out.println("Source folder path set to current directory: " + selectedPath); } } Vector<RopeFileFilter> filters = new Vector<RopeFileFilter>(); filters.add( new RopeFileFilter( new String[] {".a", ".asm", ".aut", ".s"}, "Assembly files (*.a *.asm *.aut *.s)")); filters.add(new RopeFileFilter(new String[] {".m", ".mac"}, "Macro files (*.m *.mac)")); filters.add(new RopeFileFilter(new String[] {".lst"}, "List files (*.lst)")); filters.add(new RopeFileFilter(new String[] {".txt"}, "Text files (*.txt)")); RopeFileChooser chooser = new RopeFileChooser(selectedPath, null, filters); chooser.setDialogTitle("Source document selection"); chooser.setFileFilter(filters.firstElement()); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); File file = chooser.open(this, fileText); if (file != null) { if (loadSourceFile(file)) { mainFrame.showExecWindow(baseName); } } }
/** @return The position of the first <code>Lite</code> object. */ public Point getPosition() { if (!lites.isEmpty()) return ((Lite) lites.firstElement()).getPosition(); else return new Point(); }
public void addNewEdge() { if (!canCreateEdge) { // refreshDisplay(); return; } canCreateEdge = false; Vector vertexList = argument.getTree().getVertexList(); boolean addNewEdge = false; if (!vertexList.contains(startVertex)) { addNewEdge = true; argument.getTree().addVertex(startVertex); argument.getFreeVertexList().remove(startVertex); } if (!vertexList.contains(endVertex)) { addNewEdge = true; argument.getTree().addVertex(endVertex); argument.getFreeVertexList().remove(endVertex); } if (addNewEdge) { argument.getTree().addEdge(endVertex, startVertex); // If addNewEdge is true here, either or both vertexes are new // to the tree, so new edge must be OK startVertex.setHasParent(true); calcSubtreeShapes(); displayFrame.controlFrame.updateDisplays(true); // displayFrame.controlFrame.getUndoStack().push(new // EditAction(displayFrame.controlFrame, "adding a support")); } // If reach this far, tree already contains both vertices. // No need to check if edge already exists since have checked if // vertex has a parent. Just need to check if new edge creates a // cycle. If it does, we delete the edge we just added. if (argument.isMultiRoots()) { argument.deleteDummyRoot(); argument.setMultiRoots(false); } argument.getTree().addEdge(endVertex, startVertex); startVertex.setHasParent(true); TreeVertex root; Vector roots = argument.getTree().getRoots(); if (roots.size() == 0) { deleteCycle(startVertex, endVertex); return; } if (roots.size() > 1) { argument.addDummyRoot(roots); root = argument.getDummyRoot(); } else { root = (TreeVertex) roots.firstElement(); } try { argument.getTree().breadthFirstTopSort(root); } catch (GraphException e) { deleteCycle(startVertex, endVertex); return; } // If we survive the cycle test, the edge is OK. redrawTree(true); }