Java Code Examples for org.eclipse.core.databinding.UpdateValueStrategy#setBeforeSetValidator()
The following examples show how to use
org.eclipse.core.databinding.UpdateValueStrategy#setBeforeSetValidator() .
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: VersionGridPropertySectionContribution.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void createControl(Composite composite, TabbedPropertySheetWidgetFactory widgetFactory, ExtensibleGridPropertySection page) { context = new EMFDataBindingContext(); UpdateValueStrategy versionUpdate = new UpdateValueStrategy(); versionUpdate.setAfterGetValidator(new EmptyInputValidator(Messages.GeneralSection_Version)); versionUpdate.setBeforeSetValidator(new UTF8InputValidator(Messages.GeneralSection_Version)); Text text = new Text(composite, GTKStyleHandler.removeBorderFlag(SWT.BORDER)); text.setLayoutData(GridDataFactory.swtDefaults().hint(160, SWT.DEFAULT).grab(false, false).create()); if (!GTKStyleHandler.isGTK3()) { widgetFactory.adapt(text, true, true); } text.setEnabled(false); context.bindValue(WidgetProperties.text(SWT.Modify).observe(text), EMFEditObservables.observeValue(editingDomain, process, ProcessPackage.Literals.ABSTRACT_PROCESS__VERSION), versionUpdate, null); }
Example 2
Source File: DefaultValueEditingSupport.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected Binding createBinding(IObservableValue target,final IObservableValue model) { UpdateValueStrategy targetToModel = new UpdateValueStrategy() ; targetToModel.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object input) { if(input != null && !input.toString().isEmpty()){ Input observed = (Input) ((EObjectObservableValue)model).getObserved(); if(!defaultValueTypes.contains(observed.getType())){ return ValidationStatus.error(Messages.bind(Messages.cantSetDefaultValueForType,observed.getType())) ; } } return Status.OK_STATUS; } }) ; return context.bindValue(target, model,targetToModel, null); }
Example 3
Source File: ParametersWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void createName(final Composite parent) { final Label nameLabel = new Label(parent, SWT.NONE); nameLabel.setText(Messages.name); nameLabel.setLayoutData(GridDataFactory.fillDefaults() .align(SWT.END, SWT.CENTER).create()); nameText = new Text(parent, SWT.BORDER); nameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false) .create()); final UpdateValueStrategy nameStrategy = new UpdateValueStrategy(); nameStrategy.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(final Object value) { final String errorMessage = isNameValid((String) value); if (errorMessage != null) { return ValidationStatus.error(errorMessage); } return Status.OK_STATUS; } }); dataBindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(nameText), EMFObservables.observeValue(parameterWorkingCopy, ParameterPackage.Literals.PARAMETER__NAME), nameStrategy, null); }
Example 4
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 5
Source File: SelectPageWidgetDialog.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void bindComponentId(final Text idText) { UpdateValueStrategy idStrategy = new UpdateValueStrategy(); idStrategy.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object value) { if (value == null || value.toString().isEmpty()) { return ValidationStatus.error(Messages.idIsEmpty); } if (value.toString().contains(" ")) { return ValidationStatus.error(Messages.noWhiteSpaceInPageID); } if (!FileUtil.isValidName(value.toString())) { return ValidationStatus.error(Messages.idIsInvalid); } if (existingWidgetIds.contains(value.toString().toLowerCase())) { return ValidationStatus.error(Messages.idAlreadyExists); } return Status.OK_STATUS; } }); Iterator it = context.getBindings().iterator(); Binding toRemove = null; while (it.hasNext()) { Binding object = (Binding) it.next(); if (object.getTarget().equals(idTextObservable)) { toRemove = object; } } context.removeBinding(toRemove); ControlDecorationSupport.create(context.bindValue(idTextObservable, EMFObservables.observeValue(component, ConnectorDefinitionPackage.Literals.COMPONENT__ID), idStrategy, null), SWT.LEFT); }
Example 6
Source File: InputNameEditingSupport.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected Binding createBinding(IObservableValue target, final IObservableValue model) { UpdateValueStrategy targetToModel = new UpdateValueStrategy(); targetToModel.setConverter(new Converter(String.class, String.class) { @Override public Object convert(Object from) { return from != null ? NamingUtils.toJavaIdentifier(from.toString(), false) : null; } }); targetToModel.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object input) { if (input == null || input.toString().isEmpty()) { return ValidationStatus.error(Messages.nameIsEmpty); } for (Input i : definition.getInput()) { EObject observed = (EObject) ((EObjectObservableValue) model).getObserved(); if (!i.equals(observed) && i.getName() != null && i.getName().equals(input.toString())) { return ValidationStatus.error(Messages.nameAlreadyExists); } } return Status.OK_STATUS; } }); return context.bindValue(target, model, targetToModel, null); }
Example 7
Source File: OutputNameEditingSupport.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected Binding createBinding(IObservableValue target, final IObservableValue model) { UpdateValueStrategy targetToModel = new UpdateValueStrategy(); targetToModel.setConverter(new Converter(String.class, String.class) { @Override public Object convert(Object from) { return from != null ? NamingUtils.toJavaIdentifier(from.toString(), false) : null; } }); targetToModel.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object input) { if (input == null || input.toString().isEmpty()) { return ValidationStatus.error(Messages.nameIsEmpty); } for (Input i : definition.getInput()) { EObject observed = (EObject) ((EObjectObservableValue) model).getObserved(); if (!i.equals(observed) && i.getName() != null && i.getName().equals(input.toString())) { return ValidationStatus.error(Messages.nameAlreadyExists); } } return Status.OK_STATUS; } }); return context.bindValue(target, model, targetToModel, null); }
Example 8
Source File: CronEditor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void createMinutesTab(TabFolder tablFolder) { final TabItem item = new TabItem(tablFolder, SWT.NONE); item.setText(Messages.minutes); final Composite minuteContent = new Composite(tablFolder, SWT.NONE); minuteContent.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); minuteContent.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).margins(15, 10).create()); final Label everyLabel = new Label(minuteContent, SWT.NONE); everyLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); everyLabel.setText(Messages.every); final Text minuteText = new Text(minuteContent, SWT.BORDER | SWT.SINGLE); minuteText.setLayoutData(GridDataFactory.fillDefaults().hint(70, SWT.DEFAULT).create()); UpdateValueStrategy strategy = new UpdateValueStrategy(); strategy.setAfterGetValidator(dotValidator); strategy.setConverter(StringToNumberConverter.toInteger(true)); strategy.setBeforeSetValidator(new FrequencyValidator()); context.bindValue(SWTObservables.observeText(minuteText, SWT.Modify), PojoProperties.value("minuteFrequencyForMinute").observe(cronExpression), strategy, null); final Label minuteLabel = new Label(minuteContent, SWT.NONE); minuteLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).create()); minuteLabel.setText(Messages.minuteLabel); item.setControl(minuteContent); cronExpression.setMode(item.getText()); }
Example 9
Source File: OutputTypeEditingSupport.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 10
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 11
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 12
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 13
Source File: ExpressionViewer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void bindExpression() { if (expressionBinding != null && externalDataBindingContext != null) { externalDataBindingContext.removeBinding(expressionBinding); expressionBinding.dispose(); } final IObservableValue nameObservable = getExpressionNameObservable(); final IObservableValue typeObservable = getExpressionTypeObservable(); final IObservableValue returnTypeObservable = getExpressionReturnTypeObservable(); final IObservableValue contentObservable = getExpressionContentObservable(); nameObservable.addValueChangeListener(this); typeObservable.addValueChangeListener(this); contentObservable.addValueChangeListener(this); returnTypeObservable.addValueChangeListener(this); final UpdateValueStrategy targetToModelNameStrategy = new UpdateValueStrategy(); if (mandatoryFieldName != null) { targetToModelNameStrategy .setBeforeSetValidator(mandatoryFieldValidator.orElse(new EmptyInputValidator(mandatoryFieldName))); } targetToModelNameStrategy.setConverter(getNameConverter()); final ISWTObservableValue textDelayedObservableValue = SWTObservables.observeDelayedValue(500, SWTObservables.observeText(textControl, SWT.Modify)); expressionBinding = internalDataBindingContext.bindValue(textDelayedObservableValue, nameObservable, targetToModelNameStrategy, updateValueStrategy().create()); bindEditableText(typeObservable); internalDataBindingContext.bindValue(ViewersObservables.observeSingleSelection(contentAssistText), getSelectedExpressionObservable()); if (externalDataBindingContext != null) { externalDataBindingContext.addBinding(expressionBinding); externalDataBindingContext.addValidationStatusProvider(expressionViewerValidator); } }
Example 14
Source File: ImportConfigurationWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void createControl(Composite parent) { Composite mainComposite = new Composite(parent, SWT.NONE) ; mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ; mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(20,20).create()) ; databindingContext = new DataBindingContext() ; final TableViewer viewer = new TableViewer(mainComposite, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE ) ; viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ; viewer.setContentProvider(new ArrayContentProvider()) ; viewer.setLabelProvider(new ActionLabelProvider()) ; viewer.setInput(getConfigurationImporterContributions()) ; UpdateValueStrategy startegy = new UpdateValueStrategy() ; startegy.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object value) { if(value instanceof IAction){ return Status.OK_STATUS ; } return ValidationStatus.error(Messages.mustSelectExportError); } }) ; WizardPageSupport.create(this,databindingContext) ; databindingContext.bindValue(ViewersObservables.observeSingleSelection(viewer), PojoObservables.observeValue(this, "action"),startegy,null) ; setControl(mainComposite) ; }
Example 15
Source File: ExportConfigurationWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void createControl(Composite parent) { Composite mainComposite = new Composite(parent, SWT.NONE) ; mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ; mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(20,20).create()) ; databindingContext = new DataBindingContext() ; final TableViewer viewer = new TableViewer(mainComposite, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE ) ; viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ; viewer.setContentProvider(new ArrayContentProvider()) ; viewer.setLabelProvider(new ActionLabelProvider()) ; viewer.setInput(getConfigurationExporterContributions()) ; UpdateValueStrategy startegy = new UpdateValueStrategy() ; startegy.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object value) { if(value instanceof IAction){ return Status.OK_STATUS ; } return ValidationStatus.error(Messages.mustSelectExportError); } }) ; WizardPageSupport.create(this,databindingContext) ; databindingContext.bindValue(ViewersObservables.observeSingleSelection(viewer), PojoObservables.observeValue(this, "action"),startegy,null) ; setControl(mainComposite) ; }
Example 16
Source File: AddMessageEventWizardPage.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
private Text createNameLine(final Composite composite) { final Label nameLabel = new Label(composite, SWT.NONE); nameLabel.setLayoutData(GridDataFactory.fillDefaults() .align(SWT.END, SWT.CENTER).create()); nameLabel.setText(Messages.dataNameLabel); nameText = new Text(composite, SWT.BORDER); nameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false) .create()); final IValidator nameValidator = new IValidator() { @Override public IStatus validate(final Object arg0) { if (arg0 instanceof String) { final String s = (String) arg0; if (s == null || s.isEmpty()) { return ValidationStatus.error(Messages.emptyName); } else { final List<Message> events = ModelHelper.getAllItemsOfType( ModelHelper.getMainProcess(element), ProcessPackage.eINSTANCE.getMessage()); for (final Message ev : events) { if (!ev.equals(originalMessage) && ev.getName().equals(s)) { return ValidationStatus .error(Messages.messageEventAddWizardNameAlreadyExists); } } } } return ValidationStatus.ok(); } }; final UpdateValueStrategy uvs = new UpdateValueStrategy(/* * UpdateValueStrategy. * POLICY_CONVERT */); uvs.setBeforeSetValidator(nameValidator); databindingContext.bindValue(SWTObservables.observeDelayedValue(200, SWTObservables.observeText(nameText, SWT.Modify)), EMFObservables.observeValue(workingCopyMessage, ProcessPackage.Literals.ELEMENT__NAME), uvs, null); return nameText; }
Example 17
Source File: SelectProcessWizardPage.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public void createControl(Composite parent) { Composite mainComposite = new Composite(parent, SWT.NONE) ; mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ; mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create()) ; databindingContext = new DataBindingContext() ; final FilteredTree tree = new FilteredTree(mainComposite, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE,new PatternFilter(), false) ; tree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ; TreeViewer viewer = tree.getViewer() ; viewer.setContentProvider(new ProcessContentProvider()) ; viewer.setLabelProvider(new ProcessTreeLabelProvider()) ; UpdateValueStrategy startegy = new UpdateValueStrategy() ; startegy.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object value) { if(value instanceof AbstractProcess && !(value instanceof MainProcess)){ return Status.OK_STATUS ; } return ValidationStatus.error(Messages.mustSelectProcessError); } }) ; if(diagram == null){ viewer.setInput(new Object[]{ProcessContentProvider.OTHER_PROCESSES}) ; }else{ viewer.setInput(new Object[]{diagram,ProcessContentProvider.OTHER_PROCESSES}) ; } if(diagram != null){ if(((ITreeContentProvider) viewer.getContentProvider()).hasChildren(diagram)){ viewer.expandToLevel(diagram, 1) ; } }else{ if(((ITreeContentProvider) viewer.getContentProvider()).hasChildren(ProcessContentProvider.OTHER_PROCESSES)){ viewer.expandToLevel(ProcessContentProvider.OTHER_PROCESSES, 1) ; } } WizardPageSupport.create(this,databindingContext) ; databindingContext.bindValue(ViewersObservables.observeSingleSelection(viewer), PojoObservables.observeValue(this, "selection"),startegy,null) ; setControl(mainComposite) ; }
Example 18
Source File: ExportRepositoryWizardPage.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
protected void createDestination(final Composite group) { final Label destPath = new Label(group, SWT.NONE); destPath.setText(Messages.destinationPath + " *"); destPath.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); // destination name entry field destinationCombo = new Combo(group, SWT.SINGLE | SWT.BORDER); destinationCombo .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).create()); restoreWidgetValues(); final UpdateValueStrategy pathStrategy = new UpdateValueStrategy(); pathStrategy.setAfterGetValidator(new EmptyInputValidator(Messages.destinationPath)); pathStrategy.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(final Object input) { if (!isZip) { if (!new File(input.toString()).isDirectory()) { return ValidationStatus.error(Messages.destinationPathMustBeADirectory); } } else { if (!input.toString().endsWith(".bos")) { return ValidationStatus.error(Messages.invalidFileFormat); } if (new File(input.toString()).isDirectory()) { return ValidationStatus.error(Messages.invalidFileFormat); } } return ValidationStatus.ok(); } }); dbc.bindValue(SWTObservables.observeText(destinationCombo), PojoProperties.value(ExportRepositoryWizardPage.class, "detinationPath").observe(this), pathStrategy, null); // destination browse button destinationBrowseButton = new Button(group, SWT.PUSH); destinationBrowseButton.setText(Messages.browse); destinationBrowseButton.setLayoutData(GridDataFactory.fillDefaults().hint(85, SWT.DEFAULT).create()); destinationBrowseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { handleDestinationBrowseButtonPressed(); } }); }
Example 19
Source File: CronEditor.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
protected void createDailyTab(TabFolder tablFolder) { final TabItem item = new TabItem(tablFolder, SWT.NONE); item.setText(Messages.daily); final Composite dailyContent = new Composite(tablFolder, SWT.NONE); dailyContent.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); dailyContent.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 10).create()); final Button everyRadio = new Button(dailyContent, SWT.RADIO); everyRadio.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).create()); everyRadio.setText(Messages.every); context.bindValue(SWTObservables.observeSelection(everyRadio), PojoProperties.value("useEveryDayForDaily").observe(cronExpression)); final Composite everyComposite = new Composite(dailyContent, SWT.NONE); everyComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(-65, 0).create()); everyComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).create()); final Text dayText = new Text(everyComposite, SWT.BORDER | SWT.SINGLE); dayText.setLayoutData(GridDataFactory.fillDefaults().hint(70, SWT.DEFAULT).create()); UpdateValueStrategy dayFrequencyStrategy = new UpdateValueStrategy(); dayFrequencyStrategy.setAfterGetValidator(dotValidator); dayFrequencyStrategy.setConverter(StringToNumberConverter.toInteger(true)); dayFrequencyStrategy.setBeforeSetValidator(new FrequencyValidator()); context.bindValue(SWTObservables.observeText(dayText, SWT.Modify), PojoProperties.value("dayFrequencyForDaily").observe(cronExpression), dayFrequencyStrategy, null); final Label dayLabel = new Label(everyComposite, SWT.NONE); dayLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).create()); dayLabel.setText(Messages.dayLabel); final Button everyWeekDayRadio = new Button(dailyContent, SWT.RADIO); everyWeekDayRadio.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).create()); everyWeekDayRadio.setText(Messages.everyWeekDay); final Label filler = new Label(dailyContent, SWT.NONE); filler.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); final IObservableValue hourObservable = PojoProperties.value("atHourInDay").observe(cronExpression); final IObservableValue minuteObservable = PojoProperties.value("atMinuteInDay").observe(cronExpression); final IObservableValue secondObservable = PojoProperties.value("atSecondInDay").observe(cronExpression); createStartTimeComposite(dailyContent, hourObservable, minuteObservable, secondObservable); item.setControl(dailyContent); }
Example 20
Source File: PageWidgetsWizardPage.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public void createControl(Composite parent) { context = new EMFDataBindingContext() ; final Composite mainComposite = new Composite(parent, SWT.NONE) ; mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ; mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).create()) ; final Label pageIdLabel = new Label(mainComposite, SWT.NONE); pageIdLabel.setText(Messages.pageId+" *"); pageIdLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()) ; final Text idText = new Text(mainComposite, SWT.BORDER); idText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); UpdateValueStrategy idStrategy = new UpdateValueStrategy() ; idStrategy.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object value) { if(value == null || value.toString().isEmpty()){ return ValidationStatus.error(Messages.idIsEmpty) ; }else if(value.toString().contains(" ")){ return ValidationStatus.error(Messages.noWhiteSpaceInPageID) ; }else if(!FileUtil.isValidName(value.toString())){ return ValidationStatus.error(Messages.idIsInvalid) ; } for(Page p : definition.getPage()){ if(!p.equals(originalPage) && p.getId().equals(value.toString())){ return ValidationStatus.error(Messages.idAlreadyExists) ; } } return Status.OK_STATUS; } }) ; context.bindValue(SWTObservables.observeText(idText, SWT.Modify), EMFObservables.observeValue(page, ConnectorDefinitionPackage.Literals.PAGE__ID),idStrategy,null) ; final Label displayNameLabel = new Label(mainComposite, SWT.NONE); displayNameLabel.setText(Messages.displayName); displayNameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()) ; final Text displayNameText = new Text(mainComposite, SWT.BORDER); displayNameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); IObservableValue displayNameObs = PojoProperties.value(PageWidgetsWizardPage.class, "displayName").observe(this) ; context.bindValue(SWTObservables.observeText(displayNameText, SWT.Modify),displayNameObs) ; final Label descriptionLabel = new Label(mainComposite, SWT.NONE); descriptionLabel.setText(Messages.pageDescLabel); descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create()) ; final Text descriptionText = new Text(mainComposite, SWT.BORDER | SWT.MULTI | SWT.WRAP); descriptionText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT,60).create()); IObservableValue descObs = PojoProperties.value(PageWidgetsWizardPage.class, "pageDescription").observe(this) ; context.bindValue(SWTObservables.observeText(descriptionText, SWT.Modify),descObs) ; final Label inputsLabel = new Label(mainComposite, SWT.NONE); inputsLabel.setText(Messages.widgets); inputsLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create()) ; createWidgetViewer(mainComposite) ; updateButtons(new StructuredSelection()) ; pageSupport = WizardPageSupport.create(this, context) ; setControl(mainComposite) ; }