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:com.baremetalstudios.mapleide.datatransfer.ArchiveFileManipulations.java

License:Open Source License

/**
 * Display an error dialog with the specified message.
 * /*from  w  ww.j a v  a2  s  .  c o  m*/
 * @param message
 *            the error message
 */
protected static void displayErrorDialog(String message, Shell shell) {
    MessageDialog.open(MessageDialog.ERROR, shell, getErrorDialogTitle(), message, SWT.SHEET);
}

From source file:com.bdaum.zoom.rcp.internal.StatusHandler.java

License:Open Source License

@Override
public void handle(StatusAdapter statusAdapter, int style) {
    if (style == StatusManager.SHOW) {
        final IStatus status = statusAdapter.getStatus();
        if (status.getSeverity() == IStatus.ERROR) {
            ++errors;/*from  w  w  w. ja v  a  2  s. c om*/
            UiActivator.getDefault().setRepairCat(true);
            final IWorkbench workbench = PlatformUI.getWorkbench();
            final Display display = workbench.getDisplay();
            if (!display.isDisposed())
                display.asyncExec(() -> {
                    if (!display.isDisposed()) {
                        if (dialog != null) {
                            dialog.close();
                            dialog = null;
                        }
                        Shell activeShell = display.getActiveShell();
                        if (activeShell != null) {
                            IStatus aStatus = status;
                            if (status instanceof MultiStatus) {
                                IStatus[] children = ((MultiStatus) status).getChildren();
                                if (children.length == 1)
                                    aStatus = children[0];
                            }
                            String title = NLS.bind(Messages.getString("StatusHandler.error_report"), //$NON-NLS-1$
                                    Constants.APPNAME);
                            if (status == aStatus) {
                                dialog = new AcousticMessageDialog(activeShell, title, null,
                                        NLS.bind(Messages.getString("StatusHandler.multiple_error_processing"), //$NON-NLS-1$
                                                errors, status.getMessage()),
                                        MessageDialog.ERROR,
                                        new String[] { IDialogConstants.OK_LABEL,
                                                Messages.getString("StatusHandler.View_log") }, //$NON-NLS-1$
                                        0);
                            } else
                                dialog = new AcousticMessageDialog(activeShell, title, null,
                                        NLS.bind(Messages.getString("StatusHandler.Error_processing"), errors, //$NON-NLS-1$
                                                aStatus.getMessage()),
                                        MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
                            int ret = dialog.open();
                            if (ret == 1) {
                                dialog.close();
                                IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
                                if (activeWorkbenchWindow != null) {
                                    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
                                    if (activePage != null) {
                                        try {
                                            activePage.showView(AbstractPerspective.LOG_VIEW);
                                            Shell shell = activeWorkbenchWindow.getShell();
                                            shell.setVisible(true);
                                            shell.setMinimized(false);
                                            shell.forceActive();
                                        } catch (PartInitException e) {
                                            // ignore
                                        }
                                    }
                                }
                            }
                            dialog = null;
                        }
                    }
                });
        }
    }
}

From source file:com.byterefinery.rmbench.dialogs.PrinterSetupDialog.java

License:Open Source License

protected void okPressed() {
    if (selectedPrinter != null) {

        // check margin value
        if (!validMargin((int) (margin * Display.getCurrent().getDPI().x))) {
            String[] buttons = { "Ok" };
            MessageDialog mDialog = new MessageDialog(parentShell, "Error", null,
                    Messages.PrintDialog_marginValueError, MessageDialog.ERROR, buttons, 0);
            mDialog.open();//from   w  w  w  . jav a  2 s .c o m
            marginText.setFocus();
            return;
        }

        RMBenchPlugin.getPrintState().margin = margin;
        RMBenchPlugin.getPrintState().printer = selectedPrinter;
    }

    super.okPressed();
}

From source file:com.centurylink.mdw.plugin.designer.dialogs.MdwMessageDialog.java

License:Apache License

public MdwMessageDialog(Shell shell, String title, String message, int level) {
    super(shell, title, null, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
    this.messageLevel = level;
    this.reportMessage = level >= PluginMessages.getReportingLevel();
    this.offerSend = reportMessage;
}

From source file:com.ceteva.basicIO.AddLicenseKey.java

public Point getInitialSize() {
    Display.getCurrent().getSystemImage(MessageDialog.ERROR);
    return new Point(450, 300);
}

From source file:com.conwet.wirecloud.ide.wizards.WizardProjectsImportPage.java

License:Open Source License

/**
 * Display an error dialog with the specified message.
 *
 * @param message/*from   w  w w.  j av a 2  s  .  c o m*/
 *       the error message
 */
protected void displayErrorDialog(String message) {
    MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), getErrorDialogTitle(), message,
            SWT.SHEET);
}

From source file:com.coretek.testcase.projectView.projectwizard.page.WizardNewFolderMainPage.java

License:Open Source License

/**
 * Creates a new folder resource in the selected container and with the
 * selected name. Creates any missing resource containers along the path;
 * does nothing if the container resources already exist.
 * <p>/*from w w w .  j  av a 2 s  . c o m*/
 * In normal usage, this method is invoked after the user has pressed Finish
 * on the wizard; the enablement of the Finish button implies that all
 * controls on this page currently contain valid values.
 * </p>
 * <p>
 * Note that this page caches the new folder once it has been successfully
 * created; subsequent invocations of this method will answer the same
 * folder resource without attempting to create it again.
 * </p>
 * <p>
 * This method should be called within a workspace modify operation since it
 * creates resources.
 * </p>
 * 
 * @return the created folder resource, or <code>null</code> if the folder
 *         was not created
 */
public IFolder createNewFolder() {
    if (newFolder != null) {
        return newFolder;
    }

    // create the new folder and cache it if successful
    final IPath containerPath = resourceGroup.getContainerFullPath();
    IPath newFolderPath = containerPath.append(resourceGroup.getResource());
    final IFolder newFolderHandle = createFolderHandle(newFolderPath);

    createLinkTarget();
    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) {
            CreateFolderOperation op = new CreateFolderOperation(newFolderHandle, linkTargetPath,
                    IDEWorkbenchMessages.WizardNewFolderCreationPage_title);
            try {
                // see bug
                // https://bugs.eclipse.org/bugs/show_bug.cgi?id=219901
                // directly execute the operation so that the undo state is
                // not preserved. Making this undoable can result in
                // accidental
                // folder (and file) deletions.
                op.execute(monitor, WorkspaceUndoUtil.getUIInfoAdapter(getShell()));
            } catch (final ExecutionException e) {
                getContainer().getShell().getDisplay().syncExec(new Runnable() {
                    public void run() {
                        if (e.getCause() instanceof CoreException) {
                            ErrorDialog.openError(getContainer().getShell(), // Was
                                    // Utilities.getFocusShell()
                                    IDEWorkbenchMessages.WizardNewFolderCreationPage_errorTitle, null, // no
                                    // special
                                    // message
                                    ((CoreException) e.getCause()).getStatus());
                        } else {
                            IDEWorkbenchPlugin.log(getClass(), "createNewFolder()", e.getCause()); //$NON-NLS-1$
                            MessageDialog.openError(getContainer().getShell(),
                                    IDEWorkbenchMessages.WizardNewFolderCreationPage_internalErrorTitle,
                                    NLS.bind(IDEWorkbenchMessages.WizardNewFolder_internalError,
                                            e.getCause().getMessage()));
                        }
                    }
                });
            }
        }
    };

    try {
        getContainer().run(true, true, op);
    } catch (InterruptedException e) {
        return null;
    } catch (InvocationTargetException e) {
        // ExecutionExceptions are handled above, but unexpected runtime
        // exceptions and errors may still occur.
        IDEWorkbenchPlugin.log(getClass(), "createNewFolder()", e.getTargetException()); //$NON-NLS-1$
        MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
                IDEWorkbenchMessages.WizardNewFolderCreationPage_internalErrorTitle,
                NLS.bind(IDEWorkbenchMessages.WizardNewFolder_internalError,
                        e.getTargetException().getMessage()),
                SWT.SHEET);
        return null;
    }

    newFolder = newFolderHandle;

    return newFolder;
}

From source file:com.drgarbage.utils.Messages.java

License:Apache License

public static int error(Shell shell, String title, String message) {
    MessageDialog dlg = new MessageDialog(shell, title, CoreImg.aboutDrGarbageIcon_16x16.createImage(), message,
            MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
    return dlg.open();
}

From source file:com.google.appraise.eclipse.ui.editor.CommitAttributeEditor.java

License:Open Source License

@Override
public void createControl(final Composite parent, FormToolkit toolkit) {
    link = new Link(parent, SWT.BORDER);
    link.setText("<a>" + getValue() + "</a>");
    link.addListener(SWT.Selection, new Listener() {
        @Override//ww w . j a  va 2  s  .c o  m
        public void handleEvent(Event event) {
            try {
                RepositoryCommit commit = getCommit();
                if (commit != null) {
                    CommitEditor.openQuiet(commit);
                } else {
                    MessageDialog alert = new MessageDialog(parent.getShell(), "Oops", null,
                            "Commit " + getValue() + " not found", MessageDialog.ERROR, new String[] { "OK" },
                            0);
                    alert.open();
                }
            } catch (IOException e) {
                AppraiseUiPlugin.logError("Error reading commit " + getValue(), e);
            }
        }
    });
    setControl(link);
}

From source file:com.google.dart.tools.deploy.DelayedEventsProcessor.java

License:Open Source License

private void openFile(Display display, final String path) {
    display.asyncExec(new Runnable() {
        @Override// ww w.j  a  v a 2  s .  c o m
        public void run() {
            IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            if (window == null) {
                return;
            }
            IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(path));
            IFileInfo fetchInfo = fileStore.fetchInfo();
            if (!fetchInfo.isDirectory() && fetchInfo.exists()) {
                IWorkbenchPage page = window.getActivePage();
                if (page == null) {

                    // TODO: Add a more robust way of displaying error messages at this point. Maybe a read
                    // only editor page like the Welcome editor so that users can get to the information.

                    String msg = NLS.bind("The file ''{0}'' could not be opened.", path);
                    MessageDialog.open(MessageDialog.ERROR, window.getShell(), "Open File", msg, SWT.SHEET);
                }
                try {
                    IDE.openInternalEditorOnFileStore(page, fileStore);
                    IWorkbenchPartReference partRef = page.getActivePartReference();
                    if (partRef != null) {
                        if (!page.isPageZoomed()) {
                            page.toggleZoom(partRef);
                        }
                    }
                    Shell shell = window.getShell();
                    if (shell != null) {
                        if (shell.getMinimized()) {
                            shell.setMinimized(false);
                        }
                        shell.forceActive();
                    } else {
                        throw new PartInitException("Shell could not be found");
                    }
                } catch (PartInitException e) {
                    String msg = NLS.bind("The file ''{0}'' could not be opened.\nSee log for details.",
                            fileStore.getName());
                    CoreException eLog = new PartInitException(e.getMessage());
                    Activator.getDefault().getLog()
                            .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, msg, eLog));
                    MessageDialog.open(MessageDialog.ERROR, window.getShell(), "Open File", msg, SWT.SHEET);
                }
            } else {
                String msg = NLS.bind("The file ''{0}'' could not be found.", path);
                MessageDialog.open(MessageDialog.ERROR, window.getShell(), "Open File", msg, SWT.SHEET);
            }
        }
    });
}