private void setComboBox(Table table, ComponentRole value, List componentsToMap) {
   final TableItem item = new TableItem(table, SWT.NONE);
   item.setText(new String[] {value.getFullName(), value.getAbstractInfo()});
   item.setData(value);
   TableEditor editor = new TableEditor(table);
   final CCombo comboRole = new CCombo(table, SWT.READ_ONLY);
   GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
   gd.widthHint = 200;
   comboRole.setLayoutData(gd);
   int j = 0;
   for (j = 0; j < componentsToMap.size(); j++) {
     ComponentRole c = (ComponentRole) componentsToMap.get(j);
     comboRole.add(c.getFullName());
     comboRole.setData(String.valueOf(j), c);
     auxiliarTable.put(comboRole, c, new Integer(j));
   }
   if (value.getAbstractInfo().equals(ComponentRole.standardComponent)) {
     comboRole.add(value.getFullName());
     comboRole.setData(String.valueOf(j), value);
     comboRole.select(j);
     auxiliarTable.put(comboRole, value, new Integer(j));
   } else {
     comboRole.add(
         Messages.getString(
             "org.isistan.flabot.edit.ucmeditor.dialogs.FamilyManagerDialog.noneRole")); //$NON-NLS-1$
     comboRole.setData("None", "None"); // $NON-NLS-1$ //$NON-NLS-2$
     comboRole.select(j);
   }
   editor.grabHorizontal = true;
   editor.setEditor(comboRole, item, 2);
   editorsTable.put(item, editor);
   combosTable.put(item, comboRole);
 }
 private void setComboBoxToEvents(Table table, ConditionEvent value, List events) {
   final TableItem item = new TableItem(table, SWT.NONE);
   item.setText(new String[] {value.getName(), value.getDescription()});
   item.setData(value);
   TableEditor editor = new TableEditor(table);
   final CCombo comboRole = new CCombo(table, SWT.READ_ONLY);
   GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
   gd.widthHint = 200;
   comboRole.setLayoutData(gd);
   int k = 0;
   for (int j = 0; j < events.size(); j++) {
     ConditionEvent c = (ConditionEvent) events.get(j);
     comboRole.add(c.getName());
     comboRole.setData(String.valueOf(j), c);
     auxiliarTableToEvent.put(comboRole, c, new Integer(j));
     if (value.equals(c)) {
       k = j;
     }
   }
   comboRole.select(k);
   editor.grabHorizontal = true;
   editor.setEditor(comboRole, item, 2);
   editorsTableToEvent.put(item, editor);
   combosTableToEvent.put(item, comboRole);
 }
 /** 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();
 }
 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);
     }
   }
 }
 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));
     }
   }
 }
 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;
 }
  private void setupTableEditor(final Table table) {
    final TableEditor cellEditor = new TableEditor(table);
    cellEditor.grabHorizontal = true;
    cellEditor.minimumWidth = 50;
    table.addMouseListener(
        new MouseAdapter() {
          /** Setup a new cell editor control at double click event. */
          public void mouseDoubleClick(MouseEvent e) {
            // Dispose the old editor control (if one is setup).
            Control oldEditorControl = cellEditor.getEditor();
            if (null != oldEditorControl) oldEditorControl.dispose();

            // Mouse location.
            Point mouseLocation = new Point(e.x, e.y);

            // Grab the selected row.
            TableItem item = (TableItem) table.getItem(mouseLocation);
            if (null == item) return;

            // Determine which column was selected.
            int selectedColumn = -1;
            for (int i = 0, n = table.getColumnCount(); i < n; i++) {
              if (item.getBounds(i).contains(mouseLocation)) {
                selectedColumn = i;
                break;
              }
            }

            // Setup a new editor control.
            if (-1 != selectedColumn) {
              Text editorControl = new Text(table, SWT.NONE);
              final int editorControlColumn = selectedColumn;
              editorControl.setText(item.getText(selectedColumn));
              editorControl.addModifyListener(
                  new ModifyListener() {
                    public void modifyText(ModifyEvent e) {
                      Text text = (Text) cellEditor.getEditor();
                      cellEditor.getItem().setText(editorControlColumn, text.getText());
                    }
                  });
              editorControl.selectAll();
              editorControl.setFocus();
              cellEditor.setEditor(editorControl, item, selectedColumn);
            }
          }

          /** Dispose cell editor control at mouse down (otherwise the control keep showing). */
          public void mouseDown(MouseEvent e) {
            Control oldEditorControl = cellEditor.getEditor();
            if (null != oldEditorControl) oldEditorControl.dispose();
          }
        });
  }
 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();
     }
   }
 }
  /**
   * create check boxes
   *
   * @param tableIndex
   * @param tabItem
   * @param type
   * @param roleData
   */
  private void createCheckBoxes(int tableIndex, TableItem tabItem, int type, RoleData roleData) {
    TableEditor editor = new TableEditor(table);
    boolean value = false;
    String permission = "";

    if (roleData.role.equals(BaseConstants.ADMIN)) {
      check = new Button(table, SWT.CHECK | SWT.READ_ONLY);
      value = true;
      if (type == 0) {
        permission = BaseConstants.READ;
      }
      if (type == 1) {
        permission = BaseConstants.WRITE;
      }
      if (type == 2) {
        permission = BaseConstants.DELETE;
      }
      if (type == 3) {
        permission = BaseConstants.AUTHORIZE;
      }
    } else {
      check = new Button(table, SWT.CHECK);
      if (type == 0) {
        permission = BaseConstants.READ;
        value = roleData.readPerm;
      }
      if (type == 1) {
        permission = BaseConstants.WRITE;
        value = roleData.writePerm;
      }
      if (type == 2) {
        permission = BaseConstants.DELETE;
        value = roleData.deletePerm;
      }
      if (type == 3) {
        permission = BaseConstants.AUTHORIZE;
        value = roleData.authPerm;
      }
    }
    check.setBackground(table.getBackground());
    editor.grabHorizontal = true;
    editor.setEditor(check, tabItem, tableIndex);
    check.setText(permission);
    check.setSelection(value);
    editor.layout();

    check.addSelectionListener(new RolePermissionSelectionListener(roleData));
  }
 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);
   }
 }
  private void editItem(final TableItem item) {
    NamespacedProperty expression =
        ((PublishEventMediatorAttributeImpl) item.getData()).getAttributeExpression();

    // value type table editor
    valueTypeEditor = initTableEditor(valueTypeEditor, item.getParent());
    cmbValueType = new Combo(item.getParent(), SWT.READ_ONLY);
    cmbValueType.setItems(
        new String[] {
          AttributeValueType.STRING.getLiteral(), AttributeValueType.EXPRESSION.getLiteral()
        });
    cmbValueType.setText(item.getText(2));
    valueTypeEditor.setEditor(cmbValueType, item, 2);

    item.getParent().redraw();
    item.getParent().layout();
    cmbValueType.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event evt) {
            item.setText(2, cmbValueType.getText());
          }
        });

    attributeValueEditor = initTableEditor(attributeValueEditor, item.getParent());
    attributeValue = new PropertyText(item.getParent(), SWT.NONE, cmbValueType);
    attributeValue.addProperties(item.getText(1), expression);
    attributeValueEditor.setEditor(attributeValue, item, 1);
    item.getParent().redraw();
    item.getParent().layout();
    attributeValue.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            item.setText(1, attributeValue.getText());
            Object property = attributeValue.getProperty();
            if (property instanceof NamespacedProperty) {
              item.setData(EXPRESSION_DATA, (NamespacedProperty) property);
            }
          }
        });
  }
 public void setValuesToItem(
     Table table, TableItem item, String[] values, Object valueData, TableItem newitem) {
   item.setText(values);
   item.setData(valueData);
   Object key;
   Object value;
   Hashtable newCombosTable = new Hashtable();
   for (Enumeration e = combosTable.keys(); e.hasMoreElements(); ) {
     key = (Object) e.nextElement();
     value = (Object) combosTable.get(key);
     if (!value.equals(combo)) {
       newCombosTable.put(key, value);
     }
   }
   editor = new TableEditor(table);
   combosTable = newCombosTable;
   editor.grabHorizontal = true;
   editor.setEditor(combo, item, 2);
   combosTable.put(item, combo);
   editorsTable.put(item, editor);
 }
Exemple #13
0
  /**
   * 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);
  }
  // TODO the implementation of this method is horrible and creating too many widgets
  // table/column renderer/editor should be used instead should be used instead
  protected void addInstallButtons() {
    final AtomicInteger enabledButtonCount = new AtomicInteger(0);
    tableViewerCreator.getTableViewer().getControl().setRedraw(false);
    final Table table = tableViewerCreator.getTable();
    manualInstallButtonMap = new HashMap<ModuleToInstall, Button>();
    ILibrariesService librariesService = LibManagerUiPlugin.getDefault().getLibrariesService();

    disposePreviousEditors();
    for (final TableItem item : table.getItems()) {
      TableEditor editor = new TableEditor(table);
      installButtonsEditors.add(editor);
      Control control = null;
      Object obj = item.getData();
      if (obj instanceof ModuleToInstall) {
        final ModuleToInstall data = (ModuleToInstall) obj;
        boolean isInstalled = false;
        try {
          isInstalled =
              librariesService.getLibraryStatus(data.getName()) == ELibraryInstallStatus.INSTALLED;
        } catch (BusinessException e1) { // log the error and consider as unsinstalled
          log.error(e1);
        }
        boolean hasDownloadUrl = data.getUrl_description() != null;
        if (!MavenConstants.DOWNLOAD_MANUAL.equals(
            data.getDistribution())) { // add the button to download
          final Button button = new Button(table, SWT.FLAT);
          control = button;
          enabledButtonCount.incrementAndGet();
          button.setText(
              Messages.getString("ExternalModulesInstallDialog_Download")); // $NON-NLS-1$
          button.setData(item);
          button.addSelectionListener(
              new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                  table.select(table.indexOf(item));
                  launchIndividualDownload(enabledButtonCount, data, button);
                }
              });
          button.setEnabled(!isInstalled);
          button.setToolTipText(data.toString());
        } else { // add the link for manual download
          Composite composite = new Composite(table, SWT.NONE);
          composite.setBackground(color);
          control = composite;
          GridLayout layout = new GridLayout(hasDownloadUrl ? 2 : 1, false);
          layout.marginHeight = 0;
          layout.verticalSpacing = 1;
          composite.setLayout(layout);
          if (hasDownloadUrl) {
            Link openLink = new Link(composite, SWT.NONE);
            GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(openLink);
            openLink.setBackground(color);
            // openLink.setLayoutData(gData);
            openLink.setText(
                "<a href=\"\">"
                    + Messages.getString("ExternalModulesInstallDialog.openInBrowser")
                    + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            openLink.addSelectionListener(
                new SelectionAdapter() {

                  @Override
                  public void widgetSelected(final SelectionEvent e) {
                    // Program.launch(data.getUrl_description());
                    openURL(data.getUrl_description());
                  }
                });
          } // else no download URL so just add the install buttonb
          enabledButtonCount.incrementAndGet();
          Button importButton = new Button(composite, SWT.FLAT);
          importButton.setImage(ImageProvider.getImage(ECoreImage.IMPORT_JAR));
          importButton.setToolTipText(
              Messages.getString("ImportExternalJarAction.title")); // $NON-NLS-1$
          importButton.addSelectionListener(
              new ImportButtonSelectionListener(enabledButtonCount, item));
          manualInstallButtonMap.put(data, importButton);
          GridDataFactory.fillDefaults()
              .align(SWT.RIGHT, SWT.CENTER)
              .grab(true, false)
              .applyTo(importButton);
          importButton.setEnabled(!isInstalled);
          importButton.setToolTipText(data.toString());
        }
        editor.grabHorizontal = true;
        editor.setEditor(control, item, tableViewerCreator.getColumns().indexOf(installcolumn));
        editor.layout();
        // url
        editor = new TableEditor(table);
        installButtonsEditors.add(editor);
        Composite composite = new Composite(table, SWT.NONE);
        composite.setBackground(color);
        // GridLayout layout = new GridLayout();
        FormLayout layout = new FormLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        composite.setLayout(layout);
        FormData gData = new FormData();
        gData.left = new FormAttachment(0);
        gData.right = new FormAttachment(100);
        gData.top = new FormAttachment(composite, 0, SWT.CENTER);
        final Link openLink = new Link(composite, SWT.NONE);
        openLink.setLayoutData(gData);
        openLink.setBackground(color);
        gData.height = new GC(composite).stringExtent(" ").y; // $NON-NLS-1$
        openLink.setText(
            "<a href=\"\">"
                + (hasDownloadUrl ? data.getUrl_description() : "")
                + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
        openLink.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(final SelectionEvent e) {
                // Program.launch(data.getUrl_description());
                openURL(data.getUrl_description());
              }
            });
        editor.grabHorizontal = true;
        // editor.minimumHeight = 20;
        editor.setEditor(composite, item, tableViewerCreator.getColumns().indexOf(urlcolumn));
        editor.layout();
      }
    }
    tableViewerCreator.getTableViewer().getTable().layout();
    tableViewerCreator.getTableViewer().refresh(true);
    tableViewerCreator.getTableViewer().getControl().setRedraw(true);
  }
  private void editItem(final TableItem item) {
    final ArgumentWrapper wrapper = (ArgumentWrapper) item.getData();

    argumentTypeEditor = initTableEditor(argumentTypeEditor, item.getParent());
    cmbArgumentType = new Combo(item.getParent(), SWT.READ_ONLY);
    cmbArgumentType.setItems(new String[] {LITERAL_VALUE, LITERAL_EXPRESSION});
    cmbArgumentType.setText(item.getText(0));
    argumentTypeEditor.setEditor(cmbArgumentType, item, 0);
    item.getParent().redraw();
    item.getParent().layout();
    cmbArgumentType.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event evt) {
            item.setText(0, cmbArgumentType.getText());
            if (cmbArgumentType.getSelectionIndex() == 1) {
              wrapper.setExpression(true);
              item.setText(1, wrapper.getArgumentExpression().getPropertyValue());

              String evalString = MediaType.XML.toString();
              if (wrapper.getEvaluator() != null) {
                evalString = wrapper.getEvaluator().toString();
              }
              item.setText(2, evalString);
              cmbArgumentEvaluator.setText(evalString);
              cmbArgumentEvaluator.setEnabled(true);
            } else {
              wrapper.setExpression(false);
              item.setText(1, wrapper.getArgumentValue());
              item.setText(2, "");
              cmbArgumentEvaluator.setText("");
              cmbArgumentEvaluator.setEnabled(false);
            }
          }
        });

    argumentValueEditor = initTableEditor(argumentValueEditor, item.getParent());
    argumentValue = new PropertyText(item.getParent(), SWT.NONE, cmbArgumentType);
    argumentValue.addProperties(wrapper.getArgumentValue(), wrapper.getArgumentExpression());
    argumentValueEditor.setEditor(argumentValue, item, 1);
    item.getParent().redraw();
    item.getParent().layout();
    argumentValue.addModifyListener(
        new ModifyListener() {

          public void modifyText(ModifyEvent e) {
            item.setText(1, argumentValue.getText());
            Object property = argumentValue.getProperty();
            if (property instanceof NamespacedProperty) {
              /*					if (wrapper.getEvaluator() == MediaType.XML) {
              	wrapper.setArgumentExpression((NamespacedProperty)property);
              } else if (wrapper.getEvaluator() == MediaType.JSON){
              	String modifiedText = argumentValue.getText();
              	NamespacedProperty namespacedProperty = (NamespacedProperty)property;
              	namespacedProperty.setPropertyValue(modifiedText);
              	wrapper.setArgumentExpression(namespacedProperty);
              }*/
              wrapper.setArgumentExpression((NamespacedProperty) property);
            } else {
              wrapper.setArgumentValue(property.toString());
            }
          }
        });

    argumentEvaluatorEditor = initTableEditor(argumentEvaluatorEditor, item.getParent());
    cmbArgumentEvaluator = new Combo(item.getParent(), SWT.READ_ONLY);
    cmbArgumentEvaluator.setItems(new String[] {LITERAL_XML, LITERAL_JSON});
    cmbArgumentEvaluator.setText(item.getText(2));
    argumentEvaluatorEditor.setEditor(cmbArgumentEvaluator, item, 2);
    cmbArgumentEvaluator.setEnabled(wrapper.isExpression());
    item.getParent().redraw();
    item.getParent().layout();
    cmbArgumentEvaluator.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event evt) {

            item.setText(2, cmbArgumentEvaluator.getText());
            if (cmbArgumentEvaluator.getSelectionIndex() == 0) {
              wrapper.setEvaluator(MediaType.XML);
              // argumentValue.setForcefullInlineEditing(false);
            } else {
              wrapper.setEvaluator(MediaType.JSON);
              // argumentValue.setForcefullInlineEditing(true);
            }
          }
        });

    /*		if (wrapper.isExpression()) {
    	if (wrapper.getEvaluator() == MediaType.XML){
    		argumentValue.setForcefullInlineEditing(false);
    	} else if (wrapper.getEvaluator() == MediaType.JSON){
    		argumentValue.setForcefullInlineEditing(true);
    	}
    }*/
  }
Exemple #16
0
  public boolean createTable(
      int lenX, int lenY, String[][] dataArray, typeOfCell[][] type, Object[][] extra) {
    int[] widthArr = new int[lenX];
    for (int i = 0; i < lenX; i++) widthArr[i] = normalWidth;
    widthArr[0] = Width0;
    Table varTable = new Table(_parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    if (lenY > 30) {
      if (debug) System.out.println("lenY=" + lenY);
      varTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    }
    // else varTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 10));

    varTable.setHeaderVisible(true);
    TableColumn tableColumn[] = new TableColumn[lenX];
    for (int i = 0; i < lenX; i++) {
      tableColumn[i] = new TableColumn(varTable, SWT.LEFT);
      tableColumn[i].setText(_columnName[i]);
      tableColumn[i].setWidth(widthArr[i]);
    }
    TableItem Sp[] = new TableItem[lenY];
    String[] value = new String[lenX];
    for (int j = 0; j < lenY; j++) {
      for (int i = 0; i < lenX; i++) value[i] = dataArray[i][j];
      Sp[j] = new TableItem(varTable, SWT.NONE);
      Sp[j].setText(value);

      for (int i = 0; i < lenX; i++) {
        switch (type[i][j]) {
          case Combo:
            int current = -1;
            combo = new CCombo(varTable, SWT.NONE);
            Object valueArr = extra[i][j];
            if (valueArr instanceof String[]) {
              String[] valueAsString = (String[]) valueArr;
              for (int k = 0; k < valueAsString.length; k++) {
                combo.add(valueAsString[k]);
                if (valueAsString[k].compareTo(dataArray[i][j]) == 0) current = k;
              }
              if (current == -1) {
                // org.csstudio.diag.IOCremoteManagement.Activator.errorPrint ("Wrong comboSelect");
                System.out.println("Wrong comboSelect");
              } else combo.select(current);

              TableEditor editor = new TableEditor(varTable);
              editor.grabHorizontal = editor.grabVertical = true;
              editor.setEditor(combo, Sp[j], i);
              if (dataArray[0][j].compareTo(ssRunCtrlStr) == 0) {
                comboSsRunCtrl = combo;
                comboSsRunCtrl.addSelectionListener(
                    new SelectionAdapter() {
                      public void widgetSelected(SelectionEvent e) {
                        overwriteSS();
                      }
                    });
              } else if (dataArray[0][j].compareTo(this.currentStateStr) == 0) {
                comboCurrentState = combo;
                comboCurrentState.addSelectionListener(
                    new SelectionAdapter() {
                      public void widgetSelected(SelectionEvent e) {
                        overwriteCS();
                      }
                    });
              }

            } else {
              // org.csstudio.diag.IOCremoteManagement.Activator.errorPrint ("Wrong instance");
              System.out.println("Wrong instance");
            }
            break;

          case EditableText:
            Text txt = new Text(varTable, SWT.SINGLE | SWT.BORDER);
            txt.setText(dataArray[i][j]);
            txt.addSelectionListener(
                new SelectionAdapter() {
                  public void widgetDefaultSelected(SelectionEvent e) {
                    Text t = (Text) e.widget;
                    valueChanged(t.getText());
                    System.out.println("DummyListenerText");
                  }
                });
            TableEditor editor = new TableEditor(varTable);
            editor.grabHorizontal = editor.grabVertical = true;
            editor.setEditor(txt, Sp[j], i);
            break;
            //				TODO jhatje: implement new datatypes
            //				case MB3_member:
            //					ListViewer listMB3 = new ListViewer(varTable, SWT.NONE);
            //					final String[] arr = new String[1];
            //					arr[0]=dataArray[i][j];
            //					listMB3.setContentProvider(new IStructuredContentProvider() {
            //					public void dispose() {
            //					}
            //					public Object[] getElements(Object inputElement) {
            //					IProcessVariable[] ipv = new IProcessVariable[1];
            //					ipv[0] = CentralItemFactory.createProcessVariable(arr[0]);
            //					return ipv;
            //					}
            //					public void inputChanged(Viewer viewer,Object oldInput, Object newInput) {
            //					}
            //					});
            //
            //					listMB3.setLabelProvider(new ILabelProvider() {
            //					public Image getImage(Object element) {
            //					return null;
            //					}
            //					public String getText(Object element) {
            //					IProcessVariable ipv = (IProcessVariable) element;
            //					return ipv.getName();
            //					}
            //					public void addListener(ILabelProviderListener listener) {
            //					}
            //					public void dispose() {
            //					}
            //					public boolean isLabelProperty(Object element,String property) {
            //					return false;
            //					}
            //					public void removeListener(
            //						ILabelProviderListener listener) {
            //					}
            //					});
            //					listMB3.setInput(arr);
            //					editor = new TableEditor(varTable);
            //					editor.grabHorizontal = editor.grabVertical = true;
            //
            //					List list =  listMB3.getList();
            //					list.setForeground(_display.getSystemColor(SWT.COLOR_BLUE));
            //					editor.setEditor( list, Sp[j], 1);
            //					new ProcessVariableDragSource (listMB3.getControl(), listMB3);
            //					makeContextMenu(listMB3);
            //				break;

          case Message:
            Group textGroup = new Group(_parent, SWT.NONE);
            GridLayout gridLayout = new GridLayout();
            textGroup.setLayout(gridLayout);
            gridLayout.numColumns = 1;
            textGroup.setLayoutData(
                new GridData(
                    /*GridData.GRAB_HORIZONTAL|GridData.HORIZONTAL_ALIGN_FILL|*/ GridData
                        .VERTICAL_ALIGN_FILL));
            textGroup.setText("Message:");
            Label labelWrap = new Label(textGroup, SWT.WRAP | SWT.BORDER);
            labelWrap.setText(dataArray[i][j]);
            labelWrap.setSize(20, 50);
            break;

          case String:
            break;
          default:
            // org.csstudio.diag.IOCremoteManagement.Activator.errorPrint ("Wrong switch");
            System.out.println("Wrong switch");
            break;
        }
      }
    }

    if (_warning) {
      varTable.setForeground(_display.getSystemColor(SWT.COLOR_RED));
      varTable.setBackground(_display.getSystemColor(SWT.COLOR_YELLOW));
    }

    if (debug) System.out.println("result is OK");
    // org.csstudio.diag.IOCremoteManagement.Activator.errorPrint ("result is OK");
    return true;
  }
  /** Open. */
  public void open() {
    try {
      attribute2Value = new HashMap<EAttribute, String>();
      Shell parent = getParent();
      dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

      dialogShell.setLayout(new FormLayout());
      {
        button2 = new Button(dialogShell, SWT.PUSH | SWT.CENTER);
        FormData button2LData = new FormData();
        button2LData.left = new FormAttachment(0, 1000, 330);
        button2LData.top = new FormAttachment(0, 1000, 310);
        button2LData.width = 99;
        button2LData.height = 25;
        button2.setLayoutData(button2LData);
        button2.setText("Cancel");
        button2.addListener(
            SWT.Selection,
            new Listener() {

              @Override
              public void handleEvent(Event event) {
                cancel = true;
                dialogShell.close();
              }
            });
      }

      {
        button1 = new Button(dialogShell, SWT.PUSH | SWT.CENTER);
        FormData button1LData = new FormData();
        button1LData.left = new FormAttachment(0, 1000, 229);
        button1LData.top = new FormAttachment(0, 1000, 310);
        button1LData.width = 95;
        button1LData.height = 25;
        button1.setLayoutData(button1LData);
        button1.setText("Ok");
        button1.setEnabled(true);
        button1.addListener(
            SWT.Selection,
            new Listener() {

              @Override
              public void handleEvent(Event event) {
                cancel = false;
                for (int i = 0, n = table1.getItemCount(); i < n; i++) {
                  TableItem item = table1.getItem(i);
                  if (item.getChecked()) {
                    EAttribute attribut = attributeTypen.get(i);
                    attribute2Value.put(attribut, item.getText(2));
                  }
                }
                dialogShell.close();
              }
            });
      }
      {
        FormData table1LData = new FormData();
        table1LData.left = new FormAttachment(0, 1000, 12);
        table1LData.top = new FormAttachment(0, 1000, 12);
        table1LData.width = 400;
        table1LData.height = 269;
        table1 =
            new Table(
                dialogShell,
                SWT.CHECK
                    | SWT.SINGLE
                    | SWT.FULL_SELECTION
                    | SWT.V_SCROLL
                    | SWT.H_SCROLL
                    | SWT.VIRTUAL);
        table1.setLayoutData(table1LData);
        table1.setHeaderVisible(true);
        table1.setLinesVisible(true);
        {
          tableColumn1 = new TableColumn(table1, SWT.CENTER);
          tableColumn1.setText("Create");
          tableColumn1.setWidth(60);
        }
        {
          tableColumn2 = new TableColumn(table1, SWT.LEFT);
          tableColumn2.setText("Attribute");
          tableColumn2.setWidth(200);
        }
        {
          tableColumn3 = new TableColumn(table1, SWT.LEFT);
          tableColumn3.setText("Value");
          tableColumn3.setWidth(140);
        }

        vavueCorect = new HashMap<TypeEditorValidator, Boolean>();
        typeEditorValidators = new ArrayList<TypeEditorValidator>();

        for (EAttribute attr : attributeTypen) {
          TableItem tableItem = new TableItem(table1, SWT.NONE);
          TypeEditorValidator typeEditorValidator = new TypeEditorValidator(node, attr);

          tableItem.setText(1, attr.getName());
          tableItem.setText(2, typeEditorValidator.getDefaultValue());
          table1.addListener(
              SWT.Selection,
              new Listener() {

                @Override
                public void handleEvent(Event event) {
                  if (event.detail == SWT.CHECK) {
                    TableItem tItem = (TableItem) event.item;
                    corectValueTest(tItem, tItem.getText(2));
                    refreshOkButton();
                  }
                }
              });
          typeEditorValidators.add(typeEditorValidator);
          /*
           * if (typeEditorValidator.isValid(typeEditorValidator
           * .getDefaultValue()) == null) {
           * vavueCorect.put(typeEditorValidator, corect); } else {
           * vavueCorect.put(typeEditorValidator, incorect);
           * button1.setEnabled(false); }
           */
        }
        final TableEditor editor = new TableEditor(table1);
        editor.horizontalAlignment = SWT.LEFT;
        editor.grabHorizontal = true;

        table1.addMouseListener(
            new MouseAdapter() {
              @Override
              public void mouseDown(MouseEvent event) {
                // Dispose any existing editor
                Control old = editor.getEditor();
                if (old != null) old.dispose();

                // Determine where the mouse was clicked
                Point pt = new Point(event.x, event.y);

                // Determine which row was selected
                final TableItem item = table1.getItem(pt);
                if (item != null) {
                  // Determine which column was selected
                  int column = -1;
                  for (int i = 0, n = table1.getColumnCount(); i < n; i++) {
                    Rectangle rect = item.getBounds(i);
                    if (rect.contains(pt)) {
                      // This is the selected column
                      column = i;
                      break;
                    }
                  }
                  // Column 2 holds dropdowns
                  if (column == 2) {
                    // Create the Text object for our editor
                    final Text text = new Text(table1, SWT.NONE);
                    text.setForeground(item.getForeground());

                    // Transfer any text from the cell to the Text
                    // control,
                    // set the color to match this row, select the
                    // text,
                    // and set focus to the control
                    text.setText(item.getText(column));
                    text.setForeground(item.getForeground());
                    text.selectAll();
                    text.setFocus();

                    // Recalculate the minimum width for the editor
                    editor.minimumWidth = text.getBounds().width;

                    // Set the control into the editor
                    editor.setEditor(text, item, column);

                    // Add a handler to transfer the text back to
                    // the cell
                    // any time it's modified
                    final int col = column;
                    text.addModifyListener(
                        new ModifyListener() {

                          @Override
                          public void modifyText(ModifyEvent e) {
                            item.setChecked(true);
                            corectValueTest(item, text.getText());
                            item.setText(col, text.getText());
                          }
                        });
                  }
                }
              }
            });
      }
      dialogShell.layout();
      dialogShell.setSize(450, 380);
      Rectangle shellBounds = getParent().getBounds();
      Point dialogSize = dialogShell.getSize();
      dialogShell.setLocation(
          shellBounds.x + (shellBounds.width - dialogSize.x) / 2,
          shellBounds.y + (shellBounds.height - dialogSize.y) / 2);
      dialogShell.open();
      Display display = dialogShell.getDisplay();
      while (!dialogShell.isDisposed()) {
        if (!display.readAndDispatch()) display.sleep();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemple #18
0
  /** Create the dialog area and place correctly the user interfaces widgets */
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite comp = (Composite) super.createDialogArea(parent);
    GridLayout gridLayout = new GridLayout(1, false);
    comp.setLayout(gridLayout);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    comp.setLayoutData(gridData);

    Group body = new Group(comp, SWT.SHADOW_ETCHED_IN);
    gridLayout = new GridLayout(1, false);
    body.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_BOTH);
    body.setLayoutData(gridData);

    Composite eventBody = new Composite(body, SWT.FILL);
    gridLayout = new GridLayout(2, false);
    eventBody.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_BOTH);
    eventBody.setLayoutData(gridData);

    Composite eBody = new Composite(eventBody, SWT.FILL);
    gridLayout = new GridLayout(2, false);
    eBody.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_VERTICAL);
    gridData.verticalAlignment = SWT.TOP;
    eBody.setLayoutData(gridData);

    // Events
    Label eventLbl = new Label(eBody, SWT.LEFT);
    eventLbl.setText("Event:");

    eventCbx = new Combo(eBody, SWT.NONE);
    fillEventTypesList();

    // Create a new Event
    if (event == null) {
      event = createEvent(eventCbx.getItem(0));
    } else {
      // We need to copy the original event in case the user cancels his changes
      event = WidgetCopier.copy(event);
    }
    eventCbx.setText(event.getEventName());

    eventCbx.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            String eventName = ((Combo) e.getSource()).getText();
            event.setEventName(eventName);
            createProperties();
            // DS-3322 - Page Designer - Refactoring - begin
            //                event.eAdapters().remove(localizable);
            //                localizable = (Localizable)
            // EventLocalizableAdapterFactory.INSTANCE.adapt(event, Localizable.class);
            //                editor.setLocalizable(localizable);
            //                editor.setReadOnly(isReadOnly(widget));
            // DS-3322 - Page Designer - Refactoring - end
            fillFunctionsList();
            String selection = null;
            if (fctList.getSelection().length > 0) selection = fctList.getSelection()[0];
            refreshParamControl(selection);
          }
        });

    // Functions
    Label functionsLbl = new Label(eBody, SWT.LEFT);
    functionsLbl.setText("Functions:");
    gridData = new GridData();
    gridData.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
    functionsLbl.setLayoutData(gridData);

    fctList = new List(eBody, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
    gridData = new GridData(GridData.FILL_VERTICAL);
    gridData.heightHint = 120;
    gridData.widthHint = 120;
    fctList.setLayoutData(gridData);

    fillFunctionsList();

    fctList.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            String funcName = fctList.getSelection()[0];
            event.setFunctionName(funcName);
            createParameters();
            fillParametersList();
            refreshParamControl(funcName);
          }
        });

    // parameters group
    Group paramGroup = new Group(eventBody, SWT.SHADOW_ETCHED_IN | SWT.FILL);
    paramGroup.setText(" Parameters ");
    gridLayout = new GridLayout(1, false);
    paramGroup.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_BOTH);
    paramGroup.setLayoutData(gridData);
    userParamControl = new UserParameterControl(paramGroup, SWT.FILL);
    userParamControl.setInput(event, null);
    userParamControl.setEnabled(false);

    if (!StringUtils.isEmpty(event.getFunctionName())) {
      fctList.setSelection(new String[] {event.getFunctionName()});
      refreshParamControl(event.getFunctionName());
    }

    // attributes group
    Group def = new Group(body, SWT.SHADOW_ETCHED_IN);
    def.setText(" Attributes ");
    gridLayout = new GridLayout(1, false);
    def.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_BOTH);
    def.setLayoutData(gridData);

    // Parameters table
    paramsTbl = new Table(def, SWT.SINGLE);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 100;
    paramsTbl.setLayoutData(gridData);
    paramsTbl.setHeaderVisible(true);
    paramsTbl.setLinesVisible(true);
    addColumn(paramsTbl, "Attribute", 100);
    addColumn(paramsTbl, "Value", 300);
    paramsTbl.addListener(
        SWT.MeasureItem,
        new Listener() {

          public void handleEvent(org.eclipse.swt.widgets.Event event) {
            Double dou = new Double(event.gc.getFontMetrics().getHeight() * 1.12);
            event.height = dou.intValue();
          }
        });
    final TableEditor paramsTblEditor = new TableEditor(paramsTbl);
    // The editor must have the same size as the cell and must not be any
    // smaller than 50 pixels.
    paramsTblEditor.horizontalAlignment = SWT.LEFT;
    paramsTblEditor.grabHorizontal = true;
    paramsTblEditor.grabVertical = true;
    paramsTblEditor.minimumWidth = 50;
    paramsTbl.addListener(
        SWT.MouseDown,
        new Listener() {

          public void handleEvent(org.eclipse.swt.widgets.Event event) {
            int nbColumns = paramsTbl.getColumnCount();
            Rectangle clientArea = paramsTbl.getClientArea();
            Point pt = new Point(event.x, event.y);
            int index = paramsTbl.getTopIndex();
            while (index < paramsTbl.getItemCount()) {
              boolean visible = false;
              TableItem item = paramsTbl.getItem(index);
              for (int cx = 0; cx < nbColumns; cx++) {
                Rectangle rect = item.getBounds(cx);
                if (rect.contains(pt)) {
                  installCellEditor(paramsTblEditor, item, index, cx);
                }
                if (!visible && rect.intersects(clientArea)) {
                  visible = true;
                }
              }
              if (!visible) return;
              index++;
            }
          }
        });

    fillParametersList();

    def = new Group(body, SWT.SHADOW_ETCHED_IN);
    def.setText(" Confirmation Translations ");
    gridLayout = new GridLayout(1, false);
    def.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_BOTH);
    def.setLayoutData(gridData);

    createProperties();

    // DS-3322 - Page Designer - Refactoring - begin
    //        editor = LocalizableEditorSupportFactory.createLocalizableEditor(def, 2, false, true);
    //        localizable = (Localizable) EventLocalizableAdapterFactory.INSTANCE.adapt(event,
    // Localizable.class);
    //        editor.setLocalizable(localizable);
    //        editor.setReadOnly(isReadOnly(widget));
    //        addListeners();
    // DS-3322 - Page Designer - Refactoring - end

    return comp;
  }
Exemple #19
0
  /**
   * Initialise widgets in pane.
   *
   * @throws MedleyException
   */
  protected void initWidgets() throws MedleyException {
    table = new Table(this, SWT.BORDER | SWT.FULL_SELECTION);
    table.setLinesVisible(false);
    table.setHeaderVisible(true);
    // add columns
    TableColumn column = new TableColumn(table, SWT.NULL);
    column.setText(Resources.getStr(this, "value"));
    column.setWidth(120);
    column = new TableColumn(table, SWT.NULL);
    column.setText(Resources.getStr(this, "actions"));
    column.setWidth(Settings.ACTION_COLUMN_WIDTH);
    column.setResizable(false);

    // fill in table contents and refresh cache
    refresh();

    final TableEditor valueEditor = new TableEditor(table);
    valueEditor.grabHorizontal = true;
    final TableEditor deleteEditor = new TableEditor(table);
    deleteEditor.grabHorizontal = true;

    table.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            // Clean up any previous editor control
            Control oldEditor = valueEditor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
            oldEditor = deleteEditor.getEditor();
            if (oldEditor != null) oldEditor.dispose();

            // Identify the selected row
            final TableItem titem = (TableItem) e.item;
            final int tagValueId = ((Integer) titem.getData(ID)).intValue();
            if (titem == null) return;

            // the editor for group name
            Text name = new Text(table, SWT.FLAT);
            name.setText(titem.getText(COL_VALUE));
            name.addFocusListener(
                new FocusAdapter() {
                  public void focusLost(FocusEvent ev) {
                    Text txt = (Text) valueEditor.getEditor();
                    valueEditor.getItem().setText(COL_VALUE, txt.getText());
                    // save the change to the model
                    try {
                      // update the tag group name
                      TagValue tv = new TagValue(tagValueId);
                      tv.setValue(txt.getText());
                      tv.dispose();
                    } catch (MedleyException ex) {
                      (new ExceptionWindow(getDisplay(), ex)).show();
                    }
                  }
                });
            valueEditor.setEditor(name, titem, COL_VALUE);

            // the delete button
            Button button = new Button(table, SWT.FLAT);
            try {
              button.setText(Resources.getStr(this, "delete"));
            } catch (ResourceException ex) {
              (new ExceptionWindow(getDisplay(), ex)).show();
            }
            button.addListener(
                SWT.Selection,
                new Listener() {
                  public void handleEvent(Event e) {
                    try {
                      TagValue.delete(tagValueId);
                    } catch (MedleyException ex) {
                      (new ExceptionWindow(getDisplay(), ex)).show();
                    }
                    table.remove(table.indexOf(titem));
                    table.deselectAll();
                    valueEditor.getEditor().dispose();
                    deleteEditor.getEditor().dispose();
                  }
                });
            deleteEditor.setEditor(button, titem, COL_DELETE);
          }
        });

    if (table.getItemCount() > 0) {
      TableColumn[] cols = table.getColumns();
      for (int i = 0; i < cols.length; i++) {
        if (cols[i].getResizable()) {
          cols[i].pack();
        }
      }
    }

    table.setSize(table.computeSize(SWT.DEFAULT, 200));
    FormData data = new FormData();
    data.top = new FormAttachment(0, Settings.MARGIN_TOP);
    data.bottom =
        new FormAttachment(
            100, -Settings.MARGIN_BOTTOM - Settings.BUTTON_HEIGHT - Settings.ITEM_SPACING_V);
    data.left = new FormAttachment(0, Settings.MARGIN_LEFT);
    data.right = new FormAttachment(100, -Settings.MARGIN_RIGHT);
    table.setLayoutData(data);

    // add value button
    addValueBtn = new Button(this, SWT.NONE);
    addValueBtn.setText(Resources.getStr(this, "addTagValue"));
    addValueBtn.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            try {
              TagValue tv = TagValue.create(tag.getId());
              TableItem item = new TableItem(table, SWT.NULL);
              item.setText(COL_VALUE, tv.getValue());
              item.setData(ID, new Integer(tv.getId()));
              tv.dispose();
              table.setSelection(new TableItem[] {item});
            } catch (MedleyException ex) {
              (new ExceptionWindow(getDisplay(), ex)).show();
            }
          }
        });
    data = new FormData();
    data.bottom = new FormAttachment(100, -Settings.MARGIN_BOTTOM);
    data.left = new FormAttachment(0, Settings.MARGIN_LEFT);
    data.width = Settings.BUTTON_WIDTH;
    data.height = Settings.BUTTON_HEIGHT;
    addValueBtn.setLayoutData(data);
  }
  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());
  }
  @Override
  public void createPartControl(Composite parent) {
    // TODO Auto-generated method stub
    toolkit = new FormToolkit(parent.getDisplay());
    form = toolkit.createForm(parent);
    form.setText("MetaData Editor:");

    toolkit.decorateFormHeading(form);

    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.minimumWidth = 200;
    //		FormLayout gridLayout = new FormLayout();
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridLayout.horizontalSpacing = 5;
    form.getBody().setLayout(gridLayout);

    FormData formDate = new FormData();
    formDate.height = 250;
    formDate.width = 300;

    FormData formDate0 = new FormData();
    formDate0.height = 150;
    formDate0.width = 300;
    FormData formDate2 = new FormData();
    formDate2.height = 550;
    formDate2.width = 550;

    Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    section.setText("Attribute Modifier");
    Composite sectionClient = toolkit.createComposite(section);
    sectionClient.setLayout(new FormLayout());
    section.setClient(sectionClient);

    GridData gridData2 = new GridData();
    gridData2.verticalSpan = 2;
    section.setLayoutData(gridData2);

    Section section2 = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    section2.setText("Collector");
    Composite sectionClient2 = toolkit.createComposite(section2);
    sectionClient2.setLayout(new FormLayout());
    section2.setClient(sectionClient2);

    Section section3 = toolkit.createSection(form.getBody(), Section.TITLE_BAR); // printStackTrace
    section3.setText("Collection Code");
    Composite sectionClient3 = toolkit.createComposite(section3);
    sectionClient3.setLayout(new FormLayout());
    section3.setClient(sectionClient3);

    final Table table2 =
        toolkit.createTable(
            sectionClient2, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.NONE);
    table2.setHeaderVisible(true);

    final Button submitCollectionCode = toolkit.createButton(sectionClient2, "submit", SWT.None);

    TableColumn column01 = new TableColumn(table2, SWT.NONE);
    column01.setWidth(25);
    column01.setText("#");
    TableColumn column02 = new TableColumn(table2, SWT.NONE);
    column02.setWidth(100);
    column02.setText("Name");
    TableColumn column03 = new TableColumn(table2, SWT.NONE);
    column03.setWidth(100);
    column03.setText("Collection No");
    table2.setLayoutData(formDate);
    int index = 1;
    for (SpecCollectorMap map : spec.getSpecCollectorMaps()) {
      Collector c = map.getCollector();
      TableItem item = new TableItem(table2, SWT.FULL_SELECTION);
      item.setData("collector", c);
      item.setText(0, index + "");
      index++;
      item.setText(1, c.getCollectorFullName()); // c.exe
      if (spec.getRecordNumber() == null) {
        item.setText(2, "");
      } else item.setText(2, spec.getRecordNumber());

      table2.setSelection(index);
    }

    table2.addListener(
        SWT.MouseDoubleClick,
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            Point pt = new Point(arg0.x, arg0.y);
            int ret;
            for (final TableItem item : table2.getItems()) {

              for (int i = 0; i < table2.getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                  Collector c = (Collector) item.getData("collector");
                  CollectorModDialog dialog =
                      new CollectorModDialog(Display.getDefault().getActiveShell(), c);
                  ret = dialog.open();
                }
              }
            }
          }
        });
    final Table table3 =
        toolkit.createTable(
            sectionClient3, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.NONE);
    table3.setHeaderVisible(true);

    TableColumn column31 = new TableColumn(table3, SWT.NONE);
    column31.setWidth(25);
    column31.setText("#");
    TableColumn column32 = new TableColumn(table3, SWT.NONE);
    column32.setWidth(50);
    column32.setText("Collection Code");
    TableColumn column33 = new TableColumn(table3, SWT.NONE);
    column33.setWidth(150);
    column33.setText("Collection Info");
    table3.setLayoutData(formDate0);

    Collection ccc = this.spec.getCollection();

    TableItem item31 = new TableItem(table3, SWT.NONE);
    item31.setText(0, "1");
    if (ccc != null) {
      if (ccc.getCollectionCode() == null) ccc.setCollectionCode("");
      if (ccc.getCollectionInfo() == null) ccc.setCollectionInfo("");
      item31.setText(1, ccc.getCollectionCode());
      item31.setText(2, ccc.getCollectionInfo());
    }

    final TableEditor collectionEditor = new TableEditor(table3);
    collectionEditor.horizontalAlignment = SWT.LEFT;
    collectionEditor.grabHorizontal = true;
    collectionEditor.minimumWidth = 50;
    collectionSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = collectionEditor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };

    table3.addSelectionListener(collectionSelectionListener);
    tableListener2 =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            // TODO Auto-generated method stub
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table.getItems()) {
              String editable = (String) item.getData("editable");
              if (editable.equals("true")) {}
            }
          }
        };

    tableListener2 =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table3.getItems()) {

              for (int i = 0; i < table3.getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                  Control oldEditor = collectionEditor.getEditor();
                  if (oldEditor != null) oldEditor.dispose();

                  final Combo newEditor = new Combo(table3, SWT.NONE);
                  DataUtilsService service = new DataUtilsService();
                  DataUtilsDelegate delegate = service.getDataUtilsPort();
                  final List<Collection> collections = delegate.getCollections();
                  for (Collection col : collections) {
                    newEditor.add(col.getCollectionCode());
                  }

                  newEditor.addDisposeListener(
                      new DisposeListener() {
                        @Override
                        public void widgetDisposed(DisposeEvent e) {
                          // TODO Auto-generated method stub
                          Combo combo = (Combo) collectionEditor.getEditor();
                          Collection collection = collections.get(combo.getSelectionIndex());
                          collectionEditor.getItem().setText(1, collection.getCollectionCode());
                          collectionEditor.getItem().setText(2, collection.getCollectionInfo());
                          collectionEditor
                              .getItem()
                              .setBackground(new Color(Display.getCurrent(), 255, 250, 160));

                          String methodName = (String) item.getData();
                        }
                      });

                  newEditor.setFocus();
                  collectionEditor.setEditor(newEditor, item, 1);
                }
              }
            }
          }
        };
    table3.addListener(SWT.MouseDoubleClick, tableListener2);

    final Table table =
        toolkit.createTable(sectionClient, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    table.setHeaderVisible(true);
    table.setLayoutData(formDate2);
    TableColumn column = new TableColumn(table, SWT.NONE);
    column.setWidth(200);
    column.setText("Name");
    TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setWidth(250);
    column2.setText("Data");
    TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setWidth(100);

    //		table.setLayoutData(gridData);
    /*
    		final TableItem itemName = new TableItem(table,SWT.NONE);
    		itemName.setText(0,"Scientific Name:");
    		final TableItem itemFamily = new TableItem(table, SWT.NONE);
    		itemFamily.setText(0, "Family:");
    		itemFamily.setData("setFamily");
    		final TableItem itemGenus = new TableItem(table, SWT.NONE);
    		itemGenus.setText(0, "Genus:");
    		itemGenus.setData("setGenus");
    		final TableItem itemSpecies = new TableItem(table, SWT.NONE);
    		itemSpecies.setText(0, "Species:");
    		itemSpecies.setData("setSpecies");
    		final TableItem itemCollectAt = new TableItem(table, SWT.NONE);
    		itemCollectAt.setText(0, "Collect At:");
    		itemCollectAt.setData("setCountry");
    		final TableItem itemCollectAtDarwin = new TableItem(table, SWT.NONE);
    		itemCollectAtDarwin.setText(0, "Name in Darwin's time:");
    		itemCollectAtDarwin.setData("setDcountry");
    		final TableItem itemSheetNote = new TableItem(table, SWT.NONE);
    		itemSheetNote.setText(0, "Sheet Notes:");
    		itemSheetNote.setData("setSheetNotes");
    		final TableItem itemState = new TableItem(table, SWT.NONE);
    		itemState.setText(0, "State:");
    		itemState.setData("setStateProvince");
    		final TableItem itemTown = new TableItem(table, SWT.NONE);
    		itemTown.setText(0, "Town:");
    		itemTown.setData("setTown");


    		itemName.setText(1,spec.getScientificName());
    		itemFamily.setText(1, spec.getFamily());
    		itemGenus.setText(1, spec.getGenus());
    		itemSpecies.setText(1, spec.getSpecificEpithet());
    		itemCollectAt.setText(1, spec.getCountry());
    		itemCollectAtDarwin.setText(1, spec.getDarwinCountry());
    		itemSheetNote.setText(1, spec.getSheetNotes());
    		itemState.setText(1, spec.getStateProvince());
    		itemTown.setText(1, spec.getTown());
    */

    try {
      Element root = this.configXml.selectElement("system/editor");
      for (int i = 0; i < root.getChildNodes().getLength(); i++) {
        if (root.getChildNodes().item(i).getNodeType() == Element.ELEMENT_NODE) {
          Element child = (Element) root.getChildNodes().item(i);
          System.out.println("child name = " + child.getAttribute("field"));
          if (child.getAttribute("display").equals("true")) {
            final TableItem itemName = new TableItem(table, SWT.NONE);
            System.out.println(itemName);
            itemName.setData("set" + child.getAttribute("field"));
            itemName.setData("editable", child.getAttribute("editable"));
            itemName.setData("type", child.getAttribute("type"));
            itemName.setText(0, child.getAttribute("name"));
            if (child.getAttribute("field").equals("RecordNumber")) {
              System.out.println(child.getAttribute("editable"));
            }
            Method m;

            try {
              m = spec.getClass().getMethod("get" + child.getAttribute("field"));
              System.out.println("function name = " + m.getName());
              if (child.getAttribute("type").equals("date")) {
                XMLGregorianCalendar cal = (XMLGregorianCalendar) m.invoke(spec);

                String calstr = "";
                if (cal != null) {
                  calstr = cal.toString();
                  itemName.setText(1, calstr);
                  itemName.setData("date", cal);
                }
              } else if (child.getAttribute("type").equals("string")) {
                String str = (String) m.invoke(spec);
                if (str == null) {
                  str = "";
                }
                itemName.setText(1, str);
              } else if (child.getAttribute("type").equals("int")) {
                Integer inte = (Integer) m.invoke(spec);
                itemName.setText(1, inte + "");
              }
            } catch (NoSuchMethodException e) {
              // TODO Auto-generated catch block
              System.out.println("field==" + child.getAttribute("field"));
              //						e.printStackTrace();
            } catch (SecurityException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (IllegalAccessException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (IllegalArgumentException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (InvocationTargetException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        }
      }
    } catch (XmlToolException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    final TableEditor editor = new TableEditor(table);
    // The editor must have the same size as the cell and must
    // not be any smaller than 50 pixels.
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    editor.minimumWidth = 50;
    // editing the second column
    final int EDITABLECOLUMN = 1;
    tableSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = editor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };

    final Button submitButton = toolkit.createButton(form.getBody(), "submit", SWT.None);
    submitButton.setEnabled(false);
    final Label label2 = new Label(form.getBody(), SWT.NONE);
    label2.setData("name", "label2");
    label2.setText("Modification Save Successfully");
    label2.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label2.setForeground(new Color(Display.getCurrent(), 0, 128, 64));
    label2.setVisible(false);

    final Label label3 = new Label(form.getBody(), SWT.NONE);
    label3.setData("name", "label2");
    label3.setText("Modification Save Error!");
    label3.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label3.setForeground(new Color(Display.getCurrent(), 128, 0, 0));
    label3.setVisible(false);

    final Label label4 = new Label(form.getBody(), SWT.NONE);
    label4.setData("name", "label4");
    label4.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label4.setForeground(new Color(Display.getCurrent(), 200, 0, 0));
    label4.setVisible(false);

    final TableEditor edit = new TableEditor(table);
    // The editor must have the same size as the cell and must
    // not be any smaller than 50 pixels.
    edit.horizontalAlignment = SWT.LEFT;
    edit.grabHorizontal = true;
    edit.minimumWidth = 50;
    // editing the second column
    tableSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = editor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };
    table.addSelectionListener(tableSelectionListener);
    tableListener =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            // TODO Auto-generated method stub
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table.getItems()) {
              String editable = (String) item.getData("editable");
              if (editable.equals("true")) {
                for (int i = 0; i < table.getColumnCount(); i++) {
                  Rectangle rect = item.getBounds(i);
                  if (rect.contains(pt)) {
                    Control oldEditor = editor.getEditor();
                    if (oldEditor != null) oldEditor.dispose();

                    if (item.getData("type").equals("int")) {
                      Text newEditor = new Text(table, SWT.NONE);
                      newEditor.setText(item.getText(EDITABLECOLUMN));
                      newEditor.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              Text text = (Text) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, text.getText());
                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    m.invoke(spec, new Object[] {Integer.parseInt(text.getText())});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });
                      newEditor.selectAll();
                      newEditor.setFocus();
                      editor.setEditor(newEditor, item, EDITABLECOLUMN);
                      break;
                    }

                    if (item.getData("type").equals("string")) {
                      Text newEditor = new Text(table, SWT.NONE);
                      newEditor.setText(item.getText(EDITABLECOLUMN));
                      newEditor.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              Text text = (Text) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, text.getText());
                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    m.invoke(spec, new Object[] {text.getText()});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });
                      newEditor.selectAll();
                      newEditor.setFocus();
                      editor.setEditor(newEditor, item, EDITABLECOLUMN);
                      break;
                    } else if (item.getData("type").equals("date")) {
                      CalendarCombo calendar = new CalendarCombo(table, SWT.CALENDAR);
                      XMLGregorianCalendar cal = (XMLGregorianCalendar) item.getData("date");
                      if (cal == null) {
                        calendar.setDate(new Date(System.currentTimeMillis()));
                      } else {
                        GregorianCalendar ca = cal.toGregorianCalendar();
                        calendar.setDate(ca.getTime());
                      }
                      //
                      calendar.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              CalendarCombo cc = (CalendarCombo) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, cc.getDateAsString());

                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    GregorianCalendar gc = new GregorianCalendar();
                                    gc.setTime(cc.getDate().getTime());
                                    XMLGregorianCalendar date2 =
                                        DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
                                    m.invoke(spec, new Object[] {date2});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (DatatypeConfigurationException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });

                      calendar.setFocus();
                      editor.setEditor(calendar, item, EDITABLECOLUMN);
                      break;
                    }
                  }
                } // for
              }
            }
          }
        };
    table.addListener(SWT.MouseDoubleClick, tableListener);
    submitButton.setLayoutData(gridData);
    buttonSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            try {
              //					Specimen speca = null;
              //					for(IWorkbenchPage p : pages){
              //						IViewReference ivrs [] = p.getViewReferences();
              //						for(IViewReference ivr : ivrs){
              //							if(ivr.getId().equals("TestView.view")){
              //								View v = (View)ivr.getView(true);
              //								speca = v.getGallery().getSelection()[0].getData("spec", spec);
              //								if(spec.getMissingInfo()==0){
              //									v.getGallery().getSelection()[0].setBackground(new
              // Color(Display.getCurrent(), 255,255,255));
              //								}
              //								break;
              //							}
              //						}
              //					}
              DataUtilsService service = new DataUtilsService(); // Missing
              DataUtilsDelegate delegate = service.getDataUtilsPort();
              //					Specimen ss = delegate.getSpecimenById(spec.getSpecimenId());//getView

              List<SpecCollectorMap> scms = delegate.getScms(spec.getSpecimenId());
              //					System.out.println(ss.getSpecimenId()+"***"+scms.size());
              if (spec == null) {
                System.out.println("NULL ID!");
              }
              if (scms == null) {
                System.out.println("NULL SCMS!");
              }
              String scmIds = "";
              int index = 0;
              for (SpecCollectorMap scm : scms) {
                if (index == 0) {
                  scmIds += scm.getSpecCollectorMapId();
                } else {
                  scmIds += ("-" + scm.getSpecCollectorMapId());
                }
                index++;
              }
              System.out.println("scmIds = " + scmIds);
              System.out.println("specimen Id = " + spec.getSpecimenId());
              if (scmIds.equals("")) scmIds = "0";
              Specimen updatedSpecimen = delegate.updateSpecimen(spec, scmIds);
              for (TableItem item : table.getItems()) {
                item.setBackground(new Color(Display.getCurrent(), 255, 255, 255));
                submitButton.setEnabled(false);
              }
              IWorkbenchPage pages[] = getEditorSite().getWorkbenchWindow().getPages();
              for (IWorkbenchPage p : pages) {
                IViewReference ivrs[] = p.getViewReferences();
                for (IViewReference ivr : ivrs) {
                  if (ivr.getId().equals("TestView.view")) {
                    View v = (View) ivr.getView(true);
                    v.getGallery().getSelection()[0].setData(updatedSpecimen);
                    if (spec.getMissingInfo() == 0) {
                      v.getGallery()
                          .getSelection()[0]
                          .setBackground(new Color(Display.getCurrent(), 255, 255, 255));
                    }
                    spec = updatedSpecimen;
                    break;
                  }
                }
              }
              label2.setVisible(true);
              label3.setVisible(false);
              label4.setVisible(false);
            } catch (Exception e) {
              label2.setVisible(false);
              label3.setVisible(true);
              //					label4.setText(e.getMessage());
              label4.setVisible(true);
              e.printStackTrace();
            }
          }
        }; // scientific name inserting
    submitButton.addSelectionListener(buttonSelectionListener);
    System.out.println(Platform.getInstallLocation().getURL().getPath());
    System.out.println(Platform.getInstanceLocation().getURL().getPath());
    Image image = ImageFactory.loadImage(Display.getCurrent(), ImageFactory.ACTION_SYNC);
    IStatusLineManager manager = this.getEditorSite().getActionBars().getStatusLineManager();
    Action toggleBotton =
        new SyncIDropAction("Sync with iDrop", ImageDescriptor.createFromImage(image), manager);
    if (spec.getIdropSync() == null || spec.getIdropSync() == 0) {
      toggleBotton.setEnabled(true);
    } else toggleBotton.setEnabled(true);
    form.getToolBarManager().add(toggleBotton);
    form.getToolBarManager().update(true);
  }
  /*
   * Verify the input table and according the vector amount of each input port
   * the signals are inserted into the sensors list specification
   */
  public void populateActuatorsTable(Table inputTable, ArrayList<SystemFunction> functions) {
    // If table have data clear it
    if (table.getItemCount() > 0) clearData();

    Device actuator;
    TableItem item;

    TableEditor teEditor;

    Button preWriting;
    // Button bperiodic;

    Combo cActuator;

    // Insert the inputs that not need of pre-writing
    for (int i = 0; i < inputTable.getItemCount(); i++) {
      preWriting = (Button) inputTable.getItem(i).getData("PreWcheck");
      cActuator = (Combo) inputTable.getItem(i).getData("actuator");
      if (!preWriting.getSelection()) {
        Label port = (Label) inputTable.getItem(i).getData("port");
        Text size = (Text) inputTable.getItem(i).getData("size");
        for (int z = 0; z < Integer.valueOf(size.getText()); z++) {
          item = new TableItem(table, SWT.NONE);
          item.setText(0, port.getText() + (z + 1));

          if (!cActuator.getText().isEmpty()) item.setText(1, cActuator.getText());
          // insert item components
          teEditor = new TableEditor(table);
          Button bperiodic = new Button(table, SWT.CHECK);
          bperiodic.setEnabled(false);
          bperiodic.pack();
          teEditor.minimumWidth = bperiodic.getSize().x;
          teEditor.horizontalAlignment = SWT.LEFT;
          teEditor.setEditor(bperiodic, item, 4);
          item.setData("periodic", bperiodic);
        }
      }
    }

    // insert the inputs that are specified in the pre-writing process
    for (int i = 0; i < functions.size(); i++) {
      for (int z = 0; z < functions.get(i).getOutputs().size(); z++) {
        item = new TableItem(table, SWT.NONE);
        item.setText(0, functions.get(i).getOutputs().get(z));

        teEditor = new TableEditor(table);
        Button bperiodic = new Button(table, SWT.CHECK);
        bperiodic.setEnabled(false);
        bperiodic.pack();
        teEditor.minimumWidth = bperiodic.getSize().x;
        teEditor.horizontalAlignment = SWT.LEFT;
        teEditor.setEditor(bperiodic, item, 4);
        item.setData("periodic", bperiodic);
      }
    }

    // populate Array of actuators
    for (int i = 0; i < table.getItemCount(); i++) {
      actuator = new Device(ACTUATION);
      actuator.setIndex(i);
      actuator.inputs.add(table.getItem(i).getText(0));
      if (table.getItem(i).getText(1).isEmpty()) actuator.setName(table.getItem(i).getText(1));

      actuators.add(actuator);
    }

    checkSpecified();
  }