List of usage examples for org.eclipse.jface.databinding.swt WidgetProperties selection
public static IWidgetValueProperty selection()
From source file:com.amitinside.e4.rcp.todo.parts.EditorPart.java
License:Apache License
private void updateUserInterface(Todo todo) { // check if the user interface is available // assume you have a field called "summary" // for a widget if (txtSummary != null && !txtSummary.isDisposed()) { // Deregister change listener to the old binding IObservableList providers = ctx.getValidationStatusProviders(); for (Object o : providers) { Binding b = (Binding) o; b.getTarget().removeChangeListener(listener); }//from www . j a v a2 s. c om // Remove bindings ctx.dispose(); IObservableValue target = WidgetProperties.text(SWT.Modify).observe(txtSummary); IObservableValue model = BeanProperties.value(Todo.FIELD_SUMMARY).observe(todo); ctx.bindValue(target, model); target = WidgetProperties.selection().observe(btnDone); model = BeanProperties.value(Todo.FIELD_DONE).observe(todo); ctx.bindValue(target, model); target = WidgetProperties.selection().observe(btnDone); model = BeanProperties.value(Todo.FIELD_DONE).observe(todo); ctx.bindValue(target, model); IObservableValue observeSelectionDateTimeObserveWidget = WidgetProperties.selection().observe(dateTime); IObservableValue dueDateTodoObserveValue = BeanProperties.value(Todo.FIELD_DUEDATE).observe(todo); ctx.bindValue(observeSelectionDateTimeObserveWidget, dueDateTodoObserveValue); // register listener for any changes providers = ctx.getValidationStatusProviders(); for (Object o : providers) { Binding b = (Binding) o; b.getTarget().addChangeListener(listener); } // Register for the changes providers = ctx.getValidationStatusProviders(); for (Object o : providers) { Binding b = (Binding) o; b.getTarget().addChangeListener(listener); } } }
From source file:com.amitinside.e4.rcp.todo.parts.EMFTodoDetailsPart.java
License:Apache License
private void updateUserInterface(Todo todo) { if (todo == null) { enableUserInterface(false);/*from w w w . j a v a2s . co m*/ return; } else { enableUserInterface(true); } if (txtSummary != null && !txtSummary.isDisposed()) { IObservableList providers = ctx.getValidationStatusProviders(); for (final Object o : providers) { final Binding b = (Binding) o; b.getTarget().removeChangeListener(listener); } ctx.dispose(); IObservableValue target = WidgetProperties.text(SWT.Modify).observe(txtSummary); IObservableValue model = EMFProperties.value(TodoPackage.Literals.TODO__SUMMARY).observe(todo); ctx.bindValue(target, model); target = WidgetProperties.selection().observe(btnDone); model = EMFProperties.value(TodoPackage.Literals.TODO__DONE).observe(todo); ctx.bindValue(target, model); target = WidgetProperties.text(SWT.Modify).observe(txtNote); model = EMFProperties.value(TodoPackage.Literals.TODO__NOTE).observe(todo); final IConverter converter = new IConverter() { @Override public Object getToType() { return null; } @Override public Object getFromType() { return null; } @Override public Object convert(Object elem) { System.out.println(">>>>>" + elem); return elem.toString().charAt(0); } }; final IValidator validator = new IValidator() { @Override public IStatus validate(Object value) { if (value instanceof String) { if (((String) value).matches(messages.TodoDetailsPart_5)) { flagBeforeSave = true; return ValidationStatus.OK_STATUS; } else flagBeforeSave = false; } return ValidationStatus.error(messages.TodoDetailsPart_6); } }; final UpdateValueStrategy strategy = new UpdateValueStrategy(); strategy.setBeforeSetValidator(validator); strategy.setConverter(converter); final Binding bindvalue = ctx.bindValue(target, model, strategy, null); ControlDecorationSupport.create(bindvalue, SWT.TOP | SWT.LEFT); final IObservableValue observeSelectionDateTimeObserveWidget = WidgetProperties.selection() .observe(dateTime); final IObservableValue dueDateTodoObserveValue = EMFProperties .value(TodoPackage.Literals.TODO__DUE_DATE).observe(todo); ctx.bindValue(observeSelectionDateTimeObserveWidget, dueDateTodoObserveValue); providers = ctx.getValidationStatusProviders(); for (final Object o : providers) { final Binding b = (Binding) o; b.getTarget().addChangeListener(listener); } } }
From source file:com.amitinside.e4.rcp.todo.parts.PlaygroundPart.java
License:Apache License
/** * /*from w w w . j a va 2 s .c om*/ * @param parent */ @PostConstruct public void createControls(Composite parent) { DataBindingContext ctx = new DataBindingContext(); text1 = new Text(parent, SWT.LEAD | SWT.BORDER | SWT.MULTI); text1.setText("Hallo"); text2 = new Text(parent, SWT.LEAD | SWT.BORDER | SWT.MULTI); text2.setText("Moin"); ISWTObservableValue model = WidgetProperties.text(SWT.Modify).observe(text1); ISWTObservableValue target = WidgetProperties.text(SWT.Modify).observeDelayed(2000, text2); Button button = new Button(parent, SWT.CHECK); button.setText("Hello"); // button.addSelectionListener(new SelectionAdapter() { // @Override // public void widgetSelected(SelectionEvent e) { // // } // }); ISWTObservableValue model1 = WidgetProperties.selection().observe(button); ISWTObservableValue target1 = WidgetProperties.enabled().observe(text1); ctx.bindValue(target1, model1); // This assumes you have a vogella.png file // in folder images }
From source file:com.amitinside.e4.rcp.todo.parts.TodoDetailsPart.java
License:Apache License
private void updateUserInterface(Todo todo) { // check if Todo is null if (todo == null) { enableUserInterface(false);/*w w w. j av a 2 s . c o m*/ return; } else { enableUserInterface(true); } // Check if the user interface is available // assume you have a field called "summary" // for a widget if (txtSummary != null && !txtSummary.isDisposed()) { // Deregister change listener to the old binding IObservableList providers = ctx.getValidationStatusProviders(); for (final Object o : providers) { final Binding b = (Binding) o; b.getTarget().removeChangeListener(listener); } // Remove bindings ctx.dispose(); IObservableValue target = WidgetProperties.text(SWT.Modify).observe(txtSummary); IObservableValue model = BeanProperties.value(Todo.FIELD_SUMMARY).observe(todo); ctx.bindValue(target, model); target = WidgetProperties.selection().observe(btnDone); model = BeanProperties.value(Todo.FIELD_DONE).observe(todo); ctx.bindValue(target, model); target = WidgetProperties.selection().observe(btnDone); model = BeanProperties.value(Todo.FIELD_DONE).observe(todo); ctx.bindValue(target, model); target = WidgetProperties.text(SWT.Modify).observe(txtNote); model = BeanProperties.value(Todo.FIELD_NOTE).observe(todo); final IValidator validator = new IValidator() { @Override public IStatus validate(Object value) { if (value instanceof String) { if (((String) value).matches(messages.TodoDetailsPart_5)) { return ValidationStatus.OK_STATUS; } } return ValidationStatus.error(messages.TodoDetailsPart_6); } }; final UpdateValueStrategy strategy = new UpdateValueStrategy(); strategy.setBeforeSetValidator(validator); final Binding bindvalue = ctx.bindValue(target, model, strategy, null); ControlDecorationSupport.create(bindvalue, SWT.TOP | SWT.LEFT); final IObservableValue observeSelectionDateTimeObserveWidget = WidgetProperties.selection() .observe(dateTime); final IObservableValue dueDateTodoObserveValue = BeanProperties.value(Todo.FIELD_DUEDATE).observe(todo); ctx.bindValue(observeSelectionDateTimeObserveWidget, dueDateTodoObserveValue); // register listener for any changes providers = ctx.getValidationStatusProviders(); for (final Object o : providers) { final Binding b = (Binding) o; b.getTarget().addChangeListener(listener); } // Register for the changes providers = ctx.getValidationStatusProviders(); for (final Object o : providers) { final Binding b = (Binding) o; b.getTarget().addChangeListener(listener); } } }
From source file:com.google.cloud.tools.eclipse.appengine.deploy.ui.StandardDeployPreferencesPanel.java
License:Apache License
private void setupProjectVersionDataBinding(DataBindingContext context) { ISWTObservableValue overrideButton = WidgetProperties.selection().observe(overrideDefaultVersionButton); ISWTObservableValue versionField = WidgetProperties.text(SWT.Modify).observe(version); ISWTObservableValue versionLabelEnablement = WidgetProperties.enabled().observe(versionLabel); ISWTObservableValue versionFieldEnablement = WidgetProperties.enabled().observe(version); // use an intermediary value to control the enabled state of the label and the field based on the override // checkbox's state WritableValue enablement = new WritableValue(); context.bindValue(overrideButton, enablement); context.bindValue(versionLabelEnablement, enablement); context.bindValue(versionFieldEnablement, enablement); IObservableValue overrideModel = PojoProperties.value("overrideDefaultVersioning").observe(model); IObservableValue versionModel = PojoProperties.value("version").observe(model); context.bindValue(enablement, overrideModel); context.bindValue(versionField, versionModel); context.addValidationStatusProvider( new OverrideValidator(overrideButton, versionField, new ProjectVersionValidator())); }
From source file:com.google.cloud.tools.eclipse.appengine.deploy.ui.StandardDeployPreferencesPanel.java
License:Apache License
private void setupAutoPromoteDataBinding(DataBindingContext context) { ISWTObservableValue promoteButton = WidgetProperties.selection().observe(autoPromoteButton); ISWTObservableValue stopPreviousVersion = WidgetProperties.selection().observe(stopPreviousVersionButton); ISWTObservableValue stopPreviousVersionEnablement = WidgetProperties.enabled() .observe(stopPreviousVersionButton); // use an intermediary value to control the enabled state of stopPreviousVersionButton based on the promote // checkbox's state WritableValue enablement = new WritableValue(); context.bindValue(promoteButton, enablement); context.bindValue(stopPreviousVersionEnablement, enablement); IObservableValue promoteModel = PojoProperties.value("autoPromote").observe(model); IObservableValue stopPreviousVersionModel = PojoProperties.value("stopPreviousVersion").observe(model); context.bindValue(promoteButton, promoteModel); context.bindValue(stopPreviousVersion, stopPreviousVersionModel); }
From source file:com.google.cloud.tools.eclipse.appengine.deploy.ui.StandardDeployPreferencesPanel.java
License:Apache License
private void setupBucketDataBinding(DataBindingContext context) { ISWTObservableValue overrideButton = WidgetProperties.selection().observe(overrideDefaultBucketButton); ISWTObservableValue bucketField = WidgetProperties.text(SWT.Modify).observe(bucket); ISWTObservableValue bucketLabelEnablement = WidgetProperties.enabled().observe(bucketLabel); ISWTObservableValue bucketFieldEnablement = WidgetProperties.enabled().observe(bucket); // use an intermediary value to control the enabled state of the label and the field based on the override // checkbox's state WritableValue enablement = new WritableValue(); context.bindValue(overrideButton, enablement); context.bindValue(bucketLabelEnablement, enablement); context.bindValue(bucketFieldEnablement, enablement); IObservableValue overrideModelObservable = PojoProperties.value("overrideDefaultBucket").observe(model); IObservableValue bucketModelObservable = PojoProperties.value("bucket").observe(model); context.bindValue(enablement, overrideModelObservable); context.bindValue(bucketField, bucketModelObservable); context.addValidationStatusProvider( new OverrideValidator(overrideButton, bucketField, new BucketNameValidator())); }
From source file:com.google.cloud.tools.eclipse.appengine.ui.AppEngineLibrariesSelectorGroup.java
License:Apache License
/** * We have three bindings for each library: * <ol><li>A one-way binding of the checkbox selection state to add or remove the corresponding library from our * selected-libraries list.</li>/*w w w .j a va2 s .co m*/ * <li>The opposite of the first, a one-way binding to set the checkbox selection state when the corresponding * library has been selected or if it is a dependency of another selected library.</li> * <li>A one-way binding to set the checkbox enablement when the corresponding library is a dependency of a selected * library.</li> * </ol> * @param libraryButton to which the databinding will be configured. */ private void setupDatabindingForButton(final Button libraryButton) { final Library library = (Library) libraryButton.getData(); ISWTObservableValue libraryButtonSelection = WidgetProperties.selection().observe(libraryButton); ISWTObservableValue libraryButtonEnablement = WidgetProperties.enabled().observe(libraryButton); // library selection UI -> model bindingContext.bindValue(libraryButtonSelection, new NullComputedValue(getDisplayRealm()), new UpdateValueStrategy() .setConverter(new HandleLibrarySelectionConverter(selectedLibraries, library)), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)); // UI <- library selection model bindingContext.bindValue(libraryButtonSelection, new DependentLibrarySelected(getDisplayRealm(), library.getId(), true /* resultIfFound */) { @Override protected Object calculate() { if (libraryButton.getData(BUTTON_MANUAL_SELECTION_KEY) != null) { return true; } else { return super.calculate(); } } }, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), new UpdateValueStrategy()); // UI enablement <- library is a dependency bindingContext.bindValue(libraryButtonEnablement, new DependentLibrarySelected(getDisplayRealm(), library.getId(), false /* resultIfFound */), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), new UpdateValueStrategy()); }
From source file:com.htmlhifive.tools.jslint.dialog.ConfirmLicenseDialog.java
License:Apache License
/** * ???./*from ww w. ja va2s . c om*/ */ private void initialDataBinding() { DataBindingContext context = new DataBindingContext(); // OK?Validator UpdateValueStrategy strategy = new UpdateValueStrategy(); strategy.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object value) { getButton(IDialogConstants.OK_ID).setEnabled((Boolean) value); return null; } }); IObservableValue obsSelectiveAcceptLicense = WidgetProperties.selection().observe(btnAcceptLicense); IObservableValue obsEnabledOkButton = WidgetProperties.enabled().observe(getButton(IDialogConstants.OK_ID)); context.bindValue(obsSelectiveAcceptLicense, obsEnabledOkButton, null, null); }
From source file:com.htmlhifive.tools.jslint.dialog.CreateEngineDialog.java
License:Apache License
/** * ??.//w w w. j ava 2 s . c o m */ private void initialDataBinding() { DataBindingContext context = new DataBindingContext(); // Validator MultiValidator validator = new MultiValidator() { @Override protected IStatus validate() { StringBuilder sb = new StringBuilder(); if ((Boolean) wvJshint.getValue() && (Boolean) wvJslint.getValue()) { sb.append(Messages.EM0014.getText()); } String outputPath = (String) wvOutputDir.getValue(); if (StringUtils.isEmpty(outputPath)) { sb.append(Messages.EM0009.format(Messages.DL0020.getText())); } else { IPath path = new Path(outputPath); if (!ResourcesPlugin.getWorkspace().getRoot().exists(path)) { sb.append(Messages.EM0000.format(Messages.DL0020.getText())); } } if (StringUtils.isEmpty(sb.toString())) { getButton(IDialogConstants.OK_ID).setEnabled(true); return ValidationStatus.info(Messages.DL0027.getText()); } if (getButton(IDialogConstants.OK_ID) != null) { getButton(IDialogConstants.OK_ID).setEnabled(false); } return ValidationStatus.error(sb.toString()); } }; // ?? IObservableValue obsOutputDirText = SWTObservables.observeText(textOutputDir, SWT.Modify); context.bindValue(obsOutputDirText, wvOutputDir, null, null); // JSLint??? IObservableValue obsSelectJslint = WidgetProperties.selection().observe(btnRadioJSLint); context.bindValue(obsSelectJslint, wvJslint, null, null); // JSHint??? IObservableValue obsSelectJsHint = WidgetProperties.selection().observe(btnRadioJSHint); context.bindValue(obsSelectJsHint, wvJshint); // ?? context.addValidationStatusProvider(validator); TitleAreaDialogSupport.create(this, context); }