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:com.amazonaws.eclipse.explorer.dynamodb.AddLSIDialog.java
License:Apache License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); composite.setLayout(new GridLayout()); composite = new Composite(composite, SWT.NULL); GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); composite.setLayout(new GridLayout(2, false)); // Index range key attribute name new Label(composite, SWT.NONE | SWT.READ_ONLY).setText("Attribute to Index:"); attributeNameText = new Text(composite, SWT.BORDER); bindingContext.bindValue(SWTObservables.observeText(attributeNameText, SWT.Modify), indexRangeKeyNameInKeySchemaDefinitionModel); ChainValidator<String> attributeNameValidationStatusProvider = new ChainValidator<String>( indexRangeKeyNameInKeySchemaDefinitionModel, new NotEmptyValidator("Please provide an attribute name")); bindingContext.addValidationStatusProvider(attributeNameValidationStatusProvider); bindingContext.bindValue(SWTObservables.observeText(attributeNameText, SWT.Modify), indexRangeKeyNameInAttributeDefinitionsModel); attributeNameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (attributeNameText.getText().equals(primaryRangeKeyName) && attributeTypeCombo != null && primaryRangeKeyTypeComboIndex > -1) { attributeTypeCombo.select(primaryRangeKeyTypeComboIndex); attributeTypeCombo.setEnabled(false); } else if (attributeTypeCombo != null) { attributeTypeCombo.setEnabled(true); }//w w w .j a v a2 s . co m } }); GridDataFactory.fillDefaults().grab(true, false).applyTo(attributeNameText); // Index range key attribute type new Label(composite, SWT.NONE | SWT.READ_ONLY).setText("Attribute Type:"); attributeTypeCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY); attributeTypeCombo.setItems(DATA_TYPE_STRINGS); attributeTypeCombo.select(0); bindingContext.bindValue(SWTObservables.observeSelection(attributeTypeCombo), indexRangeKeyAttributeTypeModel); // Index name new Label(composite, SWT.NONE | SWT.READ_ONLY).setText("Index Name:"); indexNameText = new Text(composite, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(indexNameText); bindingContext.bindValue(SWTObservables.observeText(indexNameText, SWT.Modify), indexNameModel); ChainValidator<String> indexNameValidationStatusProvider = new ChainValidator<String>(indexNameModel, new NotEmptyValidator("Please provide an index name")); bindingContext.addValidationStatusProvider(indexNameValidationStatusProvider); // Projection type new Label(composite, SWT.NONE | SWT.READ_ONLY).setText("Projected Attributes:"); projectionTypeCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY); projectionTypeCombo.setItems(PROJECTED_ATTRIBUTES); projectionTypeCombo.select(0); bindingContext.bindValue(SWTObservables.observeSelection(projectionTypeCombo), projectionTypeModel); projectionTypeCombo.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (projectionTypeCombo.getSelectionIndex() == 2) { // Enable the list for adding non-key attributes to the projection addAttributeButton.setEnabled(true); } else { addAttributeButton.setEnabled(false); } } public void widgetDefaultSelected(SelectionEvent e) { } }); // Non-key attributes in the projection final AttributeList attributeList = new AttributeList(composite); GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, SWT.DEFAULT).applyTo(attributeList); addAttributeButton = new Button(composite, SWT.PUSH); addAttributeButton.setText("Add Attribute"); addAttributeButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); addAttributeButton.setImage(AwsToolkitCore.getDefault().getImageRegistry().get(AwsToolkitCore.IMAGE_ADD)); addAttributeButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { AddNewAttributeDialog newAttributeTable = new AddNewAttributeDialog(); if (newAttributeTable.open() == 0) { // lazy-initialize the list if (null == localSecondaryIndex.getProjection().getNonKeyAttributes()) { localSecondaryIndex.getProjection().setNonKeyAttributes(new LinkedList<String>()); } localSecondaryIndex.getProjection().getNonKeyAttributes() .add(newAttributeTable.getNewAttributeName()); attributeList.refresh(); } } public void widgetDefaultSelected(SelectionEvent e) { } }); addAttributeButton.setEnabled(false); // Finally provide aggregate status reporting for the entire wizard page final AggregateValidationStatus aggregateValidationStatus = new AggregateValidationStatus(bindingContext, AggregateValidationStatus.MAX_SEVERITY); aggregateValidationStatus.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { Object value = aggregateValidationStatus.getValue(); if (value instanceof IStatus == false) return; IStatus status = (IStatus) value; if (status.getSeverity() == Status.ERROR) { setErrorMessage(status.getMessage()); if (okButton != null) { okButton.setEnabled(false); } } else { setErrorMessage(null); if (okButton != null) { okButton.setEnabled(true); } } } }); bindingContext.updateModels(); return composite; }
From source file:com.amazonaws.eclipse.explorer.dynamodb.CreateTableFirstPage.java
License:Apache License
public void createControl(Composite parent) { Composite comp = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(comp); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(comp); // Table name Label tableNameLabel = new Label(comp, SWT.READ_ONLY); tableNameLabel.setText("Table Name:"); final Text tableNameText = CreateTablePageUtil.newTextField(comp); bindingContext.bindValue(SWTObservables.observeText(tableNameText, SWT.Modify), tableName); ChainValidator<String> tableNameValidationStatusProvider = new ChainValidator<String>(tableName, new NotEmptyValidator("Please provide a table name")); bindingContext.addValidationStatusProvider(tableNameValidationStatusProvider); // Hash key//ww w. j ava 2s . com Group hashKeyGroup = CreateTablePageUtil.newGroup(comp, "Hash Key", 2); new Label(hashKeyGroup, SWT.READ_ONLY).setText("Hash Key Name:"); final Text hashKeyText = CreateTablePageUtil.newTextField(hashKeyGroup); bindingContext.bindValue(SWTObservables.observeText(hashKeyText, SWT.Modify), hashKeyName); ChainValidator<String> hashKeyNameValidationStatusProvider = new ChainValidator<String>(hashKeyName, new NotEmptyValidator("Please provide an attribute name for the hash key")); bindingContext.addValidationStatusProvider(hashKeyNameValidationStatusProvider); new Label(hashKeyGroup, SWT.READ_ONLY).setText("Hash Key Type:"); final Combo hashKeyTypeCombo = new Combo(hashKeyGroup, SWT.DROP_DOWN | SWT.READ_ONLY); hashKeyTypeCombo.setItems(DATA_TYPE_STRINGS); bindingContext.bindValue(SWTObservables.observeSelection(hashKeyTypeCombo), hashKeyType); hashKeyTypeCombo.select(0); // Range key Group rangeKeyGroup = CreateTablePageUtil.newGroup(comp, "Range Key", 2); final Button enableRangeKeyButton = new Button(rangeKeyGroup, SWT.CHECK); enableRangeKeyButton.setText("Enable Range Key"); GridDataFactory.fillDefaults().span(2, 1).applyTo(enableRangeKeyButton); bindingContext.bindValue(SWTObservables.observeSelection(enableRangeKeyButton), enableRangeKey); final Label rangeKeyAttributeLabel = new Label(rangeKeyGroup, SWT.READ_ONLY); rangeKeyAttributeLabel.setText("Range Key Name:"); final Text rangeKeyText = CreateTablePageUtil.newTextField(rangeKeyGroup); bindingContext.bindValue(SWTObservables.observeText(rangeKeyText, SWT.Modify), rangeKeyName); ChainValidator<String> rangeKeyNameValidationStatusProvider = new ChainValidator<String>(rangeKeyName, enableRangeKey, new NotEmptyValidator("Please provide an attribute name for the range key")); bindingContext.addValidationStatusProvider(rangeKeyNameValidationStatusProvider); final Label rangeKeyTypeLabel = new Label(rangeKeyGroup, SWT.READ_ONLY); rangeKeyTypeLabel.setText("Range Key Type:"); final Combo rangeKeyTypeCombo = new Combo(rangeKeyGroup, SWT.DROP_DOWN | SWT.READ_ONLY); rangeKeyTypeCombo.setItems(DATA_TYPE_STRINGS); bindingContext.bindValue(SWTObservables.observeSelection(rangeKeyTypeCombo), rangeKeyType); rangeKeyTypeCombo.select(0); enableRangeKeyButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { usesRangeKey = enableRangeKeyButton.getSelection(); rangeKeyAttributeLabel.setEnabled(usesRangeKey); rangeKeyText.setEnabled(usesRangeKey); rangeKeyTypeLabel.setEnabled(usesRangeKey); rangeKeyTypeCombo.setEnabled(usesRangeKey); } }); enableRangeKeyButton.setSelection(false); rangeKeyAttributeLabel.setEnabled(usesRangeKey); rangeKeyText.setEnabled(usesRangeKey); rangeKeyTypeLabel.setEnabled(usesRangeKey); rangeKeyTypeCombo.setEnabled(usesRangeKey); FontData[] fontData = tableNameLabel.getFont().getFontData(); for (FontData fd : fontData) { fd.setStyle(SWT.ITALIC); } italicFont = new Font(Display.getDefault(), fontData); // Table throughput Group throughputGroup = CreateTablePageUtil.newGroup(comp, "Table Throughput", 3); new Label(throughputGroup, SWT.READ_ONLY).setText("Read Capacity Units:"); final Text readCapacityText = CreateTablePageUtil.newTextField(throughputGroup); readCapacityText.setText("" + CAPACITY_UNIT_MINIMUM); bindingContext.bindValue(SWTObservables.observeText(readCapacityText, SWT.Modify), readCapacity); ChainValidator<Long> readCapacityValidationStatusProvider = new ChainValidator<Long>(readCapacity, new RangeValidator("Please enter a read capacity of " + CAPACITY_UNIT_MINIMUM + " or more.", CAPACITY_UNIT_MINIMUM, Long.MAX_VALUE)); bindingContext.addValidationStatusProvider(readCapacityValidationStatusProvider); Label minimumReadCapacityLabel = new Label(throughputGroup, SWT.READ_ONLY); minimumReadCapacityLabel.setText("(Minimum capacity " + CAPACITY_UNIT_MINIMUM + ")"); minimumReadCapacityLabel.setFont(italicFont); new Label(throughputGroup, SWT.READ_ONLY).setText("Write Capacity Units:"); final Text writeCapacityText = CreateTablePageUtil.newTextField(throughputGroup); writeCapacityText.setText("" + CAPACITY_UNIT_MINIMUM); Label minimumWriteCapacityLabel = new Label(throughputGroup, SWT.READ_ONLY); minimumWriteCapacityLabel.setText("(Minimum capacity " + CAPACITY_UNIT_MINIMUM + ")"); minimumWriteCapacityLabel.setFont(italicFont); bindingContext.bindValue(SWTObservables.observeText(writeCapacityText, SWT.Modify), writeCapacity); ChainValidator<Long> writeCapacityValidationStatusProvider = new ChainValidator<Long>(writeCapacity, new RangeValidator("Please enter a write capacity of " + CAPACITY_UNIT_MINIMUM + " or more.", CAPACITY_UNIT_MINIMUM, Long.MAX_VALUE)); bindingContext.addValidationStatusProvider(writeCapacityValidationStatusProvider); final Label throughputCapacityLabel = new Label(throughputGroup, SWT.WRAP); throughputCapacityLabel.setText( "Amazon DynamoDB will reserve the necessary machine resources to meet your throughput needs based on the read and write capacity specified with consistent, low-latency performance. You pay a flat, hourly rate based on the capacity you reserve."); GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); gridData.horizontalSpan = 3; gridData.widthHint = 200; throughputCapacityLabel.setLayoutData(gridData); throughputCapacityLabel.setFont(italicFont); // Help info String pricingLinkText = "<a href=\"" + "http://aws.amazon.com/dynamodb/#pricing" + "\">" + "More information on Amazon DynamoDB pricing</a>. "; CreateTablePageUtil.newLink(new WebLinkListener(), pricingLinkText, throughputGroup); // Finally provide aggregate status reporting for the entire wizard page final AggregateValidationStatus aggregateValidationStatus = new AggregateValidationStatus(bindingContext, AggregateValidationStatus.MAX_SEVERITY); aggregateValidationStatus.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { Object value = aggregateValidationStatus.getValue(); if (value instanceof IStatus == false) return; IStatus status = (IStatus) value; if (status.isOK()) { setErrorMessage(null); setMessage(OK_MESSAGE, Status.OK); } else if (status.getSeverity() == Status.WARNING) { setErrorMessage(null); setMessage(status.getMessage(), Status.WARNING); } else if (status.getSeverity() == Status.ERROR) { setErrorMessage(status.getMessage()); } setPageComplete(status.isOK()); } }); setPageComplete(false); setControl(comp); }
From source file:com.amazonaws.eclipse.explorer.s3.actions.CreateBucketWizardPage.java
License:Apache License
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.None); GridLayout layout = new GridLayout(2, false); layout.horizontalSpacing = 10;//from www. j ava 2 s . com composite.setLayout(layout); Label label = new Label(composite, SWT.None); label.setText("Bucket name: "); Text text = new Text(composite, SWT.BORDER); GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); text.setLayoutData(data); bindingContext.bindValue(bucketNameObservable, SWTObservables.observeText(text, SWT.Modify)); MultiValidator validationStatusProvider = new MultiValidator() { @Override protected IStatus validate() { String bucketName = (String) bucketNameObservable.getValue(); if (bucketName == null || bucketName.length() == 0) { return ValidationStatus.error("Please enter a bucket name"); } try { bucketNameUtils.validateBucketName(bucketName); } catch (IllegalArgumentException e) { return ValidationStatus.error(e.getMessage()); } if (!bucketNamePattern.matcher(bucketName).matches()) { return ValidationStatus.error( "Bucket name does not match requirements. See http://docs.amazonwebservices.com/AmazonS3/latest/dev/"); } if (availableBucketNames.contains(bucketName)) { return ValidationStatus.ok(); } if (unavailableBucketNames.contains(bucketName)) { return ValidationStatus.error("Bucket name in use"); } listBucket(bucketName); return ValidationStatus.error("Validating bucket name"); } }; validationStatusProvider.observeValidatedSet(availableBucketNames); validationStatusProvider.observeValidatedSet(unavailableBucketNames); bindingContext.addValidationStatusProvider(validationStatusProvider); ControlDecoration decoration = new ControlDecoration(text, SWT.TOP | SWT.LEFT); FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); decoration.setImage(fieldDecoration.getImage()); new DecorationChangeListener(decoration, validationStatusProvider.getValidationStatus()); validationStatus.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { Object value = validationStatus.getValue(); if (value instanceof IStatus == false) return; IStatus status = (IStatus) value; setMessage(status.getMessage(), status.getSeverity()); setComplete(status.isOK()); } }); setControl(composite); }
From source file:com.amazonaws.eclipse.identitymanagement.group.CreateGroupFirstPage.java
License:Apache License
public void createControl(Composite parent) { final Composite comp = new Composite(parent, SWT.NONE); comp.setLayoutData(new GridData(GridData.FILL_BOTH)); comp.setLayout(new GridLayout(1, false)); new Label(comp, SWT.NONE).setText("Group Name:"); groupNameText = new Text(comp, SWT.BORDER); groupNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); bindingContext.bindValue(SWTObservables.observeText(groupNameText, SWT.Modify), groupName); ChainValidator<String> groupNameValidationStatusProvider = new ChainValidator<String>(groupName, new NotEmptyValidator("Please provide a group name")); bindingContext.addValidationStatusProvider(groupNameValidationStatusProvider); DataBindingUtils.addStatusDecorator(groupNameText, groupNameValidationStatusProvider); // Finally provide aggregate status reporting for the entire wizard page final AggregateValidationStatus aggregateValidationStatus = new AggregateValidationStatus(bindingContext, AggregateValidationStatus.MAX_SEVERITY); aggregateValidationStatus.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { Object value = aggregateValidationStatus.getValue(); if (value instanceof IStatus == false) return; IStatus status = (IStatus) value; if (status.isOK()) { setErrorMessage(null);/*from w ww . ja v a2s . c o m*/ setMessage(OK_MESSAGE, Status.OK); } else if (status.getSeverity() == Status.WARNING) { setErrorMessage(null); setMessage(status.getMessage(), Status.WARNING); } else if (status.getSeverity() == Status.ERROR) { setErrorMessage(status.getMessage()); } setPageComplete(status.isOK()); } }); setControl(comp); setPageComplete(false); }
From source file:com.amazonaws.eclipse.identitymanagement.group.CreateGroupSecondPage.java
License:Apache License
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(1, false); layout.marginLeft = 5;//from w ww . j a v a 2 s . co m composite.setLayout(layout); GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); grantPermissionButton = new Button(composite, SWT.CHECK); grantPermissionButton.setText("Grant permissions"); grantPermissionButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (grantPermissionButton.getSelection()) { policyNameText.setEnabled(true); policyDocText.setEnabled(true); } else { policyNameText.setEnabled(false); policyDocText.setEnabled(false); } } public void widgetDefaultSelected(SelectionEvent e) { } }); bindingContext.bindValue(SWTObservables.observeSelection(grantPermissionButton), grantPermission); new Label(composite, SWT.NONE).setText("Policy Name:"); policyNameText = new Text(composite, SWT.BORDER); policyNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); bindingContext.bindValue(SWTObservables.observeText(policyNameText, SWT.Modify), policyName); ChainValidator<String> policyNameValidationStatusProvider = new ChainValidator<String>(policyName, grantPermission, new NotEmptyValidator("Please enter policy name")); bindingContext.addValidationStatusProvider(policyNameValidationStatusProvider); DataBindingUtils.addStatusDecorator(policyNameText, policyNameValidationStatusProvider); new Label(composite, SWT.NONE).setText("Policy Documentation:"); policyDocText = new Text(composite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.H_SCROLL); GridData gridData = new GridData(GridData.FILL_BOTH); gridData.minimumHeight = 250; policyDocText.setLayoutData(gridData); bindingContext.bindValue(SWTObservables.observeText(policyDocText, SWT.Modify), policyDoc); ChainValidator<String> policyDocValidationStatusProvider = new ChainValidator<String>(policyDoc, grantPermission, new NotEmptyValidator("Please enter valid policy doc")); bindingContext.addValidationStatusProvider(policyDocValidationStatusProvider); DataBindingUtils.addStatusDecorator(policyDocText, policyDocValidationStatusProvider); Link link = new Link(composite, SWT.NONE | SWT.WRAP); link.setText("For more information about the access policy language, " + "see <a href=\"" + ConceptUrl + "\">Key Concepts</a> in Using AWS Identity and Access Management."); link.addListener(SWT.Selection, new WebLinkListener()); gridData = new GridData(SWT.FILL, SWT.TOP, true, false); gridData.widthHint = 200; link.setLayoutData(gridData); setControl(composite); setPageComplete(false); // Finally provide aggregate status reporting for the entire wizard page final AggregateValidationStatus aggregateValidationStatus = new AggregateValidationStatus(bindingContext, AggregateValidationStatus.MAX_SEVERITY); aggregateValidationStatus.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { Object value = aggregateValidationStatus.getValue(); if (value instanceof IStatus == false) return; IStatus status = (IStatus) value; if (status.isOK()) { setErrorMessage(null); setMessage(OK_MESSAGE, Status.OK); } else if (status.getSeverity() == Status.WARNING) { setErrorMessage(null); setMessage(status.getMessage(), Status.WARNING); } else if (status.getSeverity() == Status.ERROR) { setErrorMessage(status.getMessage()); } setPageComplete(status.isOK()); } }); policyNameText.setEnabled(false); policyDocText.setEnabled(false); setPageComplete(true); }
From source file:com.amazonaws.eclipse.identitymanagement.role.CreateRoleFirstPage.java
License:Apache License
public void createControl(Composite parent) { final Composite comp = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(comp); comp.setLayout(new GridLayout(1, false)); new Label(comp, SWT.NONE).setText("Role Name:"); ;//from w w w.j av a 2 s .com roleNameText = new Text(comp, SWT.BORDER); bindingContext.bindValue(SWTObservables.observeText(roleNameText, SWT.Modify), roleName); ChainValidator<String> roleNameValidationStatusProvider = new ChainValidator<String>(roleName, new NotEmptyValidator("Please provide a valid role name")); bindingContext.addValidationStatusProvider(roleNameValidationStatusProvider); DataBindingUtils.addStatusDecorator(roleNameText, roleNameValidationStatusProvider); GridDataFactory.fillDefaults().grab(true, false).applyTo(roleNameText); // Finally provide aggregate status reporting for the entire wizard page final AggregateValidationStatus aggregateValidationStatus = new AggregateValidationStatus(bindingContext, AggregateValidationStatus.MAX_SEVERITY); aggregateValidationStatus.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { Object value = aggregateValidationStatus.getValue(); if (value instanceof IStatus == false) return; IStatus status = (IStatus) value; if (status.isOK()) { setErrorMessage(null); setMessage(OK_MESSAGE, Status.OK); } else if (status.getSeverity() == Status.WARNING) { setErrorMessage(null); setMessage(status.getMessage(), Status.WARNING); } else if (status.getSeverity() == Status.ERROR) { setErrorMessage(status.getMessage()); } setPageComplete(status.isOK()); } }); setPageComplete(false); setControl(comp); }
From source file:com.amazonaws.eclipse.identitymanagement.role.CreateRoleSecondPage.java
License:Apache License
private void createAccountRoleControl(Composite comp) { accountRolesButon = new Button(comp, SWT.RADIO); accountRolesButon.setText("Provide access between AWS accounts you own"); accountRolesButon.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { servicesCombo.setEnabled(false); accountIdText.setEnabled(true); internalAccountIdText.setEnabled(false); externalAccountIdText.setEnabled(false); IdentityProvidersCombo.setEnabled(false); applicationIdText.setEnabled(false); }//from w ww . j av a 2 s . com public void widgetDefaultSelected(SelectionEvent e) { } }); bindingContext.bindValue(SWTObservables.observeSelection(accountRolesButon), accountRoles); new Label(comp, SWT.NONE).setText("Account Id:"); accountIdText = new Text(comp, SWT.BORDER); accountIdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); accountIdText.setEnabled(false); bindingContext.bindValue(SWTObservables.observeText(accountIdText, SWT.Modify), accountId); ChainValidator<String> accountIdValidationStatusProvider = new ChainValidator<String>(accountId, accountRoles, new NotEmptyValidator("Please enter your account Id")); bindingContext.addValidationStatusProvider(accountIdValidationStatusProvider); DataBindingUtils.addStatusDecorator(accountIdText, accountIdValidationStatusProvider); }
From source file:com.amazonaws.eclipse.identitymanagement.role.CreateRoleSecondPage.java
License:Apache License
private void createThirdPartyControl(Composite comp) { thirdPartyRolesButton = new Button(comp, SWT.RADIO); thirdPartyRolesButton.setText("Provide access to a 3rd party AWS account"); thirdPartyRolesButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { servicesCombo.setEnabled(false); accountIdText.setEnabled(false); IdentityProvidersCombo.setEnabled(false); applicationIdText.setEnabled(false); internalAccountIdText.setEnabled(true); externalAccountIdText.setEnabled(true); }//from w ww.ja v a 2 s . c o m public void widgetDefaultSelected(SelectionEvent e) { } }); bindingContext.bindValue(SWTObservables.observeSelection(thirdPartyRolesButton), thirdPartyRoles); new Label(comp, SWT.NONE).setText("Account Id:"); internalAccountIdText = new Text(comp, SWT.BORDER); internalAccountIdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); internalAccountIdText.setEnabled(false); bindingContext.bindValue(SWTObservables.observeText(internalAccountIdText, SWT.Modify), internalAccountId); ChainValidator<String> internalAccountIdValidationStatusProvider = new ChainValidator<String>( internalAccountId, thirdPartyRoles, new NotEmptyValidator("Please enter the internal account Id")); bindingContext.addValidationStatusProvider(internalAccountIdValidationStatusProvider); DataBindingUtils.addStatusDecorator(internalAccountIdText, internalAccountIdValidationStatusProvider); new Label(comp, SWT.NONE).setText("External Id:"); ; externalAccountIdText = new Text(comp, SWT.BORDER); externalAccountIdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); externalAccountIdText.setEnabled(false); bindingContext.bindValue(SWTObservables.observeText(externalAccountIdText, SWT.Modify), externalAccountId); ChainValidator<String> externalAccountIdValidationStatusProvider = new ChainValidator<String>( externalAccountId, thirdPartyRoles, new NotEmptyValidator("Please enter the external account Id")); bindingContext.addValidationStatusProvider(externalAccountIdValidationStatusProvider); DataBindingUtils.addStatusDecorator(externalAccountIdText, externalAccountIdValidationStatusProvider); }
From source file:com.amazonaws.eclipse.identitymanagement.role.CreateRoleSecondPage.java
License:Apache License
private void createWebIdentityProviderControl(Composite comp) { webFederationRolesButton = new Button(comp, SWT.RADIO); webFederationRolesButton.setText("Provide access to web identity providers"); webFederationRolesButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { servicesCombo.setEnabled(false); accountIdText.setEnabled(false); internalAccountIdText.setEnabled(false); externalAccountIdText.setEnabled(false); IdentityProvidersCombo.setEnabled(true); applicationIdText.setEnabled(true); }/* w w w . j av a 2s. c o m*/ public void widgetDefaultSelected(SelectionEvent e) { } }); Label label = new Label(comp, SWT.NONE | SWT.WRAP); label.setText(webIdentityRoleHelpMessage); GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); gridData.widthHint = 200; label.setLayoutData(gridData); bindingContext.bindValue(SWTObservables.observeSelection(webFederationRolesButton), webProviderRoles); new Label(comp, SWT.NONE).setText("Identity Provider"); IdentityProvidersCombo = new Combo(comp, SWT.BORDER); for (String provider : IDENTITY_PROVIDERS) { IdentityProvidersCombo.add(provider); } IdentityProvidersCombo.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (IDENTITY_PROVIDERS[IdentityProvidersCombo.getSelectionIndex()].equals("Google")) { applicationIdLabel.setText("Audience"); } else { applicationIdLabel.setText("Application Id"); } } public void widgetDefaultSelected(SelectionEvent e) { } }); IdentityProvidersCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); IdentityProvidersCombo.setEnabled(false); bindingContext.bindValue(SWTObservables.observeSelection(IdentityProvidersCombo), webProvider); ChainValidator<String> webProviderValidationStatusProvider = new ChainValidator<String>(webProvider, webProviderRoles, new NotEmptyValidator("Please select an identity provider")); bindingContext.addValidationStatusProvider(webProviderValidationStatusProvider); IdentityProvidersCombo.setText("Facebook"); applicationIdLabel = new Label(comp, SWT.NONE); applicationIdLabel.setText("Application Id"); applicationIdText = new Text(comp, SWT.BORDER); applicationIdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); applicationIdText.setEnabled(false); bindingContext.bindValue(SWTObservables.observeText(applicationIdText, SWT.Modify), applicationId); ChainValidator<String> applicationIdValidationStatusProvider = new ChainValidator<String>(applicationId, webProviderRoles, new NotEmptyValidator("Please enter application Id or Audience")); bindingContext.addValidationStatusProvider(applicationIdValidationStatusProvider); DataBindingUtils.addStatusDecorator(applicationIdText, applicationIdValidationStatusProvider); }
From source file:com.amazonaws.eclipse.identitymanagement.role.CreateRoleThirdPage.java
License:Apache License
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(1, false); layout.marginLeft = 5;/*from w w w . j a v a2 s . co m*/ composite.setLayout(layout); GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); grantPermissionButton = new Button(composite, SWT.CHECK); grantPermissionButton.setText("Grant permissions"); grantPermissionButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (grantPermissionButton.getSelection()) { policyNameText.setEnabled(true); policyDocText.setEnabled(true); } else { policyNameText.setEnabled(false); policyDocText.setEnabled(false); } } public void widgetDefaultSelected(SelectionEvent e) { } }); bindingContext.bindValue(SWTObservables.observeSelection(grantPermissionButton), grantPermission); new Label(composite, SWT.NONE).setText("Policy Name:"); policyNameText = new Text(composite, SWT.BORDER); policyNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); bindingContext.bindValue(SWTObservables.observeText(policyNameText, SWT.Modify), policyName); ChainValidator<String> policyNameValidationStatusProvider = new ChainValidator<String>(policyName, grantPermission, new NotEmptyValidator("Please enter policy name")); bindingContext.addValidationStatusProvider(policyNameValidationStatusProvider); DataBindingUtils.addStatusDecorator(policyNameText, policyNameValidationStatusProvider); new Label(composite, SWT.NONE).setText("Policy Documentation:"); policyDocText = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); GridData gridData = new GridData(GridData.FILL_BOTH); gridData.minimumHeight = 250; policyDocText.setLayoutData(gridData); bindingContext.bindValue(SWTObservables.observeText(policyDocText, SWT.Modify), policyDoc); ChainValidator<String> policyDocValidationStatusProvider = new ChainValidator<String>(policyDoc, grantPermission, new NotEmptyValidator("Please enter valid policy doc")); bindingContext.addValidationStatusProvider(policyDocValidationStatusProvider); DataBindingUtils.addStatusDecorator(policyDocText, policyDocValidationStatusProvider); Link link = new Link(composite, SWT.NONE | SWT.WRAP); link.setText("For more information about the access policy language, " + "see <a href=\"" + ConceptUrl + "\">Key Concepts</a> in Using AWS Identity and Access Management."); link.addListener(SWT.Selection, new WebLinkListener()); gridData = new GridData(SWT.FILL, SWT.TOP, true, false); gridData.widthHint = 200; link.setLayoutData(gridData); // Finally provide aggregate status reporting for the entire wizard page final AggregateValidationStatus aggregateValidationStatus = new AggregateValidationStatus(bindingContext, AggregateValidationStatus.MAX_SEVERITY); aggregateValidationStatus.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { Object value = aggregateValidationStatus.getValue(); if (value instanceof IStatus == false) return; IStatus status = (IStatus) value; if (status.isOK()) { setErrorMessage(null); setMessage(OK_MESSAGE, Status.OK); } else if (status.getSeverity() == Status.WARNING) { setErrorMessage(null); setMessage(status.getMessage(), Status.WARNING); } else if (status.getSeverity() == Status.ERROR) { setErrorMessage(status.getMessage()); } setPageComplete(status.isOK()); } }); setControl(composite); }