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.siteview.mde.internal.ui.launcher.LauncherUtilsStatusHandler.java

License:Open Source License

private static void generateErrorDialog(final String title, final String message,
        final ILaunchConfiguration launchConfig, final String mode) {
    getDisplay().syncExec(new Runnable() {
        public void run() {
            Shell parentShell = getActiveShell();
            MessageDialog dialog = new MessageDialog(parentShell, title, null, message, MessageDialog.ERROR,
                    new String[] { MDEUIMessages.LauncherUtils_edit, IDialogConstants.OK_LABEL }, 1);
            int res = dialog.open();
            if (res == 0) {
                IStructuredSelection selection = new StructuredSelection(launchConfig);
                ILaunchGroup group = DebugUITools.getLaunchGroup(launchConfig, mode);
                String groupIdentifier = group == null ? IDebugUIConstants.ID_RUN_LAUNCH_GROUP
                        : group.getIdentifier();
                IStatus status = new Status(IStatus.OK, PDELaunchingPlugin.getPluginId(),
                        LauncherUtils.SELECT_WORKSPACE_FIELD, "", null); //$NON-NLS-1$
                DebugUITools.openLaunchConfigurationDialogOnGroup(parentShell, selection, groupIdentifier,
                        status);/*  w  w  w. j a  v  a2  s.c o  m*/
            }
        }
    });
}

From source file:com.siteview.mde.internal.ui.launcher.LaunchTerminationStatusHandler.java

License:Open Source License

private void handleOtherReasonsFoundInLog(final ILaunch launch) {
    Display.getDefault().asyncExec(new Runnable() {
        public void run() {
            try {
                File log = LaunchListener.getMostRecentLogFile(launch.getLaunchConfiguration());
                if (log != null && log.exists()) {
                    MessageDialog dialog = new MessageDialog(MDEPlugin.getActiveWorkbenchShell(),
                            MDEUIMessages.Launcher_error_title, null, // accept the default window icon
                            MDEUIMessages.Launcher_error_code13, MessageDialog.ERROR,
                            new String[] { MDEUIMessages.Launcher_error_displayInLogView,
                                    MDEUIMessages.Launcher_error_displayInSystemEditor,
                                    IDialogConstants.NO_LABEL },
                            OPEN_IN_ERROR_LOG_VIEW);
                    int dialog_value = dialog.open();
                    if (dialog_value == OPEN_IN_ERROR_LOG_VIEW) {
                        IWorkbenchPage page = MDEPlugin.getActivePage();
                        if (page != null) {
                            LogView errlog = (LogView) page.showView("org.eclipse.pde.runtime.LogView"); //$NON-NLS-1$
                            errlog.handleImportPath(log.getAbsolutePath());
                            errlog.sortByDateDescending();
                        }/*from w  w w  .java2s . c o  m*/
                    } else if (dialog_value == OPEN_IN_SYSTEM_EDITOR) {
                        openInEditor(log);
                    }
                }
            } catch (CoreException e) {
            }
        }
    });
}

From source file:com.synflow.cx.ui.wizards.NewFilePage.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./*from  w w w  .  ja v  a2s .c  o  m*/
 * 
 * @param initialContents
 *            initial contents of the file
 * 
 * @return the created file resource, or <code>null</code> if the file was not created
 */
public IFile createNewFile(final InputStream initialContents) {
    final IFile newFileHandle = getFile();

    IRunnableWithProgress op = new IRunnableWithProgress() {
        @Override
        public void run(IProgressMonitor monitor) {
            CreateFileOperation op = new CreateFileOperation(newFileHandle, null, initialContents, getTitle());
            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() {
                    @Override
                    public void run() {
                        if (e.getCause() instanceof CoreException) {
                            ErrorDialog.openError(getContainer().getShell(), "Could not create " + type, null,
                                    ((CoreException) e.getCause()).getStatus());
                        } else {
                            SynflowCore.log(e.getCause());
                            MessageDialog.openError(getContainer().getShell(), "Could not create " + type,
                                    NLS.bind("Internal error: {0}", 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.
        SynflowCore.log(e.getTargetException());
        MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), "Could not create " + type,
                NLS.bind("Internal error: {0}", e.getTargetException().getMessage()), SWT.SHEET);
        return null;
    }

    return newFileHandle;
}

From source file:com.synflow.ngDesign.ui.internal.wizards.NewPackagePage.java

License:Open Source License

public IFolder createNewFolder() {
    final IFolder newFolderHandle = getFolder();
    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) {
            CreateFolderOperation op = new CreateFolderOperation(newFolderHandle, null, "New Package");
            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(), "Could not create package", null,
                                    ((CoreException) e.getCause()).getStatus());
                        } else {
                            SynflowCore.log(e.getCause());
                            MessageDialog.openError(getContainer().getShell(), "Could not create package",
                                    NLS.bind("Internal error: {0}", e.getCause().getMessage()));
                        }/*from   ww  w . j a  va 2  s.  c  o  m*/
                    }
                });
            }
        }
    };

    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.
        SynflowCore.log(e.getTargetException());
        MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), "Could not create package",
                NLS.bind("Internal error: {0}", e.getTargetException().getMessage()), SWT.SHEET);
        return null;
    }

    return newFolderHandle;
}

From source file:com.toubassi.filebunker.ui.FileBunker.java

License:Open Source License

/**
 * We require 1.4.2_05 or later due to our dependence on https.  Make sure
 * we are running against that VM, or a later one.
 * //  w  ww.j  ava2s .  c o m
 * @param shell
 */
private void verifyJavaRuntimeVersion(Shell shell) {
    String version = System.getProperty("java.runtime.version");

    // Skip any leading text like "Blackdown" (see
    // http://sourceforge.net/tracker/index.php?func=detail&aid=1181135&group_id=118802&atid=682209
    for (int i = 0, count = version.length(); i < count; i++) {
        char ch = version.charAt(i);
        if (Character.isDigit(ch)) {
            version = version.substring(i);
            break;
        }
    }

    StringTokenizer tokenizer = new StringTokenizer(version, "._-");
    boolean ok = false;

    try {
        if (tokenizer.hasMoreTokens()) {
            String major = tokenizer.nextToken();
            if (Integer.parseInt(major) > 2) {
                ok = true;
            }
        }
        if (!ok && tokenizer.hasMoreTokens()) {
            String minor = tokenizer.nextToken();
            if (Integer.parseInt(minor) > 4) {
                ok = true;
            }
        }
        if (!ok && tokenizer.hasMoreTokens()) {
            String patch = tokenizer.nextToken();
            if (Integer.parseInt(patch) > 2) {
                ok = true;
            }
        }
        if (!ok && tokenizer.hasMoreTokens()) {
            String subpatch = tokenizer.nextToken();
            if (Integer.parseInt(subpatch) >= 5) {
                ok = true;
            }
        }
    } catch (NumberFormatException e) {
        Log.log(e, "Exception parsing runtime version: '" + version + "'");
        throw e;
    }

    if (!ok) {
        String[] buttons = new String[] { "Quit", "Continue" };
        String message = "FileBunker requires Java Runtime version 1.4.2_05 or later.  "
                + "You are currently running " + version + ".  If you continue, "
                + "the application is unlikely to function properly.  It is "
                + "strongly recommended that you quit and install a more recent " + "Java Runtime.";
        MessageDialog dialog = new MessageDialog(shell, "Error",
                shell.getDisplay().getSystemImage(SWT.ICON_ERROR), message, MessageDialog.ERROR, buttons, 0);
        if (dialog.open() == 0) {
            System.exit(0);
        }
    }
}

From source file:com.vectrace.MercurialEclipse.views.MergeView.java

License:Open Source License

/**
 * @see com.vectrace.MercurialEclipse.views.AbstractRootView#createActions()
 *//*ww w.j  a  v a2s . c om*/
@Override
protected void createActions() {
    completeAction = new Action(Messages.getString("MergeView.merge.complete")) { //$NON-NLS-1$
        @Override
        public void run() {
            if (areAllResolved()) {
                attemptToCommit();
                refresh(hgRoot, conflictResolvingContext);
            }
        }
    };
    completeAction.setEnabled(false);
    completeAction.setImageDescriptor(MercurialEclipsePlugin.getImageDescriptor("actions/commit.gif"));

    abortAction = new Action(Messages.getString("MergeView.merge.abort")) { //$NON-NLS-1$
        @Override
        public void run() {
            try {
                RunnableHandler runnable;
                if (!merging) {
                    runnable = new AbortRebaseHandler();
                } else {
                    UpdateHandler update = new UpdateHandler();
                    update.setCleanEnabled(true);
                    update.setRevision(".");
                    runnable = update;
                }

                runnable.setShell(table.getShell());
                runnable.run(hgRoot);
                refresh(hgRoot, conflictResolvingContext);
            } catch (CoreException e) {
                handleError(e);
            }
            MercurialUtilities.setOfferAutoCommitMerge(true);
        }
    };
    abortAction.setEnabled(false);
    abortAction.setImageDescriptor(
            PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_STOP));

    markResolvedAction = new Action(Messages.getString("MergeView.markResolved")) { //$NON-NLS-1$
        @Override
        public void run() {
            try {
                List<IFile> files = getSelections();
                if (files != null) {
                    for (IFile file : files) {
                        KeepDeleteConflict c = keepDeleteConflicts.get(file);
                        if (c != null) {
                            // just remove it from the list..
                            conflictResolvingContext.getKeepDeleteConflicts().remove(c);
                        } else {
                            HgResolveClient.markResolved(hgRoot, file);
                        }
                    }
                    populateView(true);
                }
            } catch (HgException e) {
                handleError(e);
            }
        }
    };
    markResolvedAction.setEnabled(false);
    markUnresolvedAction = new Action(Messages.getString("MergeView.markUnresolved")) { //$NON-NLS-1$
        @Override
        public void run() {
            try {
                List<IFile> files = getSelections();
                if (files != null) {
                    for (IFile file : files) {
                        KeepDeleteConflict c = keepDeleteConflicts.get(file);
                        // do nothing for keep-delete conflicts
                        if (c == null) {
                            HgResolveClient.markUnresolved(hgRoot, file);
                        }

                    }
                    populateView(true);
                }
            } catch (HgException e) {
                handleError(e);
            }
        }
    };
    markUnresolvedAction.setEnabled(false);

    deleteFileAction = new Action(Messages.getString("MergeView.deleteFile")) {
        @Override
        public void run() {
            super.run();
            try {
                List<IFile> files = getSelections();
                if (files != null) {
                    for (IFile file : files) {
                        KeepDeleteConflict c = keepDeleteConflicts.get(file);
                        if (c != null) {
                            try {
                                HgResolveClient.deleteKeepDeleteConflict(hgRoot, conflictResolvingContext, c,
                                        file);
                            } catch (Exception ex) {
                                // just in case, I've seen some random failures when the workspace isn't in sync with the file system
                                MessageDialog dialog = new MessageDialog(null, "Error Deleting File", null,
                                        ex.getMessage(), MessageDialog.ERROR, new String[] { "Ok" }, 0);
                            }
                        } else {
                            // even if it's not a keep-delete conflict, we are providing a delete file option,
                            // so delete the file either way.
                            try {
                                file.delete(true, null);
                            } catch (Exception ex) {
                                MessageDialog dialog = new MessageDialog(null, "Error Deleting File", null,
                                        ex.getMessage(), MessageDialog.ERROR, new String[] { "Ok" }, 0);
                            }
                        }

                        // refresh status
                        MercurialStatusCache.getInstance().refreshStatus(file, null);
                        ResourceUtils.touch(file);
                    }
                    populateView(true);
                }
            } catch (HgException e) {
                handleError(e);
            }
        }
    };
    deleteFileAction.setEnabled(false);
}

From source file:com.vmware.vfabric.ide.eclipse.tcserver.insight.internal.ui.TcServerInsightSection.java

License:Open Source License

@Override
public void createSection(Composite parent) {
    super.createSection(parent);
    FormToolkit toolkit = getFormToolkit(parent.getDisplay());

    Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR
            | Section.DESCRIPTION | ExpandableComposite.FOCUS_TITLE | ExpandableComposite.EXPANDED);
    section.setText("Overview");
    section.setDescription("Enable collection of performance metrics for deployed applications.");
    section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));

    Composite composite = toolkit.createComposite(section);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 8;/*w  w  w .  j a v  a  2s  .  c o  m*/
    layout.marginWidth = 8;
    composite.setLayout(layout);
    toolkit.paintBordersFor(composite);
    section.setClient(composite);

    button = toolkit.createButton(composite, "Enable gathering of metrics", SWT.CHECK);
    button.addSelectionListener(new SelectionAdapter() {
        private boolean ignoreEvents;

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (ignoreEvents) {
                return;
            }
            if (button.getSelection() && server.getOriginal() != null
                    && !TcServerInsightUtil.isInsightCompatible(server.getOriginal())) {
                MessageDialog dialog = new MessageDialog(getShell(), "Enable Spring Insight", null,
                        "This version of Spring Insight is not compatible with tc Server instances that are installed on a path that contains spaces. Enabling Spring Insight may cause tc Server to fail to startup.\n\n"
                                + "Are you sure you want to enable Spring Insight?",
                        MessageDialog.ERROR,
                        new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 1);
                if (dialog.open() != 0) {
                    try {
                        ignoreEvents = true;
                        button.setSelection(false);
                    } finally {
                        ignoreEvents = false;
                    }
                    return;
                }
            }
            execute(new ModifyInsightVmArgsCommand(serverInstance, button.getSelection()));
        }
    });
    GridDataFactory.fillDefaults().span(2, 1).applyTo(button);

    initialize();
}

From source file:com.xse.eclipseui.dialog.MessageDialogHelper.java

License:Open Source License

/**
 * Convenience method to open a standard error dialog.
 *
 * @param title//w  w  w  .j a  v  a  2s. c  o  m
 *            the dialog's title, or <code>null</code> if none
 * @param message
 *            the message
 */
public static void openError(final String title, final String message) {
    Display.getDefault().syncExec(new Runnable() {
        @Override
        public void run() {
            MessageDialog.open(MessageDialog.ERROR, Display.getDefault().getActiveShell(), title, message,
                    SWT.NONE);
        }
    });
}

From source file:com.xse.eclipseui.logging.MessageHelper.java

License:Open Source License

public static void post(final String pluginId, final Severity severity, final String title,
        final String message, final Throwable t) {
    final Status status;
    int kind = MessageDialog.INFORMATION;

    switch (severity) {
    case INFORMATION:
        status = new Status(IStatus.INFO, pluginId, message, t);
        break;/*from w  w w. j a v a2  s .  c om*/
    case WARNING:
        status = new Status(IStatus.WARNING, pluginId, message, t);
        kind = MessageDialog.WARNING;
        break;
    case ERROR:
        status = new Status(IStatus.ERROR, pluginId, message, t);
        kind = MessageDialog.ERROR;
        break;
    default:
        status = null;
        break;
    }

    if (status != null) {
        Logger.log(status);
        final int kind2 = kind;
        Display.getDefault().syncExec(new Runnable() {
            @Override
            public void run() {
                MessageDialog.open(kind2, Display.getDefault().getActiveShell(), title, message, SWT.NONE);
            }
        });
    }
}

From source file:cu.uci.abos.core.util.MessageDialogUtil.java

License:Open Source License

public static void openError(Shell parent, String title, String message, DialogCallback callback) {
    open(MessageDialog.ERROR, parent, title, message, callback);
}