List of usage examples for org.eclipse.jface.dialogs IDialogConstants OK_ID
int OK_ID
To view the source code for org.eclipse.jface.dialogs IDialogConstants OK_ID.
Click Source Link
From source file:com.amalto.workbench.editors.dialog.CustomInputDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { // create OK and Cancel buttons by default okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); // do this here because setting the text will set enablement on the ok // button//ww w .j a v a2 s . co m text.setFocus(); if (value != null) { text.setText(value); text.selectAll(); } }
From source file:com.amalto.workbench.editors.dialog.CustomInputDialog.java
License:Open Source License
/** * Sets or clears the error message. If not <code>null</code>, the OK button is disabled. * //from w w w . j av a 2 s. c o m * @param errorMessage the error message, or <code>null</code> to clear * @since 3.0 */ public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; if (errorMessageText != null && !errorMessageText.isDisposed()) { errorMessageText.setText(errorMessage == null ? " \n " : errorMessage); //$NON-NLS-1$ // Disable the error message text control if there is no error, or // no error text (empty or whitespace only). Hide it also to avoid // color change. // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130281 boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0; errorMessageText.setEnabled(hasError); errorMessageText.setVisible(hasError); errorMessageText.getParent().update(); // Access the ok button by id, in case clients have overridden button creation. // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643 Control button = getButton(IDialogConstants.OK_ID); if (button != null) { button.setEnabled(errorMessage == null); } } }
From source file:com.amalto.workbench.editors.ViewMainPage.java
License:Open Source License
private void addListener() { combox_policy.addSelectionListener(new SelectionAdapter() { @Override/*from w ww . jav a2s . c o m*/ public void widgetSelected(SelectionEvent e) { boolean toSelectXPath = combox_policy.getText().equals(selectXPath); if (toSelectXPath) { String modelName = getDatamodelName(); String entityName = concept; XpathSelectDialog dlg = getXPathSelectionDialog(Messages.ViewMainPage_titleSelectField, modelName, new SortFieldSelectionFilter()); dlg.setConceptName(entityName); String xpath = null; if (dlg.open() == IDialogConstants.OK_ID) { xpath = dlg.getXpath(); } if (xpath != null) { combox_policy.setItems(new String[] { SORT_FIELD[0], SORT_FIELD[1], xpath, selectXPath }); combox_policy.setText(xpath); combox_sortdirection.setVisible(true); combox_sortdirection.select(0); markDirtyWithoutCommit(); } else { lastSortField = lastSortField == null ? SORT_FIELD[0] : lastSortField; combox_policy.setText(lastSortField); } } else if (combox_policy.getSelectionIndex() != 0 && combox_policy.getSelectionIndex() != 1) { combox_sortdirection.setVisible(true); combox_sortdirection.select(0); lastSortField = combox_policy.getText(); markDirtyWithoutCommit(); } else { lastSortField = combox_policy.getText(); combox_sortdirection.setVisible(false); markDirtyWithoutCommit(); } } }); combox_policy.addMouseTrackListener(new MouseTrackAdapter() { @Override public void mouseHover(MouseEvent e) { combox_policy.setToolTipText(combox_policy.getText()); } }); combox_sortdirection.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { markDirtyWithoutCommit(); } }); }
From source file:com.amazonaws.eclipse.ec2.ui.ebs.CreateNewVolumeDialog.java
License:Apache License
private void updateControls() { boolean creatingFromSnapshot = useSnapshotRadioButton.getSelection(); Button okButton = getButton(IDialogConstants.OK_ID); snapshotSelectionComposite.setEnabled(creatingFromSnapshot); sizeSpinner.setEnabled(!creatingFromSnapshot); if (creatingFromSnapshot) { if (okButton != null) { Snapshot snapshot = snapshotSelectionComposite.getSelectedSnapshot(); okButton.setEnabled(snapshot != null); }//from w w w .j ava 2s . co m } else { snapshotSelectionComposite.clearSelection(); if (okButton != null) okButton.setEnabled(true); } }
From source file:com.amazonaws.eclipse.ec2.ui.ebs.VolumeSelectionTable.java
License:Apache License
@Override protected void makeActions() { refreshAction = new Action() { public void run() { refreshVolumes();//w w w.j ava 2 s.co m } }; refreshAction.setText("Refresh"); refreshAction.setToolTipText("Refresh the volume list"); refreshAction.setImageDescriptor(Ec2Plugin.getDefault().getImageRegistry().getDescriptor("refresh")); createAction = new Action() { public void run() { final CreateNewVolumeDialog dialog = new CreateNewVolumeDialog( Display.getCurrent().getActiveShell()); if (dialog.open() != IDialogConstants.OK_ID) return; new CreateVolumeThread(dialog.getAvailabilityZone(), dialog.getSize(), dialog.getSnapshotId()) .start(); } }; createAction.setText("New Volume"); createAction.setToolTipText("Create a new EBS volume"); createAction.setImageDescriptor(Ec2Plugin.getDefault().getImageRegistry().getDescriptor("add")); releaseAction = new Action() { @SuppressWarnings("unchecked") @Override public void run() { StructuredSelection selection = (StructuredSelection) viewer.getSelection(); new ReleaseVolumesThread((List<Volume>) selection.toList()).start(); } }; releaseAction.setText("Release Volume"); releaseAction.setDescription("Release selected volume(s)"); releaseAction.setImageDescriptor(Ec2Plugin.getDefault().getImageRegistry().getDescriptor("remove")); detachAction = new Action() { @Override public void run() { final Volume volume = getSelectedVolume(); new DetachVolumeThread(volume).start(); } }; detachAction.setText("Detach Volume"); detachAction.setToolTipText("Detach the selected volume from all instances."); createSnapshotAction = new Action() { @Override public void run() { new CreateSnapshotThread(getSelectedVolume()).start(); } }; createSnapshotAction.setText("Create Snapshot"); createSnapshotAction.setToolTipText("Creates a new snapshot of this volume."); createSnapshotAction .setImageDescriptor(Ec2Plugin.getDefault().getImageRegistry().getDescriptor("snapshot")); }
From source file:com.amazonaws.eclipse.ec2.ui.securitygroups.CreateSecurityGroupDialog.java
License:Apache License
/** * Validates the user input and enables or disables the Ok button as necessary. */// w w w . j a v a 2 s . c o m private void updateOkButton() { boolean b = true; if (descriptionText == null || descriptionText.getText().length() == 0) { b = false; } if (groupNameText == null || groupNameText.getText().length() == 0) { b = false; } Button okButton = getButton(IDialogConstants.OK_ID); if (okButton != null) { okButton.setEnabled(b); } }
From source file:com.amazonaws.eclipse.ec2.ui.securitygroups.EditSecurityGroupPermissionEntryDialog.java
License:Apache License
private void updateOkButton() { if (userGroupComposite == null || portRangeComposite == null) return;/*from ww w . java 2 s.c o m*/ boolean b = false; if (userGroupPermissionButton.getSelection()) { b = userGroupComposite.isComplete(); } else { b = portRangeComposite.isComplete(); } Button okButton = getButton(IDialogConstants.OK_ID); if (okButton != null) { okButton.setEnabled(b); } }
From source file:com.amazonaws.eclipse.ec2.ui.securitygroups.PermissionsComposite.java
License:Apache License
@Override protected void makeActions() { addPermissionAction = new Action() { public void run() { String securityGroup = securityGroupSelectionComposite.getSelectedSecurityGroup().getGroupName(); EditSecurityGroupPermissionEntryDialog dialog = new EditSecurityGroupPermissionEntryDialog( Display.getCurrent().getActiveShell(), securityGroup); if (dialog.open() != IDialogConstants.OK_ID) return; new AuthorizePermissionsThread(securityGroup, dialog).start(); }//w ww .j a v a 2s . c o m }; addPermissionAction.setText("Add Permissions..."); addPermissionAction.setToolTipText("Add new permissions to the selected security group"); addPermissionAction.setImageDescriptor(Ec2Plugin.getDefault().getImageRegistry().getDescriptor("add")); removePermissionAction = new Action() { public void run() { String securityGroup = securityGroupSelectionComposite.getSelectedSecurityGroup().getGroupName(); new RevokePermissionsThread(securityGroup, getSelectedIpPermission()).start(); } }; removePermissionAction.setText("Remove Permissions"); removePermissionAction.setToolTipText("Remove the selected permission from the selected security group"); removePermissionAction .setImageDescriptor(Ec2Plugin.getDefault().getImageRegistry().getDescriptor("remove")); }
From source file:com.amazonaws.eclipse.ec2.ui.views.instances.CreateAmiAction.java
License:Apache License
private void createAmiFromInstance(Instance instance) { boolean userIdIsValid = (InstanceSelectionTable.accountInfo.getUserId() != null); if (!InstanceSelectionTable.accountInfo.isValid() || !InstanceSelectionTable.accountInfo.isCertificateValid() || !userIdIsValid) { String message = "Your AWS account information doesn't appear to be fully configured yet. " + "To bundle an instance you'll need all the information configured, " + "including your AWS account ID, EC2 certificate and private key file." + "\n\nWould you like to configure it now?"; if (MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "Configure AWS Account Information", message)) { new SetupAwsAccountAction().run(); }//from w w w .j av a 2s.c o m return; } KeyPairManager keyPairManager = new KeyPairManager(); String keyName = instance.getKeyName(); String keyPairFilePath = keyPairManager .lookupKeyPairPrivateKeyFile(AwsToolkitCore.getDefault().getCurrentAccountId(), keyName); if (keyPairFilePath == null) { String message = "There is no private key registered for the key this host was launched with (" + keyName + ")."; MessageDialog.openError(Display.getCurrent().getActiveShell(), "No Registered Private Key", message); return; } BundleDialog bundleDialog = new BundleDialog(Display.getCurrent().getActiveShell()); if (bundleDialog.open() != IDialogConstants.OK_ID) return; String bundleName = bundleDialog.getImageName(); String s3Bucket = bundleDialog.getS3Bucket(); BundleJob job = new BundleJob(instance, s3Bucket, bundleName); job.schedule(); }
From source file:com.amazonaws.eclipse.ec2.ui.views.instances.InstanceSelectionTable.java
License:Apache License
@Override protected void makeActions() { refreshAction = new Action("Refresh", Ec2Plugin.getDefault().getImageRegistry().getDescriptor("refresh")) { public void run() { refreshInstances();/*from w ww .j av a 2 s . c o m*/ } public String getToolTipText() { return "Refresh instances"; } }; rebootAction = new RebootInstancesAction(this); terminateAction = new TerminateInstancesAction(this); openShellAction = new OpenShellAction(this); openShellDialogAction = new OpenShellDialogAction(this); createAmiAction = new CreateAmiAction(this); copyPublicDnsNameAction = new Action("Copy Public DNS Name", Ec2Plugin.getDefault().getImageRegistry().getDescriptor("clipboard")) { public void run() { copyPublicDnsNameToClipboard(getSelectedInstance()); } public String getToolTipText() { return "Copies this instance's public DNS name to the clipboard."; } }; attachNewVolumeAction = new Action("Attach New Volume...") { public void run() { Instance instance = getSelectedInstance(); CreateNewVolumeDialog dialog = new CreateNewVolumeDialog(Display.getCurrent().getActiveShell(), instance); if (dialog.open() != IDialogConstants.OK_ID) return; new AttachNewVolumeThread(instance, dialog.getSize(), dialog.getSnapshotId(), dialog.getDevice()) .start(); } public String getToolTipText() { return "Attaches a new Elastic Block Storage volume to this instance."; } }; startInstancesAction = new StartInstancesAction(this); stopInstancesAction = new StopInstancesAction(this); instanceStateDropDownMenuHandler = new MenuHandler(); instanceStateDropDownMenuHandler.addListener(this); instanceStateDropDownMenuHandler.add("ALL", "All Instances", true); for (InstanceType instanceType : InstanceType.values()) { instanceStateDropDownMenuHandler.add(instanceType.id, instanceType.name + " Instances"); } instanceStateDropDownMenuHandler.add("windows", "Windows Instances"); instanceStateFilterDropDownAction = new MenuAction("Status Filter", "Filter by instance state", "filter", instanceStateDropDownMenuHandler); securityGroupDropDownMenuHandler = new MenuHandler(); securityGroupDropDownMenuHandler.addListener(this); allSecurityGroupFilterItem = securityGroupDropDownMenuHandler.add("ALL", "All Security Groups", true); securityGroupFilterDropDownAction = new DynamicMenuAction("Security Groups Filter", "Filter by security group", "filter", securityGroupDropDownMenuHandler); }