List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_LABEL
String YES_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_LABEL.
Click Source Link
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 www . ja v a 2 s . co 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 * /*from w ww. j a v a 2s . 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 w w .j av a2s. c o 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.mountainminds.eclemma.internal.ui.launching.NoInstrumentedClassesHandler.java
License:Open Source License
public Object handleStatus(IStatus status, final Object source) throws CoreException { final Shell parent = EclEmmaUIPlugin.getInstance().getShell(); String title = UIMessages.NoInstrumentedClassesError_title; String message = UIMessages.NoInstrumentedClassesError_message; MessageDialog d = new MessageDialog(parent, title, null, message, MessageDialog.ERROR, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (d.open() == 0) { parent.getDisplay().asyncExec(new Runnable() { public void run() { DebugUITools.openLaunchConfigurationDialogOnGroup(parent, new StructuredSelection(source), EclEmmaUIPlugin.ID_COVERAGE_LAUNCH_GROUP); }/* w w w . java 2s . co m*/ }); } return Boolean.FALSE; }
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 */// ww w. j ava 2s .c o m 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.screens.editing.base.dialogs.MessageDialogWithResult.java
License:Open Source License
public static String[] getButtonLabels(int kind) { String[] dialogButtonLabels;//ww w. j av a 2 s . co m switch (kind) { case ERROR: case INFORMATION: case WARNING: { dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL }; break; } case CONFIRM: { dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }; break; } case QUESTION: { dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; break; } case QUESTION_WITH_CANCEL: { dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; break; } default: { throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$ } } return dialogButtonLabels; }
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,/* w w w. j av a2 s .co 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.dialogs.UpdateProjectFilesQueryDialog.java
License:Open Source License
/** * Create contents of the button bar//www .j a v a2s. c o m * @param parent */ @Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.YES_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.NO_LABEL, false); }
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./* www.ja v a2 s.c o m*/ * @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$ } } }
From source file:com.nokia.carbide.templatewizard.processes.CopyFiles.java
License:Open Source License
private void handleExistingFiles(List<FileInfo> infos, final List<IFile> existingFiles, List<FileInfo> fileInfosToCopy) { boolean overwrite = true; String autoOverwrite = projectParameter.getAttributeValue(OVERWRITE_ATTRIBUTE); if (autoOverwrite == null && !WorkbenchUtils.isJUnitRunning()) { // should ask final int[] result = { IDialogConstants.CANCEL_ID }; Display.getDefault().syncExec(new Runnable() { public void run() { Shell shell = WorkbenchUtils.getActiveShell(); String title = Messages.getString("CopyFiles.FilesExistTitle"); //$NON-NLS-1$ String message = Messages.getString("CopyFiles.OverwriteFilesQuestion"); //$NON-NLS-1$ FilesListDialog dialog = new FilesListDialog(shell, existingFiles, title, message); dialog.setAltButtonLabels(IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL); result[0] = dialog.open(); }/*w w w . j a v a2 s .co m*/ }); overwrite = result[0] == IDialogConstants.OK_ID; } else if (autoOverwrite != null) { overwrite = Boolean.parseBoolean(autoOverwrite); } if (!overwrite) { fileInfosToCopy.clear(); for (FileInfo fileInfo : infos) { if (!FileUtils.exists(fileInfo.targetFile)) fileInfosToCopy.add(fileInfo); } } }