List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeEnabled
@Deprecated public static ISWTObservableValue observeEnabled(Control control)
From source file:org.bonitasoft.studio.contract.ui.property.ContractPropertySection.java
License:Open Source License
protected void bindAddConstraintButtonEnablement(final Button button, final IObservableValue contractObservable) { final ISWTObservableValue observeEnabled = SWTObservables.observeEnabled(button); final IObservableList observeDetailList = CustomEMFEditObservables.observeDetailList(Realm.getDefault(), contractObservable, ProcessPackage.Literals.CONTRACT__INPUTS); observeDetailList.addListChangeListener(new IListChangeListener() { @Override//from w w w. j a va 2 s . c om public void handleListChange(final ListChangeEvent event) { if (!button.isDisposed()) { observeEnabled.setValue(!event.getObservableList().isEmpty()); } } }); }
From source file:org.bonitasoft.studio.contract.ui.property.ContractPropertySection.java
License:Open Source License
protected void bindRemoveButtonEnablement(final Button button, final Viewer viewer) { context.bindValue(SWTObservables.observeEnabled(button), ViewersObservables.observeSingleSelection(viewer), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), emptySelectionToBooleanStrategy()); }
From source file:org.bonitasoft.studio.contract.ui.property.ContractPropertySection.java
License:Open Source License
protected void bindUpButtonEnablement(final Button button, final Viewer viewer) { context.bindValue(SWTObservables.observeEnabled(button), ViewersObservables.observeSingleSelection(viewer), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), isFirstElementToBooleanStrategy()); }
From source file:org.bonitasoft.studio.contract.ui.property.ContractPropertySection.java
License:Open Source License
protected void bindDownButtonEnablement(final Button button, final Viewer viewer) { context.bindValue(SWTObservables.observeEnabled(button), ViewersObservables.observeSingleSelection(viewer), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), isLastElementToBooleanStrategy()); }
From source file:org.bonitasoft.studio.contract.ui.property.ContractPropertySection.java
License:Open Source License
protected void bindAddChildButtonEnablement(final Button button, final Viewer viewer) { context.bindValue(SWTObservables.observeEnabled(button), ViewersObservables.observeSingleSelection(viewer), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), emptySelectionAndComplexTypeToBooleanStrategy()); context.bindValue(SWTObservables.observeEnabled(button), EMFObservables.observeDetailValue(Realm.getDefault(), ViewersObservables.observeSingleSelection(viewer), ProcessPackage.Literals.CONTRACT_INPUT__TYPE), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), complexTypeToBooleanStrategy()); }
From source file:org.bonitasoft.studio.data.ui.property.section.AbstractDataSection.java
License:Open Source License
protected void bindSection() { if (context != null) { context.dispose();/*from www. j a v a 2 s.c o m*/ } context = new EMFDataBindingContext(); if (getEObject() != null) { if (dataTableViewer != null) { context.bindValue(ViewersObservables.observeInput(dataTableViewer), EMFEditObservables.observeValue(getEditingDomain(), getEObject(), getDataFeature())); final UpdateValueStrategy enableStrategy = new UpdateValueStrategy(); enableStrategy.setConverter(new Converter(Data.class, Boolean.class) { @Override public Object convert(Object fromObject) { return fromObject != null; } }); context.bindValue(SWTObservables.observeEnabled(updateDataButton), ViewersObservables.observeSingleSelection(dataTableViewer), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), enableStrategy); context.bindValue(SWTObservables.observeEnabled(removeDataButton), ViewersObservables.observeSingleSelection(dataTableViewer), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), enableStrategy); if (promoteDataButton != null) { final UpdateValueStrategy enableMoveStrategy = new UpdateValueStrategy(); enableMoveStrategy.setConverter(new Converter(Data.class, Boolean.class) { @Override public Object convert(Object fromObject) { return fromObject != null && ModelHelper.getParentProcess(getEObject()) != null && !((Data) fromObject).isTransient(); } }); context.bindValue(SWTObservables.observeEnabled(promoteDataButton), ViewersObservables.observeSingleSelection(dataTableViewer), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), enableMoveStrategy); } } } }
From source file:org.bonitasoft.studio.data.ui.property.section.control.DataViewer.java
License:Open Source License
public void bindControl(final DataBindingContext context, final IObservableValue dataContainerObservable) { this.dataContainerObservable = dataContainerObservable; final IObservableSet knownElements = ((ObservableListContentProvider) tableViewer.getContentProvider()) .getKnownElements();//from w ww.ja va 2 s . c o m final IObservableMap[] labelMaps = EMFObservables.observeMaps(knownElements, new EStructuralFeature[] { ProcessPackage.Literals.ELEMENT__NAME, ProcessPackage.Literals.DATA__MULTIPLE, ProcessPackage.Literals.JAVA_OBJECT_DATA__CLASS_NAME, ProcessPackage.Literals.DATA__DATA_TYPE }); tableViewer.setLabelProvider(createLabelProvider(labelMaps)); tableViewer.setInput(CustomEMFEditObservables.observeDetailList(Realm.getDefault(), dataContainerObservable, dataFeature)); context.bindValue(SWTObservables.observeEnabled(editButton), ViewersObservables.observeSingleSelection(tableViewer), neverUpdateValueStrategy().create(), updateValueStrategy().withConverter(selectionNotNull()).create()); context.bindValue(SWTObservables.observeEnabled(removeButton), ViewersObservables.observeSingleSelection(tableViewer), neverUpdateValueStrategy().create(), updateValueStrategy().withConverter(selectionNotNull()).create()); }
From source file:org.bonitasoft.studio.groovy.ui.dialog.TestGroovyScriptDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { final Composite mainComposite = (Composite) super.createDialogArea(parent); mainComposite.setLayoutData(GridDataFactory.fillDefaults().hint(400, SWT.DEFAULT).create()); mainComposite// w w w . j a v a2s .c om .setLayout(GridLayoutFactory.fillDefaults().extendedMargins(15, 15, 10, 0).spacing(0, 15).create()); final Label descriptionLabel = new Label(mainComposite, SWT.WRAP); descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); descriptionLabel.setText(Messages.testGroovyScriptDialogDescription); final Map<String, Serializable> procVariables = getProcessVariables(variables); final Map<String, Serializable> unknownVariables = getUnknownVariables(variables); if (!procVariables.isEmpty()) { createVariableGroup(mainComposite, Messages.processVariableLabel, procVariables); } if (!unknownVariables.isEmpty()) { createVariableGroup(mainComposite, Messages.unknownVariableLabel, unknownVariables); } final Composite buttonComposite = new Composite(mainComposite, SWT.NONE); buttonComposite .setLayoutData(GridDataFactory.fillDefaults().grab(false, false).align(SWT.END, SWT.FILL).create()); buttonComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create()); final Button closeButton = new Button(buttonComposite, SWT.PUSH); closeButton.setLayoutData(GridDataFactory.fillDefaults().hint(100, SWT.DEFAULT).create()); closeButton.setText(IDialogConstants.CLOSE_LABEL); closeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { close(); } }); final Button testButton = new Button(buttonComposite, SWT.PUSH); testButton.setLayoutData(GridDataFactory.fillDefaults().hint(100, SWT.DEFAULT).create()); testButton.setText(Messages.testButtonLabel); testButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { ManageConnectorJarDialog mcjd = new ManageConnectorJarDialog( Display.getDefault().getActiveShell()); int retCode = mcjd.open(); if (retCode == Window.OK) { TestGroovyScriptUtil.evaluateExpression(unit.getSource(), returnType, TestGroovyScriptUtil.getVariableValues(unit, nodes, widgetMap), mcjd.getSelectedJars()); } } catch (JavaModelException e1) { BonitaStudioLog.error(e1); } } }); DataBindingContext dbc = new DataBindingContext(); for (Entry<Label, Control> entry : widgetMap.entrySet()) { final UpdateValueStrategy strategy = new UpdateValueStrategy(); //strategy.setAfterGetValidator(new EmptyInputValidator(entry.getKey().getText())); strategy.setConverter(new Converter(String.class, Boolean.class) { @Override public Object convert(Object fromObject) { if (fromObject == null || fromObject.toString().isEmpty()) { return false; } return allWidgetFilled(); } }); dbc.bindValue(SWTObservables.observeEnabled(testButton), SWTObservables.observeText(entry.getValue(), SWT.Modify), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), strategy); } return mainComposite; }
From source file:org.bonitasoft.studio.groovy.ui.providers.GroovyScriptExpressionEditor.java
License:Open Source License
@Override public void bindExpression(EMFDataBindingContext dataBindingContext, final EObject context, Expression inputExpression, ViewerFilter[] filters, final ExpressionViewer viewer) { this.inputExpression = inputExpression; this.context = context; IObservableValue dependenciesModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__REFERENCED_ELEMENTS); IObservableValue autoDepsModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__AUTOMATIC_DEPENDENCIES); inputExpression.setType(ExpressionConstants.SCRIPT_TYPE); inputExpression.setInterpreter(ExpressionConstants.GROOVY); groovyViewer.setContext(context, filters, viewer.getExpressionNatureProvider()); nodes = groovyViewer.getFieldNodes(); if (context == null && nodes == null) { dataCombo.add(Messages.noProcessVariableAvailable); dataCombo.getTableCombo().setText(Messages.noProcessVariableAvailable); dataCombo.getTableCombo().setEnabled(false); } else if (nodes != null) { dataCombo.setInput(nodes);/* w ww . j a v a 2s .c o m*/ dataCombo.setSelection(new StructuredSelection(ProcessVariableContentProvider.SELECT_ENTRY)); if (nodes.isEmpty()) { dataCombo.getTableCombo().setEnabled(false); } } else { dataCombo.setInput(groovyViewer.getFieldNodes()); dataCombo.setSelection(new StructuredSelection(ProcessVariableContentProvider.SELECT_ENTRY)); if (groovyViewer.getFieldNodes().isEmpty()) { dataCombo.getTableCombo().setEnabled(false); } } bonitaDataCombo.setInput(GroovyUtil.getBonitaVariables(context, filters, isPageFlowContext)); bonitaDataCombo.setSelection(new StructuredSelection(ProcessVariableContentProvider.SELECT_ENTRY)); dataBindingContext.bindValue(ViewersObservables.observeInput(dependenciesViewer), dependenciesModelObservable); UpdateValueStrategy opposite = new UpdateValueStrategy(); opposite.setConverter(new Converter(Boolean.class, Boolean.class) { @Override public Object convert(Object fromObject) { return !((Boolean) fromObject); } }); dataBindingContext.bindValue(SWTObservables.observeSelection(automaticResolutionButton), autoDepsModelObservable); dataBindingContext.bindValue(SWTObservables.observeSelection(automaticResolutionButton), SWTObservables.observeEnabled(addDependencyButton), opposite, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)); depndencySection.setExpanded(!automaticResolutionButton.getSelection()); addDependencyButton.setEnabled(!inputExpression.isAutomaticDependencies()); dependencyJob = new ComputeScriptDependenciesJob(sourceViewer.getDocument()); dependencyJob.setContext(context); this.nodes.addAll(GroovyUtil.getBonitaVariables(context, filters, isPageFlowContext)); dependencyJob.setNodes(nodes); final InputLengthValidator lenghtValidator = new InputLengthValidator("", GroovyViewer.MAX_SCRIPT_LENGTH); String content = inputExpression.getContent(); if (content == null) { content = ""; } sourceViewer.getTextWidget().setText(content); sourceViewer.getDocument().addDocumentListener(new IDocumentListener() { @Override public void documentChanged(DocumentEvent event) { final String text = event.getDocument().get(); if (lenghtValidator.validate(text).isOK()) { GroovyScriptExpressionEditor.this.inputExpression.setContent(text); } if (automaticResolutionButton.getSelection()) { dependencyJob.schedule(); } } @Override public void documentAboutToBeChanged(DocumentEvent event) { } }); dependencyJob.addJobChangeListener(new IJobChangeListener() { @Override public void sleeping(IJobChangeEvent event) { } @Override public void scheduled(IJobChangeEvent event) { } @Override public void running(IJobChangeEvent event) { } @Override public void done(IJobChangeEvent event) { if (dependencyJob != null && GroovyScriptExpressionEditor.this.inputExpression.isAutomaticDependencies()) { List<EObject> deps = dependencyJob.getDependencies(document.get()); GroovyScriptExpressionEditor.this.inputExpression.getReferencedElements().clear(); if (deps != null && !deps.isEmpty()) { GroovyScriptExpressionEditor.this.inputExpression.getReferencedElements().addAll(deps); } } } @Override public void awake(IJobChangeEvent event) { } @Override public void aboutToRun(IJobChangeEvent event) { } }); final ExpressionContentProvider provider = new ExpressionContentProvider(); provider.setContext(context); final Set<Expression> filteredExpressions = new HashSet<Expression>(); Expression[] expressions = provider.getExpressions(); EObject input = provider.getContext(); if (expressions != null) { filteredExpressions.addAll(Arrays.asList(expressions)); if (input != null && filters != null) { for (Expression exp : expressions) { for (ViewerFilter filter : filters) { if (filter != null && !filter.select(groovyViewer.getSourceViewer(), input, exp)) { filteredExpressions.remove(exp); } } } } } addDependencyButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SelectDependencyDialog dialog = new SelectDependencyDialog(Display.getDefault().getActiveShell(), filteredExpressions, GroovyScriptExpressionEditor.this.inputExpression.getReferencedElements()); dialog.open(); } }); final UpdateValueStrategy evaluateStrategy = new UpdateValueStrategy(); evaluateStrategy.setConverter(new Converter(String.class, Boolean.class) { @Override public Object convert(Object fromObject) { if (fromObject == null || fromObject.toString().isEmpty()) { return false; } return true; } }); dataBindingContext.bindValue(SWTObservables.observeEnabled(testButton), SWTObservables.observeText(groovyViewer.getSourceViewer().getTextWidget(), SWT.Modify), null, evaluateStrategy); }
From source file:org.bonitasoft.studio.properties.form.sections.actions.contributions.AsynchronousSuggestBoxContribution.java
License:Open Source License
protected void bindWidgets() { if (dataBindingContext != null) { dataBindingContext.dispose();//from ww w .j ava 2s. com } dataBindingContext = new EMFDataBindingContext(); IObservableValue value = EMFEditObservables.observeValue(editingDomain, suggestBox, FormPackage.Literals.SUGGEST_BOX__ASYNCHRONOUS); value.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { ISection extensibleGridPropertySection = section.getTabbedPropertySheetPage().getCurrentTab() .getSections()[0]; if (extensibleGridPropertySection instanceof DataPropertySection) { for (IExtensibleGridPropertySectionContribution contib : ((DataPropertySection) extensibleGridPropertySection) .getContributions()) { if (contib instanceof AvailableValueContribution) { //((MultipleValuatedFieldContribution)contib).resetCombo() ; } } } } }); ; dataBindingContext.bindValue(SWTObservables.observeSelection(isAsynchronousCheckbox), EMFEditObservables .observeValue(editingDomain, suggestBox, FormPackage.Literals.SUGGEST_BOX__ASYNCHRONOUS)); dataBindingContext.bindValue( EMFEditObservables.observeValue(editingDomain, suggestBox, FormPackage.Literals.SUGGEST_BOX__ASYNCHRONOUS), SWTObservables.observeEnabled(delayText), null, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)); dataBindingContext.bindValue(SWTObservables.observeText(delayText, SWT.Modify), EMFEditObservables .observeValue(editingDomain, suggestBox, FormPackage.Literals.SUGGEST_BOX__DELAY)); }