コード例 #1
0
 /** dispose of previously set editors and their associated controls before creating new ones */
 private void disposePreviousEditors() {
   for (TableEditor te : installButtonsEditors) {
     if (te.getEditor() != null) {
       te.getEditor().dispose();
     }
     te.dispose();
   }
   installButtonsEditors.clear();
 }
コード例 #2
0
 protected void updateTablesToAddFunctionalUseCaseMap(UseCaseMap map) {
   for (int i = mappedTable.getItems().length - 1; i >= 0; i--) {
     TableEditor editor = (TableEditor) editorsTable.get(mappedTable.getItems()[i]);
     for (int j = 0; j < map.getComponentRoles().size(); j++) {
       ComponentRole c = (ComponentRole) map.getComponentRoles().get(j);
       int index = ((CCombo) editor.getEditor()).getItemCount();
       ((CCombo) editor.getEditor()).add(c.getFullName());
       ((CCombo) editor.getEditor()).setData(String.valueOf(index), c);
       auxiliarTable.put((CCombo) editor.getEditor(), c, new Integer(index));
     }
   }
 }
コード例 #3
0
 protected void updateTablesToRemoveFunctionalUseCaseMap(UseCaseMap map) {
   for (int i = mappedTable.getItems().length - 1; i >= 0; i--) {
     TableEditor editor = (TableEditor) editorsTable.get(mappedTable.getItems()[i]);
     for (int j = map.getComponentRoles().size() - 1; j >= 0; j--) {
       ComponentRole c = (ComponentRole) map.getComponentRoles().get(j);
       Integer index = (Integer) auxiliarTable.get(editor.getEditor(), c);
       if (((CCombo) editor.getEditor()).getSelectionIndex() == index) {
         ((CCombo) editor.getEditor()).select(0);
       }
       ((CCombo) editor.getEditor()).remove(index);
       ((CCombo) editor.getEditor()).redraw();
     }
   }
 }
コード例 #4
0
 protected void updateTablesToRemoveArchitecturalUseCaseMap(UseCaseMap object) {
   for (int i = mappedTable.getItems().length - 1; i >= 0; i--) {
     if (((ComponentRole) mappedTable.getItems()[i].getData()).getMap().equals(object)) {
       TableEditor editor = (TableEditor) editorsTable.get(mappedTable.getItems()[i]);
       editor.getEditor().dispose();
       mappedTable.remove(i);
     }
   }
 }
 private TableEditor initTableEditor(TableEditor editor, Table table) {
   if (null != editor) {
     Control lastCtrl = editor.getEditor();
     if (null != lastCtrl) {
       lastCtrl.dispose();
     }
   }
   editor = new TableEditor(table);
   editor.horizontalAlignment = SWT.LEFT;
   editor.grabHorizontal = true;
   return editor;
 }
コード例 #6
0
 protected void updateEventTableToRemove() {
   Vector currentEvents = new Vector();
   for (int i = 0; i < eventTable.getItemCount(); i++) {
     currentEvents.add(eventTable.getItem(i).getData());
   }
   Vector architecturalMaps = new Vector();
   for (int i = 0; i < architecturalUseCaseMapTable.getItemCount(); i++) {
     architecturalMaps.add(architecturalUseCaseMapTable.getItem(i).getData());
   }
   List events = getEvents(architecturalMaps);
   currentEvents.removeAll(events);
   for (int i = currentEvents.size() - 1; i >= 0; i--) {
     TableEditor editor =
         (TableEditor) editorsTableToEvent.get(getItemEvent(currentEvents.get(i)));
     editor.getEditor().dispose();
     eventTable.remove(i);
   }
 }
コード例 #7
0
ファイル: EventDialog.java プロジェクト: debabratahazra/DS
  /**
   * Install a cell editor for the specified editor.
   *
   * @param editor The selected editor
   * @param row The selected row
   * @param rowIndex The row index
   * @param colIndex The column index
   */
  private void installCellEditor(
      final TableEditor editor, TableItem row, int rowIndex, int colIndex) {
    // Clean up any previous editor control
    Control oldEditor = editor.getEditor();
    if (oldEditor != null) {
      oldEditor.dispose();
    }

    Control newEditor = null;
    String editName = "";
    String paramName = row.getText(0);
    java.util.List<String> values = new ArrayList<String>();
    ParameterType pt = event.getFunctionType().findParameterType(paramName);
    if (pt != null) {
      DataType dt = pt.getType();
      for (DataValue dv : dt.getValues()) {
        values.add(dv.getValue());
      }
      editName = dt.getEditorName();
    }

    // The combobox control that will be the editor must be a child of the Table
    // TODO GHA We should not be using the endsWith to determine the editor name!
    if (editName.endsWith("ComboBoxEditor")) {
      CCombo cbx = new CCombo(paramsTbl, SWT.READ_ONLY | SWT.SINGLE);
      newEditor = cbx;
      // ParameterType
      for (String v : values) {
        cbx.add(v);
      }
      cbx.setText(row.getText(EDITABLE_COLUMN));
      cbx.addSelectionListener(
          new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
              CCombo cbx = (CCombo) editor.getEditor();
              updateTableItemAndParameter(editor.getItem(), cbx.getText());
            }
          });
    }

    // The checkbox control that will be the editor must be a child of the Table
    else if (editName.endsWith("CheckBoxEditor")) {
      Button btn = new Button(paramsTbl, SWT.CHECK);
      newEditor = btn;
      boolean selected = "true".equalsIgnoreCase(row.getText(EDITABLE_COLUMN));
      btn.setSelection(selected);
      btn.addSelectionListener(
          new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
              Button btn = (Button) editor.getEditor();
              String selected = btn.getSelection() ? "true" : "false";
              updateTableItemAndParameter(editor.getItem(), selected);
            }
          });
    }

    // The text control that will be the editor must be a child of the Table
    else {
      Text txt = new Text(paramsTbl, SWT.NONE);
      newEditor = txt;
      txt.setText(row.getText(EDITABLE_COLUMN));
      txt.addModifyListener(
          new ModifyListener() {

            public void modifyText(ModifyEvent e) {
              Text text = (Text) editor.getEditor();
              updateTableItemAndParameter(editor.getItem(), text.getText());
            }
          });
      txt.selectAll();
    }

    newEditor.addFocusListener(
        new FocusAdapter() {

          public void focusLost(FocusEvent e) {
            editor.getEditor().dispose();
          }
        });
    newEditor.setFocus();
    editor.setEditor(newEditor, row, EDITABLE_COLUMN);
  }
コード例 #8
0
  public void initEditFamily(
      List ArchitecturalUseCaseMaps, List FunctionalUseCaseMaps, Family family) {
    createShell();
    Vector functionalMaps = new Vector();
    functionalMaps.addAll(FunctionalUseCaseMaps);
    functionalMaps.removeAll(ArchitecturalUseCaseMaps);
    createUseCaseMaps(shell, ArchitecturalUseCaseMaps, functionalMaps);
    fillPropertyTable(architecturalUseCaseMapTable, family.getArchitecturalUseCaseMaps());
    createEvents(shell, architecturalUseCaseMapTable);
    updateTablesToAddArchitecturalUseCaseMap(
        family.getArchitecturalUseCaseMaps(), functionalUseCaseMapTable, mappedTable);
    fillPropertyTable(functionalUseCaseMapTable, family.getFunctionalUseCaseMaps());

    for (int i = 0; i < family.getFunctionalUseCaseMaps().size(); i++)
      updateTablesToAddFunctionalUseCaseMap((UseCaseMap) family.getFunctionalUseCaseMaps().get(i));

    for (int i = 0; i < family.getFamilyElement().size(); i++) {
      FamilyElement familyElement = (FamilyElement) family.getFamilyElement().get(i);
      for (int j = 0; j < mappedTable.getItems().length; j++) {
        TableItem item = mappedTable.getItems()[j];
        if (item.getData().equals(familyElement.getArchitecturalComponent())) {
          TableEditor editor = (TableEditor) editorsTable.get(item);
          CCombo combo = ((CCombo) editor.getEditor());
          for (int k = 0; k < combo.getItemCount(); k++) {
            if (auxiliarTable.get(combo, familyElement.getFunctionalComponent()) != null
                && (Integer) auxiliarTable.get(combo, familyElement.getFunctionalComponent())
                    == k) {
              combo.select(k);
              break;
            }
          }
        }
      }
    }

    Vector auxComponents = new Vector();
    for (int i = 0; i < family.getFunctionalUseCaseMaps().size(); i++) {
      for (int j = 0;
          j < ((UseCaseMap) family.getFunctionalUseCaseMaps().get(i)).getComponentRoles().size();
          j++) {
        if (!auxComponents.contains(
            ((UseCaseMap) family.getFunctionalUseCaseMaps().get(i)).getComponentRoles().get(j))) {
          auxComponents.add(
              ((UseCaseMap) family.getFunctionalUseCaseMaps().get(i)).getComponentRoles().get(j));
        }
      }
    }

    Vector architecturalMap =
        validateUseCaseMaps(family.getArchitecturalUseCaseMaps(), new Vector());
    for (int i = 0; i < architecturalMap.size(); i++) {
      UseCaseMap useCaseMap = (UseCaseMap) architecturalMap.get(i);
      for (int j = 0; j < useCaseMap.getComponentRoles().size(); j++) {
        boolean findComponent = false;
        for (int k = 0; k < mappedTable.getItems().length; k++) {
          TableItem item = mappedTable.getItems()[k];
          if (item.getData().equals(useCaseMap.getComponentRoles().get(j))) {
            findComponent = true;
            break;
          }
        }
        if (!findComponent) {
          boolean existsUseCaseMap = false;
          for (int k = 0; k < architecturalUseCaseMapTable.getItems().length; k++) {
            TableItem item = architecturalUseCaseMapTable.getItems()[k];
            if (item.getData()
                .equals(((ComponentRole) useCaseMap.getComponentRoles().get(j)).getMap())) {
              existsUseCaseMap = true;
              break;
            }
          }
          if (!existsUseCaseMap) {
            final TableItem item = new TableItem(architecturalUseCaseMapTable, SWT.NONE);
            item.setText(
                new String[] {
                  ((ComponentRole) useCaseMap.getComponentRoles().get(j)).getMap().getName(),
                  ((ComponentRole) useCaseMap.getComponentRoles().get(j)).getMap().getDescription()
                });
            item.setData(((ComponentRole) useCaseMap.getComponentRoles().get(j)).getMap());
          }
          setComboBox(
              mappedTable, (ComponentRole) useCaseMap.getComponentRoles().get(j), auxComponents);
        }
      }
    }

    ConditionEventToConditionEventMapEntryImpl key;
    Object value;
    for (Iterator e = family.getEvents().iterator(); e.hasNext(); ) {
      key = (ConditionEventToConditionEventMapEntryImpl) e.next();
      value = family.getEvents().get(key.getKey());
      for (int j = 0; j < eventTable.getItems().length; j++) {
        TableItem item = eventTable.getItems()[j];
        if (item.getData().equals(key.getKey())) {
          TableEditor editor = (TableEditor) editorsTableToEvent.get(item);
          CCombo combo = ((CCombo) editor.getEditor());
          for (int k = 0; k < combo.getItemCount(); k++) {
            if ((Integer) auxiliarTableToEvent.get(combo, value) == k) {
              combo.select(k);
              break;
            }
          }
        }
      }
    }

    familyName.setText(modifyFamily.getName());
  }