org.eclipse.core.databinding.UpdateValueStrategy Java Examples
The following examples show how to use
org.eclipse.core.databinding.UpdateValueStrategy.
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: EditableControlWidget.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected ControlMessageSupport bindValidator(DataBindingContext ctx, ISWTObservableValue controlObservable, IObservableValue modelObservable, IValidator validator) { final UpdateValueStrategy validateOnlyStrategy = UpdateStrategyFactory.convertUpdateValueStrategy() .withValidator(validator).create(); Binding binding = ctx.bindValue(controlObservable, modelObservable, validateOnlyStrategy, validateOnlyStrategy); ControlMessageSupport controlMessageSupport = new ControlMessageSupport(binding) { @Override protected void statusChanged(IStatus status) { EditableControlWidget.this.statusChanged(status); } }; binding.validateTargetToModel(); return controlMessageSupport; }
Example #2
Source File: SelectJarsDialog.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected Control createDialogArea(Composite parent) { Control control = super.createDialogArea(parent); UpdateValueStrategy selectionStartegy = new UpdateValueStrategy() ; selectionStartegy.setAfterGetValidator(new IValidator() { @Override public IStatus validate(Object value) { if( value == null){ return ValidationStatus.error("Selection is empty") ; } return Status.OK_STATUS; } }) ; context.bindList(ViewersObservables.observeMultiSelection(tableViewer), PojoProperties.list(SelectJarsDialog.class,"selectedJars").observe(this)) ; context.bindValue(ViewersObservables.observeSingleSelection(tableViewer), PojoProperties.value(SelectJarsDialog.class,"selectedJar").observe(this), selectionStartegy, null) ; return control ; }
Example #3
Source File: RunConfigurationWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void updatePage(AbstractProcess process, Configuration configuration) { if (context != null) { context.dispose(); } if (pageSupport != null) { pageSupport.dispose(); } context = new EMFDataBindingContext(); UpdateValueStrategy targetStrategy = new UpdateValueStrategy(); targetStrategy.setBeforeSetValidator(userNameValidator); context.bindValue(textWidget.observeText(SWT.Modify), EMFObservables.observeValue(configuration, ConfigurationPackage.Literals.CONFIGURATION__USERNAME), targetStrategy, null); users = (List<String>) commandExecutor.executeCommand(GET_USERS_COMMAND, null); userProposalProvider.setProposals(users.toArray(new String[users.size()])); pageSupport = WizardPageSupport.create(this, context); }
Example #4
Source File: DataViewer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
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: ContractPropertySection.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private UpdateValueStrategy isFirstElementToBooleanStrategy() { final UpdateValueStrategy strategy = new UpdateValueStrategy(); strategy.setConverter(new Converter(Object.class, Boolean.class) { @Override public Object convert(final Object from) { if (from instanceof ContractConstraint) { final Contract contract = (Contract) ((ContractConstraint) from).eContainer(); final EList<ContractConstraint> constraints = contract.getConstraints(); return constraints.size() > 1 && constraints.indexOf(from) > 0; } return false; } }); return strategy; }
Example #6
Source File: AssignableActorsPropertySection.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
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 #7
Source File: AppEngineDeployPreferencesPanel.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
private void setupProjectSelectorDataBinding() { IViewerObservableValue projectInput = ViewerProperties.input().observe(projectSelector.getViewer()); IViewerObservableValue projectSelection = ViewerProperties.singleSelection().observe(projectSelector.getViewer()); bindingContext.addValidationStatusProvider( new ProjectSelectionValidator(projectInput, projectSelection, requireValues)); IViewerObservableValue projectList = ViewerProperties.singleSelection().observe(projectSelector.getViewer()); IObservableValue<String> projectIdModel = PojoProperties.value("projectId").observe(model); UpdateValueStrategy gcpProjectToProjectId = new UpdateValueStrategy().setConverter(new GcpProjectToProjectIdConverter()); UpdateValueStrategy projectIdToGcpProject = new UpdateValueStrategy().setConverter(new ProjectIdToGcpProjectConverter()); bindingContext.bindValue(projectList, projectIdModel, gcpProjectToProjectId, projectIdToGcpProject); }
Example #8
Source File: SelectDatabaseOutputTypeWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected Button createOneRowNColsChoice(final Composite choicesComposite, EMFDataBindingContext context) { final Button oneRowRadio = new Button(choicesComposite, SWT.RADIO); oneRowRadio.setLayoutData(GridDataFactory.fillDefaults().grab(false, false).create()); oneRowRadio.setText(Messages.oneRowNCol); final ControlDecoration oneRowDeco = new ControlDecoration(oneRowRadio, SWT.RIGHT, choicesComposite); oneRowDeco.setImage(Pics.getImage(PicsConstants.hint)); oneRowDeco.setDescriptionText(Messages.oneRowHint); final Label oneRowIcon = new Label(choicesComposite, SWT.NONE); oneRowIcon.setLayoutData( GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER).indent(15, 0).grab(true, false).create()); final UpdateValueStrategy selectImageStrategy = new UpdateValueStrategy(); selectImageStrategy.setConverter(new Converter(Boolean.class, Image.class) { @Override public Object convert(Object fromObject) { if (fromObject != null && (Boolean) fromObject) { return Pics.getImage("row_placeholder.png", ConnectorPlugin.getDefault()); } else { return Pics.getImage("row_placeholder_disabled.png", ConnectorPlugin.getDefault()); } } }); oneRowNColModeRadioObserveEnabled = SWTObservables.observeEnabled(oneRowRadio); context.bindValue(SWTObservables.observeImage(oneRowIcon), oneRowNColModeRadioObserveEnabled, null, selectImageStrategy); return oneRowRadio; }
Example #9
Source File: OpenNameAndVersionDialogTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Test public void should_diagram_name_strategy_validate_fileName() throws Exception { final OpenNameAndVersionDialog dialog = new OpenNameAndVersionDialog(realmWithDisplay.getShell(), aMainProcess().withName("MyDiagram") .withVersion("1.0").build(), diagramStore); final UpdateValueStrategy nameStrategy = dialog.diagramUpdateStrategy(""); assertThat(nameStrategy.validateAfterGet("My\\Diagram")).isNotOK(); }
Example #10
Source File: OpenNameAndVersionDialog.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected UpdateValueStrategy diagramUpdateStrategy(final String fieldName) { return updateValueStrategy().withValidator(multiValidator() .addValidator(mandatoryValidator(Messages.name)) .addValidator(maxLengthValidator(Messages.name, MAX_LENGTH)) .addValidator(fileNameValidator(Messages.name)) .addValidator(utf8InputValidator(Messages.name))).create(); }
Example #11
Source File: SelectDatabaseOutputTypeWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected Button createSingleChoice(final Composite choicesComposite, EMFDataBindingContext context) { final Button singleRadio = new Button(choicesComposite, SWT.RADIO); singleRadio.setLayoutData(GridDataFactory.fillDefaults().grab(false, false).create()); singleRadio.setText(Messages.singleValue); final Label singleIcon = new Label(choicesComposite, SWT.NONE); singleIcon.setLayoutData( GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER).indent(15, 0).grab(true, false).create()); final UpdateValueStrategy selectImageStrategy = new UpdateValueStrategy(); selectImageStrategy.setConverter(new Converter(Boolean.class, Image.class) { @Override public Object convert(Object fromObject) { if (fromObject != null && (Boolean) fromObject) { return Pics.getImage("single_placeholder.png", ConnectorPlugin.getDefault()); } else { return Pics.getImage("single_placeholder_disabled.png", ConnectorPlugin.getDefault()); } } }); singleModeRadioObserveEnabled = SWTObservables.observeEnabled(singleRadio); context.bindValue(SWTObservables.observeImage(singleIcon), singleModeRadioObserveEnabled, null, selectImageStrategy); return singleRadio; }
Example #12
Source File: InputNameObservableEditingSupportTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Test public void should_fails_validation_if_input_name_already_exists_at_same_level() throws Exception { final InputNameObservableEditingSupport editingSupport = new InputNameObservableEditingSupport(aTableViewer(), messageManager, new EMFDataBindingContext(), refactorOperationFactory, progressService); final UpdateValueStrategy convertStrategy = editingSupport.targetToModelConvertStrategy(aContract() .havingInput(aContractInput().withName("firstName"), aContractInput().withName("lastName")) .build().getInputs().get(1)); final IStatus status = convertStrategy.validateAfterGet("firstName"); assertThat(status).isNotOK(); }
Example #13
Source File: SelectDatabaseOutputTypeWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected Button createNRowsOneColChoice(final Composite choicesComposite, EMFDataBindingContext context) { final Button oneColRadio = new Button(choicesComposite, SWT.RADIO); oneColRadio.setLayoutData(GridDataFactory.fillDefaults().grab(false, false).create()); oneColRadio.setText(Messages.nRowOneCol); final ControlDecoration oneColDeco = new ControlDecoration(oneColRadio, SWT.RIGHT, choicesComposite); oneColDeco.setImage(Pics.getImage(PicsConstants.hint)); oneColDeco.setDescriptionText(Messages.oneColHint); final Label oneColIcon = new Label(choicesComposite, SWT.NONE); oneColIcon.setLayoutData( GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER).indent(15, 0).grab(true, false).create()); final UpdateValueStrategy selectImageStrategy = new UpdateValueStrategy(); selectImageStrategy.setConverter(new Converter(Boolean.class, Image.class) { @Override public Object convert(Object fromObject) { if (fromObject != null && (Boolean) fromObject) { return Pics.getImage("column_placeholder.png", ConnectorPlugin.getDefault()); } else { return Pics.getImage("column_placeholder_disabled.png", ConnectorPlugin.getDefault()); } } }); nRowsOneColModeRadioObserveEnabled = SWTObservables.observeEnabled(oneColRadio); context.bindValue(SWTObservables.observeImage(oneColIcon), nRowsOneColModeRadioObserveEnabled, null, selectImageStrategy); return oneColRadio; }
Example #14
Source File: DescriptionPropertySectionContribution.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void createControl(final Composite composite, final TabbedPropertySheetWidgetFactory widgetFactory, final ExtensibleGridPropertySection page) { composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(1, vSpan).create()); final Text text = widgetFactory.createText(composite, "", GTKStyleHandler.removeBorderFlag(SWT.BORDER | SWT.MULTI | SWT.WRAP)); text.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 120).create()); context = new EMFDataBindingContext(); final UpdateValueStrategy strategy = new UpdateValueStrategy(); strategy.setBeforeSetValidator(new InputLengthValidator(Messages.GeneralSection_Description, 254)); ControlDecorationSupport.create(context.bindValue( SWTObservables.observeDelayedValue(400, SWTObservables.observeText(text, SWT.Modify)), EMFEditObservables.observeValue(editingDomain, element, ProcessPackage.Literals.ELEMENT__DOCUMENTATION), strategy, null), SWT.LEFT | SWT.TOP); }
Example #15
Source File: SaveConnectorConfigurationWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected void doCreateControl(Composite composite) { super.doCreateControl(composite); final Composite saveComposite = new Composite(composite, SWT.NONE) ; saveComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true,false).create()) ; saveComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 10).create()) ; final Label nameLabel = new Label(saveComposite, SWT.NONE) ; nameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END,SWT.CENTER).create()) ; nameLabel.setText(Messages.name +" *") ; final Text nameText = new Text(saveComposite, SWT.BORDER) ; nameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()) ; final UpdateValueStrategy targetToModel = new UpdateValueStrategy() ; targetToModel.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object newText) { if(newText == null || newText.toString().isEmpty()){ return ValidationStatus.error(Messages.nameIsEmpty); } if(configurationStore.getChild(newText+"."+configurationStore.getCompatibleExtensions().iterator().next(), true) != null){ return ValidationStatus.error(Messages.nameAlreadyExists) ; } return Status.OK_STATUS; } }) ; context.bindValue(SWTObservables.observeText(nameText, SWT.Modify), PojoProperties.value(SaveConnectorConfigurationWizardPage.class, "confName").observe(this), targetToModel, null) ; }
Example #16
Source File: SelectConnectorConfigurationWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected UpdateValueStrategy targetUpdateValueStrategy() { return updateValueStrategy().withValidator(new IValidator() { @Override public IStatus validate(Object value) { if (value == null || value instanceof ConnectorParameter) { return ValidationStatus.error(Messages.selectAConnectorConfDefWarning); } return ValidationStatus.ok(); } }).create(); }
Example #17
Source File: AppEngineDeployPreferencesPanel.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
private void setupAccountEmailDataBinding() { AccountSelectorObservableValue accountSelectorObservableValue = new AccountSelectorObservableValue(accountSelector); UpdateValueStrategy modelToTarget = new UpdateValueStrategy().setConverter(new Converter(String.class, String.class) { @Override public Object convert(Object savedEmail) { Preconditions.checkArgument(savedEmail instanceof String); if (accountSelector.isEmailAvailable((String) savedEmail)) { return savedEmail; } else if (requireValues && accountSelector.getAccountCount() == 1) { return accountSelector.getFirstEmail(); } else { return null; } } }); final IObservableValue<String> accountEmailModel = PojoProperties.value("accountEmail").observe(model); Binding binding = bindingContext.bindValue(accountSelectorObservableValue, accountEmailModel, new UpdateValueStrategy(), modelToTarget); /* * Trigger an explicit target -> model update for the auto-select-single-account case. When the * model has a null account but there is exactly 1 login account, then the AccountSelector * automatically selects that account. That change means the AccountSelector is at odds with the * model. */ binding.updateTargetToModel(); bindingContext.addValidationStatusProvider(new AccountSelectorValidator( requireValues, accountSelector, accountSelectorObservableValue)); }
Example #18
Source File: InputTypeEditingSupport.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected Binding createBinding(IObservableValue target, IObservableValue model) { UpdateValueStrategy targetToModel = new UpdateValueStrategy() ; targetToModel.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object input) { if(input == null || input.toString().isEmpty()){ return ValidationStatus.error(Messages.typeIsEmpty) ; } return Status.OK_STATUS; } }) ; return context.bindValue(target, model,targetToModel , null); }
Example #19
Source File: InputNameObservableEditingSupportTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Test public void should_fails_validation_if_input_name_is_not_a_valid_java_identifiable() throws Exception { final InputNameObservableEditingSupport editingSupport = new InputNameObservableEditingSupport(aTableViewer(), messageManager, new EMFDataBindingContext(), refactorOperationFactory, progressService); final UpdateValueStrategy convertStrategy = editingSupport.targetToModelConvertStrategy(aContractInput().build()); final IStatus status = convertStrategy .validateAfterGet("1startsWithOne"); assertThat(status).isNotOK(); }
Example #20
Source File: OpenNameAndVersionDialogTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Test public void should_diagram_name_strategy_validate_max_length_name() throws Exception { final OpenNameAndVersionDialog dialog = new OpenNameAndVersionDialog(realmWithDisplay.getShell(), aMainProcess().withName("MyDiagram") .withVersion("1.0").build(), diagramStore); final UpdateValueStrategy nameStrategy = dialog.diagramUpdateStrategy(""); assertThat(nameStrategy.validateAfterGet( "tooooooooooooooooooooooooooooo00000000000000000000000000000000000000000000000000000000ooooooooooooooooooLong")) .isNotOK(); }
Example #21
Source File: ContractInputExpressionEditor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected UpdateValueStrategy contractInputToSelectionStrategy() { final UpdateValueStrategy referencedDataToSelection = new UpdateValueStrategy(); final IConverter referencetoDataConverter = new Converter(List.class, ContractInput.class) { @SuppressWarnings("unchecked") @Override public Object convert(final Object inputList) { final List<? extends EObject> list = inputList != null ? (List<? extends EObject>) inputList : Collections.emptyList(); return list.stream() .filter(ContractInput.class::isInstance) .map(ContractInput.class::cast) .findFirst() .map(contractInput -> { return ((Collection<ContractInput>) viewer.getInput()).stream() .filter(input -> EcoreUtil.equals(contractInput, input)) .findFirst() .orElse(null); }) .orElse(null); } }; referencedDataToSelection.setConverter(referencetoDataConverter); return referencedDataToSelection; }
Example #22
Source File: ContractPropertySection.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private UpdateValueStrategy emptySelectionAndComplexTypeToBooleanStrategy() { final UpdateValueStrategy modelStrategy = new UpdateValueStrategy(); modelStrategy.setConverter(new Converter(Object.class, Boolean.class) { @Override public Object convert(final Object from) { if (from instanceof ContractInput) { return ((ContractInput) from).getType() == ContractInputType.COMPLEX; } return false; } }); return modelStrategy; }
Example #23
Source File: ConstraintNameObservableEditingSupportTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Test public void should_create_a_convert_update_strategy() throws Exception { final ConstraintNameObservableEditingSupport editingSupport = new ConstraintNameObservableEditingSupport(aTableViewer(), null, new EMFDataBindingContext()); final UpdateValueStrategy convertStrategy = editingSupport.targetToModelConvertStrategy(aContractInput().build()); assertThat(convertStrategy.getUpdatePolicy()).isEqualTo(UpdateValueStrategy.POLICY_CONVERT); }
Example #24
Source File: DataWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void bindJavaClassText() { if (classText != null && !classText.isDisposed()) { final UpdateValueStrategy classNameStrategy = new UpdateValueStrategy(); classNameStrategy.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(final Object value) { if (value == null || value.toString().isEmpty()) { return new Status(IStatus.ERROR, DataPlugin.PLUGIN_ID, Messages.emptyClassName); } IType type = null; try { type = RepositoryManager.getInstance().getCurrentRepository().getJavaProject() .findType(value.toString()); } catch (final JavaModelException e) { } if (type == null) { return new Status(IStatus.WARNING, DataPlugin.PLUGIN_ID, NLS.bind(Messages.classNotFound, value.toString())); } return Status.OK_STATUS; } }); emfDatabindingContext.bindValue(SWTObservables.observeText(classText, SWT.Modify), EMFObservables.observeValue(data, ProcessPackage.Literals.JAVA_OBJECT_DATA__CLASS_NAME), classNameStrategy, null); } }
Example #25
Source File: InputNameObservableEditingSupport.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected UpdateValueStrategy targetToModelConvertStrategy(final EObject element) { return convertUpdateValueStrategy() .withValidator( multiValidator() .addValidator(mandatoryValidator(Messages.name)) .addValidator(maxLengthValidator(Messages.name, INPUT_NAME_MAX_LENGTH)) .addValidator(groovyReferenceValidator(Messages.name).startsWithLowerCase()) .addValidator(uniqueValidator().in(siblingContractInput(element)).onProperty("name"))).create(); }
Example #26
Source File: InputNameObservableEditingSupportTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Test public void should_fails_validation_if_input_name_is_longer_than_50_chars_exists() throws Exception { final InputNameObservableEditingSupport editingSupport = new InputNameObservableEditingSupport(aTableViewer(), messageManager, new EMFDataBindingContext(), refactorOperationFactory, progressService); final UpdateValueStrategy convertStrategy = editingSupport.targetToModelConvertStrategy(aContractInput().build()); final IStatus status = convertStrategy .validateAfterGet("afkjdshfkjdhsfkjdhsfkjhdskjfhdkjshfdkjshfkjdshfdkjshfkjsdhfkjsdhfkjsdhfkjsdhfkjdshfdkjshfkjdshfdkjshfdkjshf"); assertThat(status).isNotOK(); }
Example #27
Source File: ContractInputExpressionEditor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected UpdateValueStrategy selectionToInputNameStrategy() { final UpdateValueStrategy strategy = new UpdateValueStrategy(); final IConverter nameConverter = new Converter(ContractInput.class, String.class) { @Override public Object convert(final Object input) { return input != null ? ((ContractInput) input).getName() : null; } }; strategy.setConverter(nameConverter); return strategy; }
Example #28
Source File: ContractPropertySection.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private UpdateValueStrategy emptySelectionToBooleanStrategy() { final UpdateValueStrategy modelStrategy = new UpdateValueStrategy(); modelStrategy.setConverter(new Converter(Object.class, Boolean.class) { @Override public Object convert(final Object from) { return from != null; } }); return modelStrategy; }
Example #29
Source File: TextWidget.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public TextWidget createIn(Composite container) { if (transactionalEdit && targetToModelStrategy == null) { throw new IllegalStateException("A target to model strategy is required with transactionalEdit"); } if (transactionalEdit && targetToModelStrategy.getUpdatePolicy() != UpdateValueStrategy.POLICY_CONVERT) { throw new IllegalStateException( "Target to model strategy must have a POLICY_CONVERT strategy with transactionalEdit"); } final TextWidget control = (useNativeRender || GTKStyleHandler.isGTK3()) ? new NativeTextWidget(container, id, labelAbove, horizontalLabelAlignment, verticalLabelAlignment, labelWidth, readOnly, label, message, useCompositeMessageDecorator, labelButton, transactionalEdit, onEdit, toolkit, proposalProvider, editableStrategy, Optional.ofNullable(ctx)) : new TextWidget(container, id, labelAbove, horizontalLabelAlignment, verticalLabelAlignment, labelWidth, readOnly, label, message, useCompositeMessageDecorator, labelButton, transactionalEdit, onEdit, toolkit, proposalProvider, editableStrategy, Optional.ofNullable(ctx)); control.init(); control.setLayoutData(layoutData != null ? layoutData : gridData); buttonListner.ifPresent(control::onClickButton); placeholder.ifPresent(control::setPlaceholder); tooltip.ifPresent(control::setTooltip); if (ctx != null && modelObservable != null) { control.bindControl(ctx, delay.map(time -> control.observeText(time, SWT.Modify)) .orElse(control.observeText(SWT.Modify)), modelObservable, targetToModelStrategy, modelToTargetStrategy); validator.ifPresent( v -> control.bindValidator(ctx, delay.map(time -> control.observeText(time, SWT.Modify)) .orElse(control.observeText(SWT.Modify)), modelObservable, v)); } return control; }
Example #30
Source File: EditableControlWidget.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected ControlMessageSupport bindControl(DataBindingContext ctx, IObservableValue controlObservable, IObservableValue modelObservable, UpdateValueStrategy targetToModel, UpdateValueStrategy modelToTarget) { valueBinding = ctx.bindValue(controlObservable, modelObservable, targetToModel, modelToTarget); return new ControlMessageSupport(valueBinding) { @Override protected void statusChanged(IStatus status) { EditableControlWidget.this.statusChanged(status); } }; }