List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeSelection
@Deprecated public static ISWTObservableValue observeSelection(Control control)
control
. From source file:org.eclipse.libra.facet.ui.wizards.OSGiBundleFacetUninstallPage.java
License:Open Source License
public void createControl(Composite parent) { DataBindingContext dbc = new DataBindingContext(); WizardPageSupport.create(this, dbc); Composite container = new Composite(parent, SWT.NONE); Button[] buttons = new Button[OSGiBundleFacetUninstallStrategy.values().length]; for (int i = 0; i < buttons.length; i++) { buttons[i] = new Button(container, SWT.RADIO); buttons[i].setText(OSGiBundleFacetUninstallStrategy.values()[i].description()); dbc.bindValue(SWTObservables.observeSelection(buttons[i]), config.getOptionValues()[i], null, null); }// ww w .ja v a2 s. co m GridLayoutFactory.swtDefaults().generateLayout(container); setControl(container); Dialog.applyDialogFont(container); }
From source file:org.eclipse.mylyn.commons.repositories.ui.RepositoryLocationPart.java
License:Open Source License
protected void bind(Button button, String property) { ISWTObservableValue uiElement = SWTObservables.observeSelection(button); IObservableValue modelElement = new RepositoryLocationValueProperty(property, Boolean.FALSE.toString()) .observe(workingCopy);//from w ww. j ava 2s . c o m bindingContext.bindValue(uiElement, modelElement, null, null); }
From source file:org.eclipse.mylyn.internal.docs.epub.ui.MainPage.java
License:Open Source License
protected DataBindingContext initDataBindings() { DataBindingContext bindingContext = new DataBindingContext(); ////from w w w .ja v a 2s .com IObservableValue textObserveTextObserveWidget = SWTObservables.observeText(titleText, SWT.Modify); final IObservableValue beanTitleObserveValue = PojoObservables.observeValue(bean, "title"); //$NON-NLS-1$ UpdateValueStrategy titleStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); titleStrategy.setBeforeSetValidator(new StringValidator("A title must be specified", titleText)); //$NON-NLS-1$ bindingContext.bindValue(textObserveTextObserveWidget, beanTitleObserveValue, titleStrategy, null); // IObservableValue text_3ObserveTextObserveWidget = SWTObservables.observeText(authorText, SWT.Modify); final IObservableValue beanCreatorObserveValue = PojoObservables.observeValue(bean, "creator"); //$NON-NLS-1$ UpdateValueStrategy authorStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); authorStrategy.setBeforeSetValidator(new StringValidator("An author must be specified", authorText)); //$NON-NLS-1$ bindingContext.bindValue(text_3ObserveTextObserveWidget, beanCreatorObserveValue, authorStrategy, null); // IObservableValue dateTimeObserveSelectionObserveWidget = SWTObservables.observeSelection(dateTime); final IObservableValue beanPublicationDateObserveValue = PojoObservables.observeValue(bean, "publicationDate"); //$NON-NLS-1$ bindingContext.bindValue(dateTimeObserveSelectionObserveWidget, beanPublicationDateObserveValue, null, null); // IObservableValue text_4ObserveTextObserveWidget = SWTObservables.observeText(identifierText, SWT.Modify); final IObservableValue beanIdentifierObserveValue = PojoObservables.observeValue(bean, "identifier"); //$NON-NLS-1$ UpdateValueStrategy identifierStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); identifierStrategy .setBeforeSetValidator(new StringValidator("An identifier must be specified", identifierText)); //$NON-NLS-1$ bindingContext.bindValue(text_4ObserveTextObserveWidget, beanIdentifierObserveValue, identifierStrategy, null); // IObservableValue schemeTextObserveTextObserveWidget = SWTObservables.observeText(schemeText); final IObservableValue beanIdSchemeObserveValue = PojoObservables.observeValue(bean, "scheme"); //$NON-NLS-1$ UpdateValueStrategy schemeStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); schemeStrategy .setBeforeSetValidator(new StringValidator("An identifier scheme must be specified", schemeText)); //$NON-NLS-1$ bindingContext.bindValue(schemeTextObserveTextObserveWidget, beanIdSchemeObserveValue, schemeStrategy, null); // IObservableValue text_1ObserveTextObserveWidget = SWTObservables.observeText(copyrightText, SWT.Modify); final IObservableValue beanRightsObserveValue = PojoObservables.observeValue(bean, "rights"); //$NON-NLS-1$ UpdateValueStrategy rightsStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); rightsStrategy.setBeforeSetValidator(new StringValidator("Rights must be specified", copyrightText)); //$NON-NLS-1$ bindingContext.bindValue(text_1ObserveTextObserveWidget, beanRightsObserveValue, rightsStrategy, null); // IObservableValue comboObserveTextObserveWidget = SWTObservables.observeText(combo); final IObservableValue beanLanguageObserveValue = PojoObservables.observeValue(bean, "language"); //$NON-NLS-1$ UpdateValueStrategy languageStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); languageStrategy.setBeforeSetValidator(new StringValidator("A language must be specified", combo)); //$NON-NLS-1$ bindingContext.bindValue(comboObserveTextObserveWidget, beanLanguageObserveValue, languageStrategy, null); // IObservableValue subjectTextObserveTextObserveWidget = SWTObservables.observeText(subjectText, SWT.Modify); final IObservableValue beanSubjectObserveValue = PojoObservables.observeValue(bean, "subject"); //$NON-NLS-1$ UpdateValueStrategy subjectStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); subjectStrategy.setBeforeSetValidator(new StringValidator("A subject must be specified", subjectText)); //$NON-NLS-1$ bindingContext.bindValue(subjectTextObserveTextObserveWidget, beanSubjectObserveValue, subjectStrategy, null); // IObservableValue coverObserveTextObserveWidget = SWTObservables.observeText(coverText, SWT.Modify); IObservableValue beanCoverObserveValue = PojoObservables.observeValue(bean, "cover"); //$NON-NLS-1$ UpdateValueStrategy coverStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); coverStrategy.setBeforeSetValidator(new FileValidator( "The cover image must be a valid image file of type PNG, SVG or JPEG.", coverText, new String[] { //$NON-NLS-1$ ".png", ".svg", ".jpeg", ".jpg" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ bindingContext.bindValue(coverObserveTextObserveWidget, beanCoverObserveValue, coverStrategy, null); // IObservableValue styleSheetTextObserveTextObserveWidget = SWTObservables.observeText(styleSheetText, SWT.Modify); IObservableValue beanStyleSheetObserveValue = PojoObservables.observeValue(bean, "styleSheet"); //$NON-NLS-1$ UpdateValueStrategy styleSheetStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); styleSheetStrategy.setBeforeSetValidator(new FileValidator("The style sheet must be a valid CSS file.", //$NON-NLS-1$ styleSheetText, new String[] { ".css" })); //$NON-NLS-1$ bindingContext.bindValue(styleSheetTextObserveTextObserveWidget, beanStyleSheetObserveValue, styleSheetStrategy, null); // return bindingContext; }
From source file:org.eclipse.rcptt.ctx.debug.ui.DebugContextEditor.java
License:Open Source License
public Control create(Composite parent, FormToolkit toolkit, IWorkbenchSite site, EditorHeader header) { Section section = new SectionWithComposite("Options", Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED).grabVertical(false).create(parent, toolkit); GridDataFactory.fillDefaults().grab(true, false).applyTo(section); Composite composite = (Composite) section.getClient(); GridLayoutFactory.fillDefaults().numColumns(1).applyTo(composite); Button noLaunches = toolkit.createButton(composite, "Terminate existing launches", SWT.CHECK); dbc.bindValue(SWTObservables.observeSelection(noLaunches), EMFObservables.observeValue(getContextElement(), DebugPackage.Literals.DEBUG_CONTEXT__NO_LAUNCHES)); toolkit.createLabel(composite, "Do not terminate launches of following configurations:"); Text exceptions = toolkit.createText(composite, "", SWT.BORDER); GridDataFactory.fillDefaults().hint(300, SWT.DEFAULT).applyTo(exceptions); dbc.bindValue(SWTObservables.observeText(exceptions, SWT.Modify), EMFObservables .observeValue(getContextElement(), DebugPackage.Literals.DEBUG_CONTEXT__LAUNCH_EXCEPTIONS)); dbc.bindValue(SWTObservables.observeEnabled(exceptions), SWTObservables.observeSelection(noLaunches)); Button noLaunchShortcuts = toolkit.createButton(composite, "Clear launch configurations", SWT.CHECK); dbc.bindValue(SWTObservables.observeSelection(noLaunchShortcuts), EMFObservables .observeValue(getContextElement(), DebugPackage.Literals.DEBUG_CONTEXT__NO_LAUNCH_SHORTCUTS)); GridDataFactory.fillDefaults().grab(true, false).applyTo(composite); toolkit.createLabel(composite, "Do not delete following configurations:"); exceptions = toolkit.createText(composite, "", SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(exceptions); dbc.bindValue(SWTObservables.observeText(exceptions, SWT.Modify), EMFObservables.observeValue( getContextElement(), DebugPackage.Literals.DEBUG_CONTEXT__LAUNCH_SHORTCUT_EXCEPTIONS)); dbc.bindValue(SWTObservables.observeEnabled(exceptions), SWTObservables.observeSelection(noLaunchShortcuts)); Button noBreakpoints = toolkit.createButton(composite, "Clear breakpoints", SWT.CHECK); GridDataFactory.fillDefaults().span(2, 1).applyTo(noBreakpoints); dbc.bindValue(SWTObservables.observeSelection(noBreakpoints), EMFObservables .observeValue(getContextElement(), DebugPackage.Literals.DEBUG_CONTEXT__NO_BREAKPOINTS)); Section section5 = new SectionWithToolbar(new EditableTree("Launch configurations", new ContentProvider()), Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED).create(parent, toolkit); GridDataFactory.fillDefaults().grab(true, true).applyTo(section5); return section; }
From source file:org.eclipse.rcptt.ctx.filesystem.ui.FilesystemContextEditor.java
License:Open Source License
private void createOptionsControls(FormToolkit toolkit, Composite client) { final Button clearCheckbox = toolkit.createButton(client, "Clear root folder before context application", SWT.CHECK);/* w ww . j av a 2s. c o m*/ GridDataFactory.fillDefaults().span(3, 1).applyTo(clearCheckbox); UpdateValueStrategy strategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_ON_REQUEST); final Binding binding = dbc.bindValue(SWTObservables.observeSelection(clearCheckbox), EMFObservables .observeValue(getContextElement(), FilesystemPackage.Literals.FILESYSTEM_CONTEXT__CLEAR), strategy, null); clearCheckbox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (clearCheckbox.getSelection() && !isClearConfirmed()) { clearCheckbox.setSelection(false); return; } binding.updateTargetToModel(); } }); }
From source file:org.eclipse.rcptt.ctx.preferences.ui.PreferencesContextEditor.java
License:Open Source License
@SuppressWarnings("unused") public Control create(Composite parent, FormToolkit toolkit, IWorkbenchSite site, EditorHeader header) { Section section = new SectionWithComposite("Preferences", Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED).numColumns(2).create(parent, toolkit); Composite composite = (Composite) section.getClient(); Button cleanPreferences = toolkit.createButton(composite, "Clear preferences", SWT.CHECK); dbc.bindValue(SWTObservables.observeSelection(cleanPreferences), EMFObservables.observeValue( getContextElement(), PreferencesPackage.Literals.PREFERENCES_CONTEXT__CLEAN_PREFERENCES)); GridDataFactory.fillDefaults().span(2, 1).applyTo(cleanPreferences); Tree tree = createTree(composite, toolkit); Composite panel = createPanel(composite, toolkit); // panel.setLayoutData(new GridData(GridData.FILL_VERTICAL)); GridDataFactory.fillDefaults().grab(false, true).applyTo(panel); return section; }
From source file:org.eclipse.rcptt.ctx.workbench.ui.views.EditorsTable.java
License:Open Source License
@Override public void createControl(Composite parent) { closeEditorsButton = new Button(parent, SWT.CHECK); closeEditorsButton.setText("Close opened editors"); dbc.bindValue(SWTObservables.observeSelection(closeEditorsButton), EMFObservables.observeValue(getContent(), ScenarioPackage.eINSTANCE.getWorkbenchContext_CloseEditors())); super.createControl(parent); }
From source file:org.eclipse.rcptt.ctx.workbench.ui.views.WorkbenchContextEditor.java
License:Open Source License
private void createResetPerspectiveOption(Composite parent, FormToolkit toolkit) { resetPerspective = toolkit.createButton(parent, "Reset perspective", SWT.CHECK); resetPerspective.setEnabled(isPerspectiveSelected()); dbc.bindValue(SWTObservables.observeSelection(resetPerspective), EMFObservables.observeValue(getContextElement(), ScenarioPackage.eINSTANCE.getWorkbenchContext_ResetPerspective()), new ResetPerspectiveChangeListener(), new ResetPerspectiveChangeListener()); GridData data = new GridData(); data.horizontalSpan = 3;/*w w w . j ava 2 s .c om*/ resetPerspective.setLayoutData(data); }
From source file:org.eclipse.rcptt.ctx.workbench.ui.views.WorkbenchContextEditor.java
License:Open Source License
private void createDialogsOption(Composite parent, FormToolkit toolkit) { final Button noModalDialogs = toolkit.createButton(parent, "Close all modal dialogs", SWT.CHECK); dbc.bindValue(SWTObservables.observeSelection(noModalDialogs), EMFObservables .observeValue(getContextElement(), ScenarioPackage.eINSTANCE.getWorkbenchContext_NoModalDialogs())); GridData data = new GridData(); data.horizontalSpan = 3;//from w ww. j a v a 2 s . com noModalDialogs.setLayoutData(data); }
From source file:org.eclipse.rcptt.ctx.workbench.ui.views.WorkbenchContextEditor.java
License:Open Source License
private void createClipboardOption(Composite parent, FormToolkit toolkit) { final Button clearClipboard = toolkit.createButton(parent, "Clear clipboard", SWT.CHECK); dbc.bindValue(SWTObservables.observeSelection(clearClipboard), EMFObservables .observeValue(getContextElement(), ScenarioPackage.eINSTANCE.getWorkbenchContext_ClearClipboard())); GridData data = new GridData(); data.horizontalSpan = 3;/*from w w w .j av a 2s. com*/ clearClipboard.setLayoutData(data); }