use of org.eclipse.core.databinding.UpdateValueStrategy in project linuxtools by eclipse.
the class PackageVMPage method createControl.
@Override
public void createControl(Composite parent) {
ScrolledComposite scrollTop = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrollTop.setExpandVertical(true);
scrollTop.setExpandHorizontal(true);
final Composite container = new Composite(scrollTop, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(3).margins(6, 6).applyTo(container);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false).applyTo(container);
// Box name
final Label boxNameLabel = new Label(container, SWT.NONE);
boxNameLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ImagePull.name.label"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(boxNameLabel);
final Text boxNameText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(boxNameText);
boxNameText.setToolTipText(// $NON-NLS-1$
WizardMessages.getString("ImagePull.name.tooltip"));
// Name binding
final IObservableValue<String> boxNameObservable = BeanProperties.value(PackageVMPageModel.class, PackageVMPageModel.BOX_NAME).observe(model);
dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(boxNameText), boxNameObservable, new UpdateValueStrategy(), null);
// Box folder
final Label boxFolderLabel = new Label(container, SWT.NONE);
// $NON-NLS-1$
boxFolderLabel.setText(WizardMessages.getString("PackageVMPage.folder.label"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(boxFolderLabel);
final Text boxFolderText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(boxFolderText);
boxFolderText.setToolTipText(// $NON-NLS-1$
WizardMessages.getString("PackageVMPage.folder.desc"));
// Folder binding
final IObservableValue<String> boxFolderObservable = BeanProperties.value(PackageVMPageModel.class, PackageVMPageModel.BOX_FOLDER).observe(model);
dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(boxFolderText), boxFolderObservable, new UpdateValueStrategy(), null);
// search
final Button searchButton = new Button(container, SWT.NONE);
searchButton.setText(// $NON-NLS-1$
WizardMessages.getString("ImagePull.search.label"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(searchButton);
searchButton.addSelectionListener(onSearchFolder());
dbc.addValidationStatusProvider(new PackageVMValidationStatusProvider(boxNameObservable, boxFolderObservable));
// setup validation support
WizardPageSupport.create(this, dbc);
scrollTop.setContent(container);
Point point = container.computeSize(SWT.DEFAULT, SWT.DEFAULT);
scrollTop.setSize(point);
scrollTop.setMinSize(point);
setControl(container);
}
use of org.eclipse.core.databinding.UpdateValueStrategy in project n4js by eclipse.
the class N4JSNewClassifierWizardPage method setupBindings.
/**
* Setup additional non-component contained bindings
*/
protected void setupBindings() {
DataBindingContext dataBindingContext = this.getDataBindingContext();
@SuppressWarnings("unchecked") IObservableValue<String> moduleSpecifierValue = BeanProperties.value(WorkspaceWizardModel.class, WorkspaceWizardModel.MODULE_SPECIFIER_PROPERTY).observe(getModel());
@SuppressWarnings("unchecked") IObservableValue<Boolean> suffixVisibilityValue = BeanProperties.value(SuffixText.class, SuffixText.SUFFIX_VISIBILITY_PROPERTY).observe(workspaceWizardControl.getModuleSpecifierText());
// // Only show the suffix on input values ending with a '/' character or empty module specifiers.
dataBindingContext.bindValue(suffixVisibilityValue, moduleSpecifierValue, noUpdateValueStrategy(), WizardComponentDataConverters.strategyForPredicate(m -> {
String moduleSpecifier = (String) m;
return (moduleSpecifier.isEmpty() || moduleSpecifier.charAt(moduleSpecifier.length() - 1) == IPath.SEPARATOR);
}));
// // interface name to module specifier suffix binding
@SuppressWarnings("unchecked") IObservableValue<String> interfaceNameModelValue = BeanProperties.value(N4JSInterfaceWizardModel.class, N4JSClassifierWizardModel.NAME_PROPERTY).observe(getModel());
@SuppressWarnings("unchecked") IObservableValue<String> greySuffixValue = BeanProperties.value(SuffixText.class, SuffixText.SUFFIX_PROPERTY).observe(workspaceWizardControl.getModuleSpecifierText());
dataBindingContext.bindValue(greySuffixValue, interfaceNameModelValue, noUpdateValueStrategy(), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE));
// // Enable n4js <-> Definition value(external) is selected
@SuppressWarnings("unchecked") IObservableValue<Boolean> externalValue = BeanProperties.value(DefinitionFileModel.class, N4JSClassifierWizardModel.DEFINITION_FILE_PROPERTY).observe(getModel());
@SuppressWarnings("unchecked") IObservableValue<Boolean> n4jsEnabled = WidgetProperties.enabled().observe(otherClassifierModifiersComponent.getN4jsAnnotationBox());
dataBindingContext.bindValue(n4jsEnabled, externalValue, noUpdateValueStrategy(), WizardComponentDataConverters.strategyForPredicate(input -> getModel().isDefinitionFile() && AccessModifier.PRIVATE != getModel().getAccessModifier()));
// One way binding of the access modifiers to the enabled state of internal checkbox
@SuppressWarnings("unchecked") IObservableValue<Boolean> internalEnabledValue = WidgetProperties.enabled().observe(accessModifierComponent.getInternalAnnotationBox());
@SuppressWarnings("unchecked") IObservableValue<AccessModifier> accessModifierSelectObservable = BeanProperties.value(N4JSInterfaceWizardModel.class, N4JSClassifierWizardModel.ACCESS_MODIFIER_PROPERTY).observe(getModel());
dataBindingContext.bindValue(internalEnabledValue, accessModifierSelectObservable, noUpdateValueStrategy(), WizardComponentDataConverters.strategyForPredicate(object -> {
if (object instanceof AccessModifier) {
return isInternalAccessModifierEnabled((AccessModifier) object);
}
return false;
}));
// N4JS annotation checkbox disabled when access modifier is private
@SuppressWarnings("unchecked") IObservableValue<Boolean> n4jsEnabledValue = WidgetProperties.enabled().observe(otherClassifierModifiersComponent.getN4jsAnnotationBox());
dataBindingContext.bindValue(n4jsEnabledValue, accessModifierSelectObservable, noUpdateValueStrategy(), WizardComponentDataConverters.strategyForPredicate(object -> {
if (object instanceof AccessModifier) {
return ((AccessModifier) object != AccessModifier.PRIVATE) && getModel().isDefinitionFile();
}
return false;
}));
// Refresh wizard state on validation change
@SuppressWarnings("unchecked") IObservableValue<ValidationResult> observableValidationValue = BeanProperties.value(WorkspaceWizardModelValidator.VALIDATION_RESULT).observe(getValidator());
observableValidationValue.addValueChangeListener(new IValueChangeListener<ValidationResult>() {
@Override
public void handleValueChange(ValueChangeEvent<? extends ValidationResult> event) {
onValidationChange(event.diff.getNewValue());
}
});
}
use of org.eclipse.core.databinding.UpdateValueStrategy in project n4js by eclipse.
the class WorkspaceWizardPage method setupBindings.
private void setupBindings(WorkspaceWizardPageForm wizardForm) {
databindingContext = new DataBindingContext();
WorkspaceWizardModelValidator<M> validator = getValidator();
// Project property binding
@SuppressWarnings("unchecked") IObservableValue<IPath> projectModelValue = BeanProperties.value(WorkspaceWizardModel.class, WorkspaceWizardModel.PROJECT_PROPERTY).observe(model);
@SuppressWarnings("unchecked") IObservableValue<String> projectUI = WidgetProperties.text(SWT.Modify).observe(wizardForm.getProjectText());
// Note: No model to UI conversation here as IPath is castable to String (default behavior)
databindingContext.bindValue(projectUI, projectModelValue, new StringToPathConverter().updatingValueStrategy(), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE));
// Source folder property binding
@SuppressWarnings("unchecked") IObservableValue<IPath> sourceFolderModelValue = BeanProperties.value(WorkspaceWizardModel.class, WorkspaceWizardModel.SOURCE_FOLDER_PROPERTY).observe(model);
@SuppressWarnings("unchecked") IObservableValue<String> sourceFolderUI = WidgetProperties.text(SWT.Modify).observe(wizardForm.getSourceFolderText());
// Note: No model to UI conversation (see above)
databindingContext.bindValue(sourceFolderUI, sourceFolderModelValue, new StringToPathConverter().updatingValueStrategy(), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE));
@SuppressWarnings("unchecked") IObservableValue<Boolean> projectValidModelValue = BeanProperties.value(WorkspaceWizardModelValidator.class, WorkspaceWizardModelValidator.PROJECT_PROPERTY_VALID).observe(validator);
@SuppressWarnings("unchecked") IObservableValue<Boolean> sourceFolderBrowseEnabled = WidgetProperties.enabled().observe(wizardForm.getSourceFolderBrowseButton());
databindingContext.bindValue(sourceFolderBrowseEnabled, projectValidModelValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE));
// Module specifier property binding
@SuppressWarnings("unchecked") IObservableValue<String> moduleSpecifierModelValue = BeanProperties.value(WorkspaceWizardModel.class, WorkspaceWizardModel.MODULE_SPECIFIER_PROPERTY).observe(model);
@SuppressWarnings("unchecked") IObservableValue<String> moduleSpecifierUI = BeanProperties.value(SuffixText.class, SuffixText.TEXT_PROPERTY).observe(wizardForm.getModuleSpecifierText());
databindingContext.bindValue(moduleSpecifierUI, moduleSpecifierModelValue);
// Conditional activation of the browse buttons according to the precedent input fields validity
@SuppressWarnings("unchecked") IObservableValue<Boolean> moduleSpecifierBrowseEnabled = WidgetProperties.enabled().observe(wizardForm.getModuleSpecifierBrowseButton());
@SuppressWarnings("unchecked") IObservableValue<Boolean> sourceFolderValidValue = BeanProperties.value(WorkspaceWizardModelValidator.class, WorkspaceWizardModelValidator.SOURCE_FOLDER_PROPERTY_VALID).observe(validator);
@SuppressWarnings("unchecked") IObservableValue<Boolean> projectValidValue = BeanProperties.value(WorkspaceWizardModelValidator.class, WorkspaceWizardModelValidator.PROJECT_PROPERTY_VALID).observe(validator);
ConditionalConverter moduleSpecifierBrowseableConverter = new ConditionalConverter() {
@Override
public boolean validate(Object object) {
return validator.getSourceFolderValid() && validator.getProjectValid();
}
};
// Bind model changes of project or source folder property to the enabled state of the module specifier browse
// button.
databindingContext.bindValue(moduleSpecifierBrowseEnabled, projectValidValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), moduleSpecifierBrowseableConverter.updatingValueStrategy());
databindingContext.bindValue(moduleSpecifierBrowseEnabled, sourceFolderValidValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), moduleSpecifierBrowseableConverter.updatingValueStrategy());
}
use of org.eclipse.core.databinding.UpdateValueStrategy in project meclipse by flaper87.
the class ConnectionWizardPage method createControl.
/**
* @see IDialogPage#createControl(Composite)
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
container.setLayout(layout);
layout.numColumns = 3;
layout.verticalSpacing = 9;
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 250;
Label label;
label = new Label(container, SWT.NULL);
label.setText(getCaption("connectionWizard.label.name"));
connName = new Text(container, SWT.BORDER | SWT.SINGLE);
connName.setLayoutData(gd);
label = new Label(container, SWT.NULL);
label.setImage(help);
label.setToolTipText(getCaption("connectionWizard.tooltip.name"));
label = new Label(container, SWT.NULL);
label.setText(getCaption("connectionWizard.label.host"));
host = new Text(container, SWT.BORDER | SWT.SINGLE);
host.setLayoutData(gd);
label = new Label(container, SWT.NULL);
label.setImage(help);
label.setToolTipText(getCaption("connectionWizard.tooltip.host"));
label = new Label(container, SWT.NULL);
label.setText(getCaption("connectionWizard.label.port"));
port = new Text(container, SWT.BORDER | SWT.SINGLE);
port.setLayoutData(gd);
port.setText("27017");
label = new Label(container, SWT.NULL);
label.setImage(help);
label.setToolTipText(getCaption("connectionWizard.tooltip.port"));
/*
* label = new Label(container, SWT.NULL); label.setText("&Username:");
* username= new Text(container, SWT.BORDER | SWT.SINGLE);
* username.setLayoutData(gd);
*/
/*
* label = new Label(container, SWT.NULL); label.setText("Passwo&rd:");
* password = new Text(container, SWT.BORDER | SWT.SINGLE);
* password.setLayoutData(gd);
*/
label = new Label(container, SWT.NULL);
label.setText("Auth not supported yet...");
// add WizardPage validators
DataBindingContext dbc = new DataBindingContext();
WizardPageSupport.create(this, dbc);
dbc.bindValue(SWTObservables.observeText(connName, SWT.Modify), nameValue, new UpdateValueStrategy().setBeforeSetValidator(new NameValidator()), null);
dbc.bindValue(SWTObservables.observeText(host, SWT.Modify), hostValue, new UpdateValueStrategy().setBeforeSetValidator(new HostNameValidator()), null);
dbc.bindValue(SWTObservables.observeText(port, SWT.Modify), portValue, new UpdateValueStrategy().setBeforeSetValidator(new PortValidator()), null);
initialize();
setControl(container);
// disable Save until everything matches
setPageComplete(false);
}
use of org.eclipse.core.databinding.UpdateValueStrategy 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);
}
Aggregations