List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeText
@Deprecated public static ISWTObservableValue observeText(Control control, int event)
control
. From source file:org.bonitasoft.studio.businessobject.ui.wizard.BusinessDataModelWizardPage.java
License:Open Source License
protected void createPackageName(final DataBindingContext ctx, final Composite parent) { final Composite packageComposite = new Composite(parent, SWT.NONE); packageComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); packageComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).create()); final Label packageNameLabel = new Label(packageComposite, SWT.NONE); packageNameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).create()); packageNameLabel.setText(Messages.packageName); final Text packageNameText = new Text(packageComposite, SWT.BORDER); packageNameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); final UpdateValueStrategy targetToModel = new UpdateValueStrategy(); targetToModel.setAfterGetValidator(new IValidator() { @Override/*from ww w .j a v a 2s . c o m*/ public IStatus validate(final Object value) { return validatePackageName(value); } }); final IObservableValue packageNameObserveValue = PojoObservables.observeValue(this, "packageName"); final ISWTObservableValue packageNameObserveText = SWTObservables.observeText(packageNameText, SWT.Modify); ctx.bindValue(packageNameObserveText, packageNameObserveValue, targetToModel, null); packageNameObserveText.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(final ValueChangeEvent event) { String newPackageName = (String) event.diff.getNewValue(); if (newPackageName.isEmpty()) { newPackageName = DEFAULT_PACKAGE_NAME; } if (newPackageName.endsWith(".")) { newPackageName.substring(0, newPackageName.length() - 1); } for (final BusinessObject bo : businessObjectModel.getBusinessObjects()) { final String previousName = bo.getQualifiedName(); final String qualifiedName = newPackageName + "." + NamingUtils.getSimpleName(bo.getQualifiedName()); bo.setQualifiedName(qualifiedName); for (final Query q : bo.getQueries()) { if (previousName.equals(q.getReturnType())) { q.setReturnType(qualifiedName); } } } } }); if (businessObjectModel.getBusinessObjects().isEmpty()) { packageNameObserveText.setValue(DEFAULT_PACKAGE_NAME); } else { packageNameObserveText.setValue( NamingUtils.getPackageName(businessObjectModel.getBusinessObjects().get(0).getQualifiedName())); } }
From source file:org.bonitasoft.studio.businessobject.ui.wizard.BusinessObjectDataWizardPage.java
License:Open Source License
protected Text createDescriptionControl(final Composite mainComposite, final EMFDataBindingContext ctx) { final Label descriptionLabel = new Label(mainComposite, SWT.NONE); descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create()); descriptionLabel.setText(Messages.description); final Text descriptionText = new Text(mainComposite, SWT.BORDER | SWT.MULTI | SWT.WRAP); descriptionText//w w w. j a va 2 s . co m .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 70).create()); ctx.bindValue(SWTObservables.observeText(descriptionText, SWT.Modify), EMFObservables.observeValue(businessObjectData, ProcessPackage.Literals.ELEMENT__DOCUMENTATION), updateValueStrategy().withValidator(maxLengthValidator(Messages.description, 255)).create(), null); return descriptionText; }
From source file:org.bonitasoft.studio.businessobject.ui.wizard.BusinessObjectDataWizardPage.java
License:Open Source License
protected Text createNameControl(final Composite mainComposite, final EMFDataBindingContext ctx) { final Label nameLabel = new Label(mainComposite, SWT.NONE); nameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); nameLabel.setText(Messages.name + " *"); final Text nameText = new Text(mainComposite, SWT.BORDER); nameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); ctx.bindValue(SWTObservables.observeText(nameText, SWT.Modify), EMFObservables.observeValue(businessObjectData, ProcessPackage.Literals.ELEMENT__NAME), updateValueStrategy()/*from ww w . j a v a 2s.c o m*/ .withValidator(multiValidator().addValidator(maxLengthValidator(Messages.name, 50)) .addValidator(groovyReferenceValidator(Messages.name).startsWithLowerCase()) .addValidator(uniqueDataNameValidator()).create()) .create(), null); return nameText; }
From source file:org.bonitasoft.studio.businessobject.ui.wizard.ExportBusinessDataModelWizardPage.java
License:Open Source License
protected void createDestinationTextAndLabel(Composite mainComposite, DataBindingContext context) { final Composite composite = new Composite(mainComposite, SWT.NONE); composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).margins(0, 0).create()); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); final Label destinationLabel = new Label(composite, SWT.NONE); destinationLabel.setText(Messages.destinationPath + " *"); destinationLabel.setLayoutData(/* w ww . j a v a 2s . c o m*/ GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).grab(false, false).create()); final Text destinationText = new Text(composite, SWT.BORDER); destinationText.setLayoutData( GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create()); UpdateValueStrategy targetToModelStrategy = new UpdateValueStrategy(); targetToModelStrategy.setAfterGetValidator(new EmptyInputValidator(Messages.destinationPath)); targetToModelStrategy.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object value) { return validateFilePath(value); } }); context.bindValue(SWTObservables.observeText(destinationText, SWT.Modify), PojoObservables.observeValue(this, "destinationPath"), targetToModelStrategy, null); final Button browseButton = new Button(composite, SWT.PUSH); browseButton.setText(Messages.browse); browseButton.setLayoutData( GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).create()); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DirectoryDialog directoryDialog = new DirectoryDialog(Display.getDefault().getActiveShell(), SWT.SAVE); String path = directoryDialog.open(); if (path != null) { destinationText.setText(path); } } }); }
From source file:org.bonitasoft.studio.businessobject.ui.wizard.QueryWizardPage.java
License:Open Source License
@Override public void createControl(final Composite parent) { final DataBindingContext ctx = new DataBindingContext(); final Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(10, 10).create()); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); final Link queryLabel = new Link(composite, SWT.NO_FOCUS); queryLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).create()); queryLabel.setText(Messages.queryLink); queryLabel.addSelectionListener(new SelectionAdapter() { @Override/*from www.j a v a 2 s .c om*/ public void widgetSelected(final SelectionEvent e) { performHelp(); } }); final StyledText queryText = createQueryText(composite); queryText.setFont(getMonospaceFont()); queryText.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 120).create()); if (query.getContent() == null || query.getContent().isEmpty()) { final String queryExample = createQueryExample(businessObject); query.setContent(queryExample); if (query.getQueryParameters().isEmpty()) { for (final Field f : businessObject.getFields()) { if (f instanceof SimpleField) { query.addQueryParameter(f.getName(), ((SimpleField) f).getType().getClazz().getName()); } } } } final UpdateValueStrategy targetStrategy = new UpdateValueStrategy(); targetStrategy.setAfterGetValidator(new IValidator() { @Override public IStatus validate(final Object value) { if (value == null || value.toString().trim().isEmpty()) { return ValidationStatus.error(Messages.emptyQueryError); } return checkParametersUsage(value.toString()); } }); final UpdateValueStrategy strategy = new UpdateValueStrategy(); strategy.setAfterGetValidator(new IValidator() { @Override public IStatus validate(final Object value) { return checkParametersUsage(value.toString()); } }); queryBinding = ctx.bindValue(SWTObservables.observeText(queryText, SWT.Modify), PojoObservables.observeValue(getQuery(), "content"), targetStrategy, strategy); final Label queryParamLabel = new Label(composite, SWT.NONE); queryParamLabel .setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.FILL).indent(0, 10).create()); queryParamLabel.setText(Messages.parameters); final ControlDecoration controlDecoration = new ControlDecoration(queryParamLabel, SWT.RIGHT); controlDecoration.setImage(Pics.getImage(PicsConstants.hint)); controlDecoration.setDescriptionText(Messages.jpqlParametersHint); controlDecoration.setShowOnlyOnFocus(false); createQueryParametersTable(composite, ctx); final Label queryResultTypeLabel = new Label(composite, SWT.NONE); queryResultTypeLabel .setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).indent(0, 5).create()); queryResultTypeLabel.setText(Messages.queryResultType); final ComboViewer resultTypeViewer = createReturnTypeComboViewer(composite); resultTypeViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); resultTypeViewer.setContentProvider(ArrayContentProvider.getInstance()); resultTypeViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { final String className = element.toString(); if (List.class.getName().equals(className)) { return Messages.multipleReturnType; } else if (Long.class.getName().equals(className)) { return className + " (COUNT,SUM...etc)"; } else if (Double.class.getName().equals(className)) { return className + " (AVG...etc)"; } else if (businessObject.getQualifiedName().equals(className)) { return Messages.bind(Messages.single, businessObject.getQualifiedName()); } return super.getText(element); } }); resultTypeViewer.setInput(getSupportedReturnTypes(businessObject)); final IViewerObservableValue returnTypeSelectionObservable = ViewersObservables .observeSingleSelection(resultTypeViewer); ctx.bindValue(returnTypeSelectionObservable, PojoObservables.observeValue(getQuery(), "returnType")); returnTypeSelectionObservable.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(final ValueChangeEvent event) { queryBinding.validateTargetToModel(); } }); WizardPageSupport.create(this, ctx); setControl(composite); }
From source file:org.bonitasoft.studio.common.diagram.dialog.OpenNameAndVersionDialog.java
License:Open Source License
protected void createNameAndVersion(final Composite res, final DataBindingContext dbc) { final Label nameLabel = new Label(res, SWT.NONE); nameLabel.setText(Messages.name);//from w ww . j a v a 2s . c o m nameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); final Text nameText = new Text(res, SWT.BORDER); 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); }
From source file:org.bonitasoft.studio.common.diagram.dialog.OpenNameAndVersionForDiagramDialog.java
License:Open Source License
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//from w w w. j a v a2s.c om .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(200, SWT.DEFAULT).create()); 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); }
From source file:org.bonitasoft.studio.common.jface.OpenNameDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite res = new Composite(parent, SWT.FILL); res.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); res.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).spacing(0, 20).create()); if (message != null) { Label messageLabel = new Label(res, SWT.WRAP); messageLabel.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, true).create()); messageLabel.setText(message);//from w w w .j a v a 2s. c o m } Label nameLabel = new Label(res, SWT.NONE); nameLabel.setText(Messages.name); final Text nameText = new Text(res, SWT.BORDER); nameText.setText(srcName); nameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(10, 0).create()); if (observable != null) { binding = context.bindValue( SWTObservables.observeDelayedValue(400, SWTObservables.observeText(nameText, SWT.Modify)), observable, targetToModel, modelToTarget); ControlDecorationSupport.create(binding, SWT.LEFT); } nameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { newName = nameText.getText(); updateOkButton(); } }); return res; }
From source file:org.bonitasoft.studio.common.OpenNameAndVersionDialog.java
License:Open Source License
protected void createDiagramNameAndVersion(Composite res, final DataBindingContext dbc) { final Label nameLabel = new Label(res, SWT.NONE); nameLabel.setText(Messages.name);// w w w.jav a 2 s . c o m nameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); final Text nameText = new Text(res, SWT.BORDER); nameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(200, SWT.DEFAULT).create()); 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).create()); final ISWTObservableValue observeNameText = SWTObservables.observeText(nameText, SWT.Modify); final ISWTObservableValue observeVersionText = SWTObservables.observeText(versionText, SWT.Modify); final MultiValidator caseValidator = new MultiValidator() { @Override protected IStatus validate() { final String name = observeNameText.getValue().toString(); final String version = observeVersionText.getValue().toString(); return validateModification(name, version); } }; dbc.addValidationStatusProvider(caseValidator); ControlDecorationSupport.create(caseValidator, SWT.LEFT); final UpdateValueStrategy targetToModel = new UpdateValueStrategy(); final EmptyInputValidator emptyValidator = new EmptyInputValidator(Messages.name); final InputLengthValidator lenghtValidator = new InputLengthValidator(Messages.name, 50); final SpecialCharactersValidator specialCharValidator = new SpecialCharactersValidator(); targetToModel.setAfterGetValidator(new IValidator() { public IStatus validate(Object value) { IStatus status = emptyValidator.validate(value); if (status.isOK()) { status = lenghtValidator.validate(value); if (status.isOK()) { status = specialCharValidator.validate(value); } } return status; } }); targetToModel.setBeforeSetValidator(new UTF8InputValidator(Messages.name)); ControlDecorationSupport.create(dbc.bindValue(observeNameText, PojoProperties.value("diagramName").observe(this), targetToModel, null), SWT.LEFT); final UpdateValueStrategy versionTargetToModel = new UpdateValueStrategy(); final EmptyInputValidator verisonEmptyValidator = new EmptyInputValidator(Messages.version); final InputLengthValidator versionLenghtValidator = new InputLengthValidator(Messages.version, 50); versionTargetToModel.setAfterGetValidator(new IValidator() { public IStatus validate(Object value) { IStatus status = verisonEmptyValidator.validate(value); if (status.isOK()) { status = versionLenghtValidator.validate(value); } return status; } }); versionTargetToModel.setBeforeSetValidator(new UTF8InputValidator(Messages.version)); ControlDecorationSupport.create(dbc.bindValue(observeVersionText, PojoProperties.value("diagramVersion").observe(this), versionTargetToModel, null), SWT.LEFT); }
From source file:org.bonitasoft.studio.common.OpenNameAndVersionForDiagramDialog.java
License:Open Source License
void createPNVComposite(Composite parent, final ProcessesNameVersion pnv, 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 poolLabel = new Label(pnvCompo, SWT.NONE); poolLabel.setText(Messages.name);//from w w w. j a v a2 s . c o m final Text nameText = new Text(pnvCompo, SWT.BORDER); nameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(200, SWT.DEFAULT).create()); UpdateValueStrategy nameTargetToModel = new UpdateValueStrategy(); final EmptyInputValidator emptyValidator = new EmptyInputValidator(Messages.name); final InputLengthValidator lenghtValidator = new InputLengthValidator(Messages.name, 50); nameTargetToModel.setAfterGetValidator(new IValidator() { public IStatus validate(Object value) { IStatus status = emptyValidator.validate(value); if (status.isOK()) { status = lenghtValidator.validate(value); } return status; } }); nameTargetToModel.setBeforeSetValidator(new UTF8InputValidator(Messages.name)); ControlDecorationSupport.create(dbc.bindValue(SWTObservables.observeText(nameText, SWT.Modify), PojoProperties.value("newName").observe(pnv), nameTargetToModel, null), SWT.LEFT); final Label poolVersion = new Label(pnvCompo, SWT.NONE); poolVersion.setText(Messages.version); final Text versionText = new Text(pnvCompo, SWT.BORDER); versionText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).create()); UpdateValueStrategy versionTargetToModel = new UpdateValueStrategy(); final EmptyInputValidator verisonEmptyValidator = new EmptyInputValidator(Messages.version); final InputLengthValidator versionLenghtValidator = new InputLengthValidator(Messages.version, 50); versionTargetToModel.setAfterGetValidator(new IValidator() { public IStatus validate(Object value) { IStatus status = verisonEmptyValidator.validate(value); if (status.isOK()) { status = versionLenghtValidator.validate(value); } return status; } }); versionTargetToModel.setBeforeSetValidator(new UTF8InputValidator(Messages.version)); ControlDecorationSupport.create(dbc.bindValue(SWTObservables.observeText(versionText, SWT.Modify), PojoProperties.value("newVersion").observe(pnv), versionTargetToModel, null), SWT.LEFT); final ISWTObservableValue observeNameText = SWTObservables.observeText(nameText, SWT.Modify); final ISWTObservableValue observeVersionText = SWTObservables.observeText(versionText, SWT.Modify); final MultiValidator caseValidator = new MultiValidator() { @Override protected IStatus validate() { final String name = observeNameText.getValue().toString(); final String version = observeVersionText.getValue().toString(); int countNewProcessWithSameName = 0; for (ProcessesNameVersion pool : pools) { if (name.equals(pool.newName) && version.equals(pool.newVersion)) { countNewProcessWithSameName++; } } if (countNewProcessWithSameName > 1) { return ValidationStatus.error(Messages.bind(Messages.differentCaseSameNameError, typeLabel)); } int countOldProcessWithSameName = 0; for (ProcessesNameVersion pool : pools) { if (name.equals(pool.getAbstractProcess().getName()) && version.equals(pool.getAbstractProcess().getVersion())) { countOldProcessWithSameName++; } } if (countOldProcessWithSameName == 1) { if (diagramNameOrVersionChangeMandatory) { return ValidationStatus .error(Messages.bind(Messages.differentCaseSameNameError, typeLabel)); } else { return ValidationStatus.ok(); } } for (AbstractProcess process : processes) { if (name.equals(process.getName()) && version.equals(process.getVersion())) { return ValidationStatus .error(Messages.bind(Messages.differentCaseSameNameError, typeLabel)); } } return ValidationStatus.ok(); } }; dbc.addValidationStatusProvider(caseValidator); ControlDecorationSupport.create(caseValidator, SWT.LEFT); }