List of usage examples for org.eclipse.jface.dialogs MessageDialog MessageDialog
public MessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, int defaultIndex, String... dialogButtonLabels)
From source file:gov.nasa.arc.spife.europa.clientside.xmlrpc.ClientExceptionHandler.java
License:Open Source License
private static MessageDialog openErrorDialog(final Exception e, int dialogType, String[] buttons) { String exceptionMessage = "unknown"; if (e != null) exceptionMessage = e.getMessage(); String causeExceptionMessage = "unknown"; if (e != null && e.getCause() != null) causeExceptionMessage = e.getCause().toString(); MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), "Europa2 Problem", null, "There is a problem connecting with Europa2. It is possible that " + "there is a network problem.\n\n" + "Reason: " + truncateExceptionString(exceptionMessage) + "\n\nCause: " + truncateExceptionString(causeExceptionMessage), dialogType, buttons, 0); // 0 to select first (and only) button by default dialog.open();/*ww w .ja v a2s. c o m*/ return dialog; }
From source file:gov.nasa.ensemble.common.ui.EnsembleComposite.java
License:Open Source License
private void nolayout() { MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), "EnsembleComposite", null, "layout must be set for EnsembleComposite: " + this, MessageDialog.ERROR, new String[] { "OK" }, 1); dialog.open();/*from w w w . j ava2s . com*/ setBackground(ColorConstants.red); }
From source file:gov.nasa.ensemble.common.ui.operations.EnsembleFileSystemExportOperation.java
License:Open Source License
protected boolean queryYesNoQuestion(String message) { MessageDialog dialog = new MessageDialog(getShellForMessageDialog(), "Question", (Image) null, message, MessageDialog.NONE, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) { @Override/*w ww . j a v a 2s . c o m*/ protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; // ensure yes is the default return dialog.open() == 0; }
From source file:gov.nasa.ensemble.common.ui.wizard.AbstractEnsembleProjectExportWizardPage.java
License:Open Source License
@Override public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString;/*from ww w .j a v a2 s . c o m*/ //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) { // PATH_TO_FILE already exists. Would you like to overwrite it? //messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString); IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(path); IPath location = folder.getLocation(); File file = null; if (location == null) { file = new File(pathString); } else { file = location.toFile(); } messageString = getDialogQuestionText(file); } else { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1).toOSString()); String osString = path.toOSString(); Date date = new Date(new File(osString).lastModified()); messageString += System.getProperty("line.separator") + System.getProperty("line.separator") + "'" + path.lastSegment() + "' was last modified on: " + date; } final MessageDialog dialog = new MessageDialog(getShellForMessageDialog(), 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. WidgetUtils.runInDisplayThread(getShell(), new Runnable() { @Override public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; }
From source file:gov.nasa.ensemble.common.ui.wizard.AbstractEnsembleProjectExportWizardPage.java
License:Open Source License
/** * This override is provided to provide an appropriate shell vs the standard * approach of just using the container. */// www.j a v a2 s . c o m @Override protected boolean queryYesNoQuestion(String message) { MessageDialog dialog = new MessageDialog(getShellForMessageDialog(), IDEWorkbenchMessages.Question, (Image) null, message, MessageDialog.NONE, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) { @Override protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; // ensure yes is the default return dialog.open() == 0; }
From source file:gov.nasa.ensemble.common.ui.wizard.DefaultOverwriteQueryImpl.java
License:Open Source License
@Override public String queryOverwrite(String pathString) { if (alwaysOverwrite) { return ALL; }//from w w w . j a v a 2 s .c o m final String returnCode[] = { CANCEL }; final String msg = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteQuestion, pathString); final String[] options = { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; shell.getDisplay().syncExec(new Runnable() { @Override public void run() { MessageDialog dialog = new MessageDialog(shell, IDEWorkbenchMessages.CopyFilesAndFoldersOperation_question, null, msg, MessageDialog.QUESTION, options, 0) { @Override protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; dialog.open(); int returnVal = dialog.getReturnCode(); String[] returnCodes = { YES, ALL, NO, CANCEL }; returnCode[0] = returnVal == -1 ? CANCEL : returnCodes[returnVal]; } }); if (returnCode[0] == ALL) { alwaysOverwrite = true; } else if (returnCode[0] == CANCEL) { canceled = true; } return returnCode[0]; }
From source file:gov.nasa.ensemble.core.plan.editor.lifecycle.WizardPlanExportPage.java
License:Open Source License
/** * Displays a Yes/No question to the user with the specified message and returns * the user's response./*from w w w. jav a 2 s.co m*/ * * @param message the question to ask * @return <code>true</code> for Yes, and <code>false</code> for No */ protected boolean queryYesNoQuestion(String message) { MessageDialog dialog = new MessageDialog(getContainer().getShell(), "Question", (Image) null, message, MessageDialog.NONE, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); // ensure yes is the default return dialog.open() == 0; }
From source file:gov.nasa.ensemble.core.plan.editor.MultiPagePlanEditor.java
License:Open Source License
/** * Check to see if this plan was upgraded to the current AD * //from w w w. j a va2 s .c o m * @param plan the plan being checked * @param workbenchWindow the parent for a warning message dialog * @return true if compatibility feedback is present, false otherwise */ private static boolean checkPlanCompatibility(EPlan plan, IWorkbenchWindow workbenchWindow) { String upgradeNotes = (String) WrapperUtils.getRegistered(plan) .getTransientProperty(EditorPlugin.ATTRIBUTE_UPGRADE_NOTES); if ((upgradeNotes != null) && upgradeNotes.trim().length() > 0) { Shell parent = workbenchWindow.getShell(); String title = "Plan Compatibility"; String message = "The plan has been upgraded to the latest AD."; String version_ad = ActivityDictionary.getInstance().getVersion(); if (version_ad != null) { message += "\nversion: " + version_ad; } URL url = null; if (upgradeNotes.startsWith("http:") || upgradeNotes.endsWith("html")) { try { url = new URL(upgradeNotes); } catch (MalformedURLException e) { // fall out with url = null } } if (url != null) { MessageDialog dialog = new MessageDialog(parent, title, null, message + "\n\nDo you wish to open the report?\n" + upgradeNotes, MessageDialog.INFORMATION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); int result = dialog.open(); if (result == 0) { IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport(); try { IWebBrowser browser = browserSupport.getExternalBrowser(); browser.openURL(url); } catch (PartInitException e) { MessageDialog.openError(parent, "Error", "Failed to open external browser on URL:\n" + url); } } } else { MessageDialog dialog = new MessageDialog(parent, title, null, message + "\n\n" + upgradeNotes, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); } return true; } return false; }
From source file:gov.nasa.ensemble.core.plan.editor.MultiPagePlanEditor.java
License:Open Source License
/** * Is the user editing the plan the "custodian" of the plan? * @param plan a plan//from w ww .jav a2 s.c o m * @return whether this editor user is the custodian of the given plan */ private boolean checkCustodian(EPlan plan) { if (PlanEditorPreferences.isCheckCustodian()) { String worldPermissions = WrapperUtils.getAttributeValue(plan, PermissionConstants.WORLD_PERMISSIONS_KEY); if (worldPermissions == null || !PermissionConstants.PERMISSION_EDIT_BY_ROLE.equals(worldPermissions)) { String custodian = WrapperUtils.getAttributeValue(plan, EditorPlugin.ATTRIBUTE_CUSTODIAN); String ensembleUser = AuthenticationUtil.getEnsembleUser(); if ((custodian != null) && (ensembleUser != null) && !custodian.equals(ensembleUser)) { IWorkbenchWindow window = getEditorSite().getWorkbenchWindow(); String message = "The custodian of this plan is " + custodian + ", " + "but your username is " + ensembleUser + ". " + "Are you sure you want to save?"; MessageDialog dialog = new MessageDialog(window.getShell(), "Custodian/User mismatch", null, message, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 1); return 0 == dialog.open(); } } } return true; }
From source file:gov.redhawk.frontend.ui.internal.AllocateHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveMenuSelection(event); if (selection == null) { selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); }// www . j a v a 2 s. c o m if (selection.getFirstElement() instanceof TunerStatus && selection.size() > 1) { Object[] items = selection.toArray(); TunerStatus[] tuners = castArray(items, new TunerStatus[0]); if (tuners.length > 0) { WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), new TunerAllocationWizard(tuners[0])); dialog.open(); } } else { Object obj = selection.getFirstElement(); if (obj instanceof UnallocatedTunerContainer) { UnallocatedTunerContainer container = (UnallocatedTunerContainer) obj; TunerStatus[] tuners = getUnallocatedTunersOfType(container.getTunerContainer(), container.getTunerType()); if (tuners.length > 0) { WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), new TunerAllocationWizard(tuners[0])); dialog.open(); } } else if (obj instanceof TunerContainer) { TunerContainer container = (TunerContainer) obj; TunerStatus[] tuners = container.getTunerStatus().toArray(new TunerStatus[0]); if (tuners.length > 0) { WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), new TunerAllocationWizard(tuners[0])); dialog.open(); } else { ScaDevice<?> device = ScaEcoreUtils.getEContainerOfType(container, ScaDevice.class); if (device != null) { WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), new TunerAllocationWizard(FrontendFactory.eINSTANCE.createTunerStatus(), device)); warnNoTuners(event); dialog.open(); } else { MessageDialog warning = new MessageDialog(HandlerUtil.getActiveShell(event), "Error - No Device Found", null, "The device could not be found.", MessageDialog.ERROR, new String[] { "OK" }, 0); warning.open(); return null; } } } else if (obj instanceof ScaDevice<?>) { ScaDevice<?> device = (ScaDevice<?>) obj; TunerContainer container = TunerUtils.INSTANCE.getTunerContainer(device); if (container == null) { MessageDialog warning = new MessageDialog(HandlerUtil.getActiveShell(event), "Error - No Tuner Container Found", null, "The device's tuner container could not be found. Make sure the device's \"Data Providers Enabled\" property is set to \"true\".", MessageDialog.ERROR, new String[] { "OK" }, 0); warning.open(); return null; } TunerStatus[] tuners = container.getTunerStatus().toArray(new TunerStatus[0]); if (tuners.length > 0) { WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), new TunerAllocationWizard(tuners[0])); dialog.open(); } else { WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), new TunerAllocationWizard(FrontendFactory.eINSTANCE.createTunerStatus(), device)); warnNoTuners(event); dialog.open(); } } } return null; }