List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION
int QUESTION
To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION.
Click Source Link
From source file:com.mercatis.lighthouse3.base.ui.handlers.AbstractDeleteHandler.java
License:Apache License
protected boolean showDialog(Object[] elements) { String message = ""; if (elements.length == 1) { message = "Do you really want to delete " + LabelConverter.getLabel(elements[0]) + "?"; } else if (elements.length > 1) { message = "Do you really want to delete these " + elements.length + " elements?"; } else {//from w w w . ja v a 2 s. c o m throw new RuntimeException("No elements in selection!"); } MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Delete", null, message, MessageDialog.QUESTION, new String[] { "Yes", "No" }, 1); int button = md.open(); return button == 0; }
From source file:com.mercatis.lighthouse3.ui.operations.ui.handlers.ExecuteJobHandler.java
License:Apache License
@Override protected void execute(Object element) throws ExecutionException { if (element instanceof Job) { Job job = (Job) element;//from w ww . j ava 2 s . c o m MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Manual Execute", null, "Execute " + LabelConverter.getLabel(job) + "?", MessageDialog.QUESTION, new String[] { "Yes", "No" }, 1); int button = md.open(); if (button == 0) { LighthouseDomain lighthouseDomain = OperationBase.getJobService().getLighthouseDomainForJob(job); OperationBase.getOperationInstallationService().execute(lighthouseDomain, job.getScheduledCall()); } } }
From source file:com.mobilesorcery.sdk.importproject.MoSyncWizardProjectsImportPage.java
License:Open Source License
/** * The <code>WizardDataTransfer</code> implementation of this * <code>IOverwriteQuery</code> method asks the user whether the existing * resource at the given path should be overwritten. * * @param pathString/*from w w w . java2 s.c o m*/ * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, * <code>"ALL"</code>, or <code>"CANCEL"</code> */ @Override public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString; // Break the message up if there is a file name and a directory // and there are at least 2 segments. if (path.getFileExtension() == null || path.segmentCount() < 2) { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString); } else { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1).toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer().getShell(), IDEWorkbenchMessages.Question, null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0) { @Override protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; // run in syncExec because callback is from an operation, // which is probably not running in the UI thread. getControl().getDisplay().syncExec(new Runnable() { @Override public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; }
From source file:com.motorola.studio.android.common.utilities.EclipseUtils.java
License:Apache License
/** * Show a question message using the given title and message * /* w ww .j ava 2 s. c o m*/ * @param title * of the dialog * @param message * to be displayed in the dialog. */ public static int showQuestionWithCancelDialog(final String title, final String message) { class IntWrapper { public int diagReturn = 0; } final IntWrapper intWrapper = new IntWrapper(); Display.getDefault().syncExec(new Runnable() { public void run() { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow ww = workbench.getActiveWorkbenchWindow(); Shell shell = ww.getShell(); MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); int diagResults = dialog.open(); switch (diagResults) { case 0: intWrapper.diagReturn = SWT.YES; break; case 1: intWrapper.diagReturn = SWT.NO; break; case 2: default: intWrapper.diagReturn = SWT.CANCEL; break; } } }); return intWrapper.diagReturn; }
From source file:com.motorola.studio.android.common.utilities.EclipseUtils.java
License:Apache License
/** * Show a question message using the given title and message * /*from w ww.j a v a2 s . co m*/ * @param title * of the dialog * @param message * to be displayed in the dialog. */ public static int showQuestionYesAllCancelDialog(final String title, final String message) { class IntWrapper { public int diagReturn = 0; } final IntWrapper intWrapper = new IntWrapper(); Display.getDefault().syncExec(new Runnable() { public void run() { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow ww = workbench.getActiveWorkbenchWindow(); Shell shell = ww.getShell(); MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL }, 0); int diagResults = dialog.open(); switch (diagResults) { case 0: intWrapper.diagReturn = IDialogConstants.YES_ID; break; case 1: intWrapper.diagReturn = IDialogConstants.YES_TO_ALL_ID; break; case 2: default: intWrapper.diagReturn = IDialogConstants.NO_ID; break; } } }); return intWrapper.diagReturn; }
From source file:com.mulgasoft.emacsplus.preferences.EmacsPlusPreferencePage.java
License:Open Source License
/** * Pop up a message dialog to request the restart of the workbench *//* w w w.j a v a2 s .c om*/ private void requestRestart(String rePreference) { String reMessage = EmacsPlusActivator.getString("EmacsPlusPref_RestartMessage"); //$NON-NLS-1$ IProduct product = Platform.getProduct(); String productName = product != null && product.getName() != null ? product.getName() : EmacsPlusActivator.getString("EmacsPlusPref_DefaultProduct"); //$NON-NLS-1$ final String msg = String.format(reMessage, productName, rePreference); final String reTitle = EmacsPlusActivator.getString("EmacsPlusPref_RestartTitle"); //$NON-NLS-1$ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { if (PlatformUI.getWorkbench().isClosing()) return; // yes == 0, no == 1 MessageDialog dialog = new MessageDialog(getDefaultShell(), reTitle, null, msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (dialog.open() != Window.CANCEL) { if (dialog.getReturnCode() == 0) { // restart workbench PlatformUI.getWorkbench().restart(); } } } }); }
From source file:com.netxforge.netxstudio.screens.editing.CDOEditingService.java
License:Open Source License
@Override public void doSave(IProgressMonitor monitor) { // save could be triggered from CDOView view = dawnEditorSupport.getView(); if (view instanceof CDOTransaction) { if (view.isDirty()) { StudioUtils.cdoDumpDirtyObject((CDOTransaction) view); }//from w ww. j a va 2 s .c om if (((CDOTransaction) view).hasConflict()) { MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), "Conflict", null, "There is a conflict with another user. Would you like to rollback your current transaction?", MessageDialog.QUESTION, new String[] { "yes", "no", "Cancel" }, 1); switch (dialog.open()) { case 0: // yes ((IDawnEditor) this).getDawnEditorSupport().rollback(); break; case 1: // no break; default: // cancel break; } } else { // this.doSaveHistory(monitor); IRunnableWithProgress operation = doGetSaveOperation(monitor); if (operation == null) return; try { // This runs the options, and shows progress. new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, false, operation); // Refresh the necessary state. ((BasicCommandStack) getEditingDomain().getCommandStack()).saveIsDone(); } catch (Exception exception) { } } } }
From source file:com.nokia.carbide.cpp.internal.pi.button.ui.BupProfileEditDialog.java
License:Open Source License
public void cancelPressed() { if (cachedMap.haveUncommitedChanges()) { MessageDialog dialog = new MessageDialog(getShell(), Messages.getString("BupProfileEditDialog.uncommittedChanges"), //$NON-NLS-1$ null,// ww w.ja va 2 s . c o m Messages.getString("BupProfileEditDialog.saveChanges") + profileForThisEdit.getProfileId() //$NON-NLS-1$ + "?", //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); // default yes switch (dialog.open()) { case 0: // yes cachedMap.commitChanges(); // fall thru to no case 1: // no super.cancelPressed(); cleanUp(); case 2: // cancel default: return; } } super.cancelPressed(); cleanUp(); }
From source file:com.nokia.carbide.cpp.internal.project.ui.editors.common.CarbideFormEditor.java
License:Open Source License
void handleResourceChanged() { // The file has changed. If this editor is clean then simply // reload, otherwise ask the user if they want to reload first. boolean doReload; if (isDirty()) { String fmt = Messages.CarbideFormEditor_reloadOnChangedFilePrompt; String msg = MessageFormat.format(fmt, getEditorInput().getName()); String btnLabels[] = { Messages.CarbideFormEditor_yesButtonLabel, Messages.CarbideFormEditor_noButtonLabel }; MessageDialog dialog = new MessageDialog(this.getSite().getShell(), Messages.CarbideFormEditor_reloadOnChangedFileDialogTitle, null, msg, MessageDialog.QUESTION, btnLabels, 1);//from www . jav a 2s . c om doReload = Dialog.OK == dialog.open(); } else { doReload = true; } if (doReload) { reload(); } else { reloadRejected(); } }
From source file:com.nokia.carbide.cpp.uiq.ui.vieweditor.CommandsPage.java
License:Open Source License
/** * This code was taken from the EventCommands class. It has the validations in case the code * doesn't exist./*from www.j a v a 2s . c om*/ * @param binding * @param isNewBinding */ private void navigateToHandlerCode(IEventBinding binding, boolean isNewBinding) { IEventDescriptor eventDescriptor = binding.getEventDescriptor(); IStatus status = eventDescriptor.gotoHandlerCode(binding, isNewBinding); if (status != null) { if (!isNewBinding) { // Hmm, an error. It could be the data model was not saved. // It may just be a problem in the component's sourcegen, hence // the fallthrough to the descriptive error later. MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("CommandsPage.Error"), null, //$NON-NLS-1$ Messages.getString("CommandsPage.NoEventHandlerFound"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, //$NON-NLS-1$ //$NON-NLS-2$ 0); int result = dialog.open(); if (result == MessageDialog.OK) { if (ViewEditorUtils.saveDataModel(editor)) { status = eventDescriptor.gotoHandlerCode(binding, isNewBinding); } } } if (status != null) { Logging.log(UIDesignerPlugin.getDefault(), status); Logging.showErrorDialog(Messages.getString("CommandsPage.CouldNotNavigate"), null, status); //$NON-NLS-1$ } } }