List of usage examples for org.eclipse.jface.dialogs MessageDialog CONFIRM
int CONFIRM
To view the source code for org.eclipse.jface.dialogs MessageDialog CONFIRM.
Click Source Link
From source file:ac.soton.xeventb.ui.AbstractXEventBActionProvider.java
License:Open Source License
/** * Provides a delete action for IXEventBNavigatorObject * Deletes the xtext as well as the corresponding Event-B files * /*from w ww . ja va 2 s .c o m*/ * @param site * The information for the action provider * @return A delete action */ public Action getDeleteAction(final ICommonActionExtensionSite site) { final Action doubleClickAction = new Action("Delete") { @Override public void run() { try { final ISelection selection = site.getStructuredViewer().getSelection(); final Object obj = ((IStructuredSelection) selection).getFirstElement(); if ((obj instanceof IXEventBNavigatorObject)) { final IFile resource = ((IXEventBNavigatorObject) obj).getResource(); String name = resource.getName(); int _length = name.length(); int _minus = (_length - 1); name = name.substring(0, _minus); IPath path = resource.getLocation(); path = path.removeLastSegments(1); path = path.addTrailingSeparator().append(name); final IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IFile ifile = workspace.getRoot().getFileForLocation(path); final Shell shell = site.getViewSite().getShell(); String _name = resource.getName(); String _plus = ("Are you sure you want to delete \"" + _name); final String msg = (_plus + "\" and its corresponding Event-B files?"); final String[] options = { "Yes to All", "Yes", "No" }; final MessageDialog dialog = new MessageDialog(shell, "Confirm Delete", null, msg, MessageDialog.CONFIRM, options, 0); final int result = dialog.open(); if ((result == 0)) { resource.delete(true, null); ifile.delete(true, null); } else { if ((result == 1)) { resource.delete(true, null); } } } } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } } }; return doubleClickAction; }
From source file:com.amazonaws.eclipse.core.accounts.profiles.SdkCredentialsFileContentMonitor.java
License:Apache License
/** * Should only be invoked in the main thread *//*from ww w. j a v a 2s .c om*/ private static void showCredentialsReloadConfirmBox(File credentialsFile) { String message = "The AWS credentials file '" + credentialsFile.getAbsolutePath() + "' has been changed in the file system. " + "Do you want to reload the credentials from the updated file content?"; MessageDialog dialog = new MessageDialog(null, // use the top-level shell "AWS Credentials File Changed", AwsToolkitCore.getDefault().getImageRegistry().get(AwsToolkitCore.IMAGE_AWS_ICON), message, MessageDialog.CONFIRM, new String[] { "No", "Yes" }, 1 // default to YES ); int result = dialog.open(); if (result == 1) { AwsToolkitCore.getDefault().getAccountManager().reloadAccountInfo(); } }
From source file:com.amazonaws.eclipse.core.ui.preferences.AwsAccountPreferencePageTab.java
License:Apache License
/** * Add the enable-region-default-account check-box and the remove-this-tab * button/*from ww w . j a va 2s .c o m*/ */ private void addEnableRegionDefaultControls(Composite parent) { enableRegionDefaultAccount = new BooleanFieldEditor(getRegionAccountEnabledPrefKey(), "Enable region default account for " + region.getName(), parent); enableRegionDefaultAccount.setPreferenceStore(getPreferenceStore()); Button removeTabButton = new Button(parent, SWT.PUSH); removeTabButton.setText("Remove"); removeTabButton.setToolTipText("Remove default account configuration for this region."); removeTabButton.setImage(AwsToolkitCore.getDefault().getImageRegistry().get(AwsToolkitCore.IMAGE_REMOVE)); removeTabButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); removeTabButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { MessageDialog confirmRemoveTabDialog = new MessageDialog(Display.getDefault().getActiveShell(), "Remove all accounts for " + region.getName(), AwsToolkitCore.getDefault().getImageRegistry().get(AwsToolkitCore.IMAGE_AWS_ICON), "Are you sure you want to remove all the configured accounts for " + region.getName() + "?", MessageDialog.CONFIRM, new String[] { "Cancel", "OK" }, 1); if (confirmRemoveTabDialog.open() == 1) { AwsAccountPreferencePageTab.this.dispose(); } } }); }
From source file:com.aptana.ide.ui.io.actions.CopyFilesOperation.java
License:Open Source License
/** * @param sourceStore//from w w w . ja v a2 s . c om * the file to be copied * @param destinationStore * the destination location * @param monitor * the progress monitor * @return true if the file is successfully copied, false if the operation did not go through for any reason */ protected boolean copyFile(IFileStore sourceStore, IFileStore destinationStore, IProgressMonitor monitor) { if (sourceStore == null || CloakingUtils.isFileCloaked(sourceStore)) { return false; } boolean success = true; monitor.subTask(MessageFormat.format(Messages.CopyFilesOperation_Copy_Subtask, sourceStore.getName(), destinationStore.getName())); if (destinationStore.equals(sourceStore)) { destinationStore = getNewNameFor(destinationStore); if (destinationStore == null) { return false; } } try { IFileStore[] childStores = Utils.isDirectory(sourceStore) ? sourceStore.childStores(EFS.NONE, monitor) : new IFileStore[0]; if (Utils.exists(destinationStore) && sourceStore.getName().equals(destinationStore.getName())) { // a name conflict; ask to overwrite if (overwriteStatus != OverwriteStatus.YES_TO_ALL) { final IFileStore dStore = destinationStore; final IFileStore sStore = sourceStore; fShell.getDisplay().syncExec(new Runnable() { public void run() { MessageDialog dialog = new MessageDialog(fShell, Messages.CopyFilesOperation_OverwriteTitle, null, MessageFormat.format(Messages.CopyFilesOperation_OverwriteWarning, dStore.toString(), sStore.toString()), MessageDialog.CONFIRM, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); int retCode = dialog.open(); switch (retCode) { case 0: // Yes overwriteStatus = OverwriteStatus.YES; break; case 1: // Yes to All overwriteStatus = OverwriteStatus.YES_TO_ALL; break; case 2: // No overwriteStatus = OverwriteStatus.NO; break; default: overwriteStatus = OverwriteStatus.CANCEL; } } }); switch (overwriteStatus) { case CANCEL: monitor.setCanceled(true); // let it fall through since it would return false as well case NO: return false; } } } SyncUtils.copy(sourceStore, null, destinationStore, EFS.NONE, monitor); // copy the children recursively IFileStore destChildStore; for (IFileStore childStore : childStores) { destChildStore = destinationStore.getChild(childStore.getName()); copyFile(childStore, destChildStore, monitor); } } catch (CoreException e) { IdeLog.logError(IOUIPlugin.getDefault(), MessageFormat .format(Messages.CopyFilesOperation_ERR_FailedToCopy, sourceStore, destinationStore), e); success = false; } return success; }
From source file:com.aptana.ui.dialogs.InputMessageDialog.java
License:Open Source License
public InputMessageDialog(JsonNode questionNode, String title, String description) { super(UIUtils.getActiveShell(), title, null, description, MessageDialog.CONFIRM, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); this.dialogMessage = questionNode.path(MESSAGE).asText(); this.inputType = questionNode.path(TYPE).asText(); this.values = (ArrayNode) questionNode.path(CHOICES); input = new ArrayList<Object>(); }
From source file:com.aptana.ui.dialogs.MultipleInputMessageDialog.java
License:Open Source License
public MultipleInputMessageDialog(JsonNode questionNode, String dialogTitle, String dialogMessage) { super(UIUtils.getDisplay().getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.CONFIRM, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); this.questionsNode = questionNode; userInput = JsonNodeFactory.instance.objectNode(); }
From source file:com.servoy.eclipse.docgenerator.ui.handler.DocumentationGenerationRequestFromUI.java
License:Open Source License
public boolean confirmResourceOverwrite(final IPath path) { // If the settings say to not ask for confirmation, then just say yes. boolean mustAsk = Activator.getDefault().getPreferenceStore() .getBoolean(Activator.ASK_FOR_FILE_OVERWRITE_PREFERENCE); if (!mustAsk) { return true; }//from ww w .jav a 2 s . com // If the user already clicked "Confirm All" then just say yes. if (confirmAll) { return true; } // Ask the user if it's OK to overwrite. final boolean choice[] = new boolean[1]; Display.getDefault().syncExec(new Runnable() { public void run() { MessageDialog dlg = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Confirm file overwrite", null, "The following file already exists and will be overwritten: '" + path.toOSString() + "'. Are you sure you want the file to be overwritten?" + "\n\n" + "You can disable this confirmation dialog from the plugin preferences page.", MessageDialog.CONFIRM, new String[] { IDialogConstants.NO_LABEL, IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 3); int result = dlg.open(); if (result == 2) // the "Yes to All" button { confirmAll = true; } if (result == 3) // the "Cancel" button { canceled = true; } choice[0] = result == 1 || result == 2; // The "Yes" or "Yes to All" buttons were pressed. } }); return choice[0]; }
From source file:com.toedter.e4.demo.contacts.rap.views.DetailsView.java
License:Open Source License
@Inject public void setSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Contact contact) { if (contact != null) { if (dirtyable.isDirty()) { MessageDialog dialog = new MessageDialog(detailComposite.getShell(), "Save vCard", null, "The current vCard has been modified. Save changes?", MessageDialog.CONFIRM, new String[] { "Yes", "No" }, 0); dialog.create();/*w ww . j a v a 2 s. c o m*/ ThemeUtil.applyDialogStyles(engine, dialog.getShell()); if (dialog.open() == Window.OK) { ParameterizedCommand saveCommand = commandService.createCommand("contacts.save", Collections.EMPTY_MAP); handlerService.executeHandler(saveCommand); } } updatePartTitle(contact); } else { uiItem.setLabel("Details"); } dirtyable.setDirty(false); detailComposite.update(contact); }
From source file:com.toedter.e4.demo.contacts.swt.views.DetailsView.java
License:Open Source License
@Inject public void setSelection(@Optional Contact contact) { if (contact != null) { if (dirtyable.isDirty()) { MessageDialog dialog = new MessageDialog(detailComposite.getShell(), "Save vCard", null, "The current vCard has been modified. Save changes?", MessageDialog.CONFIRM, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); dialog.create();//from w w w . ja v a 2 s . c o m if (engine != null) { ThemeUtil.applyDialogStyles(engine, dialog.getShell()); } if (dialog.open() == Window.OK) { ParameterizedCommand saveCommand = commandService.createCommand("contacts.save", Collections.EMPTY_MAP); handlerService.executeHandler(saveCommand); } } updatePartTitle(contact); } else { uiItem.setLabel("Details"); } dirtyable.setDirty(false); detailComposite.update(contact); }
From source file:com.vectrace.MercurialEclipse.dialogs.CommitDialog.java
License:Open Source License
private boolean confirmHistoryRewrite() { if (HgFeatures.PHASES.isEnabled()) { // For secret or draft silently allow amend if (Phase.PUBLIC == currentChangeset.getPhase()) { if (!MessageDialog.openConfirm(getShell(), Messages.getString("CommitDialog.amendPublic.title"), Messages.getString("CommitDialog.amendPublic.message"))) { return false; }//from w w w. j a v a 2s . c o m currentChangeset.setDraft(); } return true; } // Always prompt if phases are not supported MessageDialog dialog = new MessageDialog(getShell(), Messages.getString("CommitDialog.reallyAmendAndRewriteHistory"), //$NON-NLS-1$ null, Messages.getString("CommitDialog.amendWarning1") //$NON-NLS-1$ + Messages.getString("CommitDialog.amendWarning2") //$NON-NLS-1$ + Messages.getString("CommitDialog.amendWarning3"), //$NON-NLS-1$ MessageDialog.CONFIRM, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 1 // default index - cancel ); dialog.setBlockOnOpen(true); // if false then may show in background return dialog.open() == 0; // 0 means yes }