List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeText
@Deprecated public static ISWTObservableValue observeText(Control control, int event)
control
. From source file:ch.elexis.core.ui.contacts.views.PatientDetailView.java
License:Open Source License
private void bindValue(Text text, String property, DataBindingContext bindingContext) { IObservableValue textObserveWidget = SWTObservables.observeDelayedValue(5, SWTObservables.observeText(text, SWT.Modify)); IObservableValue observeValue = PojoObservables.observeDetailValue(patientObservable, property, String.class); bindingContext.bindValue(textObserveWidget, observeValue, null, null); }
From source file:com.amazonaws.eclipse.android.sdk.newproject.AndroidProjectWizardPage.java
License:Open Source License
private void bindControls() { ISWTObservableValue projectNameTextObservableValue = SWTObservables.observeText(projectNameText, SWT.Modify);//from w w w . ja v a 2 s . com IObservableValue projectNameDataModelObservableValue = PojoObservables.observeValue(dataModel, "projectName"); bindingContext.bindValue(projectNameTextObservableValue, projectNameDataModelObservableValue, new UpdateValueStrategy().setAfterConvertValidator(new ProjectNameValidator()), null); ISWTObservableValue packageNameTextObservableValue = SWTObservables.observeText(packageNameText, SWT.Modify); IObservableValue packageNameDataModelObservableValue = PojoObservables.observeValue(dataModel, "packageName"); bindingContext.bindValue(packageNameTextObservableValue, packageNameDataModelObservableValue, new UpdateValueStrategy().setAfterConvertValidator(new PackageNameValidator()), null); ISWTObservableValue sampleCodeButtonObservableValue = SWTObservables.observeSelection(sampleCodeButton); IObservableValue sampleCodeDataModelObservableValue = PojoObservables.observeValue(dataModel, "sampleCodeIncluded"); bindingContext.bindValue(sampleCodeButtonObservableValue, sampleCodeDataModelObservableValue, null, null); IObservableValue androidTargetObservableValue = new AndroidTargetObservableValue(sdkTargetSelector); IObservableValue androidTargetModelObservableValue = PojoObservables.observeValue(dataModel, "androidTarget"); bindingContext.bindValue(androidTargetObservableValue, androidTargetModelObservableValue, new UpdateValueStrategy().setAfterConvertValidator(new AndroidTargetValidator()), null); aggregateValidationStatus = new AggregateValidationStatus(bindingContext.getBindings(), AggregateValidationStatus.MAX_SEVERITY); aggregateValidationStatus.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { updateErrorMessage(); } }); }
From source file:com.amazonaws.eclipse.core.ui.preferences.accounts.AccountInfoPropertyEditor.java
License:Apache License
/** * Reset the data-binding between the property of the AccountInfo POJO and * the text control provided by the concrete subclass. *///from w w w .j a v a 2s .co m protected void resetDataBinding() { // Remove the current binding if (bindingWithCurrentAccountInfo != null) { bindingWithCurrentAccountInfo.dispose(); } IObservableValue modelValue = BeansObservables.observeValue(accountInfo, propertyName); IObservableValue viewValue = SWTObservables.observeText(getTextControl(), SWT.Modify); bindingWithCurrentAccountInfo = bindingContext.bindValue(viewValue, modelValue); }
From source file:com.amazonaws.eclipse.core.ui.setupwizard.ConfigureAccountWizardPage.java
License:Apache License
public void createControl(Composite parent) { parent.setLayout(new GridLayout()); Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(450, 250)); composite.setLayout(new GridLayout(2, false)); setControl(composite);/* w ww .j a v a 2 s . c o m*/ WebLinkListener linkListener = new WebLinkListener(); GridDataFactory fullRowGridDataFactory = GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.TOP) .grab(true, false).span(2, 1); GridDataFactory firstColumnGridDataFactory = GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER); GridDataFactory secondColumnGridDataFactory = GridDataFactory.swtDefaults().align(SWT.FILL, SWT.TOP) .grab(true, false); Label label = new Label(composite, SWT.WRAP); label.setText("Before you can start using the toolkit, you need to configure an AWS account."); fullRowGridDataFactory.applyTo(label); Link link = new Link(composite, SWT.WRAP); link.addListener(SWT.Selection, linkListener); link.setText("Use your <a href=\"" + SECURITY_CREDENTIALS_URL + "\">existing credentials</a> or " + "<a href=\"" + CREATE_ACCOUNT_URL + "\">create a new AWS account</a>."); fullRowGridDataFactory.applyTo(link); // AWS Access Key ID row Label accessKeyLabel = new Label(composite, SWT.NONE); accessKeyLabel.setText("Access Key ID:"); firstColumnGridDataFactory.copy().indent(10, 5).applyTo(accessKeyLabel); Text accessKeyText = new Text(composite, SWT.BORDER); secondColumnGridDataFactory.copy().indent(0, 5).applyTo(accessKeyText); accessKeyText.setFocus(); IObservableValue accessKeyModelObservable = PojoObservables.observeValue(dataModel, dataModel.ACCESS_KEY_ID); bindingContext.bindValue(SWTObservables.observeText(accessKeyText, SWT.Modify), accessKeyModelObservable); bindingContext.addValidationStatusProvider(new ChainValidator<String>(accessKeyModelObservable, new NotEmptyValidator("Please provide an AWS Access Key ID"))); // AWS Secret Key row Label secretKeyLabel = new Label(composite, SWT.NONE); secretKeyLabel.setText("Secret Access Key:"); firstColumnGridDataFactory.copy().indent(10, 0).applyTo(secretKeyLabel); Text secretKeyText = new Text(composite, SWT.BORDER); secondColumnGridDataFactory.applyTo(secretKeyText); IObservableValue secretKeyModelObservable = PojoObservables.observeValue(dataModel, dataModel.SECRET_ACCESS_KEY); bindingContext.bindValue(SWTObservables.observeText(secretKeyText, SWT.Modify), secretKeyModelObservable); bindingContext.addValidationStatusProvider(new ChainValidator<String>(secretKeyModelObservable, new NotEmptyValidator("Please provide an AWS Secret Access Key"))); // Open Explorer view row openExplorerCheckBox = new Button(composite, SWT.CHECK); openExplorerCheckBox.setText("Open the AWS Explorer view"); openExplorerCheckBox.setSelection(true); fullRowGridDataFactory.indent(0, 5).applyTo(openExplorerCheckBox); bindingContext.bindValue(SWTObservables.observeSelection(openExplorerCheckBox), PojoObservables.observeValue(dataModel, dataModel.OPEN_EXPLORER)); Composite spacer = new Composite(composite, SWT.NONE); spacer.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 2, 1)); link = new Link(composite, SWT.WRAP); link.addListener(SWT.Selection, linkListener); link.setText("For a full walkthrough of the features available in the AWS Toolkit for Eclipse, " + "see the <a href=\"" + GETTING_STARTED_GUIDE_URL + "\">AWS Toolkit for Eclipse Getting Started Guide</a>."); fullRowGridDataFactory.applyTo(link); aggregateValidationStatus.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { Object value = aggregateValidationStatus.getValue(); if (value instanceof IStatus == false) return; IStatus status = (IStatus) value; setPageComplete(status.isOK()); } }); setPageComplete(false); parent.getShell().pack(true); Rectangle workbenchBounds = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getBounds(); Point dialogSize = this.getShell().getSize(); this.getShell().setLocation(workbenchBounds.x + (workbenchBounds.width - dialogSize.x) / 2, workbenchBounds.y + (workbenchBounds.height - dialogSize.y) / 2); }
From source file:com.amazonaws.eclipse.core.ui.wizards.TextWizardPageInput.java
License:Apache License
/** {@inheritDoc} */ public void init(final Composite parent, final DataBindingContext context) { createLabelColumn(parent);/* www . j av a 2 s . co m*/ PostBuildHook<Text> bindInputHook = new PostBuildHook<Text>() { public void run(final Text value) { context.bindValue(observableValue, SWTObservables.observeText(value, SWT.Modify)); context.addValidationStatusProvider(validator); ErrorDecorator.bind(value, validator.getValidationStatus()); } }; createInputColumn(parent, bindInputHook); }
From source file:com.amazonaws.eclipse.dynamodb.testtool.StartTestToolConfigurationWizardPage.java
License:Apache License
/** * Bind the UI to our internal model and wire up a validator to make sure * the user has input valid value(s).//from w ww. j ava 2s. c o m */ private void bindInputs() { IObservableValue observable = SWTObservables.observeText(portInput, SWT.Modify); context.bindValue(observable, portValue); context.addValidationStatusProvider(new ChainValidator<String>(observable, new PortValidator())); final AggregateValidationStatus aggregator = new AggregateValidationStatus(context, AggregateValidationStatus.MAX_SEVERITY); aggregator.addChangeListener(new IChangeListener() { public void handleChange(final ChangeEvent event) { Object value = aggregator.getValue(); if (!(value instanceof IStatus)) { return; } IStatus status = (IStatus) value; setPageComplete(status.isOK()); } }); ErrorDecorator.bind(portInput, aggregator); }
From source file:com.amazonaws.eclipse.elasticbeanstalk.server.ui.configEditor.basic.ContainerConfigEditorSection.java
License:Apache License
private void createDebugEnablementControl(Composite composite) { final Button enablement = toolkit.createButton(composite, "Enable remote debugging", SWT.CHECK); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false); layoutData.horizontalSpan = 2;/*from www.j a va 2 s . co m*/ enablement.setLayoutData(layoutData); final Label portLabel = toolkit.createLabel(composite, "Remote debugging port:"); portLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); final Text portText = toolkit.createText(composite, ""); layoutTextField(portText); ConfigurationOptionDescription jvmOptions = null; for (ConfigurationOptionDescription opt : options) { if ("JVM Options".equals(opt.getName())) { jvmOptions = opt; break; } } if (jvmOptions == null) throw new RuntimeException("Couldn't determine JVM options"); /* * These bindings are complicated because we don't copy the value across * directly. Instead, we modify the JVM options string (or respond to * modification of it). */ final IObservableValue jvmOptionsObservable = model.observeEntry(jvmOptions); final IObservableValue textObservable = SWTObservables.observeText(portText, SWT.Modify); final IObservableValue enablementObservable = SWTObservables.observeSelection(enablement); IValueChangeListener listener = new IValueChangeListener() { public void handleValueChange(ValueChangeEvent event) { portText.setEnabled((Boolean) enablementObservable.getValue()); portLabel.setEnabled((Boolean) enablementObservable.getValue()); } }; enablementObservable.addValueChangeListener(listener); setupBindingsForDebugPort(jvmOptionsObservable, textObservable); setupBindingsForDebugEnablement(jvmOptionsObservable, enablementObservable); listener.handleValueChange(null); }
From source file:com.amazonaws.eclipse.elasticbeanstalk.server.ui.configEditor.EnvironmentConfigEditorSection.java
License:Open Source License
/** * Creates a text field and label combo using the option given. *//*w ww . j a va2s . c om*/ protected void createTextField(Composite parent, ConfigurationOptionDescription option) { Label label = createLabel(toolkit, parent, option); label.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); Text text = toolkit.createText(parent, ""); layoutTextField(text); IObservableValue modelv = model.observeEntry(option); ISWTObservableValue widget = SWTObservables.observeText(text, SWT.Modify); bindingContext.bindValue(widget, modelv, new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE)); text.addModifyListener(new DirtyMarker()); ChainValidator<String> validationStatusProvider = new ChainValidator<String>(widget, null, new ConfigurationSettingValidator(option)); bindingContext.addValidationStatusProvider(validationStatusProvider); ControlDecoration decoration = new ControlDecoration(text, SWT.TOP | SWT.LEFT); decoration.setDescriptionText("Invalid value"); FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); decoration.setImage(fieldDecoration.getImage()); new DecorationChangeListener(decoration, validationStatusProvider.getValidationStatus()); }
From source file:com.amazonaws.eclipse.elasticbeanstalk.server.ui.configEditor.ExportTemplateDialog.java
License:Apache License
@Override protected Control createCustomArea(Composite parent) { parent.setLayout(new FillLayout()); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); Group templateNameGroup = new Group(composite, SWT.None); templateNameGroup.setLayout(new GridLayout(2, false)); GridData groupData = new GridData(); groupData.horizontalSpan = 2;/*from w w w . ja v a 2s . c o m*/ templateNameGroup.setLayoutData(groupData); // Update existing template final Button updateExistingRadioButton = new Button(templateNameGroup, SWT.RADIO); updateExistingRadioButton.setText("Update an existing template"); final Combo existingTemplateNamesCombo = new Combo(templateNameGroup, SWT.READ_ONLY); existingTemplateNamesCombo.setEnabled(false); if (existingTemplateNames.isEmpty()) { updateExistingRadioButton.setEnabled(false); } else { existingTemplateNamesCombo .setItems(existingTemplateNames.toArray(new String[existingTemplateNames.size()])); existingTemplateNamesCombo.select(0); } // Create new template -- default option Button createNewRadioButton = new Button(templateNameGroup, SWT.RADIO); createNewRadioButton.setText("Create a new template"); final Text templateNameText = new Text(templateNameGroup, SWT.BORDER); templateNameText.setText(templateName); templateNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); updateExistingRadioButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { templateNameText.setEnabled(!updateExistingRadioButton.getSelection()); existingTemplateNamesCombo.setEnabled(updateExistingRadioButton.getSelection()); } }); // Description new Label(composite, SWT.NONE).setText("Template description: "); final Text templateDescriptionText = new Text(composite, SWT.BORDER); templateDescriptionText.setText(""); templateDescriptionText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // Data binding bindingContext.bindValue(SWTObservables.observeSelection(createNewRadioButton), isCreatingNew); isCreatingNew.setValue(true); bindingContext.bindValue(SWTObservables.observeSelection(existingTemplateNamesCombo), existingTemplateName) .updateTargetToModel(); bindingContext.bindValue(SWTObservables.observeText(templateNameText, SWT.Modify), newTemplateName); bindingContext.bindValue(SWTObservables.observeText(templateDescriptionText, SWT.Modify), templateDescription); WritableSet inUseNames = new WritableSet(); inUseNames.addAll(existingTemplateNames); ChainValidator<String> validator = new ChainValidator<String>(newTemplateName, isCreatingNew, new NotEmptyValidator("Template name cannot be empty"), new NotInListValidator<String>(inUseNames, "Template name already in use")); bindingContext.addValidationStatusProvider(validator); // Decorate the new name field with error status ControlDecoration decoration = new ControlDecoration(templateNameText, SWT.TOP | SWT.LEFT); decoration.setDescriptionText("Invalid value"); FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); decoration.setImage(fieldDecoration.getImage()); new DecorationChangeListener(decoration, validator.getValidationStatus()); return composite; }
From source file:com.amazonaws.eclipse.elasticbeanstalk.server.ui.DeployWizardApplicationSelectionPage.java
License:Apache License
private void bindControls() { super.initializeValidators(); newApplicationNameTextObservable = SWTObservables.observeText(newApplicationNameText, SWT.Modify); bindingContext.bindValue(newApplicationNameTextObservable, PojoObservables.observeValue(wizardDataModel, DeployWizardDataModel.NEW_APPLICATION_NAME), null, null);//from w w w . j av a 2 s. c om ChainValidator<String> applicationNameValidator = new ChainValidator<String>( newApplicationNameTextObservable, createNewApplicationRadioButtonObservable, new NotEmptyValidator("Application name cannot be empty."), new NoInvalidNameCharactersValidator("Invalid characters in application name."), new NotInListValidator<String>(existingApplicationNames, "Duplicate application name.")); bindingContext.addValidationStatusProvider(applicationNameValidator); bindingContext.addValidationStatusProvider(new ChainValidator<Boolean>(applicationNamesLoaded, null, new BooleanValidator("Appliction names not yet loaded"))); new DecorationChangeListener(newApplicationNameDecoration, applicationNameValidator.getValidationStatus()); newApplicationDescriptionTextObservable = SWTObservables.observeText(newApplicationDescriptionText, SWT.Modify); bindingContext.bindValue(newApplicationDescriptionTextObservable, PojoObservables.observeValue(wizardDataModel, DeployWizardDataModel.NEW_APPLICATION_DESCRIPTION), null, null); bindingContext.bindValue(createNewApplicationRadioButtonObservable, PojoObservables.observeValue(wizardDataModel, DeployWizardDataModel.CREATING_NEW_APPLICATION), null, null); // Existing application bindings bindingContext.bindValue(SWTObservables.observeSelection(existingApplicationCombo), PojoObservables.observeValue(wizardDataModel, DeployWizardDataModel.EXISTING_APPLICATION_NAME)); // New environment bindings newEnvironmentNameTextObservable = SWTObservables.observeText(newEnvironmentNameText, SWT.Modify); bindingContext.bindValue(newEnvironmentNameTextObservable, PojoObservables.observeValue(wizardDataModel, DeployWizardDataModel.NEW_ENVIRONMENT_NAME), null, null); newEnvironmentDescriptionTextObservable = SWTObservables.observeText(newEnvironmentDescriptionText, SWT.Modify); bindingContext.bindValue(newEnvironmentDescriptionTextObservable, PojoObservables.observeValue(wizardDataModel, DeployWizardDataModel.NEW_ENVIRONMENT_DESCRIPTION), null, null); ChainValidator<String> environmentNameValidator = new ChainValidator<String>( newEnvironmentNameTextObservable, null, new NotEmptyValidator("The environment name cannot be empty."), new NoInvalidNameCharactersValidator("Invalid characters in environment name."), new NotInListValidator<String>(existingEnvironmentNames, "Duplicate environment name.")); bindingContext.addValidationStatusProvider(environmentNameValidator); bindingContext.addValidationStatusProvider(new ChainValidator<Boolean>(environmentNamesLoaded, null, new BooleanValidator("Environment names not yet loaded"))); new DecorationChangeListener(newEnvironmentNameDecoration, environmentNameValidator.getValidationStatus()); }