Example usage for org.eclipse.jface.dialogs MessageDialog ERROR

List of usage examples for org.eclipse.jface.dialogs MessageDialog ERROR

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog ERROR.

Prototype

int ERROR

To view the source code for org.eclipse.jface.dialogs MessageDialog ERROR.

Click Source Link

Document

Constant for the error image, or a simple dialog with the error image and a single OK button (value 1).

Usage

From source file:uk.ac.diamond.scisoft.arpes.calibration.wizards.GoldCalibrationWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    CalibrationWizardPage page = (CalibrationWizardPage) getContainer().getCurrentPage();
    // if last page
    if (page.getPageNumber() == 5) {
        try {//from   ww  w. j av a 2s .co  m
            if (page.runProcess())
                return true;
        } catch (InterruptedException e) {
            String errorMessage = e.getMessage();
            MessageDialog dialog = new MessageDialog(getShell(), "Saving process interrupted", null,
                    errorMessage, MessageDialog.ERROR, new String[] { "OK" }, 0);
            dialog.open();
        }
    }
    return false;
}

From source file:uk.ac.diamond.scisoft.ncd.rcp.handlers.NcdDataReductionWizardHandler.java

License:Apache License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage page = window.getActivePage();
    IStructuredSelection sel = (IStructuredSelection) page.getSelection(ProjectExplorer.VIEW_ID);
    if (sel == null || sel.isEmpty()) {
        sel = (IStructuredSelection) page.getSelection(Activator.FILEVIEW_ID);
    }/* w ww  .ja v a  2  s . c  o  m*/
    if (sel == null || sel.isEmpty()) {
        String msg = "Please select NeXus files to process in Project Explorer view before starting NCD Data Reduction Wizard.";
        Status status = new Status(IStatus.CANCEL, Activator.PLUGIN_ID, msg);
        StatusManager.getManager().handle(status, StatusManager.BLOCK | StatusManager.SHOW);
        return null;
    }

    ISourceProviderService service = (ISourceProviderService) window.getService(ISourceProviderService.class);
    NcdCalibrationSourceProvider ncdDetectorSourceProvider = (NcdCalibrationSourceProvider) service
            .getSourceProvider(NcdCalibrationSourceProvider.NCDDETECTORS_STATE);
    Map<String, NcdDetectorSettings> ncdDetectors = ncdDetectorSourceProvider.getNcdDetectors();
    if (ncdDetectors == null || ncdDetectors.isEmpty()) {
        // run the detector information command
        IHandlerService handlerService = (IHandlerService) window.getService(IHandlerService.class);
        try {
            handlerService.executeCommand("uk.ac.diamond.scisoft.ncd.rcp.readDetectorInfo", null);
        } catch (Exception ex) {
            MessageDialog dialog = new MessageDialog(window.getShell(), "Error", null, "Error:" + ex.toString(),
                    MessageDialog.ERROR, new String[] { "OK" }, 0);
            dialog.open();
        }
    }

    WizardDialog wizardDialog = new WizardDialog(Display.getDefault().getActiveShell(),
            new NcdDataReductionWizard());
    wizardDialog.open();

    return null;
}

From source file:uk.ac.diamond.scisoft.ncd.rcp.wizards.NcdDataReductionWizard.java

License:Apache License

@Override
public boolean performFinish() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

    //run the data reduction command
    IHandlerService handlerService = (IHandlerService) window.getService(IHandlerService.class);
    try {// w ww.j a va 2 s .  co  m
        handlerService.executeCommand("uk.ac.diamond.scisoft.ncd.rcp.process.wizard", null);
    } catch (Exception ex) {
        MessageDialog dialog = new MessageDialog(window.getShell(), "Error", null, "Error:" + ex.toString(),
                MessageDialog.ERROR, new String[] { "OK" }, 0);
        dialog.open();
    }
    return true;

}

From source file:uk.ac.gda.client.experimentdefinition.ui.handlers.RunExperimentCommandHandler.java

License:Open Source License

private void addExperimentToQueue(final IExperimentObject ob) throws ExecutionException {

    if (!saveAllOpenEditors()) {
        return;// ww w.  ja va 2  s.  c om
    }

    AbstractValidator validator = ExperimentFactory.getValidator();
    if (validator != null) {
        try {
            validator.validate(ob);
        } catch (InvalidBeanException e) {
            MessageDialog md = new MessageDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error(s) in XML file(s)",
                    null, e.getMessage(), MessageDialog.ERROR, new String[] { "Ignore errors", "Cancel" }, 1);
            int choice = md.open();
            if (choice == 1)
                return;
        }
    }

    ExperimentCommandProvider command;
    try {
        command = new ExperimentCommandProvider(ob);
    } catch (Exception e) {
        logger.error("Exception creating ExperimentCommandProvider." + e.getMessage());
        throw new ExecutionException("Exception creating ExperimentCommandProvider.", e);
    }

    try {
        CommandQueueViewFactory.getQueue().addToTail(command);
    } catch (Exception e) {
        logger.error("Exception adding ExperimentCommandProvider to CommandQueue." + e.getMessage());
        throw new ExecutionException("Exception adding ExperimentCommandProvider to CommandQueue.", e);
    }
}

From source file:uk.ac.gda.client.UIHelper.java

License:Open Source License

public static void showError(final String message, final String reason) {
    showMessage(MessageDialog.ERROR, message, reason);
}

From source file:uk.ac.gda.client.UIHelper.java

License:Open Source License

private static void showMessage(final int messageDialogType, final String message, final String reason) {
    Display.getDefault().syncExec(new Runnable() {
        @Override//w  w w. j  av  a  2  s  . com
        public void run() {
            StringBuilder messageString = new StringBuilder();
            messageString.append(message);
            if (reason != null) {
                messageString.append("\n\nReason:\n" + reason);
            }
            if (messageDialogType == MessageDialog.ERROR) {
                MessageDialog.openError(Display.getDefault().getActiveShell(), "Error",
                        messageString.toString());
            } else if (messageDialogType == MessageDialog.WARNING) {
                MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Warning",
                        messageString.toString());
            }
        }
    });
}

From source file:uk.ac.gda.richbeans.editors.RichBeanEditorPart.java

License:Open Source License

@Override
public void doSave(IProgressMonitor monitor) {

    if (path == null)
        return; // Nothing to save.
    final File file = new File(path);
    monitor.beginTask(file.getName(), 100);
    try {//from  w  ww  . j  a  v a  2s.com
        try {
            updateFromUIAndReturnEditingBean();
            WorkspaceModifyOperation saveOp = new WorkspaceModifyOperation() {
                @Override
                protected void execute(IProgressMonitor monitor)
                        throws CoreException, InvocationTargetException, InterruptedException {
                    try {
                        XMLHelpers.writeToXML(mappingURL, editingBean, path);

                        final IFile ifile = getIFile();
                        if (ifile != null) {
                            ifile.refreshLocal(IResource.DEPTH_ZERO, null);
                        }
                    } catch (Exception e) {
                        logger.error(
                                "Error - RichBeanEditorPart.doSave() failed. Path=" + path + e.getMessage());
                        MessageDialog dialog = new MessageDialog(getSite().getShell(), "File didn't save", null,
                                "Path=" + path, MessageDialog.ERROR, new String[] {}, 0);
                        int result = dialog.open();
                        System.out.println(result);
                        throw new InvocationTargetException(e);
                    }
                }
            };

            PlatformUI.getWorkbench().getProgressService().busyCursorWhile(saveOp);
            notifyFileSaved(file);
            dirtyContainer.setDirty(false);

        } catch (Exception e) {
            // Saving is very important as it saves the state of the editors when switching between editors, perspectives, etc.

            logger.error("Error - RichBeanEditorPart.doSave() failed. Path=" + path + e.getMessage());
            MessageDialog dialog = new MessageDialog(getSite().getShell(), "File didn't save", null,
                    "Path=" + path, MessageDialog.ERROR, new String[] {}, 0);
            int result = dialog.open();
            System.out.println(result);
        }
    } finally {
        monitor.done();
    }
}

From source file:uk.ac.stfc.isis.ibex.ui.configserver.commands.helpers.EditComponentHelper.java

License:Open Source License

private void openErrorSavingDialog(IOException e) {
    String title = "Error saving component";
    String description = "Unable to save component: " + e.getMessage();
    new MessageDialog(shell, title, null, description, MessageDialog.ERROR, OK, 0).open();
}

From source file:uk.ac.stfc.isis.ibex.ui.mainmenu.managermode.EnterManagerModeDialog.java

License:Open Source License

private static void displayError(Shell shell, String message) {
    MessageDialog error = new MessageDialog(shell, "Error", null, message, MessageDialog.ERROR,
            new String[] { "OK" }, 0);
    error.open();/*  w w  w. ja  v a  2 s.  c om*/
}

From source file:us.pwc.vista.eclipse.core.helper.MessageDialogHelper.java

License:Apache License

public static void showError(String title, String message) {
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    MessageDialog.open(MessageDialog.ERROR, shell, title, message, SWT.NONE);
}