Java Code Examples for org.eclipse.core.databinding.DataBindingContext#addValidationStatusProvider()
The following examples show how to use
org.eclipse.core.databinding.DataBindingContext#addValidationStatusProvider() .
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: CheckboxRepositoryTreeViewer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public void bindTree(final DataBindingContext context, IObservableList<IRepositoryStore<? extends IRepositoryFileStore>> stores) { inputObservable = stores; setInput(inputObservable); this.checkedElementsObservable = ViewersObservables.observeCheckedElements(this, Object.class); context.addValidationStatusProvider(new MultiValidator() { @Override protected IStatus validate() { if (checkedElementsObservable.isEmpty()) { return ValidationStatus.error(Messages.selectAtLeastOneArtifact); } return ValidationStatus.ok(); } }); collapseAll(); }
Example 2
Source File: SelectDataWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void createControl(final Composite parent) { final Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(GridDataFactory.fillDefaults().create()); composite.setLayout(GridLayoutFactory.fillDefaults().create()); final DataBindingContext dbc = new DataBindingContext(); createRadioButtonComposite(composite, dbc); final Composite stackedComposite = new Composite(composite, SWT.NONE); stackLayout = new CustomStackLayout(stackedComposite); stackedComposite.setLayout(stackLayout); stackedComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); createBusinessVariableTableViewerComposite(stackedComposite, dbc); createDocumentTableViewerComposite(stackedComposite, dbc); createInputNameField(composite, dbc); bindRadioButtonsToComposite(dbc); final MultiValidator multiValidator = new AvailableDataValidator(availableBusinessData, selectedDataObservable, availableDocuments, businessObjectStore); dbc.addValidationStatusProvider(multiValidator); WizardPageSupport.create(this, dbc); setControl(composite); }
Example 3
Source File: CategorySelectionDialog.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected Control createDialogArea(Composite parent) { final Composite mainComposite = new Composite(parent, SWT.NONE) ; mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 300).create()) ; mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10,10).create()) ; context = new DataBindingContext() ; categoryViewer = new TreeViewer(mainComposite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION) ; categoryViewer.getTree().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ; categoryViewer.setContentProvider(new DefinitionCategoryContentProvider()) ; categoryViewer.setLabelProvider(new ConnectorDefinitionTreeLabelProvider(messageProvider)) ; categoryViewer.setInput(getAllCategories()) ; final IViewerObservableList observeSelection = ViewerProperties.multipleSelection().observe(categoryViewer); MultiValidator validator = new MultiValidator() { @Override protected IStatus validate() { if(observeSelection.isEmpty()){ return ValidationStatus.error(""); } return ValidationStatus.ok(); } }; context.addValidationStatusProvider(validator); context.bindList(observeSelection, validator.observeValidatedList(PojoProperties.list("categories").observe(this)), null,new UpdateListStrategy()) ; DialogSupport.create(this,context); return mainComposite ; }
Example 4
Source File: OpenNameAndVersionDialog.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void createNameAndVersion(final Composite res, final DataBindingContext dbc) { final Label nameLabel = new Label(res, SWT.NONE); nameLabel.setText(Messages.name); nameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); final Text nameText = new Text(res, SWT.BORDER); nameText.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, "org.bonitasoft.studio.common.diagram.dialog.name.text"); nameText.setLayoutData( GridDataFactory.fillDefaults().grab(true, false).hint(200, SWT.DEFAULT).indent(10, 0).create()); final ISWTObservableValue observeNameText = SWTObservables.observeText(nameText, SWT.Modify); ControlDecorationSupport.create( dbc.bindValue(observeNameText, PojoProperties.value("name").observe(identifier), nameUpdateStrategy(), null), SWT.LEFT); final Label versionLabel = new Label(res, SWT.NONE); versionLabel.setText(Messages.version); final Text versionText = new Text(res, SWT.BORDER); versionText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(10, 0).create()); final ISWTObservableValue observeVersionText = SWTObservables.observeText(versionText, SWT.Modify); ControlDecorationSupport.create(dbc.bindValue(observeVersionText, PojoProperties.value("version").observe(identifier), versionUpdateStrategy(), null), SWT.LEFT); if (isForceNameUpdate()) { final MustUpdateValidator mustUpdateValidator = new MustUpdateValidator(abstractProcess, observeNameText, observeVersionText); dbc.addValidationStatusProvider(mustUpdateValidator); ControlDecorationSupport.create(mustUpdateValidator, SWT.LEFT); } final MultiValidator multiValidator = unicityValidator(observeNameText, observeVersionText); dbc.addValidationStatusProvider(multiValidator); ControlDecorationSupport.create(multiValidator, SWT.LEFT); }
Example 5
Source File: OpenApplicationPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public Control createControl(Composite parent, IWizardContainer wizardContainer, DataBindingContext ctx) { Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); mainComposite.setLayout(GridLayoutFactory.fillDefaults().create()); TableViewer applicationsTableViewer = new TableViewer(mainComposite); applicationsTableViewer.getControl().setLayoutData( GridDataFactory.fillDefaults().grab(true, true).hint(TABLE_WIDTH_HINT, SWT.DEFAULT).create()); applicationsTableViewer.setContentProvider(ArrayContentProvider.getInstance()); applicationsTableViewer.setLabelProvider(new ApplicationFileStoreLabelProvider()); applicationsTableViewer .setInput(repositoryAccessor.getRepositoryStore(ApplicationRepositoryStore.class).getChildren()); ColumnViewerToolTipSupport.enableFor(applicationsTableViewer); ctx.bindList(ViewersObservables.observeMultiSelection(applicationsTableViewer), applicationFileStoreObservable); ctx.addValidationStatusProvider(new org.eclipse.core.databinding.validation.MultiValidator() { @Override protected IStatus validate() { return applicationFileStoreObservable.isEmpty() ? ValidationStatus.error("No selection") : ValidationStatus.ok(); } }); return mainComposite; }
Example 6
Source File: SelectionPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public Control createControl(Composite parent, IWizardContainer wizardContainer, DataBindingContext ctx) { Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); mainComposite.setLayout(GridLayoutFactory.fillDefaults().create()); tableViewer = createTableViewer(mainComposite); tableViewer.getControl().setLayoutData( GridDataFactory.fillDefaults().grab(true, true).hint(TABLE_WIDTH_HINT, SWT.DEFAULT).create()); tableViewer.setContentProvider(ArrayContentProvider.getInstance()); tableViewer.setLabelProvider(labelProvider); tableViewer.setInput(getInput()); tableViewer.addDoubleClickListener(new WizardDoubleClickListener((WizardDialog) wizardContainer)); ColumnViewerToolTipSupport.enableFor(tableViewer); IObservableList<IRepositoryFileStore> multiSelection = ViewersObservables.observeMultiSelection(tableViewer); ctx.addValidationStatusProvider(new MultiValidator() { @Override protected IStatus validate() { return multiSelection.isEmpty() ? ValidationStatus.error("No selection") : unselectableElements.isPresent() && multiSelection.stream().anyMatch(unselectableElements.get()::contains) ? ValidationStatus.error("Unselectable element selected") : ValidationStatus.ok(); } }); return mainComposite; }
Example 7
Source File: AbstractManageDiagramWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected Composite doCreateControl(final Composite parent, final DataBindingContext context) { final Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayout(fillDefaults().numColumns(2).equalWidth(true).create()); diagramTree = new FilteredTree(mainComposite, SWT.MULTI | SWT.BORDER, new PatternFilter(), false); final TreeViewer treeViewer = diagramTree.getViewer(); treeViewer.getTree().setData(SWTBOT_WIDGET_ID_KEY, SWTBOT_ID_OPEN_DIAGRAM_TREE_ID); diagramTree .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT, 250).create()); treeViewer.setContentProvider( new ObservableListTreeContentProvider(diagramListObservableFactory(), diagramTreeStructure())); treeViewer.setLabelProvider(new DiagramLabelProvider(new FileStoreLabelProvider())); final IObservableList selectionObservable = PojoObservables.observeList(this, "selectedDiagrams"); context.bindList(ViewersObservables.observeMultiSelection(diagramTree.getViewer()), selectionObservable); context.addValidationStatusProvider(new MultiValidator() { @Override protected IStatus validate() { return selectionObservable.isEmpty() ? ValidationStatus.error(Messages.noDiagramSelected) : ValidationStatus.ok(); } }); treeViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(final DoubleClickEvent arg0) { final IWizard wizard = getWizard(); if (wizard.canFinish() && wizard.performFinish() && wizard.getContainer() instanceof WizardDialog) { ((WizardDialog) wizard.getContainer()).close(); } } }); treeViewer.setInput(diagramRepositoryStore); treeViewer.getTree().setFocus(); defaultSelection(selectionObservable); return mainComposite; }
Example 8
Source File: NewTermDbBaseInfoPage.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
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 9
Source File: NewTmDbBaseInfoPage.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
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 10
Source File: NewTermDbBaseInfoPage.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
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 11
Source File: NewTmDbBaseInfoPage.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
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 12
Source File: OpenNameAndVersionForDiagramDialog.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
void createPNVComposite(final Composite parent, final ProcessesNameVersion pnv, final DataBindingContext dbc) { final Composite pnvCompo = new Composite(parent, SWT.NONE); pnvCompo.setLayout(GridLayoutFactory.fillDefaults().equalWidth(false).numColumns(4).create()); pnvCompo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); final Label poolNameLabel = new Label(pnvCompo, SWT.NONE); poolNameLabel.setText(Messages.name); final Text poolNameText = new Text(pnvCompo, SWT.BORDER); poolNameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(200, SWT.DEFAULT).create()); poolNameText.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, "org.bonitasoft.studio.common.diagram.dialog.poolName.text"); final ISWTObservableValue observePoolNameText = SWTObservables.observeText(poolNameText, SWT.Modify); ControlDecorationSupport.create(dbc.bindValue(observePoolNameText, PojoProperties.value("newName").observe(pnv), poolUpdateStrategy(Messages.name), null), SWT.LEFT); final Label poolVersion = new Label(pnvCompo, SWT.NONE); poolVersion.setText(Messages.version); final Text poolVersionText = new Text(pnvCompo, SWT.BORDER); poolVersionText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).create()); final ISWTObservableValue observePoolVersionText = SWTObservables.observeText(poolVersionText, SWT.Modify); ControlDecorationSupport.create(dbc.bindValue(observePoolVersionText, PojoProperties.value("newVersion").observe(pnv), poolUpdateStrategy(Messages.version), null), SWT.LEFT); if (isForceNameUpdate()) { final MustUpdateValidator mustUpdateValidator = new MustUpdateValidator(pnv.getAbstractProcess(), observePoolNameText, observePoolVersionText); dbc.addValidationStatusProvider(mustUpdateValidator); ControlDecorationSupport.create(mustUpdateValidator, SWT.LEFT); } final MultiValidator processesNameVersionUnicityValidator = new ProcessesNameVersionUnicityValidator( pnv.getAbstractProcess(), observePoolNameText, observePoolVersionText, existingProcessIdentifiers(), pools); dbc.addValidationStatusProvider(processesNameVersionUnicityValidator); ControlDecorationSupport.create(processesNameVersionUnicityValidator, SWT.LEFT); }
Example 13
Source File: SelectGroupMappingWizardPage.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public void createControl(Composite parent) { super.createControl(parent) ; final Composite mainComposite = (Composite) getControl(); final Composite viewersComposite = new Composite(mainComposite, SWT.NONE) ; viewersComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT,250).create()) ; viewersComposite.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).margins(0, 0).extendedMargins(0, 0, 10, 0).equalWidth(false).create()) ; availableGroupViewer = CheckboxTableViewer.newCheckList(viewersComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL) ; availableGroupViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true,true).create()) ; availableGroupViewer.getTable().setHeaderVisible(true) ; availableGroupViewer.setContentProvider(new ArrayContentProvider()) ; final TableLayout layout = new TableLayout() ; layout.addColumnData(new ColumnWeightData(100)); availableGroupViewer.getTable().setLayout(layout) ; final TableViewerColumn columnViewer = new TableViewerColumn(availableGroupViewer, SWT.NONE) ; final TableColumn usernameColumn = columnViewer.getColumn() ; usernameColumn.setText(Messages.groupName); columnViewer.setLabelProvider(new ColumnLabelProvider()); final TableColumnSorter sorter = new TableColumnSorter(availableGroupViewer) ; sorter.setColumn(usernameColumn) ; availableGroupViewer.setInput(availableGroups) ; availableGroupViewer.setCheckedElements(selectedGroups.toArray()); context = new DataBindingContext(); final IObservableSet checkedElementsObservable = ViewersObservables.observeCheckedElements(availableGroupViewer, String.class) ; final MultiValidator notEmptyValidator = new MultiValidator() { @Override protected IStatus validate() { if(groupSelectionIsValid(checkedElementsObservable)){ return ValidationStatus.ok(); } return ValidationStatus.error(Messages.errorSelectionGroups); } } ; context.addValidationStatusProvider(notEmptyValidator); context.bindSet(checkedElementsObservable, PojoObservables.observeSet(this, "selectedGroups")); WizardPageSupport.create(this, context); setControl(mainComposite); }