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:org.eclipse.team.svn.ui.discovery.util.DiscoveryUiUtil.java

License:Open Source License

public static void displayStatus(Shell shell, final String title, final IStatus status,
        boolean showLinkToErrorLog) {
    if (shell == null) {
        shell = UIMonitorUtility.getShell();
    }//from w ww .j  av a  2  s .co  m
    String message = status.getMessage();
    if (showLinkToErrorLog) {
        message += SVNUIMessages.DiscoveryUi_seeErrorLog;
    }
    switch (status.getSeverity()) {
    case IStatus.CANCEL:
    case IStatus.INFO:
        createDialog(shell, title, message, MessageDialog.INFORMATION).open();
        break;
    case IStatus.WARNING:
        createDialog(shell, title, message, MessageDialog.WARNING).open();
        break;
    case IStatus.ERROR:
    default:
        createDialog(shell, title, message, MessageDialog.ERROR).open();
        break;
    }

}

From source file:org.eclipse.titanium.error.GUIErrorHandler.java

License:Open Source License

@Override
public void reportException(final String context, final Exception exception) {
    ErrorMessage.show("Exception", exception.getMessage() + ErrorMessage.LOG_ENTRY_NOTE, MessageDialog.ERROR);
    ErrorReporter.logExceptionStackTrace("", exception);
}

From source file:org.eclipse.titanium.error.GUIErrorHandler.java

License:Open Source License

@Override
public void reportErrorMessage(final String text) {
    ErrorMessage.show("Error", text, MessageDialog.ERROR);
}

From source file:org.eclipse.titanium.error.GUIErrorHandler.java

License:Open Source License

/**
 * This method reports a possibly bad setting, it also provides a button to
 * set this setting to a correct value.//from  w w  w .  j av a 2 s .  com
 * 
 * @param windowTitle
 *            : The title of error window to show
 * @param message
 *            : The message to show in the window
 * @param buttonTitle
 *            : The title of the button that pops up the preference page on
 *            click
 * @param prefPage
 *            : The string that provides link to the preference page (for
 *            eg. <code>org.eclipse.titanium.preferences.pages...</code>
 */
public void reportBadSetting(final String windowTitle, final String message, final String buttonTitle,
        final String prefPage) {
    ErrorMessage.show(windowTitle, message, buttonTitle, prefPage, MessageDialog.ERROR);
}

From source file:org.eclipse.titanium.error.GUIErrorHandler.java

License:Open Source License

/**
 * This method writes the collected errors to the log, and pops up a window
 * that warns the user to read the log. This method also makes the message
 * string to be empty.//from   w  w w .  j  a va2  s. c  om
 */
@Override
public void writeMessageToLog() {
    if (collectedMessage.length() != 0) {
        ErrorReporter.logError(collectedMessage.toString());
        collectedMessage.setLength(0);
        collectedMessage.trimToSize();
        ErrorMessage.show("Error log", "Various errors happened! For details see the error log.",
                MessageDialog.ERROR);
    }
}

From source file:org.eclipse.titanium.graph.gui.layouts.algorithms.MetricLayoutAlgorithm.java

License:Open Source License

private void init() {
    values = new HashMap<NodeDescriptor, Double>();
    levels = new HashMap<NodeDescriptor, Integer>();
    badNodes = new HashSet<NodeDescriptor>();
    minValue = Double.POSITIVE_INFINITY;
    maxValue = Double.NEGATIVE_INFINITY;
    filledLevels = 0;/*from w ww  . j av  a  2 s. c om*/

    if (!PreferenceManager.isEnabledOnModuleGraph(chosenMetric)) {
        ErrorReporter.logError("Error during metric layout generating: The requested metric is not"
                + " enabled. Only enabled metrics can be chosen!");
        ErrorMessage.show("Error",
                "The chosen metric must be enabled for calculation in the properties." + "Have you enabled it?",
                MessageDialog.ERROR);
        return;
    }

    final Iterator<NodeDescriptor> it = nodes.iterator();
    while (it.hasNext()) {
        final NodeDescriptor node = it.next();
        final ModuleMetricsWrapper wrapper = WrapperStore.getWrapper(node.getProject());
        final Number val = wrapper.getValue(chosenMetric, node.getName());
        if (val == null) {
            it.remove();
            badNodes.add(node);
        } else {
            final Double tempVal = Double.valueOf(val.toString());
            if (tempVal != null) {
                values.put(node, tempVal);
                if (minValue > tempVal) {
                    minValue = tempVal;
                }

                if (maxValue < tempVal) {
                    maxValue = tempVal;
                }
            }
        }
    }
}

From source file:org.eclipse.tracecompass.tmf.ui.project.wizards.SelectTracesWizardPage.java

License:Open Source License

/**
 * Method to finalize the select operation.
 *
 * @return <code>true</code> if successful else <code>false</code>
 *//*w  w w  .j a va  2 s . c  om*/
public boolean performFinish() {

    IFolder experiment = fExperiment.getResource();

    final SelectTracesOperation operation = new SelectTracesOperation(experiment, getSelection());

    IStatus status = Status.OK_STATUS;
    try {
        getContainer().run(true, true, new IRunnableWithProgress() {
            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                // Wrapper to have only one resource changed event at the
                // end of the operation.
                IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
                    @Override
                    public void run(IProgressMonitor pm) throws CoreException {
                        operation.run(pm);
                    }
                };

                IWorkspace workspace = ResourcesPlugin.getWorkspace();
                try {
                    workspace.run(workspaceRunnable, workspace.getRoot(), IWorkspace.AVOID_UPDATE, monitor);
                } catch (CoreException e) {
                    throw new InvocationTargetException(e);
                } finally {
                    monitor.done();
                }
            }
        });

        status = operation.getStatus();
    } catch (InvocationTargetException e) {
        status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SelectTracesWizardPage_SelectionError,
                e);
    } catch (InterruptedException e) {
        status = Status.CANCEL_STATUS;
    }
    if (!status.isOK()) {
        if (status.getSeverity() == IStatus.CANCEL) {
            setMessage(Messages.SelectTracesWizardPage_SelectionOperationCancelled);
            setErrorMessage(null);
        } else {
            if (status.getException() != null) {
                MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
                        Messages.SelectTracesWizardPage_InternalErrorTitle,
                        status.getMessage() + ": " + status.getException(), SWT.SHEET); //$NON-NLS-1$
            }
            setMessage(null);
            setErrorMessage(Messages.SelectTracesWizardPage_SelectionError);
        }
        return false;
    }
    setErrorMessage(null);

    return true;
}

From source file:org.eclipse.ui.dialogs.WizardExportPage.java

License:Open Source License

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

From source file:org.eclipse.ui.dialogs.WizardImportPage.java

License:Open Source License

/**
 * Display an error dialog with the specified message.
 *
 * @param message the error message/*from   ww  w.java2  s.c  om*/
 */
protected void displayErrorDialog(String message) {
    MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
            IDEWorkbenchMessages.WizardImportPage_errorDialogTitle, message, SWT.SHEET);
}

From source file:org.eclipse.ui.dialogs.WizardNewFileCreationPage.java

License:Open Source License

/**
 * Creates a new file 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  ava2s.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 on this page currently contain valid values.
 * </p>
 * <p>
 * Note that this page caches the new file once it has been successfully
 * created; subsequent invocations of this method will answer the same file
 * 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 file resource, or <code>null</code> if the file was
 *         not created
 */
public IFile createNewFile() {
    if (newFile != null) {
        return newFile;
    }

    // create the new file and cache it if successful

    final IPath containerPath = resourceGroup.getContainerFullPath();
    IPath newFilePath = containerPath.append(resourceGroup.getResource());
    final IFile newFileHandle = createFileHandle(newFilePath);
    final InputStream initialContents = getInitialContents();

    createLinkTarget();

    if (linkTargetPath != null) {
        URI resolvedPath = newFileHandle.getPathVariableManager().resolveURI(linkTargetPath);
        try {
            if (resolvedPath.getScheme() != null && resolvedPath.getSchemeSpecificPart() != null) {
                IFileStore store = EFS.getStore(resolvedPath);
                if (!store.fetchInfo().exists()) {
                    MessageDialog dlg = new MessageDialog(getContainer().getShell(),
                            IDEWorkbenchMessages.WizardNewFileCreationPage_createLinkLocationTitle, null,
                            NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_createLinkLocationQuestion,
                                    linkTargetPath),
                            MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL,
                                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                            0);
                    int result = dlg.open();
                    if (result == Window.OK) {
                        store.getParent().mkdir(0, new NullProgressMonitor());
                        OutputStream stream = store.openOutputStream(0, new NullProgressMonitor());
                        stream.close();
                    }
                    if (result == 2)
                        return null;
                }
            }
        } catch (CoreException e) {
            MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
                    IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
                    NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage,
                            e.getMessage()),
                    SWT.SHEET);

            return null;
        } catch (IOException e) {
            MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
                    IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
                    NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage,
                            e.getMessage()),
                    SWT.SHEET);

            return null;
        }
    }

    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) {
            CreateFileOperation op = new CreateFileOperation(newFileHandle, linkTargetPath, initialContents,
                    IDEWorkbenchMessages.WizardNewFileCreationPage_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 resulted in too many 
                // accidental 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.WizardNewFileCreationPage_errorTitle, null, // no special
                                    // message
                                    ((CoreException) e.getCause()).getStatus());
                        } else {
                            IDEWorkbenchPlugin.log(getClass(), "createNewFile()", e.getCause()); //$NON-NLS-1$
                            MessageDialog.openError(getContainer().getShell(),
                                    IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
                                    NLS.bind(
                                            IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage,
                                            e.getCause().getMessage()));
                        }
                    }
                });
            }
        }
    };
    try {
        getContainer().run(true, true, op);
    } catch (InterruptedException e) {
        return null;
    } catch (InvocationTargetException e) {
        // Execution Exceptions are handled above but we may still get
        // unexpected runtime errors.
        IDEWorkbenchPlugin.log(getClass(), "createNewFile()", e.getTargetException()); //$NON-NLS-1$
        MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
                IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
                NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage,
                        e.getTargetException().getMessage()),
                SWT.SHEET);

        return null;
    }

    newFile = newFileHandle;

    return newFile;
}