예제 #1
0
  /**
   * Build a collection of menu items relevant for a right-click popup menu on a Class.
   *
   * @param me a mouse event
   * @return a collection of menu items
   * @see org.tigris.gef.ui.PopupGenerator#getPopUpActions(java.awt.event.MouseEvent)
   */
  public Vector getPopUpActions(MouseEvent me) {
    Vector popUpActions = super.getPopUpActions(me);

    // Add...
    ArgoJMenu addMenu = new ArgoJMenu("menu.popup.add");
    addMenu.add(TargetManager.getInstance().getAddAttributeAction());
    addMenu.add(TargetManager.getInstance().getAddOperationAction());
    addMenu.add(new ActionAddNote());
    addMenu.add(ActionEdgesDisplay.getShowEdges());
    addMenu.add(ActionEdgesDisplay.getHideEdges());
    popUpActions.insertElementAt(addMenu, popUpActions.size() - getPopupAddOffset());

    // Show ...
    ArgoJMenu showMenu = new ArgoJMenu("menu.popup.show");
    Iterator i = ActionCompartmentDisplay.getActions().iterator();
    while (i.hasNext()) {
      showMenu.add((Action) i.next());
    }
    popUpActions.insertElementAt(showMenu, popUpActions.size() - getPopupAddOffset());

    // Modifiers ...
    popUpActions.insertElementAt(
        buildModifierPopUp(ABSTRACT | LEAF | ROOT | ACTIVE),
        popUpActions.size() - getPopupAddOffset());

    // Visibility ...
    popUpActions.insertElementAt(buildVisibilityPopUp(), popUpActions.size() - getPopupAddOffset());

    return popUpActions;
  }
 private void moveUpAndDownPage(boolean _up) {
   int index = tabbedPanel.getSelectedIndex();
   if (index < 0) return;
   Editor page = pageList.get(index);
   if (page == null) return;
   if (_up) {
     if (index == 0) return;
     pageList.removeElementAt(index);
     pageList.insertElementAt(page, index - 1);
     tabbedPanel.removeTabAt(index);
     tabbedPanel.insertTab(
         page.isActive() ? page.getName() : page.getName() + " (D)",
         null,
         page.getComponent(),
         tooltip,
         index - 1);
   } else {
     if (index == (pageList.size() - 1)) return;
     pageList.removeElementAt(index);
     pageList.insertElementAt(page, index + 1);
     tabbedPanel.removeTabAt(index);
     tabbedPanel.insertTab(
         page.isActive() ? page.getName() : page.getName() + " (D)",
         null,
         page.getComponent(),
         tooltip,
         index + 1);
   }
   tabbedPanel.setSelectedComponent(page.getComponent());
   changed = true;
 }
예제 #3
0
  public void init() {
    GridBagConstraints gbc;
    GridBagLayout gbl = new GridBagLayout();

    resourcesLabel = new Label("Resources");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(resourcesLabel, gbc);

    idLabel = new Label("Id", Label.RIGHT);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 2;
    gbl.setConstraints(idLabel, gbc);

    availableLabel = new Label("Available", Label.RIGHT);
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 2;
    gbl.setConstraints(availableLabel, gbc);

    for (int i = 0; i < resourceCount; i++) {
      Label idLabel;
      Label availableLabel;
      // create the labels
      // add labels to the vectors
      // set constraints
      idLabel = new Label();
      idLabel.setAlignment(Label.RIGHT);
      resourceIdLabelVector.insertElementAt(idLabel, i);
      gbc = new GridBagConstraints();
      gbc.gridx = 1;
      gbc.gridy = 3 + i;
      gbl.setConstraints(idLabel, gbc);

      availableLabel = new Label();
      availableLabel.setAlignment(Label.RIGHT);
      resourceAvailableLabelVector.insertElementAt(availableLabel, i);
      gbc = new GridBagConstraints();
      gbc.gridx = 2;
      gbc.gridy = 3 + i;
      gbl.setConstraints(availableLabel, gbc);
    }

    setLayout(gbl);

    add(resourcesLabel);
    add(idLabel);
    add(availableLabel);
    for (int i = 0; i < resourceCount; i++) {
      Label idLabel;
      Label availableLabel;
      idLabel = (Label) resourceIdLabelVector.elementAt(i);
      availableLabel = (Label) resourceAvailableLabelVector.elementAt(i);
      add(idLabel);
      add(availableLabel);
    }
  }
예제 #4
0
  /**
   * Function to swap two itemsets.
   *
   * @param i The first itemset.
   * @param j The second itemset.
   */
  private void swap(int i, int j) {
    Object help = itemsets.elementAt(i);

    itemsets.insertElementAt(itemsets.elementAt(j), i);
    itemsets.removeElementAt(i + 1);
    itemsets.insertElementAt(help, j);
    itemsets.removeElementAt(j + 1);
  }
  /** @see org.tigris.gef.ui.PopupGenerator#getPopUpActions(java.awt.event.MouseEvent) */
  public Vector getPopUpActions(MouseEvent me) {
    Vector popUpActions = super.getPopUpActions(me);

    // TODO: Remove this line after 0.20.
    // This is a hack that removes the ordering menu according to issue 3645
    popUpActions.remove(0);

    // popupAddOffset should be equal to the number of items added here:
    popUpActions.addElement(new JSeparator());
    popupAddOffset = 1;
    if (removeFromDiagram) {
      popUpActions.addElement(ProjectBrowser.getInstance().getRemoveFromDiagramAction());
      popupAddOffset++;
    }
    popUpActions.addElement(new ActionDeleteModelElements());
    popupAddOffset++;

    /* Check if multiple items are selected: */
    boolean ms = TargetManager.getInstance().getTargets().size() > 1;
    if (!ms) {
      // #if defined(COGNITIVE)
      // @#$LPS-COGNITIVE:GranularityType:Statement
      // @#$LPS-COGNITIVE:Localization:NestedStatement
      ToDoList list = Designer.theDesigner().getToDoList();
      Vector items = (Vector) list.elementsForOffender(getOwner()).clone();
      if (items != null && items.size() > 0) {
        ArgoJMenu critiques = new ArgoJMenu("menu.popup.critiques");
        ToDoItem itemUnderMouse = hitClarifier(me.getX(), me.getY());
        if (itemUnderMouse != null) {
          critiques.add(new ActionGoToCritique(itemUnderMouse));
          critiques.addSeparator();
        }
        int size = items.size();
        for (int i = 0; i < size; i++) {
          ToDoItem item = (ToDoItem) items.elementAt(i);
          if (item == itemUnderMouse) continue;
          critiques.add(new ActionGoToCritique(item));
        }
        popUpActions.insertElementAt(new JSeparator(), 0);
        popUpActions.insertElementAt(critiques, 0);
      }
    }
    // #endif

    // Add stereotypes submenu
    Action[] stereoActions = getApplyStereotypeActions();
    if (stereoActions != null) {
      popUpActions.insertElementAt(new JSeparator(), 0);
      ArgoJMenu stereotypes = new ArgoJMenu("menu.popup.apply-stereotypes");
      for (int i = 0; i < stereoActions.length; ++i) {
        stereotypes.addCheckItem(stereoActions[i]);
      }
      popUpActions.insertElementAt(stereotypes, 0);
    }
    return popUpActions;
  }
예제 #6
0
  public void addMethod(JMethod jMethod) throws IllegalArgumentException {
    if (jMethod == null) {
      throw new IllegalArgumentException("Class methods cannot be null");
    }

    // -- check method name and signatures *add later*

    // -- keep method list sorted for esthetics when printing
    // -- START SORT :-)
    boolean added = false;
    short modifierVal = 0;
    JModifiers modifiers = jMethod.getModifiers();

    for (int i = 0; i < methods.size(); i++) {
      JMethod tmp = (JMethod) methods.elementAt(i);
      // -- first compare modifiers
      if (tmp.getModifiers().isPrivate()) {
        if (!modifiers.isPrivate()) {
          methods.insertElementAt(jMethod, i);
          added = true;
          break;
        }
      }
      // -- compare names
      if (jMethod.getName().compareTo(tmp.getName()) < 0) {
        methods.insertElementAt(jMethod, i);
        added = true;
        break;
      }
    }
    // -- END SORT
    if (!added) methods.addElement(jMethod);

    // -- check parameter packages to make sure we have them
    // -- in our import list

    String[] pkgNames = jMethod.getParameterClassNames();
    for (int i = 0; i < pkgNames.length; i++) {
      addImport(pkgNames[i]);
    }
    // -- check return type to make sure it's included in the
    // -- import list
    JType jType = jMethod.getReturnType();
    if (jType != null) {
      while (jType.isArray()) jType = jType.getComponentType();

      if (!jType.isPrimitive()) addImport(((JClass) jType).getName());
    }
    // -- check exceptions
    JClass[] exceptions = jMethod.getExceptions();
    for (int i = 0; i < exceptions.length; i++) {
      addImport(exceptions[i].getName());
    }
  } // -- addMethod
예제 #7
0
  @SuppressWarnings({"rawtypes", "unchecked"})
  private void ladeTabelle() {
    String test = Reha.thisClass.patpanel.patDaten.get(63);
    if (test.trim().equals("")) {
      JOptionPane.showMessageDialog(
          null, "Mit der Arztliste dieses Patienten läuft etwas schief....");
    } else {
      String[] arztid = test.split("\n");

      for (int i = 0; i < arztid.length; i++) {
        String[] arzt = arztid[i].split("@");
        Vector<Vector<String>> vec =
            SqlInfo.holeFelder(
                "select nachname,vorname,strasse,ort,arztnum,bsnr,id from arzt where id = '"
                    + arzt[1]
                    + "' LIMIT 1");
        if (vec.size() >= 1) {
          Vector vec2 = (Vector) ((Vector) vec.get(0)).clone();
          vec2.insertElementAt(Boolean.valueOf(false), 0);
          atblm.addRow((Vector) vec2.clone());
        }
      }
      if (atblm.getRowCount() > 0) {
        arzttbl.setRowSelectionInterval(0, 0);
      }
      arzttbl.revalidate();
    }
  }
예제 #8
0
 public static InventoryList fetchInventory(MOB seer, MOB mob) {
   final InventoryList lst = new InventoryList();
   Vector<Coins> coinsV = null;
   int insertAt = -1;
   CMLib.beanCounter().getTotalAbsoluteNativeValue(mob);
   for (final Enumeration<Item> i = mob.items(); i.hasMoreElements(); ) {
     final Item thisItem = i.nextElement();
     if (thisItem == null) continue;
     if ((thisItem.container() == null) && (thisItem.amWearingAt(Wearable.IN_INVENTORY))) {
       if (CMLib.flags().canBeSeenBy(thisItem, seer)) lst.foundAndSeen = true;
       else lst.foundButUnseen = true;
       if ((!(thisItem instanceof Coins)) || (((Coins) thisItem).getDenomination() == 0.0))
         lst.viewItems.add(thisItem);
       else {
         coinsV = lst.moneyItems.get(((Coins) thisItem).getCurrency());
         if (coinsV == null) {
           coinsV = new Vector<Coins>();
           lst.moneyItems.put(((Coins) thisItem).getCurrency(), coinsV);
         }
         for (insertAt = 0; insertAt < coinsV.size(); insertAt++)
           if (coinsV.get(insertAt).getDenomination() > ((Coins) thisItem).getDenomination())
             break;
         if (insertAt >= coinsV.size()) coinsV.add((Coins) thisItem);
         else coinsV.insertElementAt((Coins) thisItem, insertAt);
       }
     }
   }
   return lst;
 }
  public Vector put(Range holder, Object value) {
    int pos = VectorUtil.binarySearch(ranges, holder, rangeComparator, true);
    if (pos == -1) {
      pos = 0;
    }
    Vector output = new Vector();

    int posHigh =
        VectorUtil.binarySearch(
            ranges, new RangeHolder(holder.getHigh(), holder.getHigh()), rangeComparator, true);

    Vector purged = new Vector();
    boolean positionRemoved = false;
    for (int i = (pos - 1 >= 0 ? pos - 1 : 0); i < posHigh && i < ranges.size(); i++) {
      Range clobberMe = (Range) ranges.elementAt(i);
      if (overlaps(clobberMe, holder)) {
        if (i == pos - 1) positionRemoved = true;
        output.addElement(data.remove(clobberMe));
        purged.addElement(clobberMe);
      }
    }
    for (int i = 0; i < purged.size(); i++) ranges.removeElement(purged.elementAt(i));

    if (positionRemoved) pos = pos - 1;

    ranges.insertElementAt(holder, pos);
    data.put(holder, value);
    return output;
  }
예제 #10
0
  // public MazeImpl(Point point, long seed) {
  public MazeImpl(Point point, long seed, BlockingQueue eventQueue, Client client) {
    this.eventQueue = eventQueue;
    this.client = client;
    System.out.println("MazeImpl constructor Client name:" + client.getName());

    maxX = point.getX();
    assert (maxX > 0);
    maxY = point.getY();
    assert (maxY > 0);

    // Initialize the maze matrix of cells
    mazeVector = new Vector(maxX);
    for (int i = 0; i < maxX; i++) {
      Vector colVector = new Vector(maxY);

      for (int j = 0; j < maxY; j++) {
        colVector.insertElementAt(new CellImpl(), j);
      }

      mazeVector.insertElementAt(colVector, i);
    }

    thread = new Thread(this);

    // Initialized the random number generator
    randomGen = new Random(seed);

    // Build the maze starting at the corner
    if (seed == 0) buildEmptyMaze();
    else buildMaze(new Point(0, 0));

    thread.start();
  }
예제 #11
0
 /*
  * @see org.tigris.gef.ui.PopupGenerator#getPopUpActions(
  *         java.awt.event.MouseEvent)
  */
 public Vector getPopUpActions(MouseEvent me) {
   Vector popUpActions = super.getPopUpActions(me);
   // Modifiers ...
   popUpActions.insertElementAt(
       buildModifierPopUp(ABSTRACT | LEAF | ROOT), popUpActions.size() - getPopupAddOffset());
   return popUpActions;
 }
예제 #12
0
 private static Object readValue(InputStream is, ClassLoader loader) throws Exception {
   byte type = (byte) is.read();
   if (type == -1) {
     return null;
   }
   Class vClass = null;
   if (type == 2) {
     int length = PDataStream.readInt(is);
     Vector v = new Vector(length);
     for (int i = 0; i < length; i++) {
       v.insertElementAt(readValue(is, loader), i);
     }
     return v;
   } else if (type == 0) {
     return readRealObject((byte) is.read(), is, loader);
   } else {
     int length = PDataStream.readInt(is);
     boolean primitive = PDataStream.readBoolean(is);
     if (primitive) {
       return readPrimitiveArray(length, is);
     }
     vClass =
         loader == null
             ? Class.forName(PDataStream.readUTF(is))
             : loader.loadClass(PDataStream.readUTF(is));
     Object array = Array.newInstance(vClass, length);
     for (int i = 0; i < length; i++) {
       Array.set(array, i, readValue(is, loader));
     }
     return array;
   }
 }
예제 #13
0
  private void runScript(File script) {
    FileReader fr;
    try {
      fr = new FileReader(script);
    } catch (FileNotFoundException e) {
      HF.showErrorMessage(i18n.getMessage("FileNotFound!"));
      return;
    }

    BufferedReader br = new BufferedReader(fr);

    try {
      String s = br.readLine();
      while (s != null) {
        getLSConsoleModel().setCommandLineText(s);
        getLSConsoleModel().execCommand();
        s = br.readLine();
      }
    } catch (Exception e) {
      HF.showErrorMessage(e);
      return;
    }

    if (!cbmiLSConsoleShown.isSelected()) cbmiLSConsoleShown.doClick(0);

    String s = script.getAbsolutePath();
    recentScripts.remove(s);
    recentScripts.insertElementAt(s, 0);

    while (recentScripts.size() > ClassicPrefs.getRecentScriptsSize()) {
      recentScripts.removeElementAt(recentScripts.size() - 1);
    }

    updateRecentScriptsMenu();
  }
예제 #14
0
 /**
  * Removes interval [fx,tx] from existing set such that none of its elements intersects with it
  * anymore. Existing intervals are reduced if they intersect, split into two or fully removed if
  * they are contained in [fx,tx]
  *
  * @param fx is the lower bound of the interval
  * @param tx is the upper bound of the interval
  */
 public void remove(int fx, int tx) {
   // make sure fx <= tx
   if (tx < fx) {
     int jj = tx;
     tx = fx;
     fx = jj;
   }
   // check all elements of the set for an overlap with interval [fx,tx]
   // assume that set is sorted in increasing order
   for (int i = 0; i != ranges.size(); i++) {
     RangeSetElement rse = (RangeSetElement) ranges.elementAt(i);
     if (rse.max < fx) continue; // rse is below [fx,tx]
     if (rse.min > tx) return; // rse is above [fx,tx]
     if (fx <= rse.min) {
       if (rse.max <= tx) { // rse is inside [fx,tx]
         ranges.removeElementAt(i--); // remove element, adjust index for iterating reduced set
         continue;
       }
       rse.min =
           tx + 1; // else, rse and [fx,tx] overlap, truncate intersection from rse from below
       return;
     }
     if (fx <= rse.max && tx >= rse.max) { // rse.min < fx <= rse.max <= tx
       rse.max = fx - 1; // rse and [fx,tx] overlap, truncate intersection from rse from above
       continue;
     }
     // if all conditions fail, then [fx,tx] lies inside the current interval
     // split interval into two: [rse.min,fx-1] and [tx+1,rse.max]
     RangeSetElement nrse = new RangeSetElement(rse.min, fx - 1);
     ranges.insertElementAt(nrse, i);
     rse.min = tx + 1;
     return;
   }
 }
 protected void addPage(String _typeOfPage, String _name, String _code, boolean _enabled) {
   cardLayout.show(finalPanel, "TabbedPanel");
   _name = getUniqueName(_name);
   Editor page = createPage(_typeOfPage, _name, _code);
   page.setFont(myFont);
   page.setColor(myColor);
   int index = tabbedPanel.getSelectedIndex();
   if (index == -1) {
     pageList.addElement(page);
     if (tabbedPanel.getTabCount() == 0) {
       tabbedPanel.addTab(
           page.getName(),
           null,
           page.getComponent(),
           tooltip); // This causes an exception sometimes
     } else {
       tabbedPanel.insertTab(
           page.getName(), null, page.getComponent(), tooltip, tabbedPanel.getTabCount());
     }
     index = 0;
   } else {
     index++;
     pageList.insertElementAt(page, index);
     tabbedPanel.insertTab(page.getName(), null, page.getComponent(), tooltip, index);
   }
   tabbedPanel.setSelectedComponent(page.getComponent());
   page.setActive(_enabled);
   if (!_enabled) tabbedPanel.setTitleAt(index, page.getName() + " (D)");
   updatePageCounterField(pageList.size());
   // tabbedPanel.validate(); This hangs the computer when reading a file at start-up !!!???
   tabbedPanel.repaint();
   changed = true;
 }
예제 #16
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();
   }
 }
    public ElementListModel(Vector list) {
      elements = new Vector();

      if (list != null) {
        for (int i = 0; i < list.size(); i++) {
          SchemaElement element = (SchemaElement) list.elementAt(i);

          // Find out where to insert the element...
          int index = -1;

          for (int j = 0; j < elements.size() && index == -1; j++) {
            // Compare alphabeticaly
            if (element
                    .getName()
                    .compareToIgnoreCase(((SchemaElement) elements.elementAt(j)).getName())
                <= 0) {
              index = j;
            }
          }

          if (index != -1) {
            elements.insertElementAt(element, index);
          } else {
            elements.addElement(element);
          }
        }
      }
    }
  protected TnLocation getLocationByCellTowerInfo(TnCellInfo cellTowerInfo) {
    if (cellTowerInfo == null) return null;

    synchronized (mutex) {
      int index = findCellTowerInfoIndex(cellTowerInfo);
      if (index == -1) return null;

      CellTowerMapping mapping = (CellTowerMapping) cellTowerMappingInfos.elementAt(index);
      TnLocation location = mapping.location;
      cellTowerMappingInfos.removeElementAt(index);

      if (System.currentTimeMillis()
          > location.getLocalTimeStamp() + CELL_LOCATION_CACHE_EXPIRATION_TIME) {
        return null;
      }

      cellTowerMappingInfos.insertElementAt(mapping, 0);

      TnLocation clone = new TnLocation("");
      clone.set(location);
      clone.setLocalTimeStamp(System.currentTimeMillis());
      clone.setTime(System.currentTimeMillis() / 10);

      return clone;
    }
  }
예제 #19
0
  /*
   * Adds an element to the table but in the rigth place
   */
  public void addElement(String element) {
    Vector newRow = new Vector(2);
    if (!isElement(element)) {
      newRow.add(element);
      newRow.add(new Boolean(true));

      // Let's order the data
      int i = 0;
      boolean inserted = false;
      while ((i < data.size()) && (!inserted)) {
        if (order((String) getValueAt(i, 0)).compareTo(order(element)) > 0) {
          data.insertElementAt(newRow, i);
          inserted = true;
        } else i++;
      }
      if (!inserted) {
        data.addElement(newRow);
      }

      // Create a TableModelEvent
      TableModelEvent evento;
      evento =
          new TableModelEvent(
              this,
              this.getRowCount() - 1,
              this.getRowCount() - 1,
              TableModelEvent.ALL_COLUMNS,
              TableModelEvent.INSERT);
      // and tell the listeners
      tellListeners(evento);
    } else setValueAt(new Boolean(true), whereIsElement(element), 1);
  }
  /**
   * Moves the column and heading at <code>columnIndex</code> to <code>newIndex</code>. The old
   * column at <code>columnIndex</code> will now be found at <code>newIndex</code>. The column that
   * used to be at <code>newIndex</code> is shifted left or right to make room. This will not move
   * any columns if <code>columnIndex</code> equals <code>newIndex</code>. This method also posts a
   * <code>columnMoved</code> event to its listeners.
   *
   * @param columnIndex the index of column to be moved
   * @param newIndex new index to move the column
   * @exception IllegalArgumentException if <code>column</code> or <code>newIndex</code> are not in
   *     the valid range
   */
  public void moveColumn(int columnIndex, int newIndex) {
    if ((columnIndex < 0)
        || (columnIndex >= getColumnCount())
        || (newIndex < 0)
        || (newIndex >= getColumnCount()))
      throw new IllegalArgumentException("moveColumn() - Index out of range");

    TableColumn aColumn;

    // If the column has not yet moved far enough to change positions
    // post the event anyway, the "draggedDistance" property of the
    // tableHeader will say how far the column has been dragged.
    // Here we are really trying to get the best out of an
    // API that could do with some rethinking. We preserve backward
    // compatibility by slightly bending the meaning of these methods.
    if (columnIndex == newIndex) {
      fireColumnMoved(new TableColumnModelEvent(this, columnIndex, newIndex));
      return;
    }
    aColumn = (TableColumn) tableColumns.elementAt(columnIndex);

    tableColumns.removeElementAt(columnIndex);
    boolean selected = selectionModel.isSelectedIndex(columnIndex);
    selectionModel.removeIndexInterval(columnIndex, columnIndex);

    tableColumns.insertElementAt(aColumn, newIndex);
    selectionModel.insertIndexInterval(newIndex, 1, true);
    if (selected) {
      selectionModel.addSelectionInterval(newIndex, newIndex);
    } else {
      selectionModel.removeSelectionInterval(newIndex, newIndex);
    }

    fireColumnMoved(new TableColumnModelEvent(this, columnIndex, newIndex));
  }
예제 #21
0
  /**
   * Adds the given JMethodSignature to this JClass
   *
   * @param jMethodSig the JMethodSignature to add.
   * @throws java.lang.IllegalArgumentException when the given JMethodSignature conflicts with an
   *     existing method signature.
   */
  public void addMethod(JMethodSignature jMethodSig) throws IllegalArgumentException {
    if (jMethodSig == null) {
      String err = "The JMethodSignature cannot be null.";
      throw new IllegalArgumentException(err);
    }

    // -- check method name and signatures *add later*

    // -- keep method list sorted for esthetics when printing
    // -- START SORT :-)
    boolean added = false;
    //        short modifierVal = 0;
    JModifiers modifiers = jMethodSig.getModifiers();
    for (int i = 0; i < methods.size(); i++) {
      JMethodSignature tmp = (JMethodSignature) methods.elementAt(i);
      // -- first compare modifiers
      if (tmp.getModifiers().isProtected()) {
        if (!modifiers.isProtected()) {
          methods.insertElementAt(jMethodSig, i);
          added = true;
          break;
        }
      }
      // -- compare names
      if (jMethodSig.getName().compareTo(tmp.getName()) < 0) {
        methods.insertElementAt(jMethodSig, i);
        added = true;
        break;
      }
    }
    // -- END SORT
    if (!added) methods.addElement(jMethodSig);

    // -- check return type to make sure it's included in the
    // -- import list
    JType jType = jMethodSig.getReturnType();
    if (jType != null) {
      while (jType.isArray()) jType = jType.getComponentType();

      if (!jType.isPrimitive()) addImport(jType.getName());
    }
    // -- check exceptions
    JClass[] exceptions = jMethodSig.getExceptions();
    for (JClass exception : exceptions) {
      addImport(exception.getName());
    }
  } // -- addMethod
예제 #22
0
 /** Adds an element at the current position. */
 public void addHere(Named n) {
   if (!readonly) {
     synchronized (this) {
       data.insertElementAt(n, pos);
       hash.put(n.getName(), n);
     }
   }
 }
예제 #23
0
  public void add(String s) {
    if (s == null || s.equals("")) return;

    if (list.contains(s)) {
      list.remove(s);
    }
    list.insertElementAt(s, 0);
  }
예제 #24
0
 public void insertRow(Object[] obj) {
   if (getRowCount() == 0) {
     vRows.addElement(obj);
   } else {
     vRows.insertElementAt(obj, 0);
   }
   fireTableRowsInserted(getRowCount(), getRowCount());
 }
예제 #25
0
  @Override
  public void onApplicationEvent(BusinessObjectEvent event) {

    if (event.getBusinessObject() instanceof LogMessage
        && event.getType() instanceof BusinessObjectCreated) {

      LogMessage logMessage = (LogMessage) event.getBusinessObject();
      rows.insertElementAt(logMessage, 0);

      if (!paused
          && (activeAgents.isEmpty()
              || activeAgents.contains(logMessage.getLogFile().getAgent()))) {
        visibleRows.insertElementAt(logMessage, 0);
        super.tableRowsChanged();
      }
    }
  }
예제 #26
0
  // format == null assumed here
  private final void setTokens(final String format) {
    if ((_format != null) && (format.equals(_format))) { // has already been set
      return;
    }
    _format = format;
    // reset
    final int length = _format.length();
    boolean isFirst = true;
    _separFirst = true;
    _separLast = false;
    _nSepars = 0;
    _nFormats = 0;
    _separToks.clear();
    _formatToks.clear();

    /*
     * Tokenize the format string into alphanumeric and non-alphanumeric
     * tokens as described in M. Kay page 241.
     */
    for (int j = 0, i = 0; i < length; ) {
      char c = format.charAt(i);
      for (j = i; Character.isLetterOrDigit(c); ) {
        if (++i == length) break;
        c = format.charAt(i);
      }
      if (i > j) {
        if (isFirst) {
          _separToks.addElement(".");
          isFirst = _separFirst = false;
        }
        _formatToks.addElement(format.substring(j, i));
      }

      if (i == length) break;

      c = format.charAt(i);
      for (j = i; !Character.isLetterOrDigit(c); ) {
        if (++i == length) break;
        c = format.charAt(i);
        isFirst = false;
      }
      if (i > j) {
        _separToks.addElement(format.substring(j, i));
      }
    }

    _nSepars = _separToks.size();
    _nFormats = _formatToks.size();
    if (_nSepars > _nFormats) _separLast = true;

    if (_separFirst) _nSepars--;
    if (_separLast) _nSepars--;
    if (_nSepars == 0) {
      _separToks.insertElementAt(".", 1);
      _nSepars++;
    }
    if (_separFirst) _nSepars++;
  }
예제 #27
0
 // add new value; return index inserted at if value was not already present, -1 if it was
 public int add(FormIndex index) {
   int i = indexOf(index, false);
   if (i != -1 && get(i).equals(index)) {
     return -1;
   } else {
     v.insertElementAt(index, i + 1);
     return i + 1;
   }
 }
예제 #28
0
  /**
   * Adds the specified item to the specified location in the list. If the desired index is -1 or
   * greater than the number of rows in the list, then the item is added to the end.
   *
   * @param item The item to add to the list.
   * @param index The location in the list to add the item, or -1 to add to the end.
   */
  public void add(String item, int index) {
    if ((index == -1) || (index >= items.size())) items.addElement(item);
    else items.insertElementAt(item, index);

    if (peer != null) {
      ListPeer l = (ListPeer) peer;
      l.add(item, index);
    }
  }
예제 #29
0
 /**
  * Inserts a {@link DataElement} at the specified index. After the element has been successfully
  * inserted all {@link DataListener DataListeners} will be informed.
  *
  * @param index Index at which <tt>element</tt> will be inserted. All elements with an index &gt;=
  *     <tt>index</tt> will be shifted.
  * @param element DataElement to be added.
  * @throws IllegalArgumentException if <tt>element</tt> is not of the correct type which will be
  *     checked by the method {@link #isValid}.
  */
 public void insertElementAt(int index, DataElement element) {
   if (isValid(element)) {
     _container.insertElementAt(element, index);
     element.setContainer(this);
     notifyListeners(DataEvent.createInsertEvent(this, index));
   } else {
     throwException(INSERT, element);
   }
 }
예제 #30
0
 /**
  * moveData
  *
  * @param curRow Old row for the data
  * @param newRow New row for the data
  */
 private void moveData(int curRow, int newRow) {
   int lastRow = rowData.size() - 1;
   if (curRow >= 0 && curRow <= lastRow && newRow >= 0 && newRow <= lastRow) {
     Object[] curData = (Object[]) rowData.elementAt(curRow);
     rowData.removeElementAt(curRow);
     rowData.insertElementAt(curData, newRow);
     fireTableDataChanged();
   }
 }