コード例 #1
0
 /** Brings a figure to the front. */
 public synchronized void bringToFront(Figure figure) {
   if (fFigures.contains(figure)) {
     fFigures.removeElement(figure);
     fFigures.addElement(figure);
     figure.changed();
   }
 }
コード例 #2
0
 /** Adds a figure to the list of figures. Initializes the the figure's container. */
 public Figure add(Figure figure) {
   if (!fFigures.contains(figure)) {
     fFigures.addElement(figure);
     figure.addToContainer(this);
   }
   return figure;
 }
コード例 #3
0
 /**
  * Removes a figure from the composite.
  *
  * @see #removeAll
  */
 public Figure remove(Figure figure) {
   if (fFigures.contains(figure)) {
     figure.removeFromContainer(this);
     fFigures.removeElement(figure);
   }
   return figure;
 }
コード例 #4
0
 /** Sends a figure to the back of the drawing. */
 public synchronized void sendToBack(Figure figure) {
   if (fFigures.contains(figure)) {
     fFigures.removeElement(figure);
     fFigures.insertElementAt(figure, 0);
     figure.changed();
   }
 }
コード例 #5
0
 /** Adds an editor to the current collection of active editors, and makes it a tab pane. */
 void addEditor(PluggableEditor ed) {
   if (activeEditors.contains(ed) == false) // don't add editors twice!
   {
     add(ed);
     ed.registerComponents(
         registerMenu, registerButtons, registerTree, registerTreeMenu, registerJX);
   }
 }
コード例 #6
0
  public boolean suggestHTMLEditor() {
    // if we can't find one of those, relapse to the table editor.

    if (activeEditors.contains(templateDisplay) == true) {
      setCurrentEditor(templateDisplay);
      return true;
    }
    return false;
  }
コード例 #7
0
 public void addMenuItem(String text, String loc) {
   locations.put(text, loc);
   if (filenames.contains("Test Text")) {
     filenames.remove("Test Text");
     filenames.addElement(text);
   } else {
     filenames.addElement(text);
   }
   createPopupMenu();
 }
コード例 #8
0
ファイル: Subtree.java プロジェクト: siwells/monkeypuzzle
 private void recurseSelectEdges(TreeVertex root) {
   Vector edges = root.getEdgeList();
   for (int i = 0; i < edges.size(); i++) {
     TreeEdge edge = (TreeEdge) edges.elementAt(i);
     TreeVertex dest = edge.getDestVertex();
     if (m_vertexList.contains(dest)) {
       edge.setSelected(true);
       recurseSelectEdges(dest);
     }
   }
 }
コード例 #9
0
  private void updateSelf() {
    boolean inSequence = false;
    Set availableWorkItems = _engineClient.getAvailableWorkItems();
    for (Iterator iterator = availableWorkItems.iterator(); iterator.hasNext(); ) {
      YWorkItem item = (YWorkItem) iterator.next();

      if (inSequenceWorkitemIDs.contains(item.getTaskID())) {
        inSequence = true;
      } else {
        inSequence = false;
      }

      if (item.getStatus().equals(YWorkItemStatus.statusEnabled)) {
        addEnabledWorkItem(item, inSequence);
      } else if (item.getStatus().equals(YWorkItemStatus.statusFired)) {
        addFiredWorkItem(item, inSequence);
      }
    }
    Set allWorkItems = _engineClient.getAllWorkItems();
    for (Iterator iterator = allWorkItems.iterator(); iterator.hasNext(); ) {
      YWorkItem item = (YWorkItem) iterator.next();

      if (inSequenceWorkitemIDs.contains(item.getTaskID())) {
        inSequence = true;
      } else {
        inSequence = false;
      }

      if (item.getStatus().equals(YWorkItemStatus.statusExecuting)) {
        addStartedWorkItem(item, inSequence);
      }
      if (_paramsDefinitions.getParamsForTask(item.getTaskID()) == null) {
        YTask task = _engineClient.getTaskDefinition(item.getSpecificationID(), item.getTaskID());
        String paramsAsXML = task.getInformation();
        TaskInformation taskInfo = Marshaller.unmarshalTaskInformation(paramsAsXML);
        YParametersSchema paramsForTask = taskInfo.getParamSchema();
        _paramsDefinitions.setParamsForTask(item.getTaskID(), paramsForTask);
      }
    }
  }
コード例 #10
0
  /**
   * Removes all transient editors, and ensures that the table editor and the html editor are
   * available.
   */
  void clearPluggableEditors() {
    ignoreChangeEvents = true;

    for (int i = activeEditors.size() - 1; i >= 0; i--) {
      PluggableEditor ed = (PluggableEditor) activeEditors.get(i);
      if ((ed != templateDisplay) && (ed != tableDisplay)) {
        remove(i);
      }
    }

    if (activeEditors.contains(templateDisplay) == false) {
      addEditor(templateDisplay);
    }

    if (activeEditors.contains(tableDisplay) == false) {
      addEditor(tableDisplay);
    }

    if (currentEditor != tableDisplay && currentEditor != templateDisplay) {
      suggestHTMLEditor();
    }

    ignoreChangeEvents = false;
  }
コード例 #11
0
  /**
   * register keystrokes here which are for the WHEN_IN_FOCUSED_WINDOW case. Other types of
   * keystrokes will be handled by walking the hierarchy That simplifies some potentially hairy
   * stuff.
   */
  public void registerKeyStroke(KeyStroke k, JComponent c) {
    Container topContainer = getTopAncestor(c);
    if (topContainer == null) {
      return;
    }
    Hashtable keyMap = containerMap.get(topContainer);

    if (keyMap == null) { // lazy evaluate one
      keyMap = registerNewTopContainer(topContainer);
    }

    Object tmp = keyMap.get(k);
    if (tmp == null) {
      keyMap.put(k, c);
    } else if (tmp instanceof Vector) { // if there's a Vector there then add to it.
      Vector v = (Vector) tmp;
      if (!v.contains(c)) { // only add if this keystroke isn't registered for this component
        v.addElement(c);
      }
    } else if (tmp instanceof JComponent) {
      // if a JComponent is there then remove it and replace it with a vector
      // Then add the old compoennt and the new compoent to the vector
      // then insert the vector in the table
      if (tmp != c) { // this means this is already registered for this component, no need to dup
        Vector<JComponent> v = new Vector<JComponent>();
        v.addElement((JComponent) tmp);
        v.addElement(c);
        keyMap.put(k, v);
      }
    } else {
      System.out.println("Unexpected condition in registerKeyStroke");
      Thread.dumpStack();
    }

    componentKeyStrokeMap.put(new ComponentKeyStrokePair(c, k), topContainer);

    // Check for EmbeddedFrame case, they know how to process accelerators even
    // when focus is not in Java
    if (topContainer instanceof EmbeddedFrame) {
      ((EmbeddedFrame) topContainer).registerAccelerator(k);
    }
  }
コード例 #12
0
  public void registerMenuBar(JMenuBar mb) {
    Container top = getTopAncestor(mb);
    if (top == null) {
      return;
    }
    Hashtable keyMap = containerMap.get(top);

    if (keyMap == null) { // lazy evaluate one
      keyMap = registerNewTopContainer(top);
    }
    // use the menubar class as the key
    Vector menuBars = (Vector) keyMap.get(JMenuBar.class);

    if (menuBars == null) { // if we don't have a list of menubars,
      // then make one.
      menuBars = new Vector();
      keyMap.put(JMenuBar.class, menuBars);
    }

    if (!menuBars.contains(mb)) {
      menuBars.addElement(mb);
    }
  }
コード例 #13
0
  public void displayEntry(DXEntry dxentry, DataBrokerQueryInterface ds) {
    // Set the local data variables.

    dataSource = ds;
    entry = dxentry;

    // check that the default editors have been initialised.

    if (tableDisplay == null) initTableEditor();
    if (templateDisplay == null) initHTMLEditor();

    // check for a 'no data' display - if there is no data, revert
    // to the default html 'no data' template.

    if (entry
        == null) // || entry.size() == 0) //TE: This is commented out to allow virtual nodes to be
                 // edited.
    {
      if (oldOCSig != null) {
        clearPluggableEditors();

        if (activeEditors.size() == 0) {
          addEditor(templateDisplay);
        }
        oldOCSig = null;
      }
      refreshEditors(null, ds);
    } else {
      dataSource = ds; // may be null...
      Vector ocs = entry.getOrderedOCs();

      // try to create a unique 'signature' for a group of object classes
      // This relies on them being delivered in the same order though.  (Less
      // efficient if they aren't, but otherwise shouldn't be a big problem).
      String newOCSig = new String();

      if (ocs != null)
        for (int i = 0; i < ocs.size(); i++) {
          Object ocSig = ocs.get(i);
          if (ocSig != null) newOCSig += ocSig.toString();
        }

      // Check if signiture hasn't changed.  If it *has* changed,
      // reset the editors using 'setEditors', and update
      // the 'old object class signiture' variable.
      if (newOCSig.equals(oldOCSig) == false) {
        setEditors(entry, ds, ocs);
        oldOCSig = newOCSig;
      }

      // Some quick sanity checks...
      if (entry.getStatus() == DXEntry.NEW) // check for new entries (but *not* NEW_WRITTEN)...
      {
        // don't allow editors to appear that can't edit a new entry
        trimNonNewEntryEditors();
        suggestPluggableEditor();
      } else {
        // make sure that the html template display is around...
        // XXX (a bit of a hack - this should really check that *all*
        // XXX editor that can't handle new entries have been added back...
        // XXX (maybe set flag?)
        // TE: added '&& !currentEditor.isUnique()' b/c this code always made sure the HTML
        // TE: editor is visible, whereas with a unique plugin we only want that one visible...
        // TE: unless of course I am totally confused!  See bug 674.
        if (activeEditors.contains(templateDisplay) == false && !currentEditor.isUnique()) {
          add((PluggableEditor) templateDisplay, 0);
          if (currentEditor != null) // XXX hack hack.
          setCurrentEditor(currentEditor);
        }
      }

      if (activeEditors.contains(currentEditor) == false) {
        suggestPluggableEditor();
      }

      // now that the editor set we're using has been sorted out,
      // actually go and update the editors!  (Nb. this triggers an usaved changes check)
      refreshEditors(entry, ds);
    }
  }
コード例 #14
0
  /**
   * Clear out all the old editors, and get new editors corresponding to the new object classes.
   *
   * @param entry the entry to be displayed by all the editors
   * @param ds the datasource the editors may use for more info
   * @param ocs the object classes (in order) to find editors for.
   */
  protected void setEditors(DXEntry entry, DataBrokerQueryInterface ds, Vector ocs) {

    try {
      clearPluggableEditors(); // clear all extra editors

      // search for unique structural editors...

      if ("false".equalsIgnoreCase(JXConfig.getProperty("plugins.ignoreUniqueness"))) {
        if (ocs == null) // TE: may happen if virtual entry.
        return;

        int size = ocs.size();

        for (int i = 0; i < size; i++) {
          Object objectClass = ocs.get(i);
          if (objectClass != null) {
            PluggableEditor ed = getEditor(objectClass.toString());
            if (ed != null && ed.isUnique() == true) // found a unique editor
            { // so clear old ones,
              addUniqueEditor(ed); // and use the unique one
              refreshEditors(entry, ds); // to display the data
              setCurrentEditor(ed);
              return; // ... and exit.
            }
          }
        }
      } else log.warning("skipping uniqueness test for pluggable editors");

      boolean newEdSet = false;

      // search for non-unique structural editors
      for (int i = 0; i < ocs.size(); i++) {
        Object objectClass = ocs.get(i);
        if (objectClass != null) {
          PluggableEditor ed = getEditor(objectClass.toString());
          if (ed != null) {
            addEditor(ed);

            // Force the displayed editor to be the first pluggable one...
            if (newEdSet == false) {
              setCurrentEditor(ed);
              newEdSet = true;
            }
          }
        }
      }

      // search for non-structural editors
      try {
        Attribute allOCs = entry.getAllObjectClasses();
        if (allOCs != null) {
          Enumeration vals = allOCs.getAll();
          while (vals.hasMoreElements()) {
            Object oc = vals.nextElement();
            if (oc != null) {
              String ocName = oc.toString();
              if (ocs.contains(ocName)
                  == false) // don't bother with struct objectclasses dealt with above
              {
                PluggableEditor ed = getEditor(ocName);

                if (ed != null) {
                  addEditor(ed);

                  if (ed.isUnique()) // a special service to users...
                  log.warning(
                        "WARNING: Illegal unique editor defined for oc: "
                            + ocName
                            + " not allowed - (oc not in primary structural inheritance chain)");
                }
              }
            }
          }
        }
      } catch (NamingException e) {
        log.log(
            Level.WARNING,
            "WARNING: non-fatal exception getting object classes for plugin editors. ",
            e);
      }

      addEditor(templateDisplay); // and always add old faithfulls...
      // XXX
      if (entry.getStatus() != DXEntry.NEW) // well, almost always...
      addEditor(tableDisplay);
    } catch (Exception e) {
      log.warning("Unexpected Exception in AttributeDisplay\n" + e);
      e.printStackTrace();
    }
  }
コード例 #15
0
 /** Register a new listener of document change events. */
 public void addDocumentChangeListener(DocumentChangeListener l) {
   if (l != null && !dc_listeners.contains(l)) dc_listeners.add(l);
 }
コード例 #16
0
  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);
  }
コード例 #17
0
ファイル: ImageJ.java プロジェクト: chrisp87/ImageJA
 /**
  * Adds the specified class to a Vector to keep it from being garbage collected, causing static
  * fields to be reset.
  */
 public void register(Class c) {
   if (!classes.contains(c)) classes.addElement(c);
 }
コード例 #18
0
 public void addAffyProbe(AffyProbe ap) {
   if (!probes.contains(ap)) {
     probes.add(ap);
   }
 }
コード例 #19
0
ファイル: ColorPickerPanel.java プロジェクト: ryokbys/Akira
 /**
  * This listener will be notified when the current HSB or RGB values change, depending on what
  * mode the user is in.
  */
 public void addChangeListener(ChangeListener l) {
   if (changeListeners == null) changeListeners = new Vector();
   if (changeListeners.contains(l)) return;
   changeListeners.add(l);
 }
コード例 #20
0
  /**
   * Construct (with WhiteboardSession) and send a WhiteboardObject to a contact.
   *
   * @param wbSession the white-board session, to which the object would be send
   * @param ws WhiteboardShape to convert and send
   * @param c contact
   * @return WhiteboardObject sent
   */
  public WhiteboardObject sendWhiteboardObject(WhiteboardSession wbSession, WhiteboardShape ws)
      throws OperationFailedException {
    Vector supportedWBO = new Vector(Arrays.asList(wbSession.getSupportedWhiteboardObjects()));

    if (ws instanceof WhiteboardObjectPath) {
      if (!supportedWBO.contains(WhiteboardObjectPath.NAME)) return null;
      WhiteboardObjectPath obj =
          (WhiteboardObjectPath) wbSession.createWhiteboardObject(WhiteboardObjectPath.NAME);
      ws.setID(obj.getID());
      obj.setPoints(((WhiteboardObjectPath) ws).getPoints());
      obj.setColor(ws.getColor());
      obj.setThickness(ws.getThickness());
      wbSession.sendWhiteboardObject(obj);
      return obj;
    } else if (ws instanceof WhiteboardObjectPolyLine) {
      if (!supportedWBO.contains(WhiteboardObjectPolyLine.NAME)) return null;
      WhiteboardObjectPolyLine obj =
          (WhiteboardObjectPolyLine)
              wbSession.createWhiteboardObject(WhiteboardObjectPolyLine.NAME);
      ws.setID(obj.getID());
      obj.setPoints(((WhiteboardObjectPolyLine) ws).getPoints());
      obj.setColor(ws.getColor());
      obj.setThickness(ws.getThickness());
      wbSession.sendWhiteboardObject(obj);
      return obj;
    } else if (ws instanceof WhiteboardObjectPolygon) {
      if (!supportedWBO.contains(WhiteboardObjectPolygon.NAME)) return null;
      WhiteboardObjectPolygon obj =
          (WhiteboardObjectPolygon) wbSession.createWhiteboardObject(WhiteboardObjectPolygon.NAME);
      ws.setID(obj.getID());
      obj.setPoints(((WhiteboardObjectPolygon) ws).getPoints());
      obj.setBackgroundColor(((WhiteboardObjectPolygon) ws).getBackgroundColor());
      obj.setFill(((WhiteboardObjectPolygon) ws).isFill());
      obj.setColor(ws.getColor());
      obj.setThickness(ws.getThickness());
      wbSession.sendWhiteboardObject(obj);
      return obj;
    } else if (ws instanceof WhiteboardObjectLine) {
      if (!supportedWBO.contains(WhiteboardObjectLine.NAME)) return null;
      WhiteboardObjectLine obj =
          (WhiteboardObjectLine) wbSession.createWhiteboardObject(WhiteboardObjectLine.NAME);
      ws.setID(obj.getID());
      obj.setWhiteboardPointStart(((WhiteboardObjectLine) ws).getWhiteboardPointStart());
      obj.setWhiteboardPointEnd(((WhiteboardObjectLine) ws).getWhiteboardPointEnd());
      obj.setColor(ws.getColor());
      obj.setThickness(ws.getThickness());
      wbSession.sendWhiteboardObject(obj);
      return obj;
    } else if (ws instanceof WhiteboardObjectRect) {
      if (!supportedWBO.contains(WhiteboardObjectRect.NAME)) return null;
      WhiteboardObjectRect obj =
          (WhiteboardObjectRect) wbSession.createWhiteboardObject(WhiteboardObjectRect.NAME);
      ws.setID(obj.getID());
      obj.setFill(((WhiteboardObjectRect) ws).isFill());
      obj.setHeight(((WhiteboardObjectRect) ws).getHeight());
      obj.setWhiteboardPoint(((WhiteboardObjectRect) ws).getWhiteboardPoint());
      obj.setWidth((((WhiteboardObjectRect) ws)).getWidth());
      obj.setColor(ws.getColor());
      obj.setThickness(ws.getThickness());
      wbSession.sendWhiteboardObject(obj);
      return obj;
    } else if (ws instanceof WhiteboardObjectCircle) {
      if (!supportedWBO.contains(WhiteboardObjectCircle.NAME)) return null;
      WhiteboardObjectCircle obj =
          (WhiteboardObjectCircle) wbSession.createWhiteboardObject(WhiteboardObjectCircle.NAME);
      ws.setID(obj.getID());
      obj.setFill(((WhiteboardObjectCircle) ws).isFill());
      obj.setRadius(((WhiteboardObjectCircle) ws).getRadius());
      obj.setWhiteboardPoint(((WhiteboardObjectCircle) ws).getWhiteboardPoint());
      obj.setBackgroundColor((((WhiteboardObjectCircle) ws)).getBackgroundColor());
      obj.setColor(ws.getColor());
      obj.setThickness(ws.getThickness());
      wbSession.sendWhiteboardObject(obj);
      return obj;
    } else if (ws instanceof WhiteboardObjectText) {
      if (!supportedWBO.contains(WhiteboardObjectText.NAME)) return null;
      WhiteboardObjectText obj =
          (WhiteboardObjectText) wbSession.createWhiteboardObject(WhiteboardObjectText.NAME);
      ws.setID(obj.getID());
      obj.setFontName(((WhiteboardObjectText) ws).getFontName());
      obj.setFontSize(((WhiteboardObjectText) ws).getFontSize());
      obj.setText(((WhiteboardObjectText) ws).getText());
      obj.setWhiteboardPoint(((WhiteboardObjectText) ws).getWhiteboardPoint());
      obj.setColor(ws.getColor());
      obj.setThickness(ws.getThickness());
      wbSession.sendWhiteboardObject(obj);
      return obj;
    } else if (ws instanceof WhiteboardObjectImage) {
      if (!supportedWBO.contains(WhiteboardObjectImage.NAME)) return null;
      WhiteboardObjectImage obj =
          (WhiteboardObjectImage) wbSession.createWhiteboardObject(WhiteboardObjectImage.NAME);
      ws.setID(obj.getID());
      obj.setBackgroundImage(((WhiteboardObjectImage) ws).getBackgroundImage());
      obj.setHeight(((WhiteboardObjectImage) ws).getHeight());
      obj.setWhiteboardPoint(((WhiteboardObjectImage) ws).getWhiteboardPoint());
      obj.setWidth(((WhiteboardObjectImage) ws).getWidth());
      obj.setColor(ws.getColor());
      obj.setThickness(ws.getThickness());
      wbSession.sendWhiteboardObject(obj);

      return obj;
    }

    return null;
  }