Ejemplo n.º 1
0
 public void itemStateChanged(ItemEvent event) {
   if (event.getStateChange() == ItemEvent.SELECTED) {
     int index = getSelectedIndex();
     int lower = _lower[index];
     int upper = _upper[index];
     MMultiplicity mult = null;
     if (lower >= 0) {
       mult = new MMultiplicity(lower, upper);
     }
     try {
       _setMethod.invoke(_container.getTarget(), new Object[] {mult});
     } catch (Exception e) {
       System.out.println(e.toString() + " in UMLMultiplicityComboBox.itemStateChanged()");
     }
   }
 }
Ejemplo n.º 2
0
  private void update() {
    int lower = -1;
    int upper = -1;

    try {
      Object obj = _getMethod.invoke(_container.getTarget(), _noArg);
      if (obj instanceof MMultiplicity) {
        MMultiplicity mult = (MMultiplicity) obj;
        lower = mult.getLower();
        upper = mult.getUpper();
      }
    } catch (Exception e) {
      System.out.println(e.toString() + " in UMLMultiplicityComboBox.update()");
    }
    boolean match = false;
    for (int i = 0; i < _mults.length; i++) {
      if (lower == _lower[i] && upper == _upper[i]) {
        setSelectedIndex(i);
        match = true;
        break;
      }
    }
    if (!match) {
      StringBuffer buf = new StringBuffer();
      if (lower <= 0) {
        buf.append("0..");
      } else {
        buf.append(Integer.toString(lower));
        buf.append("..");
      }
      if (upper < 0) {
        buf.append("*");
      } else {
        buf.append(Integer.toString(upper));
      }
      setSelectedItem(buf.toString());
    }
  }