// Part of this code was just copied from the generated class in order to
  // override the label provider
  @Override
  protected Composite createQualifiersTableComposition(
      FormToolkit widgetFactory, Composite parent) {
    this.qualifiers =
        new ReferencesTable(
            getDescription(
                UmlViewsRepository.Qualifiers.qualifiers_,
                UmlMessages.QualifiersPropertiesEditionPart_QualifiersLabel),
            new ReferencesTableListener() {
              public void handleAdd() {
                propertiesEditionComponent.firePropertiesChanged(
                    new PropertiesEditionEvent(
                        QualifiersCustomPropertiesEditionPartForm.this,
                        UmlViewsRepository.Qualifiers.qualifiers_,
                        PropertiesEditionEvent.COMMIT,
                        PropertiesEditionEvent.ADD,
                        null,
                        null));
                qualifiers.refresh();
              }

              public void handleEdit(EObject element) {
                propertiesEditionComponent.firePropertiesChanged(
                    new PropertiesEditionEvent(
                        QualifiersCustomPropertiesEditionPartForm.this,
                        UmlViewsRepository.Qualifiers.qualifiers_,
                        PropertiesEditionEvent.COMMIT,
                        PropertiesEditionEvent.EDIT,
                        null,
                        element));
                qualifiers.refresh();
              }

              public void handleMove(EObject element, int oldIndex, int newIndex) {
                propertiesEditionComponent.firePropertiesChanged(
                    new PropertiesEditionEvent(
                        QualifiersCustomPropertiesEditionPartForm.this,
                        UmlViewsRepository.Qualifiers.qualifiers_,
                        PropertiesEditionEvent.COMMIT,
                        PropertiesEditionEvent.MOVE,
                        element,
                        newIndex));
                qualifiers.refresh();
              }

              public void handleRemove(EObject element) {
                propertiesEditionComponent.firePropertiesChanged(
                    new PropertiesEditionEvent(
                        QualifiersCustomPropertiesEditionPartForm.this,
                        UmlViewsRepository.Qualifiers.qualifiers_,
                        PropertiesEditionEvent.COMMIT,
                        PropertiesEditionEvent.REMOVE,
                        null,
                        element));
                qualifiers.refresh();
              }

              public void navigateTo(EObject element) {}
            }) {
          @Override
          public AdapterFactoryLabelProvider getLabelProvider() {
            return new AdapterFactoryLabelProvider(adapterFactory) {
              @Override
              public String getColumnText(Object object, int columnIndex) {

                if (object instanceof Property) {
                  Property property = (Property) object;
                  if (columnIndex == tableColumnService.indexOf(TableColumnName.NAME)) {
                    return labelService.caseName(property);
                  }
                  if (columnIndex == tableColumnService.indexOf(TableColumnName.TYPE)) {
                    return labelService.caseType(property);
                  }
                }
                return super.getColumnText(object, columnIndex);
              }

              @Override
              public Image getColumnImage(Object object, int columnIndex) {
                if (columnIndex == tableColumnService.indexOf(TableColumnName.NAME)) {
                  return super.getColumnImage(object, columnIndex);
                }
                return null;
              }
            };
          }
        };
    for (ViewerFilter filter : this.qualifiersFilters) {
      this.qualifiers.addFilter(filter);
    }
    this.qualifiers.setHelpText(
        propertiesEditionComponent.getHelpContent(
            UmlViewsRepository.Qualifiers.qualifiers_, UmlViewsRepository.FORM_KIND));
    this.qualifiers.createControls(parent, widgetFactory);
    this.qualifiers.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            if (e.item != null && e.item.getData() instanceof EObject) {
              propertiesEditionComponent.firePropertiesChanged(
                  new PropertiesEditionEvent(
                      QualifiersCustomPropertiesEditionPartForm.this,
                      UmlViewsRepository.Qualifiers.qualifiers_,
                      PropertiesEditionEvent.CHANGE,
                      PropertiesEditionEvent.SELECTION_CHANGED,
                      null,
                      e.item.getData()));
            }
          }
        });
    GridData qualifiersData = new GridData(GridData.FILL_HORIZONTAL);
    qualifiersData.horizontalSpan = 3;
    this.qualifiers.setLayoutData(qualifiersData);
    this.qualifiers.setLowerBound(0);
    this.qualifiers.setUpperBound(-1);
    qualifiers.setID(UmlViewsRepository.Qualifiers.qualifiers_);
    qualifiers.setEEFType("eef::AdvancedTableComposition"); // $NON-NLS-1$
    // Start of user code for createQualifiersTableComposition
    Table table = qualifiers.getTable();
    TableColumn[] columns = table.getColumns();
    // dispose
    for (TableColumn tableColumn : columns) {
      tableColumn.dispose();
    }

    table.setHeaderVisible(true);
    tableColumnService.createMediumColumn(table, TableColumnName.NAME);
    tableColumnService.createMediumColumn(table, TableColumnName.TYPE);

    // End of user code
    return parent;
  }
コード例 #2
0
  protected Composite createAppliedProfilesReferencesTable(
      FormToolkit widgetFactory, Composite parent) {
    this.appliedProfiles =
        new ReferencesTable(
            getDescription(
                CustomUmlViewsRepository.Profiles.appliedProfiles,
                CustomUmlMessages.ProfilesPropertiesEditionPart_AppliedProfilesLabel),
            new ReferencesTableListener() {
              public void handleAdd() {
                addAppliedProfiles();
              }

              public void handleEdit(EObject element) {
                editAppliedProfiles(element);
              }

              public void handleMove(EObject element, int oldIndex, int newIndex) {
                moveAppliedProfiles(element, oldIndex, newIndex);
              }

              public void handleRemove(EObject element) {
                removeFromAppliedProfiles(element);
              }

              public void navigateTo(EObject element) {}
            }) {
          @Override
          public AdapterFactoryLabelProvider getLabelProvider() {
            return new AdapterFactoryLabelProvider(adapterFactory) {
              @Override
              public String getColumnText(Object object, int columnIndex) {
                if (object instanceof Profile) {
                  Profile profile = (Profile) object;
                  if (columnIndex == tableColumnService.indexOf(TableColumnName.PROFILE)) {
                    return labelService.caseProfile(profile);
                  }
                }
                return "";
              }

              @Override
              public Image getColumnImage(Object object, int columnIndex) {
                return null;
              }
            };
          }
        };
    for (ViewerFilter filter : this.appliedProfilesFilters) {
      this.appliedProfiles.addFilter(filter);
    }
    this.appliedProfiles.setHelpText(
        propertiesEditionComponent.getHelpContent(
            CustomUmlViewsRepository.Profiles.appliedProfiles, UmlViewsRepository.FORM_KIND));
    this.appliedProfiles.createControls(parent, widgetFactory);
    this.appliedProfiles.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            if (e.item != null && e.item.getData() instanceof EObject) {
              propertiesEditionComponent.firePropertiesChanged(
                  new PropertiesEditionEvent(
                      ProfilesPropertiesEditionPartForm.this,
                      CustomUmlViewsRepository.Profiles.appliedProfiles,
                      PropertiesEditionEvent.CHANGE,
                      PropertiesEditionEvent.SELECTION_CHANGED,
                      null,
                      e.item.getData()));
            }
          }
        });
    GridData appliedProfilesData = new GridData(GridData.FILL_HORIZONTAL);
    appliedProfilesData.horizontalSpan = 3;
    this.appliedProfiles.setLayoutData(appliedProfilesData);
    this.appliedProfiles.disableMove();
    appliedProfiles.setID(CustomUmlViewsRepository.Profiles.appliedProfiles);
    appliedProfiles.setEEFType("eef::AdvancedReferencesTable"); // $NON-NLS-1$
    // Start of user code for createAppliedProfilesTableComposition
    Table table = appliedProfiles.getTable();
    TableColumn[] columns = table.getColumns();
    // dispose
    for (TableColumn tableColumn : columns) {
      tableColumn.dispose();
    }

    table.setHeaderVisible(true);
    tableColumnService.createMediumColumn(table, TableColumnName.PROFILE);

    // End of user code
    return parent;
  }