org.eclipse.core.databinding.observable.value.IObservableValue Java Examples

The following examples show how to use org.eclipse.core.databinding.observable.value.IObservableValue. 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: AssignableActorsPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void databindactorDefinedInLaneLabel(final Assignable assignable) {
	final Lane parentLane = ModelHelper.getParentLane(assignable);
	if(parentLane != null){

		final IObservableValue observeActorDefinedInLane =
				EMFEditObservables.observeValue(getEditingDomain(),
						parentLane,
						ProcessPackage.Literals.ASSIGNABLE__ACTOR);
		emfDatabindingContext.bindValue(
				SWTObservables.observeText(actorDefinedInLaneLabel),
				observeActorDefinedInLane,
				new UpdateValueStrategy(),
				new UpdateValueStrategy().setConverter(new Converter(Object.class, String.class) {

					@Override
					public String convert(final Object fromObject) {
						if(fromObject != null){
							return "("+((Actor)fromObject).getName()+")";
						} else {
							return Messages.noActorDefinedAtLaneLevel;
						}
					}
				}));
		actorDefinedInLaneLabel.pack(true);
	}
}
 
Example #2
Source File: AggregationAndCompositionValidatorTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Before
public void init() {
    modelObservable = mock(IObservableValue.class);

    businessObject1 = createBusinessObject("bo1");
    businessObject2 = createBusinessObject("bo2");

    businessObject1.getFields().add(new RelationFieldBuilder()
            .withType(RelationType.AGGREGATION)
            .withReference(businessObject2)
            .create());
    businessObject1.getFields().add(new RelationFieldBuilder()
            .withType(RelationType.COMPOSITION)
            .withReference(businessObject2)
            .create());

    Package pakage = new PackageBuilder()
            .withName("com")
            .withBusinessObjects(businessObject1, businessObject2)
            .create();

    BusinessObjectModel bom = new BusinessObjectModelBuilder()
            .withPackages(pakage)
            .create();
    when(modelObservable.getValue()).thenReturn(bom);
}
 
Example #3
Source File: RelationFieldDetailsControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public RelationFieldDetailsControl(Composite parent, BusinessDataModelFormPage formPage,
        IObservableValue<Field> selectedFieldObservable, IObservableValue<String> descriptionObservable,
        DataBindingContext ctx) {
    super(parent, SWT.None);
    this.descriptionObservable = descriptionObservable;
    setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
    formPage.getToolkit().adapt(this);

    this.formPage = formPage;
    this.selectedFieldObservable = selectedFieldObservable;
    this.ctx = ctx;

    createDescriptionTextArea();
    createRelationKindLabel();
    createRelationKindCombo();
    createLoadingModeRadioButtons();
}
 
Example #4
Source File: DataViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void bindControl(final DataBindingContext context, final IObservableValue dataContainerObservable) {
    this.dataContainerObservable = dataContainerObservable;
    IObservableSet knownElements = ((ObservableListContentProvider) tableViewer.getContentProvider())
            .getKnownElements();
    IObservableMap[] labelMaps = EMFObservables.observeMaps(knownElements,
            new EStructuralFeature[] { ProcessPackage.Literals.ELEMENT__NAME,
                    ProcessPackage.Literals.DATA__MULTIPLE,
                    ProcessPackage.Literals.JAVA_OBJECT_DATA__CLASS_NAME, ProcessPackage.Literals.DATA__DATA_TYPE });
    tableViewer.setLabelProvider(createLabelProvider(labelMaps));
    tableViewer.setInput(CustomEMFEditObservables.observeDetailList(Realm.getDefault(), dataContainerObservable,
            dataFeature));

    IViewerObservableValue<Object> selectionObservable = ViewerProperties.singleSelection().observe(tableViewer);
    UpdateValueStrategy selectionNotNullUpdateValueStrategy = updateValueStrategy().withConverter(selectionNotNull())
            .create();

    context.bindValue(WidgetProperties.enabled().observe(editButton),
            selectionObservable,
            neverUpdateValueStrategy().create(),
            selectionNotNullUpdateValueStrategy);

    context.bindValue(WidgetProperties.enabled().observe(removeButton),
            selectionObservable,
            neverUpdateValueStrategy().create(),
            selectionNotNullUpdateValueStrategy);
}
 
Example #5
Source File: BusinessObjectListValidator.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public BusinessObjectListValidator(IObservableValue<BusinessObjectModel> businessObjectModelObservable) {
    packageNameValidator = new PackageNameValidator();
    businessObjectNameValidator = new BusinessObjectNameValidator(businessObjectModelObservable);
    aggregationAndCompositionValidator = new AggregationAndCompositionValidator(businessObjectModelObservable);
    attributeReferenceExitenceValidator = new AttributeReferenceExitenceValidator(businessObjectModelObservable);
    cyclicCompositionValidator = new CyclicCompositionValidator();
    emptyFieldsValidator = new EmptyFieldsValidator();
    fieldNameValidator = new FieldNameValidator();
    indexNameValidator = new IndexNameValidator(businessObjectModelObservable);
    multipleAggregationToItselfValidator = new MultipleAggregationToItselfValidator();
    severalCompositionReferencesValidator = new SeveralCompositionReferencesValidator(businessObjectModelObservable);
    uniqueConstraintFieldsValidator = new UniqueConstraintFieldsValidator();
    uniqueConstraintNameValidator = new UniqueConstraintNameValidator();
    queryNameValidator = new QueryNameValidator(boObservable);
    queryParameterNameValidator = new QueryParameterNameValidator(queryObservable);
    indexFieldsValidator = new IndexFieldsValidator();
}
 
Example #6
Source File: BusinessObjectNameValidatorTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Before
public void init() {
    businessObject1 = createBusinessObject("businessObject1");
    BusinessObject businessObject2 = createBusinessObject("businessObject2");

    Package pakage = new PackageBuilder()
            .withName("com")
            .withBusinessObjects(businessObject1, businessObject2)
            .create();

    BusinessObjectModel bom = new BusinessObjectModelBuilder()
            .withPackages(pakage)
            .create();
    IObservableValue<BusinessObjectModel> bomObservable = mock(IObservableValue.class);
    when(bomObservable.getValue()).thenReturn(bom);
    validator = spy(new BusinessObjectNameValidator(bomObservable));
    doReturn(ValidationStatus.ok()).when(validator).validateJavaConvention(anyString());
}
 
Example #7
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createGeneralTitleField(final Composite detailsInfoComposite) {
    final Label titleLabel = new Label(detailsInfoComposite, SWT.NONE);
    titleLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    titleLabel.setText(Messages.userTitle);

    final Text titleText = new Text(detailsInfoComposite, SWT.BORDER);
    titleText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    titleText.setMessage(Messages.titleHint);
    //		widgetMap.put(OrganizationPackage.Literals.USER__TITLE, titleText) ;

    final IObservableValue titleUserValue = EMFObservables.observeDetailValue(Realm.getDefault(),
            userSingleSelectionObservable,
            OrganizationPackage.Literals.USER__TITLE);
    context.bindValue(SWTObservables.observeText(titleText, SWT.Modify), titleUserValue);

}
 
Example #8
Source File: DatabaseConnectorOutputWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Control doCreateControl(final Composite parent,
        final EMFDataBindingContext context) {
    topComposite = new Composite(parent, SWT.NONE);
    topComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    stackLayout = new StackLayout();
    topComposite.setLayout(stackLayout);

    defaultOutputComposite = createDefaultOuputControl(topComposite, context);
    singleOutputComposite = createSingleOuputControl(topComposite, context);
    oneRowNColsOutputComposite = createOneRowNColsOuputControl(topComposite, context);
    nRowsOneColumOutputComposite = createNRowsOneColumOuputControl(topComposite, context);
    nRowsNColumsOutputComposite = createNRowsNColsOuputControl(topComposite, context);

    updateStackLayout();

    final ConnectorConfiguration configuration = getConnector().getConfiguration();
    final Expression outputTypeExpression = (Expression) getConnectorParameter(configuration, getInput(OUTPUT_TYPE_KEY))
            .getExpression();
    if (outputTypeExpression != null) {
        final IObservableValue outputTypeObservalbe = EMFObservables.observeValue(outputTypeExpression,
                ExpressionPackage.Literals.EXPRESSION__CONTENT);
        outputTypeObservalbe.addValueChangeListener(this);
    }
    return topComposite;
}
 
Example #9
Source File: DeployOrganizationControlSupplier.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createDefaultUserTextWidget(DataBindingContext ctx, final Composite mainComposite,
        IObservableValue<OrganizationFileStore> fileStoreObservable) {
    SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider(usernames());
    proposalProvider.setFiltering(true);

    TextWidget widget = new TextWidget.Builder()
            .withLabel(Messages.defaultUser)
            .grabHorizontalSpace()
            .fill()
            .labelAbove()
            .withProposalProvider(proposalProvider)
            .withTootltip(Messages.defaultUserTooltip)
            .bindTo(usernameObservable)
            .withTargetToModelStrategy(UpdateStrategyFactory.updateValueStrategy()
                    .withValidator(defaultUserValidator()))
            .inContext(ctx)
            .createIn(mainComposite);

    fileStoreObservable.addValueChangeListener(event -> {
        organizationChanged(event.diff.getNewValue().getContent(), proposalProvider);
        widget.getValueBinding().validateTargetToModel();
    });
}
 
Example #10
Source File: CodingComposite.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private void initDataBinding(){
	transientCodingValue = new WritableValue();
	DataBindingContext bindingContext = new DataBindingContext();
	
	IObservableValue targetObservable = SWTObservables.observeText(codeTxt, SWT.Modify);
	IObservableValue modelObservable = PojoObservables.observeDetailValue(transientCodingValue,
		"code", TransientCoding.class);
	bindingContext.bindValue(targetObservable, modelObservable);
	
	targetObservable = SWTObservables.observeText(displayTxt, SWT.Modify);
	modelObservable = PojoObservables.observeDetailValue(transientCodingValue, "display",
		TransientCoding.class);
	bindingContext.bindValue(targetObservable, modelObservable);
	
	setCoding(null);
}
 
Example #11
Source File: ContractPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createConstraintTabContent(final Composite parent, final IObservableValue observeContractValue) {
    final Composite buttonsComposite = createButtonContainer(parent);
    final Button addButton = createButton(buttonsComposite, Messages.add);
    final Button upButton = createButton(buttonsComposite, Messages.up);
    final Button downButton = createButton(buttonsComposite, Messages.down);
    final Button removeButton = createButton(buttonsComposite, Messages.remove);

    final ContractConstraintsTableViewer constraintsTableViewer = new ContractConstraintsTableViewer(parent,
            getWidgetFactory());
    constraintsTableViewer.getControl()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(500, SWT.DEFAULT).create());
    constraintsTableViewer.initialize(constraintController, getMessageManager(), context);
    constraintsTableViewer.setInput(CustomEMFEditObservables.observeDetailList(Realm.getDefault(), observeContractValue,
            ProcessPackage.Literals.CONTRACT__CONSTRAINTS));

    constraintsTableViewer.createAddListener(addButton);
    constraintsTableViewer.createMoveUpListener(upButton);
    constraintsTableViewer.createMoveDownListener(downButton);
    constraintsTableViewer.createRemoveListener(removeButton);

    bindAddConstraintButtonEnablement(addButton, observeContractValue);
    bindRemoveButtonEnablement(removeButton, constraintsTableViewer);
    bindUpButtonEnablement(upButton, constraintsTableViewer);
    bindDownButtonEnablement(downButton, constraintsTableViewer);
}
 
Example #12
Source File: IterationPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createInputForCardinalityGroup(final TabbedPropertySheetWidgetFactory widgetFactory,
        final Composite dataContent) {
    final Group inputGroup = widgetFactory.createGroup(dataContent, Messages.input);
    inputGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    inputGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).spacing(5, 3).create());

    final Label label = widgetFactory.createLabel(inputGroup, Messages.numberOfInstancesToCreate, SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).create());
    final ExpressionViewer cardinalityExpression = new ExpressionViewer(inputGroup, SWT.BORDER, widgetFactory);
    cardinalityExpression.getControl()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
    cardinalityExpression.addFilter(new AvailableExpressionTypeFilter(
            new String[] { ExpressionConstants.CONSTANT_TYPE, ExpressionConstants.VARIABLE_TYPE,
                    ExpressionConstants.PARAMETER_TYPE, ExpressionConstants.SCRIPT_TYPE }));
    cardinalityExpression.setExpressionNameResolver(new DefaultExpressionNameResolver("numberOfInstancesToCreate"));
    final IObservableValue selectionObservable = ViewersObservables.observeSingleSelection(selectionProvider);
    context.bindValue(ViewersObservables.observeInput(cardinalityExpression), selectionObservable);
    context.bindValue(ViewersObservables.observeSingleSelection(cardinalityExpression),
            CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), selectionObservable,
                    ProcessPackage.Literals.MULTI_INSTANTIABLE__CARDINALITY_EXPRESSION));
}
 
Example #13
Source File: ConditionComposite.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private void initDataBinding(){
	transientConditionValue = new WritableValue();
	DataBindingContext bindingContext = new DataBindingContext();
	
	IObservableValue targetObservable =
		ViewersObservables.observeSingleSelection(statusViewer);
	IObservableValue modelObservable = PojoObservables
		.observeDetailValue(transientConditionValue, "status", TransientCondition.class);
	bindingContext.bindValue(targetObservable, modelObservable);
	
	targetObservable = SWTObservables.observeText(startTxt, SWT.Modify);
	modelObservable = PojoObservables.observeDetailValue(transientConditionValue, "start",
		TransientCondition.class);
	bindingContext.bindValue(targetObservable, modelObservable);
	
	targetObservable = SWTObservables.observeText(endTxt, SWT.Modify);
	modelObservable = PojoObservables.observeDetailValue(transientConditionValue, "end",
		TransientCondition.class);
	bindingContext.bindValue(targetObservable, modelObservable);
	
	targetObservable = SWTObservables.observeText(textTxt, SWT.Modify);
	modelObservable =
		PojoObservables.observeDetailValue(transientConditionValue, "text",
			TransientCondition.class);
	bindingContext.bindValue(targetObservable, modelObservable);
	
	setCondition(null);
}
 
Example #14
Source File: EMFEditWithRefactorObservables.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static DetailObservableValueWithRefactor observeDetailValueWithRefactor(Realm realm,
        IObservableValue value, 
        EStructuralFeature eStructuralFeature,
        IRefactorOperationFactory refactorOperationFactory,
        IProgressService progressService) {
    return new DetailObservableValueWithRefactor(value, valueWithRefactorFactory(realm, eStructuralFeature, refactorOperationFactory, progressService), eStructuralFeature);
    
}
 
Example #15
Source File: StatechartDefinitionSection.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void initBinding(StyledText text) {
	IEMFValueProperty modelProperty = EMFEditProperties.value(getTransactionalEditingDomain(),
			SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION);
	ISWTObservableValue uiProperty = WidgetProperties.text(new int[] { SWT.FocusOut }).observe(text);
	IObservableValue modelPropertyObservable = modelProperty.observe(getContextObject());
	context = new ValidatingEMFDatabindingContext((EObject)editorPart.getAdapter(EObject.class),
			editorPart.getSite().getShell());
	context.bindValue(uiProperty, modelPropertyObservable, null, null);
}
 
Example #16
Source File: StringSplitListObservable.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
protected StringSplitListObservable ( final IObservableValue value, final String delimiter, final String pattern, final Object valueType )
{
    super ( value.getRealm (), new LinkedList<Object> (), valueType );

    this.value = value;
    this.pattern = pattern;
    this.delimiter = delimiter;

    value.addValueChangeListener ( this.changeListener );
    value.addStaleListener ( this.staleListener );

    value.addDisposeListener ( this.disposeListener );
}
 
Example #17
Source File: ExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void bindEditableText(final IObservableValue typeObservable) {
    final UpdateValueStrategy modelToTargetTypeStrategy = new UpdateValueStrategy();
    modelToTargetTypeStrategy.setConverter(new Converter(String.class, Boolean.class) {

        @Override
        public Object convert(final Object from) {
            if (from == null) {
                return true;
            }
            final boolean isScriptType = ExpressionConstants.SCRIPT_TYPE.equals(from.toString());
            final boolean isConnectorType = from.toString().equals(ExpressionConstants.CONNECTOR_TYPE);
            final boolean isXPathType = from.toString().equals(ExpressionConstants.XPATH_TYPE);
            final boolean isJavaType = from.toString().equals(ExpressionConstants.JAVA_TYPE);
            final boolean isQueryType = from.toString().equals(ExpressionConstants.QUERY_TYPE);
            final boolean isFormReference = from.toString().equals(ExpressionConstants.FORM_REFERENCE_TYPE);
            if (isScriptType) {
                textTooltip.setText(Messages.editScriptExpressionTooltip);
            } else if (isXPathType) {
                textTooltip.setText(Messages.editXpathExpressionTooltip);
            } else if (isJavaType) {
                textTooltip.setText(Messages.editJavaExpressionTooltip);
            } else if (isConnectorType) {
                textTooltip.setText(Messages.editConnectorExpressionTooltip);
            } else if (isQueryType) {
                textTooltip.setText(Messages.editQueryExpressionTooltip);
            } else {
                textTooltip.setText(null);
            }
            return !(isScriptType || isConnectorType || isJavaType || isXPathType || isQueryType || isFormReference);
        }

    });

    internalDataBindingContext.bindValue(SWTObservables.observeEditable(textControl), typeObservable,
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), modelToTargetTypeStrategy);
}
 
Example #18
Source File: SelectDatabaseOutputTypeWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void updateQuery() {
    if (graphicalModeSelectionValue != null) {
        final IObservableValue enableGraphicalMode = SWTObservables.observeEnabled(gModeRadio);
        if (SQLQueryUtil.isGraphicalModeSupportedFor(scriptExpression)) {
            enableGraphicalMode.setValue(true);
            updateEnabledChoices();
        } else {
            enableGraphicalMode.setValue(false);
            graphicalModeSelectionValue.setValue(false);
            scriptValue.setValue(true);
            radioGroupObservable.setValue(null);
        }
    }
}
 
Example #19
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private Binding bindTextToUserAttribute(final Text text, final EReference reference, final EAttribute attribute,
        final UpdateValueStrategy targetUpdateValueStrategy) {
    final IObservableValue personalDataValue = EMFObservables.observeDetailValue(Realm.getDefault(),
            userSingleSelectionObservable, reference);
    final IObservableValue propertyUserValue = EMFObservables.observeDetailValue(Realm.getDefault(),
            personalDataValue,
            attribute);
    return context.bindValue(SWTObservables.observeText(text, SWT.Modify), propertyUserValue,
            targetUpdateValueStrategy,
            null);
}
 
Example #20
Source File: QueryDetailsControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createDescriptionSection() {
    descriptionSection = formPage.getToolkit().createSection(this, Section.EXPANDED);
    descriptionSection.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    descriptionSection.setLayout(GridLayoutFactory.fillDefaults().create());
    descriptionSection.setText(Messages.description);

    Composite client = formPage.getToolkit().createComposite(descriptionSection);
    client.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    client.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());

    IObservableValue descriptionObservable = EMFObservables.observeDetailValue(Realm.getDefault(),
            querySelectedObservable, BusinessDataModelPackage.Literals.QUERY__DESCRIPTION);

    TextWidget widget = new TextAreaWidget.Builder()
            .widthHint(500)
            .heightHint(70)
            .bindTo(descriptionObservable)
            .inContext(ctx)
            .adapt(formPage.getToolkit())
            .createIn(client);

    ctx.bindValue(widget.observeEnable(), new ComputedValueBuilder()
            .withSupplier(() -> !isDefault())
            .build());

    descriptionSection.setClient(client);
}
 
Example #21
Source File: ExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void inputChanged(Object input, final Object oldInput) {
    if (input instanceof IObservableValue) {
        input = ((IObservableValue) input).getValue();
    }
    if (input != null) {
        manageNatureProviderAndAutocompletionProposal(input);
    }

}
 
Example #22
Source File: ConverterUtil.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public static void bindValue(DataBindingContext context,ComboViewer comboViewer,
			ConverterViewModel model) {
//		ViewerSupport.bind(comboViewer, BeansObservables.observeList(
//				model, "supportTypes", String.class),
//				Properties.selfValue(String.class));
//		
//
//		context.bindValue(ViewersObservables
//				.observeSingleSelection(comboViewer), BeansObservables
//				.observeValue(model,
//						"selectedType"));
		
//		ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider();
		comboViewer.setContentProvider(new ArrayContentProvider());
		comboViewer.setComparator(new ViewerComparator());
//		IObservableMap[] attributeMaps = BeansObservables.observeMaps(
//				viewerContentProvider.getKnownElements(),
//				ConverterBean.class, new String[] { "description" });
//		comboViewer.setLabelProvider(new ObservableMapLabelProvider(
//		attributeMaps));
//		comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class));
		
		comboViewer.setInput(model.getSupportTypes());
		IViewerObservableValue selection=ViewersObservables.observeSingleSelection(comboViewer);
		IObservableValue observableValue=BeansObservables.observeDetailValue(selection, "name", ConverterBean.class);
		context.bindValue(observableValue, BeansObservables
				.observeValue(model,
						"selectedType"));
	}
 
Example #23
Source File: IterationPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private UpdateValueStrategy refactorReturnTypeStrategy(final IObservableValue expressionReturnTypeDetailValue,
        final IObservableValue iteratorObservable) {
    final UpdateValueStrategy strategy = new UpdateValueStrategy();
    strategy.setConverter(new Converter(String.class, String.class) {

        @Override
        public Object convert(final Object value) {
            final String returnType = (String) value;
            final Expression expression = (Expression) iteratorObservable.getValue();
            final EditingDomainEObjectObservableValueWithRefactoring innerObservableValue = (EditingDomainEObjectObservableValueWithRefactoring) ((DetailObservableValueWithRefactor) expressionReturnTypeDetailValue)
                    .getInnerObservableValue();
            if (expression != null && returnType != null && innerObservableValue != null) {
                final MultiInstantiable parentFlowElement = (MultiInstantiable) ModelHelper
                        .getParentFlowElement(expression);
                final Data oldItem = ExpressionHelper.dataFromIteratorExpression(parentFlowElement, expression,
                        mainProcess(parentFlowElement));
                final Expression expressionCopy = EcoreUtil.copy(expression);
                expressionCopy.setReturnType(returnType);
                final Data newItem = ExpressionHelper.dataFromIteratorExpression(parentFlowElement, expressionCopy,
                        mainProcess(parentFlowElement));
                innerObservableValue.setRefactoringCommand(getRefactorCommand(oldItem, newItem, parentFlowElement));
            } else if (innerObservableValue != null) {
                innerObservableValue.setRefactoringCommand(null);
            }
            return value;
        }

    });
    return strategy;
}
 
Example #24
Source File: InputNameObservableEditingSupport.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected IObservableValue doCreateElementObservable(final Object element, final ViewerCell cell) {
    checkArgument(element instanceof ContractInput);
    final IObservableValue observableValue = ((ContractInput) element).eContainer() instanceof Contract ? EMFEditWithRefactorObservables
            .observeValueWithRefactor(
                    TransactionUtil.getEditingDomain(element),
                    (EObject) element,
                    ProcessPackage.Literals.CONTRACT_INPUT__NAME,
                    contractInputRefactorOperationFactory,
                    progressService) : EMFEditObservables.observeValue(TransactionUtil.getEditingDomain(element), (EObject) element,
            ProcessPackage.Literals.CONTRACT_INPUT__NAME);
    observableValue.addValueChangeListener(new ColumnViewerUpdateListener(getViewer(), element));
    return observableValue;
}
 
Example #25
Source File: DateTimeControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void bindControl(final DataBindingContext dbc, final IObservableValue modelObservable) {
    final DateTimeObservable dateObservable = new DateTimeObservable(dateControl);
    final DateTimeObservable timeObservable = new DateTimeObservable(timeControl);
    dbc.bindValue(dateObservable, modelObservable);
    dateControl.notifyListeners(SWT.Selection, new Event());
    timeObservable.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            final Date newValue = (Date) event.diff.getNewValue();
            dateControl.setTime(newValue.getHours(), newValue.getMinutes(), newValue.getMinutes());
            dateControl.notifyListeners(SWT.Selection, new Event());
        }
    });
}
 
Example #26
Source File: TmDbManagerDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 初始化数据绑定 将界面与<code>currServer</code>进行绑定
 * @return ;
 */
protected void initDataBindings() {
	DataBindingContext bindingContext = new DataBindingContext();

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

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

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

	widgetValue = WidgetProperties.text(SWT.Modify).observe(locationText);
	final IObservableValue locationModelValue = BeanProperties.value("itlDBLocation").observe(currServer);
	bindingContext.bindValue(widgetValue, locationModelValue, null, null);

	widgetValue = WidgetProperties.text(SWT.Modify).observe(usernameText);
	final IObservableValue usernameModelValue = BeanProperties.value("userName").observe(currServer);
	bindingContext.bindValue(widgetValue, usernameModelValue, null, null);

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

	ViewerSupport.bind(dbTableViewer, currServerdbListInput,
			BeanProperties.values(new String[] { "index", "dbName", "langs" }));

}
 
Example #27
Source File: ConverterBuilderTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_create_and_use_string_to_int_converter() {

    IConverter stringToInt = ConverterBuilder.<String, Integer> newConverter()
            .fromType(String.class)
            .toType(Integer.class)
            .withConvertFunction(Integer::parseInt)
            .create();

    IConverter intToString = ConverterBuilder.<Integer, String> newConverter()
            .fromType(Integer.class)
            .toType(String.class)
            .withConvertFunction(String::valueOf)
            .create();

    A a = new A();
    B b = new B();

    DataBindingContext ctx = new DataBindingContext();
    IObservableValue<String> observeA = PojoProperties.value("a").observe(a);
    IObservableValue<Integer> observeB = PojoProperties.value("b").observe(b);
    ctx.bindValue(observeA, observeB, UpdateStrategyFactory.updateValueStrategy().withConverter(stringToInt).create(),
            UpdateStrategyFactory.updateValueStrategy().withConverter(intToString).create());

    observeA.setValue("123");
    assertThat(b.getB()).isEqualTo(123);

    observeB.setValue(321);
    assertThat(a.getA()).isEqualTo("321");
}
 
Example #28
Source File: ProjectSettingLanguagePage.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private void initDataBindings() {
	DataBindingContext ctx = new DataBindingContext();

	IObservableValue widgetValue = ViewersObservables.observeSingleSelection(srcLangComboViewer);
	IObservableValue modelValue = BeanProperties.value(ProjectInfoBean.class, "sourceLang").observe(projCfgBean);
	ctx.bindValue(widgetValue, modelValue, null, null);
}
 
Example #29
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createGeneralJobLabel(final Composite detailsInfoComposite) {
    final Label jobLabel = new Label(detailsInfoComposite, SWT.NONE);
    jobLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    jobLabel.setText(Messages.jobLabel);

    final Text jobText = new Text(detailsInfoComposite, SWT.BORDER);
    jobText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    jobText.setMessage(Messages.jobHint);
    final IObservableValue jobUserValue = EMFObservables.observeDetailValue(Realm.getDefault(),
            userSingleSelectionObservable,
            OrganizationPackage.Literals.USER__JOB_TITLE);
    context.bindValue(SWTObservables.observeText(jobText, SWT.Modify), jobUserValue);

}
 
Example #30
Source File: ConverterUtil.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public static void bindValue(DataBindingContext context,ComboViewer comboViewer,
			ConverterViewModel model) {
//		ViewerSupport.bind(comboViewer, BeansObservables.observeList(
//				model, "supportTypes", String.class),
//				Properties.selfValue(String.class));
//		
//
//		context.bindValue(ViewersObservables
//				.observeSingleSelection(comboViewer), BeansObservables
//				.observeValue(model,
//						"selectedType"));
		
//		ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider();
		comboViewer.setContentProvider(new ArrayContentProvider());
		comboViewer.setComparator(new ViewerComparator());
//		IObservableMap[] attributeMaps = BeansObservables.observeMaps(
//				viewerContentProvider.getKnownElements(),
//				ConverterBean.class, new String[] { "description" });
//		comboViewer.setLabelProvider(new ObservableMapLabelProvider(
//		attributeMaps));
//		comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class));
		
		comboViewer.setInput(model.getSupportTypes());
		IViewerObservableValue selection=ViewersObservables.observeSingleSelection(comboViewer);
		IObservableValue observableValue=BeansObservables.observeDetailValue(selection, "name", ConverterBean.class);
		context.bindValue(observableValue, BeansObservables
				.observeValue(model,
						"selectedType"));
	}