protected DataBindingContext initDataBindings() {
   EditingDomain ed = getEclipseContext().get(EditingDomain.class);
   DataBindingContext bindingContext = new DataBindingContext();
   //
   IObservableValue nameTextObserveTextObserveWidget =
       SWTObservables.observeDelayedValue(300, SWTObservables.observeText(nameText, SWT.Modify));
   IObservableValue modelTitleObserveValue =
       EMFEditProperties.value(ed, StorynotesPackage.Literals.SETTING_NOTE__NAME).observe(model);
   bindingContext.bindValue(nameTextObserveTextObserveWidget, modelTitleObserveValue, null, null);
   //
   IObservableValue textObserveTextObserveWidget =
       SWTObservables.observeDelayedValue(
           1000, SWTObservables.observeText(contentText, SWT.Modify));
   IObservableValue modelDescriptionObserveValue =
       EMFEditProperties.value(ed, StorynotesPackage.Literals.SETTING_NOTE__DESCRIPTION)
           .observe(model);
   bindingContext.bindValue(
       textObserveTextObserveWidget, modelDescriptionObserveValue, null, null);
   //
   IObservableValue typeTextObserveTextObserveWidget =
       SWTObservables.observeDelayedValue(1000, SWTObservables.observeText(typeText, SWT.Modify));
   IObservableValue modelKindObserveValue =
       EMFEditProperties.value(ed, StorynotesPackage.Literals.SETTING_NOTE__KIND).observe(model);
   bindingContext.bindValue(typeTextObserveTextObserveWidget, modelKindObserveValue, null, null);
   //
   return bindingContext;
 }
  @Override
  public void bind(final IEMFEditContext context) {
    super.bind(context);

    final IEMFEditListProperty emfProperty =
        EMFEditProperties.list(getEditingDomain(), getEFeature());
    fModelObservable = emfProperty.observeDetail(getBaseObservable());
    ((IObserving) fModelObservable).getObserved();

    fWidget.viewer.setInput(fModelObservable);
    fButtonGroup.connectTo(fWidget.viewer, fModelObservable, null);

    register(fWidget.table, IEFPropertyExpressions.EOBJECT_LIST_ID);
    fSelectionProvider = new ElementSourceSelectionProvider(fWidget.viewer, this);
    ViewerUtil.setSelectionProvider(fWidget.table, fSelectionProvider);

    {
      final int operations = (DND.DROP_DEFAULT | DND.DROP_COPY | DND.DROP_MOVE);
      final Transfer[] transfers = new Transfer[] {LocalTransfer.getInstance()};
      fWidget.viewer.addDragSupport(operations, transfers, new ViewerDragAdapter(fWidget.viewer));
      fWidget.viewer.addDropSupport(
          operations,
          transfers,
          new EditingDomainViewerDropAdapter(getEditingDomain(), fWidget.viewer));
    }

    fSingleSelectionObservable = ViewersObservables.observeSinglePostSelection(fWidget.viewer);

    fButtonGroup.updateState();
  }
  protected void bind(DataBindingContext bindingContext) {
    // Name
    bindingContext.bindValue(
        WidgetProperties.text(SWT.FocusOut).observe(propertyComposite.getTextName()),
        EMFEditProperties.value(getEditingDomain(), ScrPackage.eINSTANCE.getProperty_Name())
            .observeDetail(getCurrentSelection()));

    // Type
    bindingContext.bindValue(
        ViewersObservables.observeSingleSelection(propertyComposite.getComboType()),
        EMFEditProperties.value(getEditingDomain(), ScrPackage.eINSTANCE.getProperty_Type())
            .observeDetail(getCurrentSelection()));

    // Value
    bindingContext.bindValue(
        WidgetProperties.text(SWT.FocusOut).observe(propertyComposite.getTextValue()),
        EMFEditProperties.value(getEditingDomain(), ScrPackage.eINSTANCE.getProperty_Value())
            .observeDetail(getCurrentSelection()));
  }
  public void bind(EMFDataBindingContext context) {
    IObservableValue capExpressionObservable =
        SWTObservables.observeText(this.getTxtExpressionName(), SWT.Modify);

    IEMFValueProperty profileExpressionProperty =
        EMFEditProperties.value(
            editingService.getEditingDomain(),
            FeaturePath.fromList(expressionFeature, LibraryPackage.Literals.EXPRESSION__NAME));

    context.bindValue(
        capExpressionObservable, profileExpressionProperty.observe(owner), null, null);
  }
Beispiel #5
0
  /**
   * Bind.
   *
   * @param editingDomain the editing domain
   * @param eStructuralFeatureList the e structural feature list
   * @param master the master
   */
  public void bind(
      EditingDomain editingDomain,
      EStructuralFeature[] eStructuralFeatureList,
      IObservableValue master) {

    // remove old binding (if exist)
    if (binding != null) {
      dataBindContext.removeBinding(binding);
    }

    binding =
        dataBindContext.bindValue(
            SWTObservables.observeSelection(this),
            EMFEditProperties.value(editingDomain, FeaturePath.fromList(eStructuralFeatureList))
                .observeDetail(master));
  }
  private Composite createForm(
      Composite parent,
      final EMFDataBindingContext context,
      WritableValue master,
      boolean isImport) {
    CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM);

    CTabItem item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.ModelTooling_Common_TabDefault);

    parent = createScrollableContainer(folder);
    item.setControl(parent.getParent());

    if (getEditor().isShowXMIId() || getEditor().isLiveModel()) {
      ControlFactory.createXMIId(parent, this);
    }

    IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);

    if (isImport) {
      ControlFactory.createFindImport(parent, Messages, this, context);
      folder.setSelection(0);
      return folder;
    }

    ControlFactory.createTextField(
        parent,
        Messages.ModelTooling_Common_Id,
        master,
        context,
        textProp,
        EMFEditProperties.value(
            getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID));
    ControlFactory.createTextField(
        parent,
        Messages.ModelTooling_UIElement_AccessibilityPhrase,
        getMaster(),
        context,
        textProp,
        EMFEditProperties.value(
            getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__ACCESSIBILITY_PHRASE));
    ControlFactory.createSelectedElement(
        parent, this, context, Messages.PerspectiveStackEditor_SelectedElement);

    // ------------------------------------------------------------
    {
      Label l = new Label(parent, SWT.NONE);
      l.setText(Messages.PerspectiveStackEditor_Perspectives);
      l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false));

      final TableViewer viewer = new TableViewer(parent);
      viewer.setContentProvider(new ObservableListContentProvider());
      viewer.setLabelProvider(new ComponentLabelProvider(getEditor(), Messages));
      GridData gd = new GridData(GridData.FILL_BOTH);
      viewer.getControl().setLayoutData(gd);

      IEMFListProperty prop =
          EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN);
      viewer.setInput(prop.observeDetail(getMaster()));

      Composite buttonComp = new Composite(parent, SWT.NONE);
      buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false));
      GridLayout gl = new GridLayout();
      gl.marginLeft = 0;
      gl.marginRight = 0;
      gl.marginWidth = 0;
      gl.marginHeight = 0;
      buttonComp.setLayout(gl);

      Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_Up);
      b.setImage(createImage(ResourceProvider.IMG_Obj16_arrow_up));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              if (!viewer.getSelection().isEmpty()) {
                IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
                if (s.size() == 1) {
                  Object obj = s.getFirstElement();
                  MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue();
                  int idx = container.getChildren().indexOf(obj) - 1;
                  if (idx >= 0) {
                    if (Util.moveElementByIndex(
                        getEditingDomain(), (MUIElement) obj, getEditor().isLiveModel(), idx)) {
                      viewer.setSelection(new StructuredSelection(obj));
                    }
                  }
                }
              }
            }
          });

      b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_Down);
      b.setImage(createImage(ResourceProvider.IMG_Obj16_arrow_down));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              if (!viewer.getSelection().isEmpty()) {
                IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
                if (s.size() == 1) {
                  Object obj = s.getFirstElement();
                  MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue();
                  int idx = container.getChildren().indexOf(obj) + 1;
                  if (idx < container.getChildren().size()) {
                    if (Util.moveElementByIndex(
                        getEditingDomain(), (MUIElement) obj, getEditor().isLiveModel(), idx)) {
                      viewer.setSelection(new StructuredSelection(obj));
                    }
                  }
                }
              }
            }
          });

      b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setImage(createImage(ResourceProvider.IMG_Obj16_table_add));
      b.setText(Messages.ModelTooling_Common_AddEllipsis);
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              handleAddPerspective();
            }
          });

      b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_Remove);
      b.setImage(createImage(ResourceProvider.IMG_Obj16_table_delete));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              if (!viewer.getSelection().isEmpty()) {
                List<?> elements = ((IStructuredSelection) viewer.getSelection()).toList();

                Command cmd =
                    RemoveCommand.create(
                        getEditingDomain(),
                        getMaster().getValue(),
                        UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN,
                        elements);
                if (cmd.canExecute()) {
                  getEditingDomain().getCommandStack().execute(cmd);
                }
              }
            }
          });
    }

    ControlFactory.createCheckBox(
        parent,
        Messages.ModelTooling_UIElement_ToBeRendered,
        getMaster(),
        context,
        WidgetProperties.selection(),
        EMFEditProperties.value(
            getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__TO_BE_RENDERED));
    ControlFactory.createCheckBox(
        parent,
        Messages.ModelTooling_UIElement_Visible,
        getMaster(),
        context,
        WidgetProperties.selection(),
        EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__VISIBLE));

    item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.ModelTooling_Common_TabSupplementary);

    parent = createScrollableContainer(folder);
    item.setControl(parent.getParent());

    ControlFactory.createStringListWidget(
        parent,
        Messages,
        this,
        Messages.CategoryEditor_Tags,
        ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS,
        VERTICAL_LIST_WIDGET_INDENT);
    ControlFactory.createMapProperties(
        parent,
        Messages,
        this,
        Messages.ModelTooling_Contribution_PersistedState,
        ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__PERSISTED_STATE,
        VERTICAL_LIST_WIDGET_INDENT);

    if (project == null) {
      createUITreeInspection(folder);
    }

    folder.setSelection(0);

    return folder;
  }
  /* (non-Javadoc)
   * @see org.bonitasoft.studio.common.properties.IExtensibleGridPropertySectionContribution#createControl(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory, org.bonitasoft.studio.common.properties.ExtensibleGridPropertySection)
   */
  @Override
  public void createControl(
      Composite composite,
      TabbedPropertySheetWidgetFactory widgetFactory,
      ExtensibleGridPropertySection extensibleGridPropertySection) {
    SimulationTransition transition;
    if (((Activity) eObject).getLoopTransition() == null) {
      transition = SimulationFactory.eINSTANCE.createSimulationTransition();
      editingDomain
          .getCommandStack()
          .execute(
              new SetCommand(
                  editingDomain,
                  eObject,
                  SimulationPackage.Literals.SIMULATION_ACTIVITY__LOOP_TRANSITION,
                  transition));
    } else {
      transition = ((Activity) eObject).getLoopTransition();
    }

    composite.setLayout(new GridLayout(2, false));
    Composite radioComposite = widgetFactory.createComposite(composite);
    radioComposite.setLayout(new FillLayout());
    radioComposite.setLayoutData(GridDataFactory.fillDefaults().create());
    Button expressionRadio = widgetFactory.createButton(radioComposite, "Expression", SWT.RADIO);
    Button probaRadio = widgetFactory.createButton(radioComposite, "Probability", SWT.RADIO);

    final Composite stackComposite = widgetFactory.createComposite(composite);
    stackComposite.setLayoutData(GridDataFactory.fillDefaults().hint(300, SWT.DEFAULT).create());
    final StackLayout stackLayout = new StackLayout();
    stackComposite.setLayout(stackLayout);

    final Composite probaComposite = widgetFactory.createComposite(stackComposite);
    FillLayout layout = new FillLayout();
    layout.marginWidth = 10;
    probaComposite.setLayout(layout);
    Text probaText = widgetFactory.createText(probaComposite, "", SWT.BORDER);

    ControlDecoration controlDecoration = new ControlDecoration(probaText, SWT.LEFT | SWT.TOP);
    FieldDecoration fieldDecoration =
        FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
    controlDecoration.setImage(fieldDecoration.getImage());
    controlDecoration.setDescriptionText(Messages.mustBeAPercentage);

    final Composite expressionComposite = widgetFactory.createComposite(stackComposite);
    FillLayout layout2 = new FillLayout();
    layout2.marginWidth = 10;
    expressionComposite.setLayout(layout2);
    ExpressionViewer expressionText =
        new ExpressionViewer(
            expressionComposite,
            SWT.BORDER,
            widgetFactory,
            editingDomain,
            SimulationPackage.Literals.SIMULATION_TRANSITION__EXPRESSION);
    Expression selection = transition.getExpression();
    if (selection == null) {
      selection = ExpressionFactory.eINSTANCE.createExpression();
      editingDomain
          .getCommandStack()
          .execute(
              SetCommand.create(
                  editingDomain,
                  transition,
                  SimulationPackage.Literals.SIMULATION_TRANSITION__EXPRESSION,
                  selection));
    }
    context.bindValue(
        ViewerProperties.singleSelection().observe(expressionText),
        EMFEditProperties.value(
                editingDomain, SimulationPackage.Literals.SIMULATION_TRANSITION__EXPRESSION)
            .observe(eObject));
    expressionText.setInput(eObject);

    boolean useExpression = transition.isUseExpression();
    if (useExpression) {
      stackLayout.topControl = expressionComposite;
    } else {
      stackLayout.topControl = probaComposite;
    }
    expressionRadio.setSelection(useExpression);
    probaRadio.setSelection(!useExpression);

    expressionRadio.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (((Button) e.getSource()).getSelection()) {
              stackLayout.topControl = expressionComposite;
            } else {
              stackLayout.topControl = probaComposite;
            }
            stackComposite.layout();
          }
        });

    context = new EMFDataBindingContext();
    context.bindValue(
        SWTObservables.observeSelection(expressionRadio),
        EMFEditObservables.observeValue(
            editingDomain,
            transition,
            SimulationPackage.Literals.SIMULATION_TRANSITION__USE_EXPRESSION));
    context.bindValue(
        SWTObservables.observeText(probaText, SWT.Modify),
        EMFEditObservables.observeValue(
            editingDomain,
            transition,
            SimulationPackage.Literals.SIMULATION_TRANSITION__PROBABILITY),
        new UpdateValueStrategy()
            .setConverter(
                StringToNumberConverter.toDouble(BonitaNumberFormat.getPercentInstance(), false))
            .setAfterGetValidator(
                new WrappingValidator(
                    controlDecoration,
                    new StringToDoubleValidator(
                        StringToNumberConverter.toDouble(
                            BonitaNumberFormat.getPercentInstance(), false)))),
        new UpdateValueStrategy()
            .setConverter(
                NumberToStringConverter.fromDouble(
                    BonitaNumberFormat.getPercentInstance(), false)));
  }
public class CommandEditor extends AbstractComponentEditor {

  private Composite composite;
  private EMFDataBindingContext context;
  private EStackLayout stackLayout;
  private List<Action> actions = new ArrayList<Action>();

  private IEMFEditListProperty COMMAND__PARAMETERS =
      EMFEditProperties.list(getEditingDomain(), CommandsPackageImpl.Literals.COMMAND__PARAMETERS);

  @Inject
  public CommandEditor() {
    super();
  }

  @PostConstruct
  void init() {
    actions.add(
        new Action(
            Messages.CommandEditor_AddCommandParameter,
            createImageDescriptor(ResourceProvider.IMG_CommandParameter)) {
          @Override
          public void run() {
            handleAddCommandParameter();
          }
        });
  }

  @Override
  public Image getImage(Object element, Display display) {
    return createImage(ResourceProvider.IMG_Command);
  }

  @Override
  public String getLabel(Object element) {
    return Messages.CommandEditor_Label;
  }

  @Override
  public String getDescription(Object element) {
    return Messages.CommandEditor_Description;
  }

  @Override
  public Composite doGetEditor(Composite parent, Object object) {
    if (composite == null) {
      context = new EMFDataBindingContext();
      if (getEditor().isModelFragment()) {
        composite = new Composite(parent, SWT.NONE);
        stackLayout = new EStackLayout();
        composite.setLayout(stackLayout);
        createForm(composite, context, getMaster(), false);
        createForm(composite, context, getMaster(), true);
      } else {
        composite = createForm(parent, context, getMaster(), false);
      }
    }

    if (getEditor().isModelFragment()) {
      Control topControl;
      if (Util.isImport((EObject) object)) {
        topControl = composite.getChildren()[1];
      } else {
        topControl = composite.getChildren()[0];
      }

      if (stackLayout.topControl != topControl) {
        stackLayout.topControl = topControl;
        composite.layout(true, true);
      }
    }

    getMaster().setValue(object);
    return composite;
  }

  private Composite createForm(
      Composite parent, EMFDataBindingContext context, IObservableValue master, boolean isImport) {
    CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM);

    CTabItem item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.ModelTooling_Common_TabDefault);

    parent = createScrollableContainer(folder);
    item.setControl(parent.getParent());

    IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);

    if (getEditor().isShowXMIId() || getEditor().isLiveModel()) {
      ControlFactory.createXMIId(parent, this);
    }

    if (isImport) {
      ControlFactory.createFindImport(parent, Messages, this, context);

      return folder;
    }

    ControlFactory.createTextField(
        parent,
        Messages.ModelTooling_Common_Id,
        master,
        context,
        textProp,
        EMFEditProperties.value(
            getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID));
    ControlFactory.createTextField(
        parent,
        Messages.CommandEditor_Name,
        master,
        context,
        textProp,
        EMFEditProperties.value(
            getEditingDomain(), CommandsPackageImpl.Literals.COMMAND__COMMAND_NAME));
    ControlFactory.createTextField(
        parent,
        Messages.CommandEditor_LabelDescription,
        master,
        context,
        textProp,
        EMFEditProperties.value(
            getEditingDomain(), CommandsPackageImpl.Literals.COMMAND__DESCRIPTION));

    // ------------------------------------------------------------
    {
      Label l = new Label(parent, SWT.NONE);
      l.setText(Messages.CommandEditor_Category);
      l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false));

      Text t = new Text(parent, SWT.BORDER);
      TextPasteHandler.createFor(t);
      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      t.setLayoutData(gd);
      t.setEditable(false);
      context.bindValue(
          textProp.observeDelayed(200, t),
          EMFEditProperties.value(
                  getEditingDomain(),
                  FeaturePath.fromList(
                      CommandsPackageImpl.Literals.COMMAND__CATEGORY,
                      ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID))
              .observeDetail(getMaster()));

      final Button b = new Button(parent, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_FindEllipsis);
      b.setImage(createImage(ResourceProvider.IMG_Obj16_zoom));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              CommandCategorySelectionDialog dialog =
                  new CommandCategorySelectionDialog(
                      b.getShell(),
                      getEditor().getModelProvider(),
                      (MCommand) getMaster().getValue(),
                      Messages);
              dialog.open();
            }
          });
    }

    // ------------------------------------------------------------
    {
      Label l = new Label(parent, SWT.NONE);
      l.setText(Messages.CommandEditor_Parameters);
      l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false));

      final TableViewer viewer =
          new TableViewer(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
      ObservableListContentProvider cp = new ObservableListContentProvider();
      viewer.setContentProvider(cp);
      viewer.setLabelProvider(new ComponentLabelProvider(getEditor(), Messages));

      GridData gd = new GridData(GridData.FILL_BOTH);
      viewer.getControl().setLayoutData(gd);

      IEMFEditListProperty mProp =
          EMFEditProperties.list(
              getEditingDomain(), CommandsPackageImpl.Literals.COMMAND__PARAMETERS);
      viewer.setInput(mProp.observeDetail(getMaster()));

      Composite buttonComp = new Composite(parent, SWT.NONE);
      buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false));
      GridLayout gl = new GridLayout();
      gl.marginLeft = 0;
      gl.marginRight = 0;
      gl.marginWidth = 0;
      gl.marginHeight = 0;
      buttonComp.setLayout(gl);

      Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_Up);
      b.setImage(createImage(ResourceProvider.IMG_Obj16_arrow_up));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              if (!viewer.getSelection().isEmpty()) {
                IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
                if (s.size() == 1) {
                  Object obj = s.getFirstElement();
                  MCommand container = (MCommand) getMaster().getValue();
                  int idx = container.getParameters().indexOf(obj) - 1;
                  if (idx >= 0) {
                    Command cmd =
                        MoveCommand.create(
                            getEditingDomain(),
                            getMaster().getValue(),
                            CommandsPackageImpl.Literals.COMMAND__PARAMETERS,
                            obj,
                            idx);

                    if (cmd.canExecute()) {
                      getEditingDomain().getCommandStack().execute(cmd);
                      viewer.setSelection(new StructuredSelection(obj));
                    }
                  }
                }
              }
            }
          });

      b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_Down);
      b.setImage(createImage(ResourceProvider.IMG_Obj16_arrow_down));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              if (!viewer.getSelection().isEmpty()) {
                IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
                if (s.size() == 1) {
                  Object obj = s.getFirstElement();
                  MCommand container = (MCommand) getMaster().getValue();
                  int idx = container.getParameters().indexOf(obj) + 1;
                  if (idx < container.getParameters().size()) {
                    Command cmd =
                        MoveCommand.create(
                            getEditingDomain(),
                            getMaster().getValue(),
                            CommandsPackageImpl.Literals.COMMAND__PARAMETERS,
                            obj,
                            idx);

                    if (cmd.canExecute()) {
                      getEditingDomain().getCommandStack().execute(cmd);
                      viewer.setSelection(new StructuredSelection(obj));
                    }
                  }
                }
              }
            }
          });

      b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_AddEllipsis);
      b.setImage(createImage(ResourceProvider.IMG_Obj16_table_add));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              handleAddCommandParameter();
            }
          });

      b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_Remove);
      b.setImage(createImage(ResourceProvider.IMG_Obj16_table_delete));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              if (!viewer.getSelection().isEmpty()) {
                List<?> keybinding = ((IStructuredSelection) viewer.getSelection()).toList();
                Command cmd =
                    RemoveCommand.create(
                        getEditingDomain(),
                        getMaster().getValue(),
                        CommandsPackageImpl.Literals.COMMAND__PARAMETERS,
                        keybinding);
                if (cmd.canExecute()) {
                  getEditingDomain().getCommandStack().execute(cmd);
                }
              }
            }
          });
    }

    item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.ModelTooling_Common_TabSupplementary);

    parent = createScrollableContainer(folder);
    item.setControl(parent.getParent());

    ControlFactory.createStringListWidget(
        parent,
        Messages,
        this,
        Messages.ModelTooling_ApplicationElement_Tags,
        ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS,
        VERTICAL_LIST_WIDGET_INDENT);

    folder.setSelection(0);

    return folder;
  }

  @Override
  public IObservableList getChildList(Object element) {
    return COMMAND__PARAMETERS.observe(element);
  }

  @Override
  public String getDetailLabel(Object element) {
    MCommand cmd = (MCommand) element;
    if (cmd.getCommandName() != null && cmd.getCommandName().trim().length() > 0) {
      return cmd.getCommandName();
    }

    return null;
  }

  @Override
  public FeaturePath[] getLabelProperties() {
    return new FeaturePath[] {
      FeaturePath.fromList(CommandsPackageImpl.Literals.COMMAND__COMMAND_NAME)
    };
  }

  protected void handleAddCommandParameter() {
    MCommandParameter param = MCommandsFactory.INSTANCE.createCommandParameter();
    setElementId(param);

    Command cmd =
        AddCommand.create(
            getEditingDomain(),
            getMaster().getValue(),
            CommandsPackageImpl.Literals.COMMAND__PARAMETERS,
            param);

    if (cmd.canExecute()) {
      getEditingDomain().getCommandStack().execute(cmd);
      getEditor().setSelection(param);
    }
  }

  @Override
  public List<Action> getActions(Object element) {
    ArrayList<Action> l = new ArrayList<Action>(super.getActions(element));
    l.addAll(actions);
    return l;
  }
}
  private Composite createForm(
      Composite parent, EMFDataBindingContext context, IObservableValue master, boolean isImport) {
    CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM);

    CTabItem item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.ModelTooling_Common_TabDefault);

    parent = createScrollableContainer(folder);
    item.setControl(parent.getParent());

    IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);

    if (getEditor().isShowXMIId() || getEditor().isLiveModel()) {
      ControlFactory.createXMIId(parent, this);
    }

    if (isImport) {
      ControlFactory.createFindImport(parent, Messages, this, context);

      return folder;
    }

    ControlFactory.createTextField(
        parent,
        Messages.ModelTooling_Common_Id,
        master,
        context,
        textProp,
        EMFEditProperties.value(
            getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID));
    ControlFactory.createTextField(
        parent,
        Messages.CommandEditor_Name,
        master,
        context,
        textProp,
        EMFEditProperties.value(
            getEditingDomain(), CommandsPackageImpl.Literals.COMMAND__COMMAND_NAME));
    ControlFactory.createTextField(
        parent,
        Messages.CommandEditor_LabelDescription,
        master,
        context,
        textProp,
        EMFEditProperties.value(
            getEditingDomain(), CommandsPackageImpl.Literals.COMMAND__DESCRIPTION));

    // ------------------------------------------------------------
    {
      Label l = new Label(parent, SWT.NONE);
      l.setText(Messages.CommandEditor_Category);
      l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false));

      Text t = new Text(parent, SWT.BORDER);
      TextPasteHandler.createFor(t);
      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      t.setLayoutData(gd);
      t.setEditable(false);
      context.bindValue(
          textProp.observeDelayed(200, t),
          EMFEditProperties.value(
                  getEditingDomain(),
                  FeaturePath.fromList(
                      CommandsPackageImpl.Literals.COMMAND__CATEGORY,
                      ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID))
              .observeDetail(getMaster()));

      final Button b = new Button(parent, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_FindEllipsis);
      b.setImage(createImage(ResourceProvider.IMG_Obj16_zoom));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              CommandCategorySelectionDialog dialog =
                  new CommandCategorySelectionDialog(
                      b.getShell(),
                      getEditor().getModelProvider(),
                      (MCommand) getMaster().getValue(),
                      Messages);
              dialog.open();
            }
          });
    }

    // ------------------------------------------------------------
    {
      Label l = new Label(parent, SWT.NONE);
      l.setText(Messages.CommandEditor_Parameters);
      l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false));

      final TableViewer viewer =
          new TableViewer(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
      ObservableListContentProvider cp = new ObservableListContentProvider();
      viewer.setContentProvider(cp);
      viewer.setLabelProvider(new ComponentLabelProvider(getEditor(), Messages));

      GridData gd = new GridData(GridData.FILL_BOTH);
      viewer.getControl().setLayoutData(gd);

      IEMFEditListProperty mProp =
          EMFEditProperties.list(
              getEditingDomain(), CommandsPackageImpl.Literals.COMMAND__PARAMETERS);
      viewer.setInput(mProp.observeDetail(getMaster()));

      Composite buttonComp = new Composite(parent, SWT.NONE);
      buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false));
      GridLayout gl = new GridLayout();
      gl.marginLeft = 0;
      gl.marginRight = 0;
      gl.marginWidth = 0;
      gl.marginHeight = 0;
      buttonComp.setLayout(gl);

      Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_Up);
      b.setImage(createImage(ResourceProvider.IMG_Obj16_arrow_up));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              if (!viewer.getSelection().isEmpty()) {
                IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
                if (s.size() == 1) {
                  Object obj = s.getFirstElement();
                  MCommand container = (MCommand) getMaster().getValue();
                  int idx = container.getParameters().indexOf(obj) - 1;
                  if (idx >= 0) {
                    Command cmd =
                        MoveCommand.create(
                            getEditingDomain(),
                            getMaster().getValue(),
                            CommandsPackageImpl.Literals.COMMAND__PARAMETERS,
                            obj,
                            idx);

                    if (cmd.canExecute()) {
                      getEditingDomain().getCommandStack().execute(cmd);
                      viewer.setSelection(new StructuredSelection(obj));
                    }
                  }
                }
              }
            }
          });

      b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_Down);
      b.setImage(createImage(ResourceProvider.IMG_Obj16_arrow_down));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              if (!viewer.getSelection().isEmpty()) {
                IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
                if (s.size() == 1) {
                  Object obj = s.getFirstElement();
                  MCommand container = (MCommand) getMaster().getValue();
                  int idx = container.getParameters().indexOf(obj) + 1;
                  if (idx < container.getParameters().size()) {
                    Command cmd =
                        MoveCommand.create(
                            getEditingDomain(),
                            getMaster().getValue(),
                            CommandsPackageImpl.Literals.COMMAND__PARAMETERS,
                            obj,
                            idx);

                    if (cmd.canExecute()) {
                      getEditingDomain().getCommandStack().execute(cmd);
                      viewer.setSelection(new StructuredSelection(obj));
                    }
                  }
                }
              }
            }
          });

      b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_AddEllipsis);
      b.setImage(createImage(ResourceProvider.IMG_Obj16_table_add));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              handleAddCommandParameter();
            }
          });

      b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_Remove);
      b.setImage(createImage(ResourceProvider.IMG_Obj16_table_delete));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              if (!viewer.getSelection().isEmpty()) {
                List<?> keybinding = ((IStructuredSelection) viewer.getSelection()).toList();
                Command cmd =
                    RemoveCommand.create(
                        getEditingDomain(),
                        getMaster().getValue(),
                        CommandsPackageImpl.Literals.COMMAND__PARAMETERS,
                        keybinding);
                if (cmd.canExecute()) {
                  getEditingDomain().getCommandStack().execute(cmd);
                }
              }
            }
          });
    }

    item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.ModelTooling_Common_TabSupplementary);

    parent = createScrollableContainer(folder);
    item.setControl(parent.getParent());

    ControlFactory.createStringListWidget(
        parent,
        Messages,
        this,
        Messages.ModelTooling_ApplicationElement_Tags,
        ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS,
        VERTICAL_LIST_WIDGET_INDENT);

    folder.setSelection(0);

    return folder;
  }
  private Composite createForm(Composite parent) {
    parent = new Composite(parent, SWT.NONE);
    GridLayout gl = new GridLayout(3, false);
    gl.horizontalSpacing = 10;
    parent.setLayout(gl);

    if (getEditor().isShowXMIId() || getEditor().isLiveModel()) {
      ControlFactory.createXMIId(parent, this);
    }

    IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
    {
      Label l = new Label(parent, SWT.NONE);
      l.setText(Messages.StringModelFragment_ParentId);
      l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

      Composite comp = new Composite(parent, SWT.NONE);
      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalSpan = 2;
      comp.setLayoutData(gd);
      gl = new GridLayout(2, false);
      gl.marginWidth = gl.marginHeight = 0;
      gl.verticalSpacing = 0;
      gl.marginLeft = gl.marginBottom = gl.marginRight = gl.marginTop = 0;
      comp.setLayout(gl);

      Text t = new Text(comp, SWT.BORDER);
      t.setEditable(false);
      gd = new GridData(GridData.FILL_HORIZONTAL);
      t.setLayoutData(gd);
      context.bindValue(
          textProp.observeDelayed(200, t),
          EMFEditProperties.value(
                  getEditingDomain(),
                  FragmentPackageImpl.Literals.STRING_MODEL_FRAGMENT__PARENT_ELEMENT_ID)
              .observeDetail(getMaster()));

      final Button b = new Button(comp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_FindEllipsis);
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              FindParentReferenceElementDialog dialog =
                  new FindParentReferenceElementDialog(
                      b.getShell(),
                      StringModelFragment.this,
                      (MStringModelFragment) getMaster().getValue());
              dialog.open();
            }
          });
    }

    {
      Label l = new Label(parent, SWT.NONE);
      l.setText(Messages.StringModelFragment_Featurename);
      l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

      Composite comp = new Composite(parent, SWT.NONE);
      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalSpan = 2;
      comp.setLayoutData(gd);
      gl = new GridLayout(2, false);
      gl.marginWidth = gl.marginHeight = 0;
      gl.verticalSpacing = 0;
      gl.marginLeft = gl.marginBottom = gl.marginRight = gl.marginTop = 0;
      comp.setLayout(gl);

      Text t = new Text(comp, SWT.BORDER);
      gd = new GridData(GridData.FILL_HORIZONTAL);
      t.setLayoutData(gd);
      context.bindValue(
          textProp.observeDelayed(200, t),
          EMFEditProperties.value(
                  getEditingDomain(),
                  FragmentPackageImpl.Literals.STRING_MODEL_FRAGMENT__FEATURENAME)
              .observeDetail(getMaster()));

      final Button button = new Button(comp, SWT.PUSH | SWT.FLAT);
      button.setText(Messages.ModelTooling_Common_FindEllipsis);
      button.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              FeatureSelectionDialog dialog =
                  new FeatureSelectionDialog(
                      button.getShell(),
                      getEditingDomain(),
                      (MStringModelFragment) getMaster().getValue());
              dialog.open();
            }
          });
    }

    {
      Label l = new Label(parent, SWT.NONE);
      l.setText(Messages.StringModelFragment_PositionInList);
      l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

      Text t = new Text(parent, SWT.BORDER);
      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalSpan = 2;
      t.setLayoutData(gd);
      context.bindValue(
          textProp.observeDelayed(200, t),
          EMFEditProperties.value(
                  getEditingDomain(),
                  FragmentPackageImpl.Literals.STRING_MODEL_FRAGMENT__POSITION_IN_LIST)
              .observeDetail(getMaster()));
    }

    // ------------------------------------------------------------
    {
      Label l = new Label(parent, SWT.NONE);
      l.setText(Messages.StringModelFragment_Elements);
      l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false));

      final TableViewer viewer = new TableViewer(parent);
      viewer.setContentProvider(new ObservableListContentProvider());
      viewer.setLabelProvider(new ComponentLabelProvider(getEditor()));
      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.heightHint = 300;
      viewer.getControl().setLayoutData(gd);

      IEMFListProperty prop =
          EMFProperties.list(FragmentPackageImpl.Literals.MODEL_FRAGMENT__ELEMENTS);
      viewer.setInput(prop.observeDetail(getMaster()));

      Composite buttonComp = new Composite(parent, SWT.NONE);
      buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false));
      gl = new GridLayout(2, false);
      gl.marginLeft = 0;
      gl.marginRight = 0;
      gl.marginWidth = 0;
      gl.marginHeight = 0;
      buttonComp.setLayout(gl);

      Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_Up);
      b.setImage(getImage(b.getDisplay(), ARROW_UP));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              if (!viewer.getSelection().isEmpty()) {
                IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
                if (s.size() == 1) {
                  Object obj = s.getFirstElement();
                  MModelFragment container = (MModelFragment) getMaster().getValue();
                  int idx = container.getElements().indexOf(obj) - 1;
                  if (idx >= 0) {
                    Command cmd =
                        MoveCommand.create(
                            getEditingDomain(),
                            getMaster().getValue(),
                            FragmentPackageImpl.Literals.MODEL_FRAGMENT__ELEMENTS,
                            obj,
                            idx);

                    if (cmd.canExecute()) {
                      getEditingDomain().getCommandStack().execute(cmd);
                      viewer.setSelection(new StructuredSelection(obj));
                    }
                  }
                }
              }
            }
          });

      b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_Down);
      b.setImage(getImage(b.getDisplay(), ARROW_DOWN));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              if (!viewer.getSelection().isEmpty()) {
                IStructuredSelection s = (IStructuredSelection) viewer.getSelection();
                if (s.size() == 1) {
                  Object obj = s.getFirstElement();
                  MModelFragment container = (MModelFragment) getMaster().getValue();
                  int idx = container.getElements().indexOf(obj) + 1;
                  if (idx < container.getElements().size()) {
                    Command cmd =
                        MoveCommand.create(
                            getEditingDomain(),
                            getMaster().getValue(),
                            FragmentPackageImpl.Literals.MODEL_FRAGMENT__ELEMENTS,
                            obj,
                            idx);

                    if (cmd.canExecute()) {
                      getEditingDomain().getCommandStack().execute(cmd);
                      viewer.setSelection(new StructuredSelection(obj));
                    }
                  }
                }
              }
            }
          });

      final ComboViewer childrenDropDown = new ComboViewer(buttonComp);
      childrenDropDown
          .getControl()
          .setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      childrenDropDown.setContentProvider(new ArrayContentProvider());
      childrenDropDown.setLabelProvider(
          new LabelProvider() {
            @Override
            public String getText(Object element) {
              FeatureClass eclass = (FeatureClass) element;
              return eclass.label;
            }
          });
      childrenDropDown.setComparator(
          new ViewerComparator() {
            @Override
            public int compare(Viewer viewer, Object e1, Object e2) {
              FeatureClass eClass1 = (FeatureClass) e1;
              FeatureClass eClass2 = (FeatureClass) e2;
              return eClass1.label.compareTo(eClass2.label);
            }
          });

      List<FeatureClass> list = new ArrayList<FeatureClass>();
      Util.addClasses(ApplicationPackageImpl.eINSTANCE, list);
      list.addAll(
          getEditor()
              .getFeatureClasses(
                  FragmentPackageImpl.Literals.MODEL_FRAGMENT,
                  FragmentPackageImpl.Literals.MODEL_FRAGMENT__ELEMENTS));

      childrenDropDown.setInput(list);
      childrenDropDown.getCombo().select(0);

      b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setImage(getImage(b.getDisplay(), TABLE_ADD_IMAGE));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              EClass eClass =
                  ((FeatureClass)
                          ((IStructuredSelection) childrenDropDown.getSelection())
                              .getFirstElement())
                      .eClass;
              EObject eObject = EcoreUtil.create(eClass);

              Command cmd =
                  AddCommand.create(
                      getEditingDomain(),
                      getMaster().getValue(),
                      FragmentPackageImpl.Literals.MODEL_FRAGMENT__ELEMENTS,
                      eObject);

              if (cmd.canExecute()) {
                getEditingDomain().getCommandStack().execute(cmd);
                getEditor().setSelection(eObject);
              }
            }
          });

      b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
      b.setText(Messages.ModelTooling_Common_Remove);
      b.setImage(getImage(b.getDisplay(), TABLE_DELETE_IMAGE));
      b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
      b.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              if (!viewer.getSelection().isEmpty()) {
                List<?> elements = ((IStructuredSelection) viewer.getSelection()).toList();

                Command cmd =
                    RemoveCommand.create(
                        getEditingDomain(),
                        getMaster().getValue(),
                        FragmentPackageImpl.Literals.MODEL_FRAGMENT__ELEMENTS,
                        elements);
                if (cmd.canExecute()) {
                  getEditingDomain().getCommandStack().execute(cmd);
                }
              }
            }
          });
    }

    return parent;
  }
  protected Composite createForm(Composite parent, EMFDataBindingContext context) {
    CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM);

    CTabItem item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.ModelTooling_Common_TabDefault);

    parent = createScrollableContainer(folder);
    item.setControl(parent.getParent());

    IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);

    if (getEditor().isShowXMIId() || getEditor().isLiveModel()) {
      ControlFactory.createXMIId(parent, this);
    }

    ControlFactory.createTextField(
        parent,
        Messages.ModelTooling_Common_Id,
        getMaster(),
        context,
        textProp,
        EMFEditProperties.value(
            getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID));

    ControlFactory.createBindingContextWiget(
        parent, Messages, this, Messages.ApplicationEditor_BindingContexts);

    ControlFactory.createCheckBox(
        parent,
        Messages.ModelTooling_UIElement_ToBeRendered,
        getMaster(),
        context,
        WidgetProperties.selection(),
        EMFEditProperties.value(
            getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__TO_BE_RENDERED));
    ControlFactory.createCheckBox(
        parent,
        Messages.ModelTooling_UIElement_Visible,
        getMaster(),
        context,
        WidgetProperties.selection(),
        EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__VISIBLE));

    item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.ModelTooling_Common_TabSupplementary);

    parent = createScrollableContainer(folder);
    item.setControl(parent.getParent());

    ControlFactory.createTextField(
        parent,
        Messages.ModelTooling_UIElement_AccessibilityPhrase,
        getMaster(),
        context,
        textProp,
        EMFEditProperties.value(
            getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__ACCESSIBILITY_PHRASE));
    ControlFactory.createStringListWidget(
        parent,
        Messages,
        this,
        Messages.ModelTooling_Context_Variables,
        UiPackageImpl.Literals.CONTEXT__VARIABLES,
        VERTICAL_LIST_WIDGET_INDENT);
    ControlFactory.createStringListWidget(
        parent,
        Messages,
        this,
        Messages.AddonsEditor_Tags,
        ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS,
        VERTICAL_LIST_WIDGET_INDENT);
    ControlFactory.createMapProperties(
        parent,
        Messages,
        this,
        Messages.ModelTooling_Contribution_PersistedState,
        ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__PERSISTED_STATE,
        VERTICAL_LIST_WIDGET_INDENT);

    if (project == null) {
      createUITreeInspection(folder);
    }

    folder.setSelection(0);

    return folder;
  }
  protected Control createMultipleResourceComposite(
      Section section, TabbedPropertySheetWidgetFactory widgetFactory) {
    final Composite client = widgetFactory.createComposite(section);
    client.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    client.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).create());
    resourceTableViewer = new TableViewer(client, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
    resourceTableViewer
        .getControl()
        .setLayoutData(
            GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 60).create());
    resourceTableViewer.setContentProvider(new ArrayContentProvider());
    resourceTableViewer.setLabelProvider(new LabelProvider());
    final ControlDecoration cd =
        new ControlDecoration(resourceTableViewer.getControl(), SWT.TOP | SWT.LEFT);
    cd.setImage(Pics.getImage(PicsConstants.hint));
    cd.setDescriptionText(Messages.filewidget_resource_hint_multiple);

    final Composite buttonComposite = widgetFactory.createComposite(client);
    buttonComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create());
    buttonComposite.setLayout(
        GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 3).create());
    final Button addResourceButton =
        widgetFactory.createButton(buttonComposite, Messages.Add, SWT.PUSH);
    addResourceButton.setLayoutData(
        GridDataFactory.fillDefaults().grab(true, false).hint(85, SWT.DEFAULT).create());
    addResourceButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            final SelectDocumentInBonitaStudioRepository selectDocumentInBonitaStudioRepository =
                new SelectDocumentInBonitaStudioRepository(Display.getDefault().getActiveShell());
            if (IDialogConstants.OK_ID == selectDocumentInBonitaStudioRepository.open()) {
              editingDomain
                  .getCommandStack()
                  .execute(
                      AddCommand.create(
                          editingDomain,
                          element,
                          FormPackage.Literals.FILE_WIDGET__INTIAL_RESOURCE_LIST,
                          selectDocumentInBonitaStudioRepository.getSelectedDocument().getName()));
              resourceTableViewer.refresh();
            }
          }
        });
    final Button removeResourceButton =
        widgetFactory.createButton(buttonComposite, Messages.Remove, SWT.PUSH);
    removeResourceButton.setLayoutData(
        GridDataFactory.fillDefaults().grab(true, false).hint(85, SWT.DEFAULT).create());
    removeResourceButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            editingDomain
                .getCommandStack()
                .execute(
                    RemoveCommand.create(
                        editingDomain,
                        element,
                        FormPackage.Literals.FILE_WIDGET__INTIAL_RESOURCE_LIST,
                        ((IStructuredSelection) resourceTableViewer.getSelection()).toList()));
            resourceTableViewer.refresh();
          }
        });

    resourceTableViewer.setInput(
        EMFEditProperties.list(
                editingDomain, FormPackage.Literals.FILE_WIDGET__INTIAL_RESOURCE_LIST)
            .observe(element));

    return client;
  }