List of usage examples for org.eclipse.jface.databinding.swt WidgetProperties selection
public static IWidgetValueProperty selection()
From source file:org.bonitasoft.studio.properties.form.sections.actions.contributions.MaxItemsSectionContribution.java
License:Open Source License
protected void bindWidgets() { if (dataBinding != null) { dataBinding.dispose();/* w ww . ja va 2s. c o m*/ } if (spinner != null && !spinner.isDisposed()) { dataBinding = new EMFDataBindingContext(); ISWTObservableValue spinnerSelection = WidgetProperties.selection().observe(spinner); ISWTObservableValue buttonSelection = WidgetProperties.selection().observe(useMaxItemsButton); ISWTObservableValue spinnerEnablement = WidgetProperties.enabled().observe(spinner); IEMFEditValueProperty maxItems = EMFEditProperties.value(editingDomain, FormPackage.Literals.SUGGEST_BOX__MAX_ITEMS); IEMFEditValueProperty useMaxItems = EMFEditProperties.value(editingDomain, FormPackage.Literals.SUGGEST_BOX__USE_MAX_ITEMS); dataBinding.bindValue(spinnerSelection, maxItems.observe(element)); dataBinding.bindValue(buttonSelection, useMaxItems.observe(element)); dataBinding.bindValue(spinnerEnablement, useMaxItems.observe(element)); } }
From source file:org.bonitasoft.studio.properties.sections.loop.MultiInstantiationPropertyContribution.java
License:Open Source License
protected void refreshBinding() { if (context != null) { context.dispose();/*from ww w . jav a 2s. com*/ } context = new EMFDataBindingContext(); Expression condition = activity.getLoopCondition(); if (condition == null) { condition = ExpressionFactory.eINSTANCE.createExpression(); condition.setReturnTypeFixed(true); condition.setReturnType(Boolean.class.getName()); editingDomain.getCommandStack().execute(SetCommand.create(editingDomain, activity, ProcessPackage.Literals.ACTIVITY__LOOP_CONDITION, condition)); } loopConditionViewer.setEditingDomain(editingDomain); loopConditionViewer.setInput(activity); loopConditionViewer.setSelection(new StructuredSelection(condition)); Expression max = activity.getLoopMaximum(); if (max == null) { max = ExpressionFactory.eINSTANCE.createExpression(); max.setReturnTypeFixed(true); max.setReturnType(Integer.class.getName()); editingDomain.getCommandStack().execute(SetCommand.create(editingDomain, activity, ProcessPackage.Literals.ACTIVITY__LOOP_MAXIMUM, max)); } maximumViewer.setEditingDomain(editingDomain); maximumViewer.setInput(activity); maximumViewer.setSelection(new StructuredSelection(max)); context.bindValue(WidgetProperties.selection().observe(loopRadio), EMFEditProperties .value(editingDomain, ProcessPackage.Literals.ACTIVITY__IS_LOOP).observe(activity)); bindMultiInstanciationParameters(); }
From source file:org.bonitasoft.studio.properties.sections.loop.MultiInstantiationPropertyContribution.java
License:Open Source License
protected void bindMultiInstanciationParameters() { multiInstantiation = activity.getMultiInstantiation(); initMultiInstanciationModelIfNeeded(); context.bindValue(WidgetProperties.selection().observe(multiRadio), EMFEditProperties .value(editingDomain, ProcessPackage.Literals.ACTIVITY__IS_MULTI_INSTANCE).observe(activity)); bindCardinality();/* ww w. ja v a2 s . c o m*/ bindCompletionCondition(); context.bindValue(WidgetProperties.selection().observe(sequentialButton), EMFEditProperties.value(editingDomain, ProcessPackage.Literals.MULTI_INSTANTIATION__SEQUENTIAL) .observe(multiInstantiation)); /*Collection Data Chooser*/ collectionDataChooser.setInput(new WritableList( ModelHelper.getAccessibleData(ModelHelper.getParentProcess(activity)), Data.class)); context.bindValue(ViewersObservables.observeSingleSelection(collectionDataChooser), EMFEditObservables.observeValue(editingDomain, multiInstantiation, ProcessPackage.Literals.MULTI_INSTANTIATION__COLLECTION_DATA_TO_MULTI_INSTANTIATE)); listOutputDataChooser.setInput(new WritableList( ModelHelper.getAccessibleData(ModelHelper.getParentProcess(activity)), Data.class)); /*List for output data*/ context.bindValue(ViewerProperties.singleSelection().observe(listOutputDataChooser), EMFEditProperties .value(editingDomain, ProcessPackage.Literals.MULTI_INSTANTIATION__LIST_DATA_CONTAINING_OUTPUT_RESULTS) .observe(multiInstantiation)); /*Input Data Chooser*/ inputDataChooser.setInput(EMFObservables.observeList(activity, ProcessPackage.Literals.DATA_AWARE__DATA)); context.bindValue(ViewerProperties.singleSelection().observe(inputDataChooser), EMFEditProperties.value(editingDomain, ProcessPackage.Literals.MULTI_INSTANTIATION__INPUT_DATA) .observe(multiInstantiation)); /*Output Data Chooser*/ outputDataChooser.setInput(EMFObservables.observeList(activity, ProcessPackage.Literals.DATA_AWARE__DATA)); context.bindValue(ViewerProperties.singleSelection().observe(outputDataChooser), EMFEditProperties.value(editingDomain, ProcessPackage.Literals.MULTI_INSTANTIATION__OUTPUT_DATA) .observe(multiInstantiation)); bindFieldsForEnablement(); }
From source file:org.bonitasoft.studio.properties.sections.loop.MultiInstantiationPropertyContribution.java
License:Open Source License
protected void bindCardinality() { context.bindValue(WidgetProperties.selection().observe(useCardinalityButton), EMFEditProperties.value(editingDomain, ProcessPackage.Literals.MULTI_INSTANTIATION__USE_CARDINALITY) .observe(multiInstantiation)); context.bindValue(ViewerProperties.singleSelection().observe(cardinalityExpression), EMFEditProperties.value(editingDomain, ProcessPackage.Literals.MULTI_INSTANTIATION__CARDINALITY) .observe(multiInstantiation)); Expression cardinality = multiInstantiation.getCardinality(); if (cardinality == null) { cardinality = ExpressionFactory.eINSTANCE.createExpression(); cardinality.setReturnType(Integer.class.getName()); cardinality.setReturnTypeFixed(true); }//from ww w.j a va 2 s . c om cardinalityExpression.setInput(multiInstantiation); cardinalityExpression.setSelection(new StructuredSelection(cardinality)); }
From source file:org.bonitasoft.studio.properties.sections.loop.MultiInstantiationPropertyContribution.java
License:Open Source License
protected void bindFieldsForEnablement() { context.bindValue(WidgetProperties.enabled().observe(cardinalityExpression.getTextControl()), WidgetProperties.selection().observe(useCardinalityButton)); context.bindValue(WidgetProperties.enabled().observe(cardinalityExpression.getButtonControl()), WidgetProperties.selection().observe(useCardinalityButton)); context.bindValue(WidgetProperties.enabled().observe(collectionDataChooser.getControl()), WidgetProperties.selection().observe(useCollectionButton)); context.bindValue(WidgetProperties.enabled().observe(inputDataChooser.getControl()), WidgetProperties.selection().observe(useCollectionButton)); context.bindValue(WidgetProperties.enabled().observe(outputDataChooser.getControl()), WidgetProperties.selection().observe(useCollectionButton)); context.bindValue(WidgetProperties.enabled().observe(listOutputDataChooser.getControl()), WidgetProperties.selection().observe(useCollectionButton)); }
From source file:org.eclipse.cdt.internal.docker.launcher.ContainerDataVolumeDialog.java
License:Open Source License
@Override protected Control createDialogArea(final Composite parent) { final Composite container = new Composite(parent, SWT.NONE); final int COLUMNS = 3; GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(1, 1).grab(true, true).applyTo(container); GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(COLUMNS).applyTo(container); // Container path final Label containerPathLabel = new Label(container, SWT.NONE); containerPathLabel.setText(WizardMessages.getString("ContainerDataVolumeDialog.containerPathLabel")); //$NON-NLS-1$ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(containerPathLabel); final Text containerPathText = new Text(container, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(containerPathText); final IObservableValue containerPathObservable = BeanProperties .value(DataVolumeModel.class, DataVolumeModel.CONTAINER_PATH).observe(model); dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(containerPathText), containerPathObservable); // mount type final Label explanationLabel = new Label(container, SWT.NONE); explanationLabel.setText(WizardMessages.getString("ContainerDataVolumeDialog.explanationLabel")); //$NON-NLS-1$ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(true, false) .applyTo(explanationLabel);//from w w w. j av a 2 s . com final int INDENT = 20; // No mount final Button noMountButton = new Button(container, SWT.RADIO); noMountButton.setText(WizardMessages.getString("ContainerDataVolumeDialog.noMountButton")); //$NON-NLS-1$ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(INDENT, 0).span(COLUMNS, 1) .grab(true, false).applyTo(noMountButton); bindButton(noMountButton, MountType.NONE); // File System mount final Button fileSystemMountButton = new Button(container, SWT.RADIO); fileSystemMountButton.setText(WizardMessages.getString("ContainerDataVolumeDialog.fileSystemMountButton")); //$NON-NLS-1$ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(INDENT, 0).span(COLUMNS, 1) .grab(true, false).applyTo(fileSystemMountButton); final Label hostPathLabel = new Label(container, SWT.NONE); hostPathLabel.setText(WizardMessages.getString("ContainerDataVolumeDialog.hostPathLabel")); //$NON-NLS-1$ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(2 * INDENT, SWT.DEFAULT) .grab(false, false).applyTo(hostPathLabel); final Text hostPathText = new Text(container, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(hostPathText); final IObservableValue hostPathObservable = BeanProperties .value(DataVolumeModel.class, DataVolumeModel.HOST_PATH_MOUNT).observe(model); dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(hostPathText), hostPathObservable); // browse for directory final Button hostPathDirectoryButton = new Button(container, SWT.NONE); hostPathDirectoryButton.setText(WizardMessages.getString("ContainerDataVolumeDialog.directoryButton")); //$NON-NLS-1$ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false) .applyTo(hostPathDirectoryButton); hostPathDirectoryButton.addSelectionListener(onHostDirectoryPath()); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false) .applyTo(new Label(container, SWT.NONE)); // optional read-only access final Button readOnlyButton = new Button(container, SWT.CHECK); readOnlyButton.setText(WizardMessages.getString("ContainerDataVolumeDialog.readOnlyButton")); //$NON-NLS-1$ readOnlyButton.setToolTipText(WizardMessages.getString("ContainerDataVolumeDialog.readOnlyButtonTooltip")); //$NON-NLS-1$ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS - 2, 1).grab(true, false) .applyTo(readOnlyButton); final ISWTObservableValue readOnlyButtonObservable = WidgetProperties.selection().observe(readOnlyButton); dbc.bindValue(readOnlyButtonObservable, BeanProperties.value(DataVolumeModel.class, DataVolumeModel.READ_ONLY_VOLUME).observe(model)); // browse for file final Button hostPathFileButton = new Button(container, SWT.NONE); hostPathFileButton.setText(WizardMessages.getString("ContainerDataVolumeDialog.fileButton")); //$NON-NLS-1$ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(hostPathFileButton); hostPathFileButton.addSelectionListener(onHostFilePath()); bindButton(fileSystemMountButton, MountType.HOST_FILE_SYSTEM, hostPathText, hostPathDirectoryButton, hostPathFileButton, readOnlyButton); // Container mount final Button containerMountButton = new Button(container, SWT.RADIO); containerMountButton.setText(WizardMessages.getString("ContainerDataVolumeDialog.containerMountButton")); //$NON-NLS-1$ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(INDENT, 0).span(COLUMNS, 1) .grab(true, false).applyTo(containerMountButton); final Label containerSelectionLabel = new Label(container, SWT.NONE); containerSelectionLabel .setText(WizardMessages.getString("ContainerDataVolumeDialog.containerSelectionLabel")); //$NON-NLS-1$ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(2 * INDENT, SWT.DEFAULT) .applyTo(containerSelectionLabel); final Combo containerSelectionCombo = new Combo(container, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(1, 1) .applyTo(containerSelectionCombo); new ControlDecoration(containerSelectionCombo, SWT.TOP | SWT.LEFT); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false) .applyTo(new Label(container, SWT.NONE)); bindButton(containerMountButton, MountType.CONTAINER, containerSelectionCombo); final ComboViewer containerSelectionComboViewer = new ComboViewer(containerSelectionCombo); containerSelectionComboViewer.setContentProvider(new ArrayContentProvider()); containerSelectionComboViewer.setInput(this.containerNames); final IObservableValue selectedContainerObservable = BeanProperties .value(DataVolumeModel.class, DataVolumeModel.CONTAINER_MOUNT).observe(model); dbc.bindValue(WidgetProperties.selection().observe(containerSelectionCombo), selectedContainerObservable); new ContentProposalAdapter(containerSelectionCombo, new ComboContentAdapter() { @Override public void insertControlContents(Control control, String text, int cursorPosition) { final Combo combo = (Combo) control; final Point selection = combo.getSelection(); combo.setText(text); selection.x = text.length(); selection.y = selection.x; combo.setSelection(selection); } }, getContainerNameContentProposalProvider(containerSelectionCombo), null, null); // error message final Composite errorContainer = new Composite(container, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(COLUMNS, 1).grab(true, true) .applyTo(errorContainer); GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(errorContainer); final Label errorMessageIcon = new Label(errorContainer, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(20, SWT.DEFAULT).applyTo(errorMessageIcon); final Label errorMessageLabel = new Label(errorContainer, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(errorMessageLabel); setupValidationSupport(errorMessageIcon, errorMessageLabel); return container; }
From source file:org.eclipse.cdt.internal.docker.launcher.ContainerDataVolumeDialog.java
License:Open Source License
/** * Binds the given {@link MountType} to the given {@link Button} when it is * selected, and set the enablement of the associated {@link Control} at the * same time (ie: the {@link Control} are only enabled when the given * {@link Button} is selected.// ww w. j a va2 s.c o m * * @param button * the {@link Button} to bind * @param mountType * the {@link MountType} to bind to the {@link Button} * @param controls * the {@link Control}s to enable or disable when the Button is * selected/unselected. * @return */ private Binding bindButton(final Button button, final MountType mountType, final Control... controls) { return dbc.bindValue(WidgetProperties.selection().observe(button), BeanProperties.value(DataVolumeModel.class, DataVolumeModel.MOUNT_TYPE).observe(model), new UpdateValueStrategy() { @Override public Object convert(Object value) { if (value.equals(Boolean.TRUE)) { setEnabled(controls, true); return mountType; } setEnabled(controls, false); return null; } private void setEnabled(final Control[] controls, final boolean enabled) { for (Control control : controls) { control.setEnabled(enabled); } } }, new UpdateValueStrategy() { @Override public Object convert(final Object value) { if (mountType.equals(value)) { button.setEnabled(true); } return mountType.equals(value); } }); }
From source file:org.eclipse.e4.internal.tools.wizards.classes.NewDynamicMenuContributionClassWizard.java
License:Open Source License
@Override public void addPages() { addPage(new AbstractNewClassPage("Classinformation", "New Dynamic Menu Contribution", "Create a new dynamic menu contribution class", root, ResourcesPlugin.getWorkspace().getRoot(), initialString) {//from ww w . j a v a 2s . c o m @Override protected JavaClass createInstance() { return new DynamicMenuContributionClass(root); } @Override protected void createFields(Composite parent, DataBindingContext dbc) { IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); { Label l = new Label(parent, SWT.NONE); l.setText("AboutToShow Method"); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); dbc.bindValue(textProp.observe(t), BeanProperties.value("aboutToShowMethodName").observe(getClazz())); l = new Label(parent, SWT.NONE); } { Label l = new Label(parent, SWT.NONE); l.setText("AboutToShow Method"); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); dbc.bindValue(textProp.observe(t), BeanProperties.value("aboutToHideMethodName").observe(getClazz())); dbc.bindValue(WidgetProperties.enabled().observe(t), BeanProperties.value("useAboutToHide").observe(getClazz())); Button b = new Button(parent, SWT.CHECK); dbc.bindValue(WidgetProperties.selection().observe(b), BeanProperties.value("useAboutToHide").observe(getClazz())); } } }); }
From source file:org.eclipse.e4.internal.tools.wizards.classes.NewHandlerClassWizard.java
License:Open Source License
@Override public void addPages() { addPage(new AbstractNewClassPage("Classinformation", "New Handler", "Create a new handler class", root, ResourcesPlugin.getWorkspace().getRoot(), initialString) { @Override//from w ww . j a v a 2s . c o m protected JavaClass createInstance() { return new HandlerClass(root); } @Override protected void createFields(Composite parent, DataBindingContext dbc) { IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); { Label l = new Label(parent, SWT.NONE); l.setText("Execute Method"); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); dbc.bindValue(textProp.observe(t), BeanProperties.value("executeMethodName").observe(getClazz())); l = new Label(parent, SWT.NONE); } { Label l = new Label(parent, SWT.NONE); l.setText("Can-Execute Method"); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); dbc.bindValue(textProp.observe(t), BeanProperties.value("canExecuteMethodName").observe(getClazz())); dbc.bindValue(WidgetProperties.enabled().observe(t), BeanProperties.value("useCanExecute").observe(getClazz())); Button b = new Button(parent, SWT.CHECK); dbc.bindValue(WidgetProperties.selection().observe(b), BeanProperties.value("useCanExecute").observe(getClazz())); } } }); }
From source file:org.eclipse.e4.internal.tools.wizards.classes.NewPartClassWizard.java
License:Open Source License
@Override public void addPages() { addPage(new AbstractNewClassPage("Classinformation", "New Part", "Create a new part class", root, ResourcesPlugin.getWorkspace().getRoot(), initialString) { @Override//www . j a v a 2 s . c o m protected void createFields(Composite parent, DataBindingContext dbc) { IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); IWidgetValueProperty enabledProp = WidgetProperties.enabled(); { Label l = new Label(parent, SWT.NONE); l.setText("PostContruct Method"); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); dbc.bindValue(textProp.observe(t), BeanProperties.value("postConstructMethodName").observe(getClazz())); dbc.bindValue(enabledProp.observe(t), BeanProperties.value("usePostConstruct").observe(getClazz())); Button b = new Button(parent, SWT.CHECK); dbc.bindValue(WidgetProperties.selection().observe(b), BeanProperties.value("usePostConstruct").observe(getClazz())); } { Label l = new Label(parent, SWT.NONE); l.setText("Predestroy Method"); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); dbc.bindValue(textProp.observe(t), BeanProperties.value("preDestroyMethodName").observe(getClazz())); dbc.bindValue(enabledProp.observe(t), BeanProperties.value("usePredestroy").observe(getClazz())); Button b = new Button(parent, SWT.CHECK); dbc.bindValue(WidgetProperties.selection().observe(b), BeanProperties.value("usePredestroy").observe(getClazz())); } { Label l = new Label(parent, SWT.NONE); l.setText("Focus Method"); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); dbc.bindValue(textProp.observe(t), BeanProperties.value("focusMethodName").observe(getClazz())); dbc.bindValue(enabledProp.observe(t), BeanProperties.value("useFocus").observe(getClazz())); Button b = new Button(parent, SWT.CHECK); dbc.bindValue(WidgetProperties.selection().observe(b), BeanProperties.value("useFocus").observe(getClazz())); } { Label l = new Label(parent, SWT.NONE); l.setText("Persist Method"); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); dbc.bindValue(textProp.observe(t), BeanProperties.value("persistMethodName").observe(getClazz())); dbc.bindValue(enabledProp.observe(t), BeanProperties.value("usePersist").observe(getClazz())); Button b = new Button(parent, SWT.CHECK); dbc.bindValue(WidgetProperties.selection().observe(b), BeanProperties.value("usePersist").observe(getClazz())); } } @Override protected JavaClass createInstance() { return new PartClass(root); } }); }