List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeSelection
@Deprecated public static ISWTObservableValue observeSelection(Control control)
control
. 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 w ww .jav a 2 s .c o 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.basic.EnvironmentTypeConfigEditorSection.java
License:Apache License
@Override protected void createCombo(Composite parent, ConfigurationOptionDescription option) { Label label = createLabel(toolkit, parent, option); label.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); final Combo combo = new Combo(parent, SWT.READ_ONLY); combo.setItems(option.getValueOptions().toArray(new String[option.getValueOptions().size()])); IObservableValue modelv = model.observeEntry(option); ISWTObservableValue widget = SWTObservables.observeSelection(combo); parentEditor.getDataBindingContext().bindValue(widget, modelv, new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE)); final String oldEnvironmentType = (String) modelv.getValue(); // After you do the confirmation, we will update the environment and refresh the layout. combo.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { boolean confirmation = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Change Environment Type", CHANGE_ENVIRONMENT_TYPE_WARNING); if (confirmation == true) { parentEditor.destroyOldLayouts(); UpdateEnvironmentRequest rq = generateUpdateEnvironmentTypeRequest(); if (rq != null) { UpdateEnvironmentAndRefreshLayoutJob job = new UpdateEnvironmentAndRefreshLayoutJob( environment, rq); job.schedule();//w ww . jav a 2 s . co m } } else { combo.setText(oldEnvironmentType); } } public void widgetDefaultSelected(SelectionEvent e) { } }); }
From source file:com.amazonaws.eclipse.elasticbeanstalk.server.ui.configEditor.EnvironmentConfigEditorSection.java
License:Open Source License
/** * Creates a checkbox control with the option given. *//*w ww . j a v a2s . c om*/ protected void createCheckbox(Composite parent, ConfigurationOptionDescription option) { Button button = toolkit.createButton(parent, getName(option), SWT.CHECK); GridData layoutData = new GridData(); layoutData.horizontalSpan = 2; button.setLayoutData(layoutData); IObservableValue modelv = model.observeEntry(option); ISWTObservableValue widget = SWTObservables.observeSelection(button); bindingContext.bindValue(widget, modelv, new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE)); button.addSelectionListener(new DirtyMarker()); }
From source file:com.amazonaws.eclipse.elasticbeanstalk.server.ui.configEditor.EnvironmentConfigEditorSection.java
License:Open Source License
/** * Creates a drop-down combo with the option given. */// w w w. j ava 2 s .co m protected void createCombo(Composite parent, ConfigurationOptionDescription option) { Label label = createLabel(toolkit, parent, option); label.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); Combo combo = new Combo(parent, SWT.READ_ONLY); combo.setItems(option.getValueOptions().toArray(new String[option.getValueOptions().size()])); IObservableValue modelv = model.observeEntry(option); ISWTObservableValue widget = SWTObservables.observeSelection(combo); parentEditor.bindingContext .bindValue(widget, modelv, new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE)) .updateTargetToModel(); combo.addSelectionListener(new DirtyMarker()); }
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 . j a va 2 s.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 createApplicationSection(Composite composite) { Group applicationGroup = newGroup(composite, "Application:", 2); applicationGroup.setLayout(new GridLayout(2, false)); createNewApplicationRadioButton = newRadioButton(applicationGroup, "Create a new application:", 2, true); createNewApplicationRadioButtonObservable = SWTObservables .observeSelection(createNewApplicationRadioButton); new NewApplicationOptionsComposite(applicationGroup); existingApplicationRadioButton = newRadioButton(applicationGroup, "Choose an existing application:", 1); existingApplicationCombo = newCombo(applicationGroup); existingApplicationCombo.setEnabled(false); }
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);/* ww w . j a v a2 s . c o m*/ 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()); }
From source file:com.amazonaws.eclipse.elasticbeanstalk.server.ui.DeployWizardEnvironmentConfigPage.java
License:Apache License
/** * Creates validation bindings for the controls on this page. */// w w w . j a va 2 s . c om private void bindControls() { initializeValidators(); // Key pair usingKeyPairObservable = SWTObservables.observeSelection(usingKeyPair); bindingContext.bindValue(usingKeyPairObservable, PojoObservables.observeValue(wizardDataModel, DeployWizardDataModel.USING_KEY_PAIR), null, null); IViewerObservableValue keyPairSelectionObservable = ViewersObservables .observeSingleSelection(keyPairComposite.getViewer()); bindingContext.bindValue(keyPairSelectionObservable, PojoObservables.observeValue(wizardDataModel, DeployWizardDataModel.KEY_PAIR), null, null); ChainValidator<String> keyPairValidator = new ChainValidator<String>(keyPairSelectionObservable, usingKeyPairObservable, new ValidKeyPairValidator(AwsToolkitCore.getDefault().getCurrentAccountId())); bindingContext.addValidationStatusProvider(keyPairValidator); usingCnameObservable = SWTObservables.observeSelection(usingCnameButton); bindingContext.bindValue(usingCnameObservable, PojoObservables.observeValue(wizardDataModel, DeployWizardDataModel.USING_CNAME), null, null) .updateTargetToModel(); bindingContext .bindValue(SWTObservables.observeText(cname, SWT.Modify), PojoObservables.observeValue(wizardDataModel, DeployWizardDataModel.CNAME), null, null) .updateTargetToModel(); // SSL cert bindingContext.bindValue(sslCertObservable, PojoObservables.observeValue(wizardDataModel, DeployWizardDataModel.SSL_CERTIFICATE_ID)); // CNAME // TODO: make CNAME conform to exact spec, check for in-use ChainValidator<String> chainValidator = new ChainValidator<String>( SWTObservables.observeText(cname, SWT.Modify), usingCnameObservable, new NotEmptyValidator("CNAME cannot be empty."), new NoInvalidNameCharactersValidator("Invalid characters in CNAME.")); bindingContext.addValidationStatusProvider(chainValidator); ControlDecoration cnameDecoration = newControlDecoration(cname, "Enter a CNAME to launch your server"); new DecorationChangeListener(cnameDecoration, chainValidator.getValidationStatus()); // Health check URL bindingContext.bindValue(healthCheckURLObservable, PojoObservables.observeValue(wizardDataModel, DeployWizardDataModel.HEALTH_CHECK_URL)); // SNS topic bindingContext.bindValue(snsTopicObservable, PojoObservables.observeValue(wizardDataModel, DeployWizardDataModel.SNS_ENDPOINT)); }
From source file:com.amazonaws.eclipse.elasticbeanstalk.webproject.JavaWebProjectWizardPage.java
License:Open Source License
@SuppressWarnings("static-access") private void bindControls() { UpdateValueStrategy projectNameUpdateStrategy = new UpdateValueStrategy(); projectNameUpdateStrategy.setAfterConvertValidator(new NewProjectNameValidator()); bindingContext.bindValue(SWTObservables.observeText(projectNameText, SWT.Modify), PojoObservables.observeValue(dataModel, dataModel.PROJECT_NAME), projectNameUpdateStrategy, null); final IObservableValue accountId = new WritableValue(); accountId.setValue(dataModel.getAccountId()); accountSelectionComposite.addSelectionListener(new SelectionAdapter() { @Override//from w w w. j ava 2 s .co m public void widgetSelected(SelectionEvent e) { accountId.setValue(accountSelectionComposite.getSelectedAccountId()); } }); bindingContext.bindValue(accountId, PojoObservables.observeValue(dataModel, dataModel.ACCOUNT_ID), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)); bindingContext.bindValue(SWTObservables.observeSelection(travelLogRadioButton), PojoObservables.observeValue(dataModel, dataModel.SAMPLE_APP_INCLUDED), null, null); }
From source file:com.amazonaws.eclipse.explorer.cloudformation.wizard.CreateStackWizardFirstPage.java
License:Apache License
private void createStackNameControl(final Composite comp, int fieldDecorationWidth) { // Whether the user already set the stack name. boolean stackNameExists = false; new Label(comp, SWT.READ_ONLY).setText("Stack Name: "); Control stackNameControl = null; if (wizard.getDataModel().getMode() == Mode.Create) { Text stackNameText = new Text(comp, SWT.BORDER); bindingContext.bindValue(SWTObservables.observeText(stackNameText, SWT.Modify), stackName) .updateTargetToModel();// w w w .j a va 2 s . c o m stackNameControl = stackNameText; } else { Combo combo = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN); if (stackName.getValue() != null) { combo.setItems(new String[] { (String) stackName.getValue() }); stackNameExists = true; } else { combo.setItems(new String[] { LOADING_STACKS }); } combo.select(0); bindingContext.bindValue(SWTObservables.observeSelection(combo), stackName).updateTargetToModel(); stackNameControl = combo; stackName.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { if ((Boolean) useTemplateFile.getValue()) { validateTemplateFile((String) templateFile.getValue()); } else { validateTemplateUrl((String) templateUrl.getValue()); } } }); if (!stackNameExists) { loadStackNames(combo); } } GridDataFactory.fillDefaults().grab(true, false).span(2, 1).indent(fieldDecorationWidth, 0) .applyTo(stackNameControl); ChainValidator<String> stackNameValidationStatusProvider = new ChainValidator<String>(stackName, new NotEmptyValidator("Please provide a stack name")); bindingContext.addValidationStatusProvider(stackNameValidationStatusProvider); addStatusDecorator(stackNameControl, stackNameValidationStatusProvider); }