List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeVisible
@Deprecated public static ISWTObservableValue observeVisible(Control control)
From source file:org.bonitasoft.studio.properties.form.sections.actions.contributions.OutputSectionContribution.java
License:Open Source License
protected void bindWidgets() { if (operationViewer != null && !operationViewer.isDisposed()) { if (dataBinding != null) { dataBinding.dispose();/*ww w . j a v a2 s . com*/ } dataBinding = new EMFDataBindingContext(); operationViewer.setContext(dataBinding); Operation action = element.getAction(); if (action == null) { action = ExpressionFactory.eINSTANCE.createOperation(); Operator op = ExpressionFactory.eINSTANCE.createOperator(); op.setType(ExpressionConstants.ASSIGNMENT_OPERATOR); op.setExpression("="); action.setOperator(op); Expression variableExp = ExpressionFactory.eINSTANCE.createExpression(); Expression actionExp = ExpressionFactory.eINSTANCE.createExpression(); action.setLeftOperand(variableExp); action.setRightOperand(actionExp); editingDomain.getCommandStack().execute( SetCommand.create(editingDomain, element, FormPackage.Literals.WIDGET__ACTION, action)); } operationViewer.setEditingDomain(getEditingDomain()); operationViewer.setEObject(element); UpdateValueStrategy strategy = new UpdateValueStrategy(); strategy.setConverter(new Converter(Boolean.class, Boolean.class) { public Object convert(Object fromObject) { return !((Boolean) fromObject).booleanValue(); } }); dataBinding.bindValue( SWTObservables.observeVisible( ExtensibleGridPropertySection.getLabelCompositeOf(operationViewer.getParent())), EMFEditObservables.observeValue(getEditingDomain(), element, FormPackage.Literals.WIDGET__READ_ONLY), strategy, strategy); dataBinding.bindValue( SWTObservables.observeVisible(operationViewer.getParent()), EMFEditObservables .observeValue(getEditingDomain(), element, FormPackage.Literals.WIDGET__READ_ONLY), strategy, strategy); if (element instanceof FileWidget) { dataBinding.bindValue( SWTObservables.observeVisible( ExtensibleGridPropertySection.getLabelCompositeOf(operationViewer.getParent())), EMFEditObservables.observeValue(getEditingDomain(), element, FormPackage.Literals.FILE_WIDGET__DOWNLOAD_ONLY), strategy, strategy); dataBinding.bindValue(SWTObservables.observeVisible(operationViewer.getParent()), EMFEditObservables .observeValue(getEditingDomain(), element, FormPackage.Literals.FILE_WIDGET__DOWNLOAD_ONLY), strategy, strategy); } } }
From source file:org.bonitasoft.studio.properties.form.sections.actions.table.DynamicTableDataPropertySection.java
License:Open Source License
protected void bindColumn(DynamicTable dynamicTable) { dataBindingContext.bindValue(SWTObservables.observeSelection(allowAddRemoveColumnButton), EMFEditObservables.observeValue(getEditingDomain(), dynamicTable, FormPackage.Literals.DYNAMIC_TABLE__ALLOW_ADD_REMOVE_COLUMN)); if (dynamicTable != null) { Expression minNumberOfColumn = dynamicTable.getMinNumberOfColumn(); if (minNumberOfColumn == null) { minNumberOfColumn = ExpressionFactory.eINSTANCE.createExpression(); minNumberOfColumn.setReturnType(Integer.class.getName()); minNumberOfColumn.setReturnTypeFixed(true); getEditingDomain().getCommandStack().execute(SetCommand.create(getEditingDomain(), dynamicTable, FormPackage.Literals.DYNAMIC_TABLE__MIN_NUMBER_OF_COLUMN, minNumberOfColumn)); }/*from www. ja v a 2 s . c o m*/ } if (dynamicTable != null) { Expression maxNumberOfColumn = dynamicTable.getMaxNumberOfColumn(); if (maxNumberOfColumn == null) { maxNumberOfColumn = ExpressionFactory.eINSTANCE.createExpression(); maxNumberOfColumn.setReturnType(Integer.class.getName()); maxNumberOfColumn.setReturnTypeFixed(true); getEditingDomain().getCommandStack().execute(SetCommand.create(getEditingDomain(), dynamicTable, FormPackage.Literals.DYNAMIC_TABLE__MAX_NUMBER_OF_COLUMN, maxNumberOfColumn)); } } /* * Synchronize with the model. * */ dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(textOrDataMinColumn), EMFEditProperties .value(getEditingDomain(), FormPackage.Literals.DYNAMIC_TABLE__MIN_NUMBER_OF_COLUMN) .observe(dynamicTable)); dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(textOrDataMaxColumn), EMFEditProperties .value(getEditingDomain(), FormPackage.Literals.DYNAMIC_TABLE__MAX_NUMBER_OF_COLUMN) .observe(dynamicTable)); dataBindingContext.bindValue(SWTObservables.observeSelection(limitMinColumnButton), EMFEditObservables.observeValue(getEditingDomain(), dynamicTable, FormPackage.Literals.DYNAMIC_TABLE__LIMIT_MIN_NUMBER_OF_COLUMN)); dataBindingContext.bindValue(SWTObservables.observeSelection(limitMaxColumnButton), EMFEditObservables.observeValue(getEditingDomain(), dynamicTable, FormPackage.Literals.DYNAMIC_TABLE__LIMIT_MAX_NUMBER_OF_COLUMN)); /* * Enable the combo only if we want to set a number limitation. * */ dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMinColumn.getControl()), SWTObservables.observeSelection(limitMinColumnButton)); dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMinColumn.getTextControl()), SWTObservables.observeSelection(limitMinColumnButton)); dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMinColumn.getToolbar()), SWTObservables.observeSelection(limitMinColumnButton)); dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMaxColumn.getControl()), SWTObservables.observeSelection(limitMaxColumnButton)); dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMaxColumn.getTextControl()), SWTObservables.observeSelection(limitMaxColumnButton)); dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMaxColumn.getToolbar()), SWTObservables.observeSelection(limitMaxColumnButton)); dataBindingContext.bindValue(SWTObservables.observeVisible(limitMinColumnButton), SWTObservables.observeSelection(allowAddRemoveColumnButton), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); dataBindingContext.bindValue(SWTObservables.observeVisible(limitMaxColumnButton), SWTObservables.observeSelection(allowAddRemoveColumnButton), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); dataBindingContext.bindValue(SWTObservables.observeVisible(textOrDataMinColumn.getControl()), SWTObservables.observeSelection(allowAddRemoveColumnButton), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); dataBindingContext.bindValue(SWTObservables.observeVisible(textOrDataMaxColumn.getControl()), SWTObservables.observeSelection(allowAddRemoveColumnButton), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); textOrDataMaxColumn.setInput(dynamicTable); textOrDataMinColumn.setInput(dynamicTable); }
From source file:org.bonitasoft.studio.properties.form.sections.actions.table.DynamicTableDataPropertySection.java
License:Open Source License
protected void bindRow(DynamicTable dynamicTable) { dataBindingContext.bindValue(SWTObservables.observeSelection(allowAddRemoveRowButton), EMFEditObservables.observeValue(getEditingDomain(), dynamicTable, FormPackage.Literals.DYNAMIC_TABLE__ALLOW_ADD_REMOVE_ROW)); if (dynamicTable != null) { Expression minNumberOfRow = dynamicTable.getMinNumberOfColumn(); if (minNumberOfRow == null) { minNumberOfRow = ExpressionFactory.eINSTANCE.createExpression(); minNumberOfRow.setReturnType(Integer.class.getName()); minNumberOfRow.setReturnTypeFixed(true); getEditingDomain().getCommandStack().execute(SetCommand.create(getEditingDomain(), dynamicTable, FormPackage.Literals.DYNAMIC_TABLE__MIN_NUMBER_OF_ROW, minNumberOfRow)); }/*w w w.j a va2 s. c o m*/ } if (dynamicTable != null) { Expression maxNumberOfRow = dynamicTable.getMaxNumberOfRow(); if (maxNumberOfRow == null) { maxNumberOfRow = ExpressionFactory.eINSTANCE.createExpression(); maxNumberOfRow.setReturnType(Integer.class.getName()); maxNumberOfRow.setReturnTypeFixed(true); getEditingDomain().getCommandStack().execute(SetCommand.create(getEditingDomain(), dynamicTable, FormPackage.Literals.DYNAMIC_TABLE__MAX_NUMBER_OF_ROW, maxNumberOfRow)); } } /* * Synchronize with the model. * */ dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(textOrDataMinRow), EMFEditProperties.value(getEditingDomain(), FormPackage.Literals.DYNAMIC_TABLE__MIN_NUMBER_OF_ROW) .observe(dynamicTable)); dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(textOrDataMaxRow), EMFEditProperties.value(getEditingDomain(), FormPackage.Literals.DYNAMIC_TABLE__MAX_NUMBER_OF_ROW) .observe(dynamicTable)); dataBindingContext.bindValue(SWTObservables.observeSelection(limitMinRowButton), EMFEditObservables.observeValue(getEditingDomain(), dynamicTable, FormPackage.Literals.DYNAMIC_TABLE__LIMIT_MIN_NUMBER_OF_ROW)); dataBindingContext.bindValue(SWTObservables.observeSelection(limitMaxRowButton), EMFEditObservables.observeValue(getEditingDomain(), dynamicTable, FormPackage.Literals.DYNAMIC_TABLE__LIMIT_MAX_NUMBER_OF_ROW)); /* * Enable the combo only if we want to set a number limitation. * */ dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMinRow.getControl()), SWTObservables.observeSelection(limitMinRowButton)); dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMinRow.getTextControl()), SWTObservables.observeSelection(limitMinRowButton)); dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMinRow.getToolbar()), SWTObservables.observeSelection(limitMinRowButton)); dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMaxRow.getControl()), SWTObservables.observeSelection(limitMaxRowButton)); dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMaxRow.getTextControl()), SWTObservables.observeSelection(limitMaxRowButton)); dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMaxRow.getToolbar()), SWTObservables.observeSelection(limitMaxRowButton)); dataBindingContext.bindValue(SWTObservables.observeVisible(limitMinRowButton), EMFEditObservables.observeValue(getEditingDomain(), dynamicTable, FormPackage.Literals.DYNAMIC_TABLE__ALLOW_ADD_REMOVE_ROW), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); dataBindingContext.bindValue(SWTObservables.observeVisible(limitMaxRowButton), EMFEditObservables.observeValue(getEditingDomain(), dynamicTable, FormPackage.Literals.DYNAMIC_TABLE__ALLOW_ADD_REMOVE_ROW), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); dataBindingContext.bindValue(SWTObservables.observeVisible(textOrDataMinRow.getControl()), EMFEditObservables.observeValue(getEditingDomain(), dynamicTable, FormPackage.Literals.DYNAMIC_TABLE__ALLOW_ADD_REMOVE_ROW), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); dataBindingContext.bindValue(SWTObservables.observeVisible(textOrDataMaxRow.getControl()), EMFEditObservables.observeValue(getEditingDomain(), dynamicTable, FormPackage.Literals.DYNAMIC_TABLE__ALLOW_ADD_REMOVE_ROW), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); textOrDataMinRow.setInput(dynamicTable); textOrDataMaxRow.setInput(dynamicTable); }
From source file:org.bonitasoft.studio.properties.form.sections.actions.table.TableDataPropertySection.java
License:Open Source License
@Override protected void refreshDataBinding() { super.refreshDataBinding(); if (getEObject() != null) { UpdateValueStrategy not = new UpdateValueStrategy() .setConverter(new Converter(Boolean.class, Boolean.class) { public Object convert(Object fromObject) { return !((Boolean) fromObject); }//from ww w .java 2 s. c o m }); dataBindingContext.bindValue(SWTObservables.observeSelection(allowSelectionButton), EMFEditObservables .observeValue(getEditingDomain(), getEObject(), FormPackage.Literals.TABLE__ALLOW_SELECTION)); dataBindingContext.bindValue(SWTObservables.observeSelection(allowSingleSelection), EMFEditObservables.observeValue(getEditingDomain(), getEObject(), FormPackage.Literals.TABLE__SELECTION_MODE_IS_MULTIPLE), not, not); dataBindingContext.bindValue(SWTObservables.observeSelection(allowMultipleSelection), EMFEditObservables.observeValue(getEditingDomain(), getEObject(), FormPackage.Literals.TABLE__SELECTION_MODE_IS_MULTIPLE)); Expression maxRowForPagination = getEObject().getMaxRowForPagination(); if (maxRowForPagination == null) { maxRowForPagination = ExpressionFactory.eINSTANCE.createExpression(); getEditingDomain().getCommandStack().execute(SetCommand.create(getEditingDomain(), getEObject(), FormPackage.Literals.TABLE__MAX_ROW_FOR_PAGINATION, maxRowForPagination)); } dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(paginationMaxNumber), EMFEditProperties.value(getEditingDomain(), FormPackage.Literals.TABLE__MAX_ROW_FOR_PAGINATION) .observe(getEObject())); paginationMaxNumber.setInput(getEObject()); paginationMaxNumber.setEditingDomain(getEditingDomain()); dataBindingContext.bindValue(SWTObservables.observeEnabled(paginationMaxNumber.getTextControl()), EMFEditObservables.observeValue(getEditingDomain(), getEObject(), FormPackage.Literals.TABLE__ALLOW_SELECTION), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), not); dataBindingContext.bindValue(SWTObservables.observeEnabled(paginationMaxNumber.getButtonControl()), EMFEditObservables.observeValue(getEditingDomain(), getEObject(), FormPackage.Literals.TABLE__ALLOW_SELECTION), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), not); Expression selectedValues = getEObject().getMaxRowForPagination(); if (selectedValues == null) { selectedValues = ExpressionFactory.eINSTANCE.createExpression(); getEditingDomain().getCommandStack().execute(SetCommand.create(getEditingDomain(), getEObject(), FormPackage.Literals.TABLE__SELECTED_VALUES, selectedValues)); } dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(initialSelectedValues), EMFEditProperties.value(getEditingDomain(), FormPackage.Literals.TABLE__SELECTED_VALUES) .observe(getEObject())); initialSelectedValues.setInput(getEObject()); initialSelectedValues.setEditingDomain(getEditingDomain()); Expression columnForInitialSelectionIndex = getEObject().getColumnForInitialSelectionIndex(); if (columnForInitialSelectionIndex == null) { columnForInitialSelectionIndex = ExpressionFactory.eINSTANCE.createExpression(); getEditingDomain().getCommandStack() .execute(SetCommand.create(getEditingDomain(), getEObject(), FormPackage.Literals.TABLE__COLUMN_FOR_INITIAL_SELECTION_INDEX, columnForInitialSelectionIndex)); } dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(initialFromColumn), EMFEditProperties .value(getEditingDomain(), FormPackage.Literals.TABLE__COLUMN_FOR_INITIAL_SELECTION_INDEX) .observe(getEObject())); initialFromColumn.setInput(getEObject()); initialFromColumn.setEditingDomain(getEditingDomain()); /*Hide if no selection allowed*/ dataBindingContext.bindValue(SWTObservables.observeVisible(allowedSelectionCompo), EMFEditObservables.observeValue(getEditingDomain(), getEObject(), FormPackage.Literals.TABLE__ALLOW_SELECTION), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); dataBindingContext.bindValue(SWTObservables.observeVisible(allowSingleSelection), EMFEditObservables.observeValue(getEditingDomain(), getEObject(), FormPackage.Literals.TABLE__ALLOW_SELECTION), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); dataBindingContext.bindValue(SWTObservables.observeVisible(allowMultipleSelection), EMFEditObservables.observeValue(getEditingDomain(), getEObject(), FormPackage.Literals.TABLE__ALLOW_SELECTION), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); contrib.setEditingDomain(getEditingDomain()); contrib.setEObject(getEObject()); contrib.superBind(); } }
From source file:org.bonitasoft.studio.simulation.wizards.AddResourceAssignmentWizardPage.java
License:Open Source License
public void createControl(Composite parent) { context = new DataBindingContext(); Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayout(new GridLayout(3, false)); Label resourceIDLabel = new Label(mainComposite, SWT.NONE); resourceIDLabel.setText(Messages.resourceName); combo = new Combo(mainComposite, SWT.READ_ONLY); for (IRepositoryFileStore artifact : resourceStore.getChildren()) { combo.add(artifact.getDisplayName()); }/*ww w . j a v a 2 s.c om*/ if (combo.getItemCount() > 0) { combo.select(0); } if (resourceUsage != null && resourceUsage.getResourceID() != null) { combo.setText(resourceUsage.getResourceID()); } combo.setLayoutData(GridDataFactory.swtDefaults().hint(150, SWT.DEFAULT).create()); createResourceButton = new Button(mainComposite, SWT.FLAT); createResourceButton.setText(Messages.create); createResourceButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { EditSimulationResourceWizard wiz = new EditSimulationResourceWizard(); if (new WizardDialog(Display.getCurrent().getActiveShell(), wiz).open() == WizardDialog.OK) { combo.removeAll(); for (IRepositoryFileStore artifact : resourceStore.getChildren()) { combo.add(artifact.getDisplayName()); } combo.setText(wiz.getArtifact().getDisplayName()); getContainer().updateButtons(); } } }); Label quantityLabel = new Label(mainComposite, SWT.NONE); quantityLabel.setText(Messages.quantity); quantityText = new Text(mainComposite, SWT.BORDER); quantityText.setLayoutData(GridDataFactory.swtDefaults().hint(130, SWT.DEFAULT).span(2, 1).create()); if (resourceUsage != null) { quantityText.setText(String.valueOf(resourceUsage.getQuantity())); } else { quantityText.setText("1");//$NON-NLS-1$ } Label durationLabel = new Label(mainComposite, SWT.NONE); durationLabel.setText(Messages.duration); Composite radioComposite = new Composite(mainComposite, SWT.NONE); radioComposite .setLayoutData(GridDataFactory.swtDefaults().hint(SWT.DEFAULT, SWT.DEFAULT).span(2, 1).create()); radioComposite.setLayout(new GridLayout(2, false)); useActivity = new Button(radioComposite, SWT.RADIO); useActivity.setText(Messages.AddResourceAssignmentWizardPage_useActivity); Button useCustom = new Button(radioComposite, SWT.RADIO); useCustom.setText(Messages.AddResourceAssignmentWizardPage_useCustom); if (resourceUsage != null) { useActivity.setSelection(resourceUsage.isUseActivityDuration()); useCustom.setSelection(!resourceUsage.isUseActivityDuration()); } else { useActivity.setSelection(true); useCustom.setSelection(false); } durationWidget = new DurationComposite(mainComposite, false, false, true, true, true, true, null); durationWidget.setLayoutData(GridDataFactory.fillDefaults().span(3, 1).create()); if (activity != null) { durationWidget.setMaxDuration(activity.getExecutionTime()); if (resourceUsage != null) { durationWidget.setDuration(resourceUsage.getDuration()); } else { durationWidget.setDuration(activity.getExecutionTime()); } } context.bindValue(SWTObservables.observeVisible(durationWidget), SWTObservables.observeSelection(useCustom)); setControl(mainComposite); getContainer().updateButtons(); }
From source file:org.bonitasoft.studio.simulation.wizards.AddSimulationDataWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { final Composite composite = new Composite(parent, SWT.NONE); context = new DataBindingContext(); WizardPageSupport.create(this, context); composite.setLayout(new GridLayout(2, false)); createNameAndDescription(composite); createTypeCombo(composite);// w w w. j ava 2 s. co m configStackComposite = new Composite(composite, SWT.NONE); sLayout = new StackLayout(); configStackComposite.setLayout(sLayout); configStackComposite.setLayoutData( GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT, 200).create()); Composite booleanComposite = createBooleanConfigurationComposite(configStackComposite); configCompositeMap.put(SimulationPackage.eINSTANCE.getSimulationBoolean(), booleanComposite); Composite literalsComposite = createLiteralsConfigurationComposite(configStackComposite); configCompositeMap.put(SimulationPackage.eINSTANCE.getSimulationLiteralData(), literalsComposite); Composite numberComposite = createNumberConfigurationComposite(configStackComposite); configCompositeMap.put(SimulationPackage.eINSTANCE.getSimulationNumberData(), numberComposite); context.bindValue(SWTObservables.observeVisible(configStackComposite), SWTObservables.observeSelection(isExpressionBased), null, new UpdateValueStrategy().setConverter( new org.eclipse.core.databinding.conversion.Converter(Boolean.class, Boolean.class) { @Override public Object convert(Object fromObject) { return !((Boolean) fromObject); } })); /* So like that it forces call to isPageCOmplete after that the model is updated. * what would be even better it to implement validator on each related bindings instead of doing the work in isPageComplete * */ WizardPageSupport.create(this, context); changeDataConfigurationComposite( (EClass) ((IStructuredSelection) datatypeCombo.getSelection()).getFirstElement()); setControl(composite); }
From source file:org.bonitasoft.studio.simulation.wizards.AddSimulationDataWizardPage.java
License:Open Source License
private void createNameAndDescription(Composite composite) { Label nameLabel = new Label(composite, SWT.NONE); nameLabel.setText(Messages.dataNameLabel); final Text labelText = new Text(composite, SWT.BORDER); labelText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); // Add an validator so that age can only be a number IValidator validator = new IValidator() { Set<String> existingDataNames = null; @Override/*from ww w . jav a 2s. c o m*/ public IStatus validate(Object arg0) { if (existingDataNames == null) { existingDataNames = new HashSet<String>(); if (element != null) { for (SimulationData simuData : element.getSimulationData()) { existingDataNames.add(simuData.getName()); } } } if (existingDataNames.contains(labelText.getText())) { return ValidationStatus.error("Data name already exists."); } return ValidationStatus.ok(); } }; UpdateValueStrategy strategy = new UpdateValueStrategy(); strategy.setBeforeSetValidator(validator); Binding bindingDataName = context.bindValue(SWTObservables.observeText(labelText, SWT.Modify), PojoObservables.observeValue(this, "dataName"), strategy, null); ControlDecorationSupport.create(bindingDataName, SWT.TOP | SWT.LEFT); //labelText.addModifyListener(updateButtonModifyListener) ; Label isExpressionLabel = new Label(composite, SWT.NONE); isExpressionLabel.setText(Messages.BasedOn); Composite radioBasedComposite = new Composite(composite, SWT.NONE); radioBasedComposite.setLayout(new GridLayout(2, true)); isExpressionBased = new Button(radioBasedComposite, SWT.RADIO); isExpressionBased.setText(Messages.Expression); isExpressionBased.setSelection(expressionBased); isOtherBased = new Button(radioBasedComposite, SWT.RADIO); isOtherBased.setSelection(!expressionBased); isOtherBased.setText(Messages.AddSimulationDataWizardPage_probability); context.bindValue(SWTObservables.observeSelection(isExpressionBased), PojoObservables.observeValue(this, "expressionBased")); context.bindValue(SWTObservables.observeSelection(isOtherBased), PojoObservables.observeValue(this, "expressionBased"), new UpdateValueStrategy().setConverter(new Converter(Boolean.class, Boolean.class) { @Override public Object convert(Object fromObject) { return !(Boolean) fromObject; } }), new UpdateValueStrategy().setConverter(new Converter(Boolean.class, Boolean.class) { @Override public Object convert(Object fromObject) { return !(Boolean) fromObject; } })); Label expressionLabel = new Label(composite, SWT.NONE); expressionLabel.setText(Messages.Expression); ExpressionViewer expressionViewer = new ExpressionViewer(composite, SWT.BORDER, null);//FIXME: Expressionviewer expressionViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); if (element != null) { expressionViewer.setInput(element); } else { expressionViewer.setInput(data.eContainer()); } expressionViewer.addFilter(new AvailableExpressionTypeFilter( new String[] { ExpressionConstants.CONSTANT_TYPE, ExpressionConstants.VARIABLE_TYPE, ExpressionConstants.SCRIPT_TYPE, ExpressionConstants.SIMULATION_VARIABLE_TYPE })); expressionViewer.setSelection(new StructuredSelection(dataExpression)); context.bindValue(SWTObservables.observeVisible(expressionLabel), SWTObservables.observeSelection(isExpressionBased)); context.bindValue(SWTObservables.observeVisible(expressionViewer.getControl()), SWTObservables.observeSelection(isExpressionBased)); isOtherBased.addSelectionListener(updateButtonSelectionListener); isExpressionBased.addSelectionListener(updateButtonSelectionListener); }
From source file:org.eclipse.rcptt.internal.launching.ext.ui.wizards.NewAUTPage.java
License:Open Source License
private void createControlArch(final Composite parent) { Label archLabel = new Label(parent, SWT.NONE); archLabel.setText("Architecture:"); Composite archGroup = new Composite(parent, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(true).applyTo(archGroup); GridDataFactory.fillDefaults().span(1, 1).grab(true, false).applyTo(archGroup); Button b32 = new Button(archGroup, SWT.RADIO); Button b64 = new Button(archGroup, SWT.RADIO); b32.setText("32bit"); b64.setText("64bit"); dbc.bindValue(SWTObservables.observeEnabled(b32), archEnabled); dbc.bindValue(SWTObservables.observeEnabled(b64), archEnabled); dbc.bindValue(SWTObservables.observeSelection(b64), platformArchitecture64); dbc.bindValue(SWTObservables.observeSelection(b32), platformArchitecture32); final Link archLink = new Link(parent, SWT.UNDERLINE_LINK); archLink.setText("There is no appropriate JVM configured. <a>Configure JVM...</a>"); GridDataFactory.fillDefaults().span(3, 1).grab(true, false).applyTo(archLink); archLink.addSelectionListener(new SelectionAdapter() { @Override/*from w w w .j a v a 2 s . com*/ public void widgetSelected(SelectionEvent e) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, JREsPreferencePage.ID, new String[] { JREsPreferencePage.ID }, null); if (dialog.open() == PreferenceDialog.OK) { validatePlatform(); } } }); ISWTObservableValue archLinkObservable = SWTObservables.observeVisible(archLink); archLinkObservable.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { // Hides container as well (like "display: none") GridData data = (GridData) archLink.getLayoutData(); data.exclude = !archLink.getVisible(); parent.layout(false); } }); dbc.bindValue(archLinkObservable, architectureError); }
From source file:org.eclipse.rcptt.internal.launching.ext.ui.wizards.NewAUTPage.java
License:Open Source License
private void createControlAdvanced(Composite parent) { final Link advanced = new Link(parent, SWT.UNDERLINE_LINK); advanced.setText("<a>Advanced...</a>"); GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).span(3, 1).grab(true, false).applyTo(advanced); advanced.addSelectionListener(new SelectionAdapter() { @Override/* w ww . j a v a 2 s.c o m*/ public void widgetSelected(SelectionEvent e) { if (advancedHandler != null) { advancedHandler.run(); } } }); dbc.bindValue(SWTObservables.observeVisible(advanced), showAdvanced); }
From source file:org.kalypso.gml.ui.internal.feature.editProperties.EditFeaturePropertiesPage.java
License:Open Source License
private void createRadioGroup(final Composite parent) { final Group radioButtonGroup = new Group(parent, SWT.SHADOW_ETCHED_IN); radioButtonGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); radioButtonGroup//from w ww .j av a 2s . c o m .setText(Messages.getString("org.kalypso.ui.editor.actions.FeatureBatchEditActionDelegate.3")); //$NON-NLS-1$ GridLayoutFactory.swtDefaults().applyTo(radioButtonGroup); final FeaturePropertyOperation currentOperation = m_data.getOperation(); final EditFeaturePropertiesData data = m_data; for (final FeaturePropertyOperation operation : FeaturePropertyOperation.values()) { final String label = operation.toString(); final String tooltip = operation.getDescription(); final Button radio = new Button(radioButtonGroup, SWT.RADIO); radio.setText(label); radio.setToolTipText(tooltip); radio.setSelection(operation == currentOperation); radio.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final org.eclipse.swt.events.SelectionEvent e) { if (radio.getSelection()) data.setOperation(operation); } }); } final ISWTObservableValue target = SWTObservables.observeVisible(radioButtonGroup); final IObservableValue model = BeansObservables.observeValue(m_data, EditFeaturePropertiesData.PROPERTY_ISNUMERIC); m_binding.bindValue(target, model); }