Java Code Examples for org.eclipse.core.databinding.observable.value.IObservableValue#getValue()

The following examples show how to use org.eclipse.core.databinding.observable.value.IObservableValue#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExpressionCollectionViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected MultiValidator createListExpressionValidator() {
    final ListExpression listExpression = (ListExpression) getValue();
    final IObservableValue listValue = EMFObservables.observeValue(listExpression,
            ExpressionPackage.Literals.LIST_EXPRESSION__EXPRESSIONS);
    return new MultiValidator() {

        @Override
        protected IStatus validate() {
            if (isTableMode()) {
                final AbstractExpression expression = getValue();
                if (expression instanceof ListExpression) {
                    listValue.getValue();
                    if (listExpression.getExpressions() == null || listExpression.getExpressions().isEmpty()) {
                        return ValidationStatus
                                .error(Messages.bind(Messages.AtLeastOneRowShouldBeAddedFor, mandatoryLabel));
                    }
                }
            }
            return ValidationStatus.ok();
        }
    };
}
 
Example 2
Source File: ExpressionCollectionViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected MultiValidator createTableExpressionValidator() {
    final TableExpression tableExpression = (TableExpression) getValue();
    final IObservableValue tableValue = EMFObservables.observeValue(tableExpression,
            ExpressionPackage.Literals.TABLE_EXPRESSION__EXPRESSIONS);
    return new MultiValidator() {

        @Override
        protected IStatus validate() {
            if (isTableMode()) {
                final AbstractExpression expression = getValue();
                if (expression instanceof TableExpression) {
                    tableValue.getValue();
                    if (tableExpression.getExpressions() == null || tableExpression.getExpressions().isEmpty()) {
                        return ValidationStatus
                                .error(Messages.bind(Messages.AtLeastOneRowShouldBeAddedFor, mandatoryLabel));
                    }
                }
            }
            return ValidationStatus.ok();
        }
    };
}
 
Example 3
Source File: ExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void validateExternalDatabindingContextTargets(final DataBindingContext dbc) {
    if (dbc != null) {
        final IObservableList validationStatusProviders = dbc.getValidationStatusProviders();
        final Iterator iterator = validationStatusProviders.iterator();
        while (iterator.hasNext()) {
            final ValidationStatusProvider validationStatusProvider = (ValidationStatusProvider) iterator.next();
            final IObservableValue validationStatus = validationStatusProvider.getValidationStatus();
            if (!(validationStatus instanceof UnmodifiableObservableValue)) {
                final IStatus status = (IStatus) validationStatus.getValue();
                if (status != null) {
                    if (status.getSeverity() == IStatus.OK) {
                        validationStatus.setValue(ValidationStatus.ok());
                    } else if (status.getSeverity() == IStatus.WARNING) {
                        validationStatus.setValue(ValidationStatus.warning(status.getMessage()));
                    } else if (status.getSeverity() == IStatus.INFO) {
                        validationStatus.setValue(ValidationStatus.info(status.getMessage()));
                    } else if (status.getSeverity() == IStatus.ERROR) {
                        validationStatus.setValue(ValidationStatus.error(status.getMessage()));
                    } else if (status.getSeverity() == IStatus.CANCEL) {
                        validationStatus.setValue(ValidationStatus.cancel(status.getMessage()));
                    }
                }
            }
        }
    }
}
 
Example 4
Source File: FlexExistingArtifactDeployPreferencesPanelTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private static IStatus getDeployArtifactPathValidationStatus(
    AppEngineDeployPreferencesPanel panel) {
  DataBindingContext context = panel.getDataBindingContext();
  for (Object provider : context.getValidationStatusProviders()) {
    if (provider instanceof DeployArtifactValidator) {
      IObservableValue value = ((DeployArtifactValidator) provider).getValidationStatus();
      return (IStatus) value.getValue();
    }
  }
  return null;
}
 
Example 5
Source File: FlexDeployPreferencesPanelTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private static IStatus getAppYamlPathValidationStatus(FlexDeployPreferencesPanel panel) {
  DataBindingContext context = panel.getDataBindingContext();
  for (Object provider : context.getValidationStatusProviders()) {
    if (provider instanceof AppYamlValidator) {
      IObservableValue value = ((AppYamlValidator) provider).getValidationStatus();
      return (IStatus) value.getValue();
    }
  }
  return null;
}
 
Example 6
Source File: AbstractBdmFormPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void init(IObservableValue<BusinessObjectModel> workingCopyObservable,
        IObservableValue<BusinessObject> boSelectedObservable, IDocument document) {
    super.init(workingCopyObservable.getValue(), document);
    this.workingCopyObservable = workingCopyObservable;
    this.boSelectedObservable = boSelectedObservable;
    editorContribution.observeDeployRequired()
            .addValueChangeListener(e -> updateDeployRequiredComposite(e.diff.getNewValue()));
}
 
Example 7
Source File: UniqueValidator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private Predicate<Object> hasSamePropertyValue(final Object value) {
    return new Predicate<Object>() {

        @Override
        public boolean apply(final Object input) {
            Object currentPropertyValue = input;
            if (propertyName != null) {
                final IObservableValue observeValue = PojoObservables.observeValue(new SimpleRealm(), input, propertyName);
                currentPropertyValue = observeValue.getValue();
            }
            return value.equals(currentPropertyValue);
        }
    };
}
 
Example 8
Source File: ContractPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private IConverter createObserveVariableToEnableButtonConverter(final IObservableValue observeData) {
    return new Converter(List.class, Boolean.class) {

        @Override
        public Object convert(final Object fromObject) {
            if (fromObject != null) {
                final List<Data> fromObjectList = newArrayList(
                        filter((List<Data>) fromObject, instanceOf(BusinessObjectData.class)));
                final List<EObject> documentList = (List<EObject>) observeData.getValue();
                return !fromObjectList.isEmpty() || (documentList != null && !documentList.isEmpty());
            }
            return false;
        }
    };
}
 
Example 9
Source File: ContractInputController.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ContractInput add(final ColumnViewer viewer) {
    final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    final IObservableValue contractObservable = (IObservableValue) viewer.getInput();
    final ContractInput parentInput = (ContractInput) selection.getFirstElement();
    final Contract contract = (Contract) contractObservable.getValue();
    final ContractInput defaultInput = createDefaultInput(contract);
    final EObject targetContainer = targetContainer(parentInput, contract);
    CustomEMFEditObservables.observeList(targetContainer, inputContainerFeature(targetContainer)).add(defaultInput);
    viewer.getControl().getDisplay().asyncExec(new EditNameRunnable(viewer, defaultInput));
    return defaultInput;
}
 
Example 10
Source File: ContractInputController.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void remove(final ColumnViewer viewer) {
    final IObservableValue contractObservable = (IObservableValue) viewer.getInput();
    final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    final List<?> selectedInput = selection.toList();
    Contract contract = (Contract) contractObservable.getValue();
    if (openConfirmation(selectedInput)) {
        final RefactorContractInputOperation refactorOperation = newRefactorOperation(contract);
        final TransactionalEditingDomain editingDomain = editingDomain(contract);
        refactorOperation.setEditingDomain(editingDomain);
        refactorOperation.setAskConfirmation(shouldAskConfirmation());
        final CompoundCommand compoundCommand = refactorOperation.getCompoundCommand();
        for (final Object input : selectedInput) {
            final ContractInput contractInput = (ContractInput) input;
            contract = ModelHelper.getFirstContainerOfType(contractInput, Contract.class);
            //Parent input has been removed in current selection
            if (contract == null) {
                continue;
            }
            refactorOperation.addItemToRefactor(null, contractInput);
            compoundCommand.append(DeleteCommand.create(editingDomain, contractInput));
            final Collection<ContractConstraint> constraintsReferencingInput = constraintsReferencingSingleInput(contract, contractInput);
            if (!constraintsReferencingInput.isEmpty()) {
                compoundCommand.append(DeleteCommand.create(editingDomain, constraintsReferencingInput));
            }
        }
        try {
            if (refactorOperation.canExecute()) {
                progressService.run(true, true, refactorOperation);
            }
        } catch (final InvocationTargetException | InterruptedException e) {
            BonitaStudioLog.error("Failed to remove contract input.", e);
            openErrorDialog(e);
        }
    }
}
 
Example 11
Source File: BusinessDataViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private boolean poolHasBusinessData() {
    IObservableValue observableValue = getDataContainerObservable();
    if(observableValue != null) {
        final Pool pool = (Pool) observableValue.getValue();
        if(pool != null) {
            return pool.getData().stream().anyMatch(BusinessObjectData.class::isInstance);
        }
    }
    return false;
}
 
Example 12
Source File: NewTermDbBaseInfoPage.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
protected void initDataBindings() {
	DataBindingContext bindingContext = new DataBindingContext();
	WizardPageSupport.create(this, bindingContext);

	IObservableValue widgetValue = WidgetProperties.text(SWT.Modify).observe(dbNameText);
	final IObservableValue dbNameModelValue = BeanProperties.value("dbName").observe(dbModel);
	bindingContext.bindValue(widgetValue, dbNameModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(instanceText);
	final IObservableValue instanceModelValue = BeanProperties.value("instance").observe(dbModel);
	bindingContext.bindValue(widgetValue, instanceModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(hostText);
	final IObservableValue hostModelValue = BeanProperties.value("host").observe(dbModel);
	bindingContext.bindValue(widgetValue, hostModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(portText);
	final IObservableValue protModelValue = BeanProperties.value("port").observe(dbModel);
	bindingContext.bindValue(widgetValue, protModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(locationText);
	final IObservableValue locationModelValue = BeanProperties.value("itlDBLocation").observe(dbModel);
	bindingContext.bindValue(widgetValue, locationModelValue, null, null);
	//
	widgetValue = WidgetProperties.text(SWT.Modify).observe(usernameText);
	final IObservableValue usernameModelValue = BeanProperties.value("userName").observe(dbModel);
	bindingContext.bindValue(widgetValue, usernameModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(passwordText);
	final IObservableValue passwordModelValue = BeanProperties.value("password").observe(dbModel);
	bindingContext.bindValue(widgetValue, passwordModelValue, null, null);

	MultiValidator myValidator = new MultiValidator() {

		@Override
		protected IStatus validate() {
			dbNameModelValue.getValue();
			instanceModelValue.getValue();
			hostModelValue.getValue();
			protModelValue.getValue();
			locationModelValue.getValue();
			usernameModelValue.getValue();
			passwordModelValue.getValue();
			return validator();
		}
	};
	bindingContext.addValidationStatusProvider(myValidator);
}
 
Example 13
Source File: NewTmDbBaseInfoPage.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
protected void initDataBindings() {
	DataBindingContext bindingContext = new DataBindingContext();
	WizardPageSupport.create(this, bindingContext);

	IObservableValue widgetValue = WidgetProperties.text(SWT.Modify).observe(dbNameText);
	final IObservableValue dbNameModelValue = BeanProperties.value("dbName").observe(dbModel);
	bindingContext.bindValue(widgetValue, dbNameModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(instanceText);
	final IObservableValue instanceModelValue = BeanProperties.value("instance").observe(dbModel);
	bindingContext.bindValue(widgetValue, instanceModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(hostText);
	final IObservableValue hostModelValue = BeanProperties.value("host").observe(dbModel);
	bindingContext.bindValue(widgetValue, hostModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(portText);
	final IObservableValue protModelValue = BeanProperties.value("port").observe(dbModel);
	bindingContext.bindValue(widgetValue, protModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(locationText);
	final IObservableValue locationModelValue = BeanProperties.value("itlDBLocation").observe(dbModel);
	bindingContext.bindValue(widgetValue, locationModelValue, null, null);
	//
	widgetValue = WidgetProperties.text(SWT.Modify).observe(usernameText);
	final IObservableValue usernameModelValue = BeanProperties.value("userName").observe(dbModel);
	bindingContext.bindValue(widgetValue, usernameModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(passwordText);
	final IObservableValue passwordModelValue = BeanProperties.value("password").observe(dbModel);
	bindingContext.bindValue(widgetValue, passwordModelValue, null, null);

	MultiValidator myValidator = new MultiValidator() {

		@Override
		protected IStatus validate() {
			dbNameModelValue.getValue();
			instanceModelValue.getValue();
			hostModelValue.getValue();
			protModelValue.getValue();
			locationModelValue.getValue();
			usernameModelValue.getValue();
			passwordModelValue.getValue();
			return validator();
		}
	};
	bindingContext.addValidationStatusProvider(myValidator);
}
 
Example 14
Source File: NewTermDbBaseInfoPage.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
protected void initDataBindings() {
	DataBindingContext bindingContext = new DataBindingContext();
	WizardPageSupport.create(this, bindingContext);

	IObservableValue widgetValue = WidgetProperties.text(SWT.Modify).observe(dbNameText);
	final IObservableValue dbNameModelValue = BeanProperties.value("dbName").observe(dbModel);
	bindingContext.bindValue(widgetValue, dbNameModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(instanceText);
	final IObservableValue instanceModelValue = BeanProperties.value("instance").observe(dbModel);
	bindingContext.bindValue(widgetValue, instanceModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(hostText);
	final IObservableValue hostModelValue = BeanProperties.value("host").observe(dbModel);
	bindingContext.bindValue(widgetValue, hostModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(portText);
	final IObservableValue protModelValue = BeanProperties.value("port").observe(dbModel);
	bindingContext.bindValue(widgetValue, protModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(locationText);
	final IObservableValue locationModelValue = BeanProperties.value("itlDBLocation").observe(dbModel);
	bindingContext.bindValue(widgetValue, locationModelValue, null, null);
	//
	widgetValue = WidgetProperties.text(SWT.Modify).observe(usernameText);
	final IObservableValue usernameModelValue = BeanProperties.value("userName").observe(dbModel);
	bindingContext.bindValue(widgetValue, usernameModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(passwordText);
	final IObservableValue passwordModelValue = BeanProperties.value("password").observe(dbModel);
	bindingContext.bindValue(widgetValue, passwordModelValue, null, null);

	MultiValidator myValidator = new MultiValidator() {

		@Override
		protected IStatus validate() {
			dbNameModelValue.getValue();
			instanceModelValue.getValue();
			hostModelValue.getValue();
			protModelValue.getValue();
			locationModelValue.getValue();
			usernameModelValue.getValue();
			passwordModelValue.getValue();
			return validator();
		}
	};
	bindingContext.addValidationStatusProvider(myValidator);
}
 
Example 15
Source File: NewTmDbBaseInfoPage.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
protected void initDataBindings() {
	DataBindingContext bindingContext = new DataBindingContext();
	WizardPageSupport.create(this, bindingContext);

	IObservableValue widgetValue = WidgetProperties.text(SWT.Modify).observe(dbNameText);
	final IObservableValue dbNameModelValue = BeanProperties.value("dbName").observe(dbModel);
	bindingContext.bindValue(widgetValue, dbNameModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(instanceText);
	final IObservableValue instanceModelValue = BeanProperties.value("instance").observe(dbModel);
	bindingContext.bindValue(widgetValue, instanceModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(hostText);
	final IObservableValue hostModelValue = BeanProperties.value("host").observe(dbModel);
	bindingContext.bindValue(widgetValue, hostModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(portText);
	final IObservableValue protModelValue = BeanProperties.value("port").observe(dbModel);
	bindingContext.bindValue(widgetValue, protModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(locationText);
	final IObservableValue locationModelValue = BeanProperties.value("itlDBLocation").observe(dbModel);
	bindingContext.bindValue(widgetValue, locationModelValue, null, null);
	//
	widgetValue = WidgetProperties.text(SWT.Modify).observe(usernameText);
	final IObservableValue usernameModelValue = BeanProperties.value("userName").observe(dbModel);
	bindingContext.bindValue(widgetValue, usernameModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(passwordText);
	final IObservableValue passwordModelValue = BeanProperties.value("password").observe(dbModel);
	bindingContext.bindValue(widgetValue, passwordModelValue, null, null);

	MultiValidator myValidator = new MultiValidator() {

		@Override
		protected IStatus validate() {
			dbNameModelValue.getValue();
			instanceModelValue.getValue();
			hostModelValue.getValue();
			protModelValue.getValue();
			locationModelValue.getValue();
			usernameModelValue.getValue();
			passwordModelValue.getValue();
			return validator();
		}
	};
	bindingContext.addValidationStatusProvider(myValidator);
}