@Override
 public void setTargetObject(EObject target) {
   super.setTargetObject(target);
   if (_opSelectorComposite != null && !_opSelectorComposite.isDisposed()) {
     _opSelectorComposite.setTargetObject((EObject) target);
   }
 }
Esempio n. 2
0
  @Override
  public void setBinding(Binding impl) {
    super.setBinding(impl);
    if (impl instanceof CamelBindingType) {
      this._binding = (CamelBindingType) impl;
      setInUpdate(true);
      if (this._binding.getConfigURI() != null) {
        _configURIText.setText(this._binding.getConfigURI());
      } else {
        _configURIText.setText(""); // $NON-NLS-1$
      }

      if (_opSelectorComposite != null && !_opSelectorComposite.isDisposed()) {
        OperationSelectorType opSelector =
            OperationSelectorUtil.getFirstOperationSelector(this._binding);
        _opSelectorComposite.setBinding(this._binding);
        _opSelectorComposite.setOperation((SwitchYardOperationSelectorType) opSelector);
      }
      if (_binding.getName() == null) {
        _nameText.setText(""); // $NON-NLS-1$
      } else {
        _nameText.setText(_binding.getName());
      }

      setInUpdate(false);
      validate();
    } else {
      this._binding = null;
    }
    addObservableListeners();
  }
Esempio n. 3
0
 protected void handleModify(final Control control) {
   if (control.equals(_configURIText)) {
     updateFeature(_binding, "configURI", _configURIText.getText().trim()); // $NON-NLS-1$
   } else if (control.equals(_opSelectorComposite)) {
     int opType = _opSelectorComposite.getSelectedOperationSelectorType();
     updateOperationSelectorFeature(
         opType, _opSelectorComposite.getSelectedOperationSelectorValue());
     fireChangedEvent(_opSelectorComposite);
   } else if (control.equals(_nameText)) {
     super.updateFeature(_binding, "name", _nameText.getText().trim()); // $NON-NLS-1$
   }
   super.handleModify(control);
   setHasChanged(false);
   setDidSomething(true);
 }
Esempio n. 4
0
  @Override
  public void createContents(Composite parent, int style) {
    _panel = new Composite(parent, style);
    _panel.setLayout(new FillLayout());
    if (getRootGridData() != null) {
      _panel.setLayoutData(getRootGridData());
    }

    getSchedulerTabControl(_panel);

    if (getTargetObject() != null && getTargetObject() instanceof Service) {
      if (_opSelectorComposite != null && !_opSelectorComposite.isDisposed()) {
        _opSelectorComposite.setTargetObject((EObject) getTargetObject());
      }
    }
  }
  private Control getConsumerTabControl(Composite tabFolder) {
    Composite composite = new Composite(tabFolder, SWT.NONE);
    GridLayout gl = new GridLayout(2, false);
    composite.setLayout(gl);

    _nameText = createLabelAndText(composite, Messages.label_name);

    _hostText = createLabelAndText(composite, Messages.label_hostStar);
    _portText = createLabelAndText(composite, Messages.label_port);
    _usernameText = createLabelAndText(composite, Messages.label_userName);
    _passwordText = createLabelAndText(composite, Messages.label_password);
    _passwordText.setEchoChar('*');
    _securedCheckbox = createCheckbox(composite, Messages.label_secured, 2);

    Group consumeGroup = new Group(composite, SWT.NONE);
    consumeGroup.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
    consumeGroup.setLayout(new GridLayout(2, false));
    consumeGroup.setText(Messages.label_consumerOptions);

    getToolkit().createLabel(consumeGroup, Messages.label_accountType, SWT.NONE);
    _accountTypeCombo = new ComboViewer(consumeGroup);
    _accountTypeCombo.getControl().setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
    _accountTypeCombo.setContentProvider(ArrayContentProvider.getInstance());
    _accountTypeCombo.setLabelProvider(new LabelProvider());
    MailConsumerAccountType[] accountTypes =
        new MailConsumerAccountType[] {MailConsumerAccountType.IMAP, MailConsumerAccountType.POP3};
    _accountTypeCombo.setInput(accountTypes);
    getToolkit().adapt(_accountTypeCombo.getControl(), true, true);

    _folderNameText = createLabelAndText(consumeGroup, Messages.label_folderName);
    _fetchSizeText = createLabelAndText(consumeGroup, Messages.label_fetchSize, 2);
    _unseenCheckbox = createCheckbox(consumeGroup, Messages.label_unreadOnly, 2);
    _deleteCheckbox = createCheckbox(consumeGroup, Messages.label_delete, 2);

    _opSelectorComposite = new OperationSelectorComposite(composite, SWT.NONE, this);
    _opSelectorComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
    _opSelectorComposite.setLayout(new GridLayout(2, false));
    _opSelectorComposite.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            handleModify(_opSelectorComposite);
          }
        });

    return composite;
  }
  @Override
  public void setBinding(Binding impl) {
    super.setBinding(impl);
    if (impl instanceof CamelMailBindingType) {
      _binding = (CamelMailBindingType) impl;

      _bindingValue.setValue(_binding);

      if (_binding.getConsume() == null) {
        TransactionalEditingDomain domain = getDomain(_binding);
        if (domain != null) {
          domain
              .getCommandStack()
              .execute(
                  new RecordingCommand(domain) {
                    protected void doExecute() {
                      _binding.setConsume(MailFactory.eINSTANCE.createCamelMailConsumerType());
                    }
                  });
        } else {
          _binding.setConsume(MailFactory.eINSTANCE.createCamelMailConsumerType());
        }
      }

      // refresh the operation selector control
      if (_opSelectorComposite != null
          && !_opSelectorComposite.isDisposed()
          && getTargetObject() != null) {
        _opSelectorComposite.setTargetObject(getTargetObject());
      }

      _opSelectorComposite.setBinding(_binding);
    } else {
      _bindingValue.setValue(null);
    }
  }
Esempio n. 7
0
  private Control getSchedulerTabControl(Composite tabFolder) {
    Composite composite = new Composite(tabFolder, SWT.NONE);
    GridLayout gl = new GridLayout(2, false);
    composite.setLayout(gl);

    _nameText = createLabelAndText(composite, Messages.label_name);

    _configURIText = createLabelAndText(composite, Messages.label_configUriStar);

    if (getTargetObject() != null && getTargetObject() instanceof Service) {
      _opSelectorComposite = new OperationSelectorComposite(composite, SWT.NONE);
      _opSelectorComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
      _opSelectorComposite.setLayout(new GridLayout(2, false));
      _opSelectorComposite.addChangeListener(
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              handleModify(_opSelectorComposite);
            }
          });
    }

    return composite;
  }
  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);
  }