List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeSelection
@Deprecated public static ISWTObservableValue observeSelection(Control control)
control
. From source file:net.sf.rcer.conn.ui.preferences.ConnectionsPreferencePage.java
License:Open Source License
/** * Initializes the data binding for the user interface components. *//*from w w w. j av a2s . com*/ private void bindControls() { UpdateValueStrategy targetToModel; context = new DataBindingContext(); // observe changes in the selection of the connection list IObservableValue selection = ViewersObservables.observeSingleSelection(connectionViewer); // bind the description (String, may not be empty) context.bindValue(SWTObservables.observeText(descriptionText, SWT.Modify), BeansObservables.observeDetailValue(selection, "description", String.class), //$NON-NLS-1$ new UpdateValueStrategy().setBeforeSetValidator( new NotEmptyValidator(Messages.ConnectionsPreferencePage_DescriptionEmptyError)), new UpdateValueStrategy()); // bind the connection type IObservableValue connectionTypeObservable = BeansObservables.observeDetailValue(selection, "connectionType", //$NON-NLS-1$ ConnectionType.class); context.bindValue(SWTObservables.observeSelection(connectionTypeCombo), connectionTypeObservable, new UpdateValueStrategy().setConverter(new ConnectionTypeFromStringConverter()), new UpdateValueStrategy().setConverter(new ConnectionTypeToStringConverter())); // bind the system ID context.bindValue(SWTObservables.observeText(sidText, SWT.Modify), BeansObservables.observeDetailValue(selection, "systemID", String.class), //$NON-NLS-1$ new UpdateValueStrategy().setBeforeSetValidator( new StringLengthValidator(Messages.ConnectionsPreferencePage_SystemIDValidator, 3, 3)), new UpdateValueStrategy()); // bind the router context.bindValue(SWTObservables.observeText(routerText, SWT.Modify), BeansObservables.observeDetailValue(selection, "router", String.class), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); // bind the application server context.bindValue(SWTObservables.observeText(applicationServerText, SWT.Modify), BeansObservables.observeDetailValue(selection, "applicationServer", String.class), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); new VisibilityUpdater(details, applicationServerText, applicationServerLabel, connectionTypeObservable, ConnectionType.DIRECT); // TODO #002 ensure that the app server is required for direct connections // bind the system number targetToModel = new UpdateValueStrategy(); targetToModel.setConverter(StringToNumberConverter.toInteger(true)); // TODO #002 ensure that the system number is required for direct connections // targetToModel.setAfterGetValidator(new ConditionalNotEmptyValidator( // connectionTypeObservable, ConnectionType.DIRECT, "System Number must be set for direct connections.")); targetToModel.setBeforeSetValidator( new IntegerRangeValidator(Messages.ConnectionsPreferencePage_SystemNumberValidator, 0, 99)); context.bindValue(SWTObservables.observeText(systemNumberText, SWT.Modify), BeansObservables.observeDetailValue(selection, "systemNumber", null), //$NON-NLS-1$ targetToModel, new UpdateValueStrategy().setConverter(NumberToStringConverter.fromInteger(true))); new VisibilityUpdater(details, systemNumberText, systemNumberLabel, connectionTypeObservable, ConnectionType.DIRECT); // bind the message server context.bindValue(SWTObservables.observeText(messageServerText, SWT.Modify), BeansObservables.observeDetailValue(selection, "messageServer", String.class), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); new VisibilityUpdater(details, messageServerText, messageServerLabel, connectionTypeObservable, ConnectionType.LOAD_BALANCED); // TODO #002 ensure that the message server is required for lb connections // bind the message server port context.bindValue(SWTObservables.observeText(messageServerPortText, SWT.Modify), BeansObservables.observeDetailValue(selection, "messageServerPort", null), //$NON-NLS-1$ new UpdateValueStrategy().setConverter(StringToNumberConverter.toInteger(true)), new UpdateValueStrategy().setConverter(NumberToStringConverter.fromInteger(true))); new VisibilityUpdater(details, messageServerPortText, messageServerPortLabel, connectionTypeObservable, ConnectionType.LOAD_BALANCED); // TODO #002 ensure that the port is required for lb connections // bind the logon group context.bindValue(SWTObservables.observeText(logonGroupText, SWT.Modify), BeansObservables.observeDetailValue(selection, "loadBalancingGroup", String.class), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); new VisibilityUpdater(details, logonGroupText, logonGroupLabel, connectionTypeObservable, ConnectionType.LOAD_BALANCED); // TODO #002 ensure that the logon group is required for lb connections // bind the default client context.bindValue(SWTObservables.observeText(defaultClientText, SWT.Modify), BeansObservables.observeDetailValue(selection, "defaultClient", String.class), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); // bind the default user context.bindValue(SWTObservables.observeText(defaultUserText, SWT.Modify), BeansObservables.observeDetailValue(selection, "defaultUser", String.class), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); // bind the default locale context.bindValue(SWTObservables.observeSelection(defaultLocaleCombo), BeansObservables.observeDetailValue(selection, "defaultLocale", Locale.class), //$NON-NLS-1$ new UpdateValueStrategy().setConverter(new LocaleFromStringConverter()), new UpdateValueStrategy().setConverter(new LocaleToStringConverter(false))); // supply the error label with the aggregated status context.bindValue(SWTObservables.observeText(errorDisplayLabel), new AggregateValidationStatus(context.getBindings(), AggregateValidationStatus.MAX_SEVERITY), null, null); // provide the connection list with input data connectionViewer.setContentProvider(new ObservableListContentProvider()); connectionViewer.setInput(connections); // select the first entry, if any exist if (connections.size() > 0) { connectionViewer.setSelection(new StructuredSelection(connections.get(0))); } }
From source file:net.sf.rcer.jcoimport.SummaryPage.java
License:Open Source License
public void createControl(Composite parent) { Composite top = new Composite(parent, SWT.NONE); GridLayoutFactory.swtDefaults().applyTo(top); Label info = new Label(top, SWT.NONE); info.setText(Messages.SummaryPage_InfoLabel); checkboxPlugin = new Button(top, SWT.CHECK); context.bindValue(SWTObservables.observeSelection(checkboxPlugin), BeansObservables.observeValue(generatorSettings, "pluginProjectSelected"), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); checkboxDocPlugin = new Button(top, SWT.CHECK); context.bindValue(SWTObservables.observeSelection(checkboxDocPlugin), BeansObservables.observeValue(generatorSettings, "docPluginProjectSelected"), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); checkboxIDocPlugin = new Button(top, SWT.CHECK); context.bindValue(SWTObservables.observeSelection(checkboxIDocPlugin), BeansObservables.observeValue(generatorSettings, "IDocPluginProjectSelected"), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); checkboxFragmentWin32 = new Button(top, SWT.CHECK); context.bindValue(SWTObservables.observeSelection(checkboxFragmentWin32), BeansObservables.observeValue(generatorSettings, "win32FragmentSelected"), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); checkboxFragmentWin64IA = new Button(top, SWT.CHECK); context.bindValue(SWTObservables.observeSelection(checkboxFragmentWin64IA), BeansObservables.observeValue(generatorSettings, "win64IAFragmentSelected"), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); checkboxFragmentWin64x86 = new Button(top, SWT.CHECK); context.bindValue(SWTObservables.observeSelection(checkboxFragmentWin64x86), BeansObservables.observeValue(generatorSettings, "win64x86FragmentSelected"), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); checkboxFragmentLinux32 = new Button(top, SWT.CHECK); context.bindValue(SWTObservables.observeSelection(checkboxFragmentLinux32), BeansObservables.observeValue(generatorSettings, "linux32FragmentSelected"), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); checkboxFragmentLinux64IA = new Button(top, SWT.CHECK); context.bindValue(SWTObservables.observeSelection(checkboxFragmentLinux64IA), BeansObservables.observeValue(generatorSettings, "linux64IAFragmentSelected"), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); checkboxFragmentLinux64x86 = new Button(top, SWT.CHECK); context.bindValue(SWTObservables.observeSelection(checkboxFragmentLinux64x86), BeansObservables.observeValue(generatorSettings, "linux64x86FragmentSelected"), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); checkboxFragmentDarwin32 = new Button(top, SWT.CHECK); context.bindValue(SWTObservables.observeSelection(checkboxFragmentDarwin32), BeansObservables.observeValue(generatorSettings, "darwin32FragmentSelected"), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); checkboxFragmentDarwin64 = new Button(top, SWT.CHECK); context.bindValue(SWTObservables.observeSelection(checkboxFragmentDarwin64), BeansObservables.observeValue(generatorSettings, "darwin64FragmentSelected"), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); @SuppressWarnings("unused") Label spacer = new Label(top, SWT.NONE); Composite export = new Composite(top, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(export); checkboxExportBundles = new Button(export, SWT.CHECK); GridDataFactory.swtDefaults().span(2, 1).applyTo(checkboxExportBundles); checkboxExportBundles.setText(Messages.SummaryPage_ExportToDropinsLabel); context.bindValue(SWTObservables.observeSelection(checkboxExportBundles), BeansObservables.observeValue(generatorSettings, "bundleExportSelected"), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); Label exportLabel = new Label(export, SWT.NONE); exportLabel.setText(Messages.SummaryPage_TargetPathLabel); Text exportPathText = new Text(export, SWT.SINGLE | SWT.BORDER); GridDataFactory.swtDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(exportPathText); context.bindValue(SWTObservables.observeText(exportPathText, SWT.Modify), BeansObservables.observeValue(generatorSettings, "exportPath"), //$NON-NLS-1$ new UpdateValueStrategy(), new UpdateValueStrategy()); // TODO validate the target path updateCheckboxes();//from w w w. j ava 2 s.c om setControl(top); Dialog.applyDialogFont(top); }
From source file:net.sourceforge.appgen.editor.MappingDataEditor.java
License:Apache License
private void bindValues() { dataBindingContext = new DataBindingContext(); UpdateValueStrategy fileUpdateValueStrategy = new UpdateValueStrategy(); fileUpdateValueStrategy.setConverter(new StringToFileConverter()); ConnectionInformation connectionInformation = mappingData.getConnectionInformation(); GenerationInformation generationInformation = mappingData.getGenerationInformation(); dataBindingContext.bindValue(SWTObservables.observeSelection(databaseNameCombo), BeansObservables.observeValue(connectionInformation, "name"), null, null); dataBindingContext.bindValue(SWTObservables.observeText(databaseSchemaText, SWT.Modify), BeansObservables.observeValue(connectionInformation, "schema"), null, null); dataBindingContext.bindValue(SWTObservables.observeText(outputDirText, SWT.Modify), BeansObservables.observeValue(generationInformation, "outputDir"), fileUpdateValueStrategy, null); dataBindingContext.bindValue(SWTObservables.observeText(packageNameText, SWT.Modify), BeansObservables.observeValue(generationInformation, "packageName"), null, null); }
From source file:org.bonitasoft.studio.actors.ui.section.AssignableActorsPropertySection.java
License:Open Source License
@Override protected void updateDatabinding() { super.updateDatabinding(); actorDefinedInLaneLabel.setText(""); final Assignable assignable = (Assignable) getEObject(); if (assignable != null) { EObject current = assignable;/*from w w w . j av a2 s . com*/ while (current != null && !(current instanceof Lane)) { current = current.eContainer(); } useLaneActorButton.setEnabled(current instanceof Lane); final IObservableValue value = EMFEditObservables.observeValue(getEditingDomain(), assignable, ProcessPackage.Literals.TASK__OVERRIDE_ACTORS_OF_THE_LANE); emfDatabindingContext.bindValue(SWTObservables.observeSelection(taskActorButton), value); emfDatabindingContext.bindValue(SWTObservables.observeSelection(useLaneActorButton), value, new UpdateValueStrategy(), new UpdateValueStrategy().setConverter(new Converter(Boolean.class, Boolean.class) { @Override public Object convert(Object from) { return !(Boolean) from; } })); final UpdateValueStrategy updateValueStrategy = new UpdateValueStrategy() .setConverter(new Converter(Boolean.class, Boolean.class) { @Override public Object convert(Object from) { return !(Boolean) from; } }); emfDatabindingContext.bindValue(SWTObservables.observeEnabled(actorComboViewer.getControl()), SWTObservables.observeSelection(useLaneActorButton), new UpdateValueStrategy(), updateValueStrategy); databindactorDefinedInLaneLabel(assignable); } }
From source file:org.bonitasoft.studio.actors.ui.wizard.page.UsersWizardPage.java
License:Open Source License
private void refreshBinding(final User selectedUser) { if (context != null) { context.dispose();// ww w .jav a2s. c o m } if (pageSupport != null) { pageSupport.dispose(); } context = new EMFDataBindingContext(); userMemberShips.clear(); if (selectedUser != null) { setControlEnabled(getInfoGroup(), true); if (userList != null) { managerNameCombo.removeAll(); managerNameCombo.add(""); for (User u : userList) { if (!u.equals(selectedUser)) { managerNameCombo.add(u.getUserName()); } } } UpdateValueStrategy strategy = new UpdateValueStrategy(); strategy.setConverter(new Converter(String.class, String.class) { @Override public Object convert(Object fromObject) { if (userList != null) { for (User u : userList) { if (selectedUser != null && u.getManager() != null && u.getManager().equals(selectedUser.getUserName())) { u.setManager((String) fromObject); } } } return fromObject; } }); userNameValidator.setValidator(new IValidator() { @Override public IStatus validate(Object value) { if (value.toString().isEmpty()) { return ValidationStatus.error(Messages.nameIsEmpty); } for (User u : userList) { if (!u.equals(selectedUser)) { if (u.getUserName().equals(value)) { return ValidationStatus.error(Messages.userNameAlreadyExists); } } } return Status.OK_STATUS; } }); strategy.setAfterGetValidator(userNameValidator); IObservableValue value = EMFObservables.observeValue(selectedUser, OrganizationPackage.Literals.USER__USER_NAME); value.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(ValueChangeEvent event) { User user = (User) ((EObjectObservableValue) event.getObservable()).getObserved(); String oldUserValue = event.diff.getOldValue().toString(); for (Membership m : userMemberShips) { m.setUserName(user.getUserName()); } // managerNameCombo.removeAll() ; // managerNameCombo.add("") ; updateDelegueeMembership(event.diff.getOldValue().toString(), event.diff.getNewValue().toString()); getViewer().refresh(user); } }); context.bindValue( SWTObservables.observeDelayedValue(500, SWTObservables.observeText(usernameText, SWT.Modify)), value, strategy, null); UpdateValueStrategy mandatoryStrategy = new UpdateValueStrategy(); passwordValidator.setValidator(new EmptyInputValidator(Messages.password)); mandatoryStrategy.setAfterGetValidator(passwordValidator); IObservableValue observeValue = EMFObservables.observeValue(selectedUser.getPassword(), OrganizationPackage.Literals.PASSWORD_TYPE__VALUE); context.bindValue(SWTObservables.observeText(passwordText, SWT.Modify), observeValue, mandatoryStrategy, null); observeValue.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(ValueChangeEvent event) { IObservableValue value = event.getObservableValue(); PasswordType password = (PasswordType) ((EObjectObservableValue) value).getObserved(); password.setEncrypted(false); } }); context.bindValue(SWTObservables.observeSelection(managerNameCombo), EMFObservables.observeValue(selectedUser, OrganizationPackage.Literals.USER__MANAGER)); for (Entry<EAttribute, Control> entry : generalWidgetMap.entrySet()) { EAttribute attributre = entry.getKey(); Control control = entry.getValue(); if (!control.isDisposed()) { IObservableValue observableValue = EMFObservables.observeValue(selectedUser, attributre); UpdateValueStrategy mandatoryStartegy = null; if (attributre.equals(OrganizationPackage.Literals.USER__FIRST_NAME) || attributre.equals(OrganizationPackage.Literals.USER__LAST_NAME)) { observableValue.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(ValueChangeEvent event) { getViewer().refresh(((EObjectObservableValue) event.getObservable()).getObserved()); } }); mandatoryStartegy = new UpdateValueStrategy(); if (attributre.equals(OrganizationPackage.Literals.USER__FIRST_NAME)) { mandatoryStartegy.setAfterGetValidator(new EmptyInputValidator(Messages.firstName)); } else if (attributre.equals(OrganizationPackage.Literals.USER__LAST_NAME)) { mandatoryStartegy.setAfterGetValidator(new EmptyInputValidator(Messages.lastName)); } } if (mandatoryStartegy != null) { ControlDecorationSupport .create(context.bindValue(SWTObservables.observeText(control, SWT.Modify), observableValue, mandatoryStartegy, null), SWT.LEFT); } else { context.bindValue(SWTObservables.observeText(control, SWT.Modify), observableValue); } } } if (selectedUser.getPersonalData() == null) { selectedUser.setPersonalData(OrganizationFactory.eINSTANCE.createContactData()); } for (Entry<EAttribute, Control> entry : personalWidgetMap.entrySet()) { EAttribute attributre = entry.getKey(); Control control = entry.getValue(); if (!control.isDisposed()) { IObservableValue observableValue = EMFObservables.observeValue(selectedUser.getPersonalData(), attributre); context.bindValue(SWTObservables.observeText(control, SWT.Modify), observableValue); } } if (selectedUser.getProfessionalData() == null) { selectedUser.setProfessionalData(OrganizationFactory.eINSTANCE.createContactData()); } for (Entry<EAttribute, Control> entry : professionalWidgetMap.entrySet()) { EAttribute attributre = entry.getKey(); Control control = entry.getValue(); if (!control.isDisposed()) { context.bindValue(SWTObservables.observeText(control, SWT.Modify), EMFObservables.observeValue(selectedUser.getProfessionalData(), attributre)); } } for (Entry<Metadata, Control> entry : metadataWidgetMap.entrySet()) { Metadata metadata = entry.getKey(); Control control = entry.getValue(); if (!control.isDisposed()) { context.bindValue(SWTObservables.observeText(control, SWT.Modify), EMFObservables.observeValue(metadata, OrganizationPackage.Literals.METADATA__VALUE)); } } for (Entry<Membership, Map<EAttribute, Control>> entry : membershipWidgetMap.entrySet()) { final Membership membership = entry.getKey(); final Map<EAttribute, Control> controls = entry.getValue(); for (Entry<EAttribute, Control> e : controls.entrySet()) { final EAttribute attributre = e.getKey(); final Control control = e.getValue(); if (!control.isDisposed()) { UpdateValueStrategy selectionStrategy = new UpdateValueStrategy(); selectionStrategy.setAfterConvertValidator(new IValidator() { @Override public IStatus validate(Object value) { if (value == null || value.toString().isEmpty()) { return ValidationStatus.error(Messages.emtpyMembershipValue); } return Status.OK_STATUS; } }); if (attributre.equals(OrganizationPackage.Literals.MEMBERSHIP__GROUP_NAME)) { selectionStrategy.setConverter(new Converter(String.class, String.class) { @Override public Object convert(Object from) { String path = (String) from; if (!path.isEmpty()) { String parentPath = path.substring(0, path.lastIndexOf(GroupContentProvider.GROUP_SEPARATOR)); String groupName = path.substring( path.lastIndexOf(GroupContentProvider.GROUP_SEPARATOR) + 1, path.length()); if (parentPath.isEmpty()) { membership.setGroupParentPath(null); } else { membership.setGroupParentPath(parentPath); } return groupName; } else { return ""; } } }); } UpdateValueStrategy modelStrategy = null; if (attributre.equals(OrganizationPackage.Literals.MEMBERSHIP__GROUP_NAME)) { modelStrategy = new UpdateValueStrategy(); modelStrategy.setConverter(new Converter(String.class, String.class) { @Override public Object convert(Object from) { if (membership.getGroupParentPath() != null && !membership.getGroupParentPath().isEmpty()) { String parentPath = membership.getGroupParentPath(); if (!membership.getGroupParentPath() .endsWith(GroupContentProvider.GROUP_SEPARATOR)) { parentPath = parentPath + GroupContentProvider.GROUP_SEPARATOR; } String path = parentPath + from; return path; } else if (from != null && !from.toString().isEmpty()) { return GroupContentProvider.GROUP_SEPARATOR + membership.getGroupName(); } else { return ""; } } }); } ControlDecorationSupport.create(context.bindValue(SWTObservables.observeSelection(control), EMFObservables.observeValue(membership, attributre), selectionStrategy, modelStrategy), SWT.LEFT); } } } pageSupport = WizardPageSupportWithoutMessages.create(this, context); } else { setControlEnabled(getInfoGroup(), false); } }
From source file:org.bonitasoft.studio.businessobject.ui.wizard.BusinessObjectDataWizardPage.java
License:Open Source License
protected void createIsMultipleControl(final Composite mainComposite, final EMFDataBindingContext ctx) { new Label(mainComposite, SWT.NONE); final Button multipleCheckbox = new Button(mainComposite, SWT.CHECK); multipleCheckbox.setLayoutData(fillDefaults().grab(true, false).create()); multipleCheckbox.setText(Messages.multipleBusinessData); multipleObservableValue = EMFObservables.observeValue(businessObjectData, ProcessPackage.Literals.DATA__MULTIPLE); ctx.bindValue(SWTObservables.observeSelection(multipleCheckbox), multipleObservableValue); }
From source file:org.bonitasoft.studio.businessobject.ui.wizard.control.AttributesTabItemControl.java
License:Open Source License
private Composite createRelationFieldDetailContent(final Group detailGroup, final DataBindingContext ctx, final IViewerObservableValue attributeSelectionObservable, final IViewerObservableValue viewerObservableValue) { final Composite composite = new Composite(detailGroup, SWT.NONE); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); composite/*from w w w. j a va2s. co m*/ .setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).spacing(15, 10).create()); final Label relationKindLabel = new Label(composite, SWT.NONE); relationKindLabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).create()); relationKindLabel.setText(Messages.relation); final ControlDecoration controlDecoration = new ControlDecoration(relationKindLabel, SWT.RIGHT); controlDecoration.setDescriptionText(Messages.realtionTooltip); controlDecoration.setImage(Pics.getImage(PicsConstants.hint)); controlDecoration.setMarginWidth(-2); final ComboViewer relationComboViewer = new ComboViewer(composite, SWT.BORDER | SWT.READ_ONLY); relationComboViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); relationComboViewer.setContentProvider(ArrayContentProvider.getInstance()); relationComboViewer.setLabelProvider(new RelationKindLabelProvider()); relationComboViewer.setInput(RelationField.Type.values()); ctx.bindValue(ViewersObservables.observeSingleSelection(relationComboViewer), PojoObservables.observeDetailValue(attributeSelectionObservable, "type", Type.class)); new Label(composite, SWT.NONE); final Composite lazyRadioComposite = new Composite(composite, SWT.NONE); lazyRadioComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); lazyRadioComposite .setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).spacing(25, 0).create()); final Button lazyRadio = new Button(lazyRadioComposite, SWT.RADIO); lazyRadio.setLayoutData(GridDataFactory.swtDefaults().grab(false, false).create()); lazyRadio.setText(Messages.loadOnDemand); final ControlDecoration lazyDecorator = new ControlDecoration(lazyRadio, SWT.RIGHT); lazyDecorator.setImage(Pics.getImage(PicsConstants.hint)); lazyDecorator.setDescriptionText(Messages.loadOnDemandHint); lazyDecorator.setMarginWidth(-5); final Button eagerRadio = new Button(lazyRadioComposite, SWT.RADIO); eagerRadio.setLayoutData(GridDataFactory.swtDefaults().grab(false, false).create()); eagerRadio.setText(Messages.alwaysLoad); final ControlDecoration eagerDecorator = new ControlDecoration(eagerRadio, SWT.RIGHT); eagerDecorator.setImage(Pics.getImage(PicsConstants.hint)); eagerDecorator.setMarginWidth(-5); viewerObservableValue.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(final ValueChangeEvent event) { final BusinessObject bo = (BusinessObject) event.diff.getNewValue(); if (bo != null) { eagerDecorator.setDescriptionText(Messages.bind(Messages.alwaysLoadHint, NamingUtils.getSimpleName(bo.getQualifiedName()))); } } }); final SelectObservableValue radioGroupObservable = new SelectObservableValue(FetchType.class); radioGroupObservable.addOption(FetchType.LAZY, SWTObservables.observeSelection(lazyRadio)); radioGroupObservable.addOption(FetchType.EAGER, SWTObservables.observeSelection(eagerRadio)); ctx.bindValue(radioGroupObservable, PojoObservables.observeDetailValue(attributeSelectionObservable, "fetchType", FetchType.class)); return composite; }
From source file:org.bonitasoft.studio.businessobject.ui.wizard.control.QueriesTabItemControl.java
License:Open Source License
protected void createControl(DataBindingContext ctx, final IViewerObservableValue viewerObservableValue) { setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.TOP).create()); setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(5, 5).create()); final Composite radioComposite = new Composite(this, SWT.NONE); radioComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, false).span(2, 1).create()); radioComposite.setLayout(/*from www . j a va 2 s.c o m*/ GridLayoutFactory.fillDefaults().numColumns(2).extendedMargins(5, 5, 5, 0).spacing(20, 0).create()); Button defaultQueriesRadioButton = new Button(radioComposite, SWT.RADIO); defaultQueriesRadioButton.setLayoutData(GridDataFactory.swtDefaults().create()); defaultQueriesRadioButton.setText(Messages.defaultQueriesOption); ControlDecoration controlDecoration = new ControlDecoration(defaultQueriesRadioButton, SWT.RIGHT); controlDecoration.setDescriptionText(Messages.defaultQueriesHint); controlDecoration.setImage(Pics.getImage(PicsConstants.hint)); controlDecoration.setShowOnlyOnFocus(false); controlDecoration.setMarginWidth(-5); Button customQueriesRadioButton = new Button(radioComposite, SWT.RADIO); customQueriesRadioButton.setText(Messages.customQueriesOption); final Composite stackComposite = new Composite(this, SWT.NONE); stackComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).create()); final StackLayout stackLayout = new StackLayout(); stackComposite.setLayout(stackLayout); final Composite defaultComposite = createDefaultQueriesControl(ctx, viewerObservableValue, stackComposite); final Composite customComposite = createCustomQueriesControl(ctx, viewerObservableValue, stackComposite); SelectObservableValue radioGroupObservable = new SelectObservableValue(String.class); radioGroupObservable.addOption(DEFAULT, SWTObservables.observeSelection(defaultQueriesRadioButton)); radioGroupObservable.addOption(CUSTOM, SWTObservables.observeSelection(customQueriesRadioButton)); radioGroupObservable.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(ValueChangeEvent event) { Object newValue = event.diff.getNewValue(); if (DEFAULT.equals(newValue)) { stackLayout.topControl = defaultComposite; } else { stackLayout.topControl = customComposite; } stackComposite.layout(); } }); defaultQueriesRadioButton.setSelection(true); stackLayout.topControl = defaultComposite; }
From source file:org.bonitasoft.studio.condition.ui.expression.ComparisonExpressionEditor.java
License:Open Source License
@Override public void bindExpression(EMFDataBindingContext dataBindingContext, EObject context, Expression inputExpression, ViewerFilter[] viewerTypeFilters, ExpressionViewer expressionViewer) { this.inputExpression = inputExpression; final IObservableValue contentModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__CONTENT); final IObservableValue nameModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__NAME); final IObservableValue dependenciesModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__REFERENCED_ELEMENTS); final IObservableValue autoDepsModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__AUTOMATIC_DEPENDENCIES); final IObservableValue returnTypeModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE); final ISWTObservableValue observeText = SWTObservables .observeText(comparisonEditor.getViewer().getControl(), SWT.Modify); dataBindingContext.bindValue(observeText, contentModelObservable); observeText.addValueChangeListener(new IValueChangeListener() { @Override/*w ww .j a v a2s . co m*/ public void handleValueChange(ValueChangeEvent event) { if (ComparisonExpressionEditor.this.inputExpression.isAutomaticDependencies()) { updateDependencies(); } } }); dataBindingContext.bindValue(observeText, nameModelObservable); 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)); dependencySection.setExpanded(!automaticResolutionButton.getSelection()); addDependencyButton.setEnabled(!inputExpression.isAutomaticDependencies()); ControlDecorationSupport.create(dataBindingContext.bindValue( ViewersObservables.observeSingleSelection(typeCombo), returnTypeModelObservable), SWT.LEFT); typeCombo.getCombo().setEnabled(!inputExpression.isReturnTypeFixed()); 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 && viewerTypeFilters != null) { for (Expression exp : expressions) { for (ViewerFilter filter : viewerTypeFilters) { if (filter != null && !filter.select(comparisonEditor.getViewer(), input, exp)) { filteredExpressions.remove(exp); } } } } } addDependencyButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SelectDependencyDialog dialog = new SelectDependencyDialog(Display.getDefault().getActiveShell(), filteredExpressions, ComparisonExpressionEditor.this.inputExpression.getReferencedElements()); dialog.open(); } }); }
From source file:org.bonitasoft.studio.connector.model.definition.dialog.SelectPageWidgetDialog.java
License:Open Source License
private Control createShowDocumentsComposite(Component widget) { final Composite mainComposite = new Composite(section, SWT.NONE); mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 0).create()); final Button showDocumentButton = new Button(mainComposite, SWT.CHECK); showDocumentButton.setText(Messages.showDocuments); showDocumentButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); if (widget instanceof org.bonitasoft.studio.connector.model.definition.Text) { context.bindValue(SWTObservables.observeSelection(showDocumentButton), EMFObservables.observeValue(widget, ConnectorDefinitionPackage.Literals.TEXT__SHOW_DOCUMENTS)); } else if (widget instanceof org.bonitasoft.studio.connector.model.definition.List) { context.bindValue(SWTObservables.observeSelection(showDocumentButton), EMFObservables.observeValue(widget, ConnectorDefinitionPackage.Literals.LIST__SHOW_DOCUMENTS)); }/* w w w. j av a 2s .c o m*/ return mainComposite; }