public DateFilterUtil(Class<T> eObjClass, EStructuralFeature... dateFeature) {
   final EStructuralFeature tail = dateFeature[dateFeature.length - 1];
   this.dateFeature = FeaturePath.fromList(dateFeature);
   if (!Date.class.isAssignableFrom(tail.getEType().getInstanceClass())) {
     throw new IllegalArgumentException(
         "feature type " + tail.getEType().getInstanceClass() + " not a Date subclass");
   }
 }
  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);
  }
示例#3
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));
  }
 @Override
 public FeaturePath[] getLabelProperties() {
   return new FeaturePath[] {
     FeaturePath.fromList(UiPackageImpl.Literals.UI_ELEMENT__TO_BE_RENDERED)
   };
 }
  private void bindControls(final DataBindingContext context) {
    final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(getTargetObject());
    final Realm realm = SWTObservables.getRealm(_nameText.getDisplay());

    _bindingValue = new WritableValue(realm, null, CamelMailBindingType.class);

    org.eclipse.core.databinding.Binding binding =
        context.bindValue(
            SWTObservables.observeText(_nameText, new int[] {SWT.Modify}),
            ObservablesUtil.observeDetailValue(
                domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_Name()),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                .setAfterConvertValidator(
                    new StringEmptyValidator(
                        "Mail binding name should not be empty", Status.WARNING)),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    /*
     * we also want to bind the name field to the binding name. note that
     * the model to target updater is configured to NEVER update. we want
     * the camel binding name to be the definitive source for this field.
     */
    binding =
        context.bindValue(
            SWTObservables.observeText(_nameText, new int[] {SWT.Modify}),
            ObservablesUtil.observeDetailValue(
                domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_Name()),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                .setAfterConvertValidator(
                    new StringEmptyValidator(
                        "Mail binding name should not be empty", Status.WARNING)),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding =
        context.bindValue(
            SWTObservables.observeText(_hostText, new int[] {SWT.Modify}),
            ObservablesUtil.observeDetailValue(
                domain, _bindingValue, MailPackage.Literals.CAMEL_MAIL_BINDING_TYPE__HOST),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                .setAfterConvertValidator(new StringEmptyValidator(Messages.error_emptyHost)),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding =
        context.bindValue(
            SWTObservables.observeText(_portText, new int[] {SWT.Modify}),
            ObservablesUtil.observeDetailValue(
                domain, _bindingValue, MailPackage.Literals.CAMEL_MAIL_BINDING_TYPE__PORT),
            new EMFUpdateValueStrategyNullForEmptyString(
                    "Port must be a valid numeric value or follow the pattern for escaped properties (i.e. '${propName}').",
                    UpdateValueStrategy.POLICY_CONVERT)
                .setAfterConvertValidator(
                    new EscapedPropertyIntegerValidator(
                        "Port must be a valid numeric value or follow the pattern for escaped properties (i.e. '${propName}').")),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    FeaturePath path =
        FeaturePath.fromList(
            MailPackage.Literals.CAMEL_MAIL_BINDING_TYPE__CONSUME,
            MailPackage.Literals.CAMEL_MAIL_CONSUMER_TYPE__FETCH_SIZE);

    binding =
        context.bindValue(
            SWTObservables.observeText(_fetchSizeText, new int[] {SWT.Modify}),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, path),
            new EMFUpdateValueStrategyNullForEmptyString(
                    "Fetch Size must be a valid numeric value or follow the pattern for escaped properties (i.e. '${propName}').",
                    UpdateValueStrategy.POLICY_CONVERT)
                .setAfterConvertValidator(
                    new EscapedPropertyIntegerValidator(
                        "Fetch Size must be a valid numeric value or follow the pattern for escaped properties (i.e. '${propName}').")),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    path =
        FeaturePath.fromList(
            MailPackage.Literals.CAMEL_MAIL_BINDING_TYPE__CONSUME,
            MailPackage.Literals.CAMEL_MAIL_CONSUMER_TYPE__ACCOUNT_TYPE);
    binding =
        context.bindValue(
            ViewersObservables.observeSingleSelection(_accountTypeCombo),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, path),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding =
        context.bindValue(
            SWTObservables.observeText(_usernameText, new int[] {SWT.Modify}),
            ObservablesUtil.observeDetailValue(
                domain, _bindingValue, MailPackage.Literals.CAMEL_MAIL_BINDING_TYPE__USERNAME),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding =
        context.bindValue(
            SWTObservables.observeText(_passwordText, new int[] {SWT.Modify}),
            ObservablesUtil.observeDetailValue(
                domain, _bindingValue, MailPackage.Literals.CAMEL_MAIL_BINDING_TYPE__PASSWORD),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    path =
        FeaturePath.fromList(
            MailPackage.Literals.CAMEL_MAIL_BINDING_TYPE__CONSUME,
            MailPackage.Literals.CAMEL_MAIL_CONSUMER_TYPE__FOLDER_NAME);
    binding =
        context.bindValue(
            SWTObservables.observeText(_folderNameText, new int[] {SWT.Modify}),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, path),
            new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    path =
        FeaturePath.fromList(
            MailPackage.Literals.CAMEL_MAIL_BINDING_TYPE__CONSUME,
            MailPackage.Literals.CAMEL_MAIL_CONSUMER_TYPE__UNSEEN);
    binding =
        context.bindValue(
            SWTObservables.observeSelection(_unseenCheckbox),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, path),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding =
        context.bindValue(
            SWTObservables.observeSelection(_securedCheckbox),
            ObservablesUtil.observeDetailValue(
                domain, _bindingValue, MailPackage.Literals.CAMEL_MAIL_BINDING_TYPE__SECURE),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    path =
        FeaturePath.fromList(
            MailPackage.Literals.CAMEL_MAIL_BINDING_TYPE__CONSUME,
            MailPackage.Literals.CAMEL_MAIL_CONSUMER_TYPE__DELETE);
    binding =
        context.bindValue(
            SWTObservables.observeSelection(_deleteCheckbox),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, path),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    _opSelectorComposite.bindControls(domain, context);
  }
示例#6
0
 @Override
 public FeaturePath[] getLabelProperties() {
   return new FeaturePath[] {
     FeaturePath.fromList(CommandsPackageImpl.Literals.COMMAND__COMMAND_NAME)
   };
 }
示例#7
0
  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;
  }