Search in sources :

Example 11 with DataBindingContext

use of org.eclipse.core.databinding.DataBindingContext in project meclipse by flaper87.

the class FilterWizardPage method createControl.

@Override
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.FILL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 3;
    layout.verticalSpacing = 9;
    GridData gd = new GridData(SWT.FILL);
    gd.widthHint = 250;
    Label label;
    label = new Label(container, SWT.NULL);
    label.setText(getCaption("filterWizard.label.name"));
    nameText = new Text(container, SWT.BORDER | SWT.SINGLE);
    nameText.setLayoutData(gd);
    label = new Label(container, SWT.NULL);
    label.setImage(help);
    label.setToolTipText(getCaption("filterWizard.tooltip.name"));
    label = new Label(container, SWT.NULL);
    label.setText(getCaption("filterWizard.label.query"));
    queryText = new Text(container, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.FILL);
    queryText.setLayoutData(gd);
    label = new Label(container, SWT.NULL);
    label.setToolTipText(getCaption("filterWizard.tooltip.query"));
    label.setImage(help);
    // add WizardPage validators
    DataBindingContext dbc = new DataBindingContext();
    WizardPageSupport.create(this, dbc);
    dbc.bindValue(SWTObservables.observeText(nameText, SWT.Modify), nameValue, new UpdateValueStrategy().setBeforeSetValidator(new FilterNameValidator()), null);
    dbc.bindValue(SWTObservables.observeText(queryText, SWT.Modify), queryValue, new UpdateValueStrategy().setBeforeSetValidator(new JSONValidator()), null);
    setControl(container);
    // disable save until everything matches
    setPageComplete(false);
}
Also used : UpdateValueStrategy(org.eclipse.core.databinding.UpdateValueStrategy) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) DataBindingContext(org.eclipse.core.databinding.DataBindingContext)

Example 12 with DataBindingContext

use of org.eclipse.core.databinding.DataBindingContext in project translationstudio8 by heartsome.

the class NewTermDbBaseInfoPage method initDataBindings.

protected void initDataBindings() {
    DataBindingContext bindingContext = new DataBindingContext();
    WizardPageSupport.create(this, bindingContext);
    IObservableValue widgetValue = WidgetProperties.text(SWT.Modify).observe(dbNameText);
    final IObservableValue dbNameModelValue = BeanProperties.value("dbName").observe(dbModel);
    bindingContext.bindValue(widgetValue, dbNameModelValue, null, null);
    widgetValue = WidgetProperties.text(SWT.Modify).observe(instanceText);
    final IObservableValue instanceModelValue = BeanProperties.value("instance").observe(dbModel);
    bindingContext.bindValue(widgetValue, instanceModelValue, null, null);
    widgetValue = WidgetProperties.text(SWT.Modify).observe(hostText);
    final IObservableValue hostModelValue = BeanProperties.value("host").observe(dbModel);
    bindingContext.bindValue(widgetValue, hostModelValue, null, null);
    widgetValue = WidgetProperties.text(SWT.Modify).observe(portText);
    final IObservableValue protModelValue = BeanProperties.value("port").observe(dbModel);
    bindingContext.bindValue(widgetValue, protModelValue, null, null);
    widgetValue = WidgetProperties.text(SWT.Modify).observe(locationText);
    final IObservableValue locationModelValue = BeanProperties.value("itlDBLocation").observe(dbModel);
    bindingContext.bindValue(widgetValue, locationModelValue, null, null);
    //
    widgetValue = WidgetProperties.text(SWT.Modify).observe(usernameText);
    final IObservableValue usernameModelValue = BeanProperties.value("userName").observe(dbModel);
    bindingContext.bindValue(widgetValue, usernameModelValue, null, null);
    widgetValue = WidgetProperties.text(SWT.Modify).observe(passwordText);
    final IObservableValue passwordModelValue = BeanProperties.value("password").observe(dbModel);
    bindingContext.bindValue(widgetValue, passwordModelValue, null, null);
    MultiValidator myValidator = new MultiValidator() {

        @Override
        protected IStatus validate() {
            dbNameModelValue.getValue();
            instanceModelValue.getValue();
            hostModelValue.getValue();
            protModelValue.getValue();
            locationModelValue.getValue();
            usernameModelValue.getValue();
            passwordModelValue.getValue();
            return validator();
        }
    };
    bindingContext.addValidationStatusProvider(myValidator);
}
Also used : DataBindingContext(org.eclipse.core.databinding.DataBindingContext) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) MultiValidator(org.eclipse.core.databinding.validation.MultiValidator)

Example 13 with DataBindingContext

use of org.eclipse.core.databinding.DataBindingContext in project translationstudio8 by heartsome.

the class NewTmDbBaseInfoPage method initDataBindings.

protected void initDataBindings() {
    DataBindingContext bindingContext = new DataBindingContext();
    WizardPageSupport.create(this, bindingContext);
    IObservableValue widgetValue = WidgetProperties.text(SWT.Modify).observe(dbNameText);
    final IObservableValue dbNameModelValue = BeanProperties.value("dbName").observe(dbModel);
    bindingContext.bindValue(widgetValue, dbNameModelValue, null, null);
    widgetValue = WidgetProperties.text(SWT.Modify).observe(instanceText);
    final IObservableValue instanceModelValue = BeanProperties.value("instance").observe(dbModel);
    bindingContext.bindValue(widgetValue, instanceModelValue, null, null);
    widgetValue = WidgetProperties.text(SWT.Modify).observe(hostText);
    final IObservableValue hostModelValue = BeanProperties.value("host").observe(dbModel);
    bindingContext.bindValue(widgetValue, hostModelValue, null, null);
    widgetValue = WidgetProperties.text(SWT.Modify).observe(portText);
    final IObservableValue protModelValue = BeanProperties.value("port").observe(dbModel);
    bindingContext.bindValue(widgetValue, protModelValue, null, null);
    widgetValue = WidgetProperties.text(SWT.Modify).observe(locationText);
    final IObservableValue locationModelValue = BeanProperties.value("itlDBLocation").observe(dbModel);
    bindingContext.bindValue(widgetValue, locationModelValue, null, null);
    //
    widgetValue = WidgetProperties.text(SWT.Modify).observe(usernameText);
    final IObservableValue usernameModelValue = BeanProperties.value("userName").observe(dbModel);
    bindingContext.bindValue(widgetValue, usernameModelValue, null, null);
    widgetValue = WidgetProperties.text(SWT.Modify).observe(passwordText);
    final IObservableValue passwordModelValue = BeanProperties.value("password").observe(dbModel);
    bindingContext.bindValue(widgetValue, passwordModelValue, null, null);
    MultiValidator myValidator = new MultiValidator() {

        @Override
        protected IStatus validate() {
            dbNameModelValue.getValue();
            instanceModelValue.getValue();
            hostModelValue.getValue();
            protModelValue.getValue();
            locationModelValue.getValue();
            usernameModelValue.getValue();
            passwordModelValue.getValue();
            return validator();
        }
    };
    bindingContext.addValidationStatusProvider(myValidator);
}
Also used : DataBindingContext(org.eclipse.core.databinding.DataBindingContext) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) MultiValidator(org.eclipse.core.databinding.validation.MultiValidator)

Example 14 with DataBindingContext

use of org.eclipse.core.databinding.DataBindingContext in project eclipse-pmd by acanda.

the class AddRuleSetConfigurationWizardPage method initDataBindings.

private DataBindingContext initDataBindings() {
    final DataBindingContext bindingContext = new DataBindingContext();
    // 
    final IObservableValue locationObserveText = SWTObservables.observeDelayedValue(200, SWTObservables.observeText(location, SWT.Modify));
    final IObservableValue locationObserveValue = BeansObservables.observeValue(controller.getModel(), "location");
    bindingContext.bindValue(locationObserveText, locationObserveValue, null, null);
    // 
    final ObservableListContentProvider rulesContentProvider = new ObservableListContentProvider();
    final IObservableMap rulesObserveMap = PojoObservables.observeMap(rulesContentProvider.getKnownElements(), Rule.class, "name");
    tableViewer.setLabelProvider(new ObservableMapLabelProvider(rulesObserveMap));
    tableViewer.setContentProvider(rulesContentProvider);
    // 
    final IObservableList rulesObserveList = BeansObservables.observeList(Realm.getDefault(), controller.getModel(), "rules");
    tableViewer.setInput(rulesObserveList);
    // 
    final IObservableValue nameObserveTextObserveWidget = SWTObservables.observeDelayedValue(100, SWTObservables.observeText(name, SWT.Modify));
    final IObservableValue controllergetModelNameObserveValue = BeansObservables.observeValue(controller.getModel(), "name");
    bindingContext.bindValue(nameObserveTextObserveWidget, controllergetModelNameObserveValue, null, null);
    // 
    final IObservableValue observeVisibleBrowseObserveWidget = WidgetProperties.visible().observe(browse);
    final IObservableValue browseEnabledControllergetModelObserveValue = BeanProperties.value("browseEnabled").observe(controller.getModel());
    bindingContext.bindValue(observeVisibleBrowseObserveWidget, browseEnabledControllergetModelObserveValue, null, null);
    // 
    return bindingContext;
}
Also used : IObservableMap(org.eclipse.core.databinding.observable.map.IObservableMap) ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) DataBindingContext(org.eclipse.core.databinding.DataBindingContext) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) ObservableMapLabelProvider(org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList)

Example 15 with DataBindingContext

use of org.eclipse.core.databinding.DataBindingContext in project eclipse-pmd by acanda.

the class SelectConfigurationTypeWizardPage method initDataBindings.

private DataBindingContext initDataBindings() {
    final DataBindingContext bindingContext = new DataBindingContext();
    // 
    final IObservableValue workspaceTypeView = WidgetProperties.selection().observe(workspaceRadioButton);
    final IObservableValue workspaceTypeModel = BeanProperties.value("workspaceTypeSelected").observe(controller.getModel());
    bindingContext.bindValue(workspaceTypeView, workspaceTypeModel, null, null);
    // 
    final IObservableValue projectTypeView = WidgetProperties.selection().observe(projectRadioButton);
    final IObservableValue projectTypeModel = BeanProperties.value("projectTypeSelected").observe(controller.getModel());
    bindingContext.bindValue(projectTypeView, projectTypeModel, null, null);
    // 
    final IObservableValue fileSystemTypeView = WidgetProperties.selection().observe(fileSystemRadioButton);
    final IObservableValue fileSystemTypeModel = BeanProperties.value("fileSystemTypeSelected").observe(controller.getModel());
    bindingContext.bindValue(fileSystemTypeView, fileSystemTypeModel, null, null);
    // 
    final IObservableValue observeSelectionRemoteRadioButtonObserveWidget = WidgetProperties.selection().observe(remoteRadioButton);
    final IObservableValue remoteTypeSelectedControllergetModelObserveValue = BeanProperties.value("remoteTypeSelected").observe(controller.getModel());
    bindingContext.bindValue(observeSelectionRemoteRadioButtonObserveWidget, remoteTypeSelectedControllergetModelObserveValue, null, null);
    // 
    return bindingContext;
}
Also used : DataBindingContext(org.eclipse.core.databinding.DataBindingContext) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue)

Aggregations

DataBindingContext (org.eclipse.core.databinding.DataBindingContext)15 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)9 ConversionConfigBean (net.heartsome.cat.convert.ui.model.ConversionConfigBean)2 UpdateValueStrategy (org.eclipse.core.databinding.UpdateValueStrategy)2 IObservableList (org.eclipse.core.databinding.observable.list.IObservableList)2 MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)2 ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 Text (org.eclipse.swt.widgets.Text)2 ProjectInfoBean (net.heartsome.cat.common.bean.ProjectInfoBean)1 IObservableMap (org.eclipse.core.databinding.observable.map.IObservableMap)1 IObservableSet (org.eclipse.core.databinding.observable.set.IObservableSet)1 ObservableMapLabelProvider (org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider)1