Example usage for org.eclipse.jface.databinding.swt SWTObservables observeEnabled

List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeEnabled

Introduction

In this page you can find the example usage for org.eclipse.jface.databinding.swt SWTObservables observeEnabled.

Prototype

@Deprecated
public static ISWTObservableValue observeEnabled(Control control) 

Source Link

Document

Returns an observable value tracking the enabled state of the given control

Usage

From source file:org.objectstyle.wolips.wooeditor.editor.DisplayGroupDetailsPage.java

License:Open Source License

private void bind() {
    // XXX This method is too long
    if (myDisplayGroup == null) {
        return;/* www .  ja v  a  2  s.  c  o  m*/
    }
    myBindingContext = new DataBindingContext();

    myBindingContext.bindValue(SWTObservables.observeText(myNameText, SWT.Modify),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.NAME), null, null);

    myBindingContext.bindList(SWTObservables.observeItems(myClassNameCombo),
            BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.CLASS_NAME_LIST),
            null, null);
    myBindingContext.bindValue(SWTObservables.observeSingleSelectionIndex(myClassNameCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.CLASS_NAME_INDEX), null, null);

    myBindingContext.bindList(SWTObservables.observeItems(myEntityCombo),
            BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.ENTITY_LIST), null,
            null);
    myBindingContext.bindValue(SWTObservables.observeEnabled(myMasterDetailGroup),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);

    UpdateValueStrategy booleanInverse = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE) {
        @Override
        protected IStatus doSet(final IObservableValue observableValue, final Object value) {
            Boolean newValue = !(Boolean) value;
            return super.doSet(observableValue, newValue);
        }
    };

    myBindingContext.bindValue(SWTObservables.observeEnabled(myEntityCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), booleanInverse);
    myBindingContext.bindValue(CustomSWTObservables.observeText(myEntityCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.ENTITY_NAME), null, null);

    myBindingContext.bindValue(SWTObservables.observeEnabled(myEditingContextText),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), booleanInverse);
    myBindingContext.bindValue(SWTObservables.observeText(myEditingContextText, SWT.Modify),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.EDITING_CONTEXT), null, null);

    myBindingContext.bindValue(SWTObservables.observeSelection(myHasDetailButton),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL), null, null);

    myBindingContext.bindList(SWTObservables.observeItems(myMasterEntityCombo),
            BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.ENTITY_LIST), null,
            null);
    myBindingContext.bindValue(CustomSWTObservables.observeText(myMasterEntityCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.MASTER_ENTITY_NAME), null, null);

    myBindingContext.bindList(SWTObservables.observeItems(myDetailKeyCombo),
            BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.DETAIL_KEY_LIST),
            null, null);

    myBindingContext.bindValue(CustomSWTObservables.observeText(myDetailKeyCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.DETAIL_KEY_NAME), null, null);

    myBindingContext.bindValue(SWTObservables.observeSelection(myEntriesPerBatchSpinner),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.ENTRIES_PER_BATCH), null, null);

    myBindingContext.bindValue(SWTObservables.observeSelection(mySelectsFirstObjectButton),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.SELECTS_FIRST_OBJECT), null, null);

    myBindingContext.bindList(SWTObservables.observeItems(myQualificationCombo),
            BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.QUALIFICATION_LIST),
            null, null);
    myBindingContext.bindValue(SWTObservables.observeSingleSelectionIndex(myQualificationCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.QUALIFICATION_INDEX), null, null);

    myBindingContext.bindValue(SWTObservables.observeSelection(myFetchOnLoadButton),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.FETCHES_ON_LOAD), null, null);

    myBindingContext.bindList(SWTObservables.observeItems(mySortAttributeCombo),
            BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.SORT_LIST), null,
            null);

    myBindingContext.bindValue(CustomSWTObservables.observeSelection(mySortAttributeCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.SORT_ORDER_KEY), null, null);

    myBindingContext.bindValue(CustomSWTObservables.observeSelection(mySortRadioGroup),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.SORT_ORDER), null, null);

    UpdateValueStrategy fetchSpecEmpty = new UpdateValueStrategy();
    fetchSpecEmpty.setConverter(new IConverter() {
        public Object convert(final Object fromObject) {
            boolean result = fromObject != null && ((List<?>) fromObject).size() > 0;
            if (!myHasDetailButton.getSelection()) {
                return result;
            }
            return false;
        }

        public Object getFromType() {
            return new ArrayList<String>();
        }

        public Object getToType() {
            return true;
        }
    });

    UpdateValueStrategy fetchSpecEnabled = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE) {
        @Override
        protected IStatus doSet(final IObservableValue observableValue, final Object value) {
            Boolean newValue = false;
            if (myFetchSpecCombo.getItemCount() > 0) {
                newValue = !(Boolean) value;
            }
            return super.doSet(observableValue, newValue);
        }
    };
    myBindingContext.bindValue(SWTObservables.observeEnabled(myFetchSpecCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), fetchSpecEnabled);

    myBindingContext.bindValue(SWTObservables.observeEnabled(myFetchSpecCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.FETCH_SPEC_LIST),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), fetchSpecEmpty);

    myBindingContext.bindList(SWTObservables.observeItems(myFetchSpecCombo),
            BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.FETCH_SPEC_LIST),
            null, null);

    UpdateValueStrategy fetchSpecSelection = new UpdateValueStrategy() {
        @Override
        protected IStatus doSet(IObservableValue observableValue, Object value) {
            if (value == null || value.equals("")) {
                value = DisplayGroup.FETCH_SPEC_NONE;
            }
            return super.doSet(observableValue, value);
        }
    };
    myBindingContext.bindValue(CustomSWTObservables.observeSelection(myFetchSpecCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.FETCH_SPEC_NAME), null,
            fetchSpecSelection);

    myEntityCombo.addModifyListener(myEntityModifyListener);
    myMasterEntityCombo.addModifyListener(myMasterEntityListener);
    mySortAttributeCombo.addSelectionListener(mySortEntityListener);

}

From source file:org.openscada.prototype.da.spreadsheet.ControllerEditorPart.java

License:Open Source License

@Override
public void createPartControl(final Composite parent) {
    this.dbc = new DataBindingContext();

    createConsole();//from   ww w .j a  v a 2  s. co m

    this.serverController = new ServerController(SWTObservables.getRealm(parent.getDisplay()));

    final Composite wrapper = new Composite(parent, SWT.NONE);
    parent.setLayout(new FillLayout());

    final GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = layout.marginWidth = 0;
    wrapper.setLayout(layout);

    // create spreadsheet file

    {
        final Label label = new Label(wrapper, SWT.NONE);
        label.setText("Spreadsheet File:");

        final Composite sub = new Composite(wrapper, SWT.NONE);
        sub.setLayout(new GridLayout(4, false));
        sub.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

        this.controllerText = new Text(sub, SWT.BORDER);
        this.controllerText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

        this.dbc.bindValue(SWTObservables.observeText(this.controllerText, SWT.Modify), EMFObservables
                .observeValue(this.controller, SpreadseetControllerPackage.Literals.CONTROLLER__SPREADSHEET));

        {
            final Button button = new Button(sub, SWT.PUSH);
            button.setText("File System");
            button.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent e) {
                    chooseFile();
                }
            });
        }
        {
            final Button button = new Button(sub, SWT.PUSH);
            button.setText("Variables");
            button.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent e) {
                    chooseVariable();
                }
            });
        }

        this.loadButton = new Button(sub, SWT.PUSH);
        this.loadButton.setText("Load");
        this.loadButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                loadSpreadsheet();
            }
        });

    }

    // create connection information

    {

        final Label label = new Label(wrapper, SWT.NONE);
        label.setText("Connection Information:");

        final Composite sub = new Composite(wrapper, SWT.NONE);
        sub.setLayout(new GridLayout(3, false));
        sub.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

        final Text text = new Text(sub, SWT.SINGLE | SWT.BORDER);
        text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        this.dbc.bindValue(SWTObservables.observeText(text, SWT.Modify), EMFObservables.observeValue(
                this.controller, SpreadseetControllerPackage.Literals.CONTROLLER__CONNECTION_ENDPOINT));

        final Button startButton = new Button(sub, SWT.PUSH);
        startButton.setText("Start");
        startButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                startServer();
            }
        });
        final Button stopButton = new Button(sub, SWT.PUSH);
        stopButton.setText("Stop");
        stopButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                stopServer();
            }
        });

        // enablement
        this.dbc.bindValue(SWTObservables.observeEnabled(text),
                new InvertedObserableValue(this.serverController.getRunningState()));
        this.dbc.bindValue(SWTObservables.observeEnabled(startButton),
                new InvertedObserableValue(this.serverController.getRunningState()));
        this.dbc.bindValue(SWTObservables.observeEnabled(stopButton), this.serverController.getRunningState());
    }

    {
        final Label label = new Label(wrapper, SWT.NONE);
        label.setText("Naming mode:");

        final ComboViewer combo = new ComboViewer(wrapper, SWT.READ_ONLY | SWT.DROP_DOWN);

        combo.setContentProvider(new ArrayContentProvider());
        combo.setInput(NamingMode.values());

        this.dbc.bindValue(ViewersObservables.observeSingleSelection(combo), EMFObservables
                .observeValue(this.controller, SpreadseetControllerPackage.Literals.CONTROLLER__NAMING_MODE));
    }

    // tab folder

    final CTabFolder tabFolder = new CTabFolder(wrapper, SWT.BOTTOM | SWT.FLAT);

    {
        final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
        gd.horizontalSpan = 2;
        tabFolder.setLayoutData(gd);
    }

    {
        // create table
        final CTabItem itemTab = new CTabItem(tabFolder, SWT.NONE);
        itemTab.setText("Items");
        final Composite itemTabControl = new Composite(tabFolder, SWT.NONE);
        itemTabControl.setLayout(new FillLayout());
        itemTab.setControl(itemTabControl);

        createItemTable(itemTabControl);
    }

    {
        // create table
        final CTabItem grantedTab = new CTabItem(tabFolder, SWT.NONE);
        grantedTab.setText("Granted");
        final Composite grantedTabControl = new Composite(tabFolder, SWT.NONE);
        grantedTabControl.setLayout(new FillLayout());
        grantedTab.setControl(grantedTabControl);
        createGrantedTable(grantedTabControl);
    }

    // select first tab
    tabFolder.setSelection(0);

    // dirty listeners
    EMFObservables.observeValue(this.controller, SpreadseetControllerPackage.Literals.CONTROLLER__SPREADSHEET)
            .addValueChangeListener(new SetDirtyListener());
    EMFObservables
            .observeValue(this.controller, SpreadseetControllerPackage.Literals.CONTROLLER__CONNECTION_ENDPOINT)
            .addValueChangeListener(new SetDirtyListener());
    EMFObservables.observeValue(this.controller, SpreadseetControllerPackage.Literals.CONTROLLER__NAMING_MODE)
            .addValueChangeListener(new SetDirtyListener());
    EMFObservables.observeValue(this.controller, SpreadseetControllerPackage.Literals.CONTROLLER__NAMING_MODE)
            .addValueChangeListener(new IValueChangeListener() {

                @Override
                public void handleValueChange(final ValueChangeEvent event) {
                    System.out.println("attribute: " + event.getObservableValue());
                }
            });
}

From source file:org.reap.internal.core.binding.BindingManager.java

License:Open Source License

private IObservable createSWTObservable(final Control control, final BindingConfig binding) {
    IObservable obs = null;/*from   w w  w . j a v a  2 s.c  o m*/
    switch (binding.getType()) {
    case BACKGROUND:
        obs = SWTObservables.observeBackground(control);
        break;
    case EDITABLE:
        obs = SWTObservables.observeEditable(control);
        break;
    case ENABLED:
        obs = SWTObservables.observeEnabled(control);
        break;
    case FONT:
        obs = SWTObservables.observeFont(control);
        break;
    case FOREGROUND:
        obs = SWTObservables.observeForeground(control);
        break;
    case ITEMS:
        obs = SWTObservables.observeItems(control);
        break;
    case MAX:
        obs = SWTObservables.observeMax(control);
        break;
    case MIN:
        obs = SWTObservables.observeMin(control);
        break;
    case SELECTION:
        obs = SWTObservables.observeSelection(control);
        break;
    case SINGLESELECTIONINDEX:
        obs = SWTObservables.observeSingleSelectionIndex(control);
        break;
    case TEXT:
        obs = SWTObservables.observeText(control);
        break;
    case TEXTFOCUSOUT:
        obs = SWTObservables.observeText(control, SWT.FocusOut);
        break;
    case TEXTMODIFY:
        obs = SWTObservables.observeText(control, SWT.Modify);
        break;
    case TEXTNONE:
        obs = SWTObservables.observeText(control, SWT.None);
        break;
    case TOOLTIPTEXT:
        obs = SWTObservables.observeTooltipText(control);
        break;
    case VISIBLE:
        obs = SWTObservables.observeVisible(control);
        break;
    default:
        throw new IllegalArgumentException();
    }
    return obs;
}

From source file:org.reap.internal.core.persistence.config.PersistenceConfigPage.java

License:Open Source License

private void bind() {
    if (config == null) {
        final IExtensionRegistry reg = Platform.getExtensionRegistry();
        final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
        config = PersistenceConfigFactory.createPersistenceConfig(reg, store);
    }//  www  .j ava2 s.  c  o  m

    final DataBindingContext context = new DataBindingContext();

    final IObservableValue observeUseSystemProperties = BeansObservables.observeValue(config,
            "useSystemProperties");
    context.bindValue(SWTObservables.observeSelection(useSystemProperties), observeUseSystemProperties, null,
            null);
    context.bindValue(SWTObservables.observeVisible(comp), observeUseSystemProperties, null,
            new NegateBoolean());

    final IObservableValue observeHost = BeansObservables.observeValue(config, "host");
    context.bindValue(SWTObservables.observeText(hostText, SWT.Modify), observeHost, null, null);
    final IObservableValue observePort = BeansObservables.observeValue(config, "port");
    context.bindValue(SWTObservables.observeText(portText, SWT.Modify), observePort, null, null);
    final IObservableValue observeDatabase = BeansObservables.observeValue(config, "database");
    context.bindValue(SWTObservables.observeText(databaseText, SWT.Modify), observeDatabase, null, null);
    context.bindValue(SWTObservables.observeText(usernameText, SWT.Modify),
            BeansObservables.observeValue(config, "username"), null, null);
    context.bindValue(SWTObservables.observeText(passwordText, SWT.Modify),
            BeansObservables.observeValue(config, "password"), null, null);

    final IObservableValue observejdbcFreeSetting = BeansObservables.observeValue(config, "driverFreeSetting");
    context.bindValue(SWTObservables.observeSelection(freeDriverInput), observejdbcFreeSetting, null, null);
    context.bindValue(SWTObservables.observeEnabled(jdbcCombo), observejdbcFreeSetting, null,
            new NegateBoolean());
    context.bindValue(SWTObservables.observeEnabled(jdbcText), observejdbcFreeSetting, null, null);
    final IObservableValue observeDialectFreeSetting = BeansObservables.observeValue(config,
            "dialectFreeSetting");
    context.bindValue(SWTObservables.observeSelection(freeDialectInput), observeDialectFreeSetting, null, null);
    context.bindValue(SWTObservables.observeEnabled(dialectCombo), observeDialectFreeSetting, null,
            new NegateBoolean());
    context.bindValue(SWTObservables.observeEnabled(dialectText), observeDialectFreeSetting, null, null);

    final IObservableMap attributeMapOrm = BeansObservables.observeMap(
            Observables.staticObservableSet(new HashSet<ORMManagerConfig>(config.getOrmManagers())),
            ORMManagerConfig.class, "name");
    crmViewer.setLabelProvider(new ObservableMapLabelProvider(attributeMapOrm));
    crmViewer.setContentProvider(new ArrayContentProvider());
    crmViewer.setInput(config.getOrmManagers());
    final IObservableValue observeOrmManager = BeansObservables.observeValue(config, "ormManager");
    context.bindValue(ViewersObservables.observeSingleSelection(crmViewer), observeOrmManager, null, null);

    final IObservableMap attributeMapDatabase = BeansObservables.observeMap(
            Observables.staticObservableSet(new HashSet<DatabaseSystemConfig>(config.getDatabaseSystems())),
            DatabaseSystemConfig.class, "name");
    databaseSystemViewer.setLabelProvider(new ObservableMapLabelProvider(attributeMapDatabase));
    databaseSystemViewer.setContentProvider(new ArrayContentProvider());
    databaseSystemViewer.setInput(config.getDatabaseSystems());
    final IObservableValue observeDatabankSystem = BeansObservables.observeValue(config, "databaseSystem");
    context.bindValue(ViewersObservables.observeSingleSelection(databaseSystemViewer), observeDatabankSystem,
            null, null);

    final IObservableSet observeDetailSet = BeansObservables.observeDetailSet(Realm.getDefault(),
            observeDatabankSystem, "driverConfigs", DriverConfig.class);
    final IObservableMap attributeMapDriverConfig = BeansObservables.observeMap(observeDetailSet,
            DriverConfig.class, "driver");
    jdbcViewer.setLabelProvider(new ObservableMapLabelProvider(attributeMapDriverConfig));
    jdbcViewer.setContentProvider(new ObservableSetContentProvider());
    jdbcViewer.setInput(observeDetailSet);
    context.bindValue(ViewersObservables.observeSingleSelection(jdbcViewer),
            BeansObservables.observeValue(config, "driverConfig"), null, null);

    context.bindValue(SWTObservables.observeText(jdbcText, SWT.Modify),
            BeansObservables.observeValue(config, "driverConfigFree"), null, null);

    final IObservableSet dialectSet = MasterDetailObservables.detailSet(new ComputedValue() {
        @Override
        protected Object calculate() {
            ORMManagerConfig value = (ORMManagerConfig) observeOrmManager.getValue();
            DatabaseSystemConfig value2 = (DatabaseSystemConfig) observeDatabankSystem.getValue();

            final WritableSet retSet = WritableSet.withElementType(DialectConfig.class);

            if (value != null && value2 != null) {
                for (DialectConfig dialectConfig : value.getDialectConfigs()) {
                    if (dialectConfig.getReference().equals(value2.getSubProtocol())) {
                        retSet.add(dialectConfig);
                    }
                }
                databaseDialects: for (DialectConfig dialectConfig : value2.getDialectConfigs()) {
                    if (dialectConfig.getReference().equals(value.getId())) {
                        for (Object o : retSet) {
                            if (((DialectConfig) o).getDialect().equals(dialectConfig.getDialect())) {
                                continue databaseDialects;
                            }
                        }
                        retSet.add(dialectConfig);
                    }
                }
            }

            return retSet;
        }
    }, new IObservableFactory() {
        public IObservable createObservable(final Object target) {
            return (WritableSet) target;
        }
    }, DialectConfig.class);

    final IObservableMap attributeMapDialectConfig = BeansObservables.observeMap(dialectSet,
            DialectConfig.class, "dialect");
    dialectViewer.setLabelProvider(new ObservableMapLabelProvider(attributeMapDialectConfig));
    dialectViewer.setContentProvider(new ObservableSetContentProvider());
    dialectViewer.setInput(dialectSet);
    context.bindValue(ViewersObservables.observeSingleSelection(dialectViewer),
            BeansObservables.observeValue(config, "dialectConfig"), null, null);

    context.bindValue(SWTObservables.observeText(dialectText, SWT.Modify),
            BeansObservables.observeValue(config, "dialectConfigFree"), null, null);

    context.bindValue(SWTObservables.observeText(urlLabel), new ComputedValue() {
        @Override
        protected Object calculate() {
            final StringBuffer buffer = new StringBuffer();
            buffer.append("jdbc:")
                    .append(((DatabaseSystemConfig) observeDatabankSystem.getValue()).getSubProtocol())
                    .append("://").append(observeHost.getValue()).append(":").append(observePort.getValue())
                    .append("/").append(observeDatabase.getValue());
            return buffer.toString();
        }
    }, null, null);
}

From source file:org.salever.swtjface.demo.binding.TreeViewerWithListFactory.java

License:Open Source License

private void initExtraBindings(DataBindingContext dbc) {
    final IObservableValue beanViewerSelection = ViewersObservables.observeSingleSelection(beanViewer);
    IObservableValue beanSelected = new ComputedValue(Boolean.TYPE) {
        protected Object calculate() {
            return Boolean.valueOf(beanViewerSelection.getValue() != null);
        }/*  w  ww. j  av a2 s .c  o  m*/
    };
    dbc.bindValue(SWTObservables.observeEnabled(addChildBeanButton), beanSelected);
    dbc.bindValue(SWTObservables.observeEnabled(removeBeanButton), beanSelected);

    clipboard = new WritableValue();
    dbc.bindValue(SWTObservables.observeEnabled(copyButton), beanSelected);
    dbc.bindValue(SWTObservables.observeEnabled(pasteButton), new ComputedValue(Boolean.TYPE) {
        protected Object calculate() {
            return Boolean.valueOf(clipboard.getValue() != null);
        }
    });

    ViewerSupport.bind(beanViewer, input, BeanProperties.list("list", BeanItem.class),
            BeanProperties.value(Bean.class, "text"));
}

From source file:org.talend.updates.runtime.ui.ChooseUpdateSitesWizardPage.java

License:Open Source License

protected void initDataBindings() {
    SelectObservableValue featureRepoLocationTypeObservable = new SelectObservableValue(
            UpdateSiteLocationType.class);
    {/*  w w  w . j av a  2  s. com*/
        DataBindingContext defaultRemoteBC = new DataBindingContext();
        // define default Repo bindings
        IObservableValue btnDefaultRemoteSitesObserveSelection = SWTObservables
                .observeSelection(btnDefaultRemoteSites);
        featureRepoLocationTypeObservable.addOption(UpdateSiteLocationType.DEFAULT_REPO,
                btnDefaultRemoteSitesObserveSelection);
        // fake binding to trigger an update of the defaultRemoteBC validation to reset the validation message
        defaultRemoteBC.bindValue(btnDefaultRemoteSitesObserveSelection, new WritableValue());
        // bind the validation messages to the wizard page
        WizardPageSupport.create(this, defaultRemoteBC);
    }
    // define remote custom Repo url bindings
    // define validator for text fields
    {
        DataBindingContext remoteRepoBC = new DataBindingContext();
        UpdateValueStrategy afterConvertRemoteRepoValidator = new UpdateValueStrategy()
                .setAfterConvertValidator(updateWizardModel.new RemoteRepoURIValidator());
        // bind selection to model value
        IObservableValue btnCustomUpdateSiteObserveSelection = SWTObservables
                .observeSelection(btnCustomUpdateSite);
        featureRepoLocationTypeObservable.addOption(UpdateSiteLocationType.REMOTE_REPO,
                btnCustomUpdateSiteObserveSelection);
        // bind selection to enable text field
        IObservableValue textObserveEnabled = SWTObservables.observeEnabled(CustomSiteText);
        remoteRepoBC.bindValue(textObserveEnabled, btnCustomUpdateSiteObserveSelection, null, null);
        // bind text modification to model with validation
        IObservableValue customSiteTextObserveText = SWTObservables.observeText(CustomSiteText, SWT.Modify);
        remoteRepoBC.bindValue(customSiteTextObserveText,
                PojoObservables.observeValue(updateWizardModel, "featureRepositories.remoteRepoUriStr"), //$NON-NLS-1$
                afterConvertRemoteRepoValidator, null);
        // bind the validation messages to the wizard page
        WizardPageSupport.create(this, remoteRepoBC);
    }
    {
        // define local folder Repo bindings
        DataBindingContext localRepoBC = new DataBindingContext();
        UpdateValueStrategy afterConvertLocalFolderValidator = new UpdateValueStrategy()
                .setAfterConvertValidator(updateWizardModel.new LocalRepoFolderValidator());

        // bind selection to model
        IObservableValue btnLocalFolderObserveSelection = SWTObservables.observeSelection(btnLocalFolder);
        featureRepoLocationTypeObservable.addOption(UpdateSiteLocationType.LOCAL_FOLDER,
                btnLocalFolderObserveSelection);

        // bind selection to text fiedl enabled
        IObservableValue localFolderTextObserveEnabled = SWTObservables.observeEnabled(localFolderText);
        localRepoBC.bindValue(localFolderTextObserveEnabled, btnLocalFolderObserveSelection, null, null);
        // bind selection to browse button enabled
        IObservableValue localFolderBrowseButtonObserveEnabled = SWTObservables
                .observeEnabled(localFolderBrowseButton);
        localRepoBC.bindValue(localFolderBrowseButtonObserveEnabled, btnLocalFolderObserveSelection, null,
                null);
        // bind text field to model
        IObservableValue localFolderTextObserveText = SWTObservables.observeText(localFolderText, SWT.Modify);
        localRepoBC.bindValue(localFolderTextObserveText,
                PojoObservables.observeValue(updateWizardModel, "featureRepositories.localRepoPathStr"), //$NON-NLS-1$
                afterConvertLocalFolderValidator, null);
        //
        // bind the validation messages to the wizard page
        WizardPageSupport.create(this, localRepoBC);
    }
    DataBindingContext radioBC = new DataBindingContext();
    radioBC.bindValue(featureRepoLocationTypeObservable,
            PojoObservables.observeValue(updateWizardModel, "featureRepositories.updateSiteLocationType")); //$NON-NLS-1$
}

From source file:synergyviewcore.media.ui.MarkerInterval.java

License:Open Source License

/**
 * Instantiates a new media control composite.
 * /*from   w ww  . j  a  v a 2  s  .com*/
 * @param parent
 *            the parent
 * @param style
 *            the style
 */
public MediaControlComposite(Composite parent, int style) {
    super(parent, style);
    this.setLayout(new GridLayout(3, false));
    createMediaConstrols();
    createMediaTimeSlider();
    createMediaTimeScaler();

    _ctx.bindValue(SWTObservables.observeEnabled(_playPulse), SWTObservables.observeVisible(_timeBarViewer));
    _ctx.bindValue(SWTObservables.observeEnabled(_playPulse), SWTObservables.observeVisible(_timeScale));
}

From source file:uk.ac.stfc.isis.ibex.ui.devicescreens.dialogs.TargetPropertiesWidget.java

License:Open Source License

private void bind() {
    DataBindingContext bindingContext = new DataBindingContext();

    bindingContext.bindValue(SWTObservables.observeText(valueText, SWT.Modify),
            BeanProperties.value("valueText").observe(viewModel));
    bindingContext.bindValue(SWTObservables.observeEnabled(valueText),
            BeanProperties.value("valueTextEnabled").observe(viewModel));

    bindingContext.bindValue(SWTObservables.observeText(txtDescription),
            BeanProperties.value("descriptionText").observe(viewModel));

    bindingContext.bindValue(SWTObservables.observeEnabled(table),
            BeanProperties.value("tableEnabled").observe(viewModel));

    viewModel.addPropertyChangeListener("properties", new PropertyChangeListener() {

        @Override/*from   w  w w. jav  a  2 s  . c o  m*/
        public void propertyChange(PropertyChangeEvent evt) {
            table.setRows(viewModel.getProperties());
        }
    });

    table.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            viewModel.setTableSelection(table.firstSelectedRow());
        }
    });
}