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.mindquarry.desktop.client.MindClient.java

License:Open Source License

private void createLock() {
    File f = new File(LOCK_FILE);

    try {//from   w  w  w .jav  a  2s  . c  o m
        if (!f.exists()) {
            f.createNewFile();
        }
    } catch (IOException e) {
        log.error("Cannot create lock file '" + f.getAbsolutePath() + "'", e); //$NON-NLS-1$
    }

    // this is the recommended way to implement locking, it doesn't leave
    // a lock file, not even if the app crashes:
    FileChannel fileChannel;
    try {
        fileChannel = (new FileOutputStream(f)).getChannel();
        fileLock = fileChannel.tryLock();
        if (fileLock == null) {
            MessageDialog dlg = new MessageDialog(getShell(),
                    I18N.getString("Mindquarry Client already running"), null,
                    I18N.getString("The Mindquarry Desktop Client seems to be running "
                            + "already. Only one instance of the Desktop Client can be "
                            + "running at a time. If you are sure that the Desktop Client "
                            + "isn't running, select 'Start anyway'."),
                    MessageDialog.ERROR,
                    new String[] { I18N.getString("Exit"), I18N.getString("Start anyway") }, 0);
            int result = dlg.open();
            if (result == 0) {
                System.exit(1);
            } else {
                log.warn("Starting despite lock file"); //$NON-NLS-1$
            }
        } else {
            log.info("Aquired lock: " + fileLock);
        }
    } catch (IOException e) {
        log.error("Cannot create lock on lock file '" + f.getAbsolutePath(), e);
    }
    // Note: no need to delete the lock, the JVM will care about that
}

From source file:com.mindquarry.desktop.client.MindClient.java

License:Open Source License

/**
 * Displays an error message and prompts the user to check their credentials
 * in the preferences dialog, or to cancel.
 * /* w ww.  j a v a  2  s .  co m*/
 * @param exception
 *            Contains the error message to be displayed.
 * @return True if and only if preferences dialog was shown to user which
 *         means that the credentials were potentially updated.
 */
public boolean handleNotAuthorizedException(NotAuthorizedException exception) {
    // create custom error message with the option to open the preferences
    // dialog
    MessageDialog messageDialog = new MessageDialog(getShell(), I18N.getString("Error"), //$NON-NLS-1$
            null, (exception.getLocalizedMessage() + "\n\n" //$NON-NLS-1$
                    + I18N.getString(
                            "Please check your username and password settings in the preferences dialog.")), //$NON-NLS-1$
            MessageDialog.ERROR, new String[] { I18N.getString("Go to preferences"), //$NON-NLS-1$
                    I18N.getString("Cancel") //$NON-NLS-1$
            }, 0);

    int buttonClicked = messageDialog.open();
    switch (buttonClicked) {
    case 0: // go to preferences
        showPreferenceDialog(true);
        return true;

    case 1: // cancel
        displayNotConnected();
        return false;
    }
    return false;
}

From source file:com.mindquarry.desktop.client.MindClient.java

License:Open Source License

/**
 * Displays an error message and prompts the user to check their server
 * settings in the preferences dialog, or to cancel.
 * /*from   ww w  .  j a  v  a 2  s  . c om*/
 * @param exception
 *            Contains the unknown host.
 * @return True if and only if preferences dialog was shown to user which
 *         means that the server details were potentially updated.
 */
public boolean handleUnknownHostException(UnknownHostException exception) {
    // create custom error message with the option to open the preferences
    // dialog
    MessageDialog messageDialog = new MessageDialog(getShell(), I18N.getString("Error"), //$NON-NLS-1$
            null, (I18N.get("Unknown server: \"{0}\"", exception.getLocalizedMessage()) //$NON-NLS-1$
                    + "\n\n" //$NON-NLS-1$
                    + I18N.getString("Please check your Mindquarry server URL in the preferences dialog.")), //$NON-NLS-1$
            MessageDialog.ERROR, new String[] { I18N.getString("Go to preferences"), //$NON-NLS-1$
                    I18N.getString("Cancel") //$NON-NLS-1$
            }, 0);

    int buttonClicked = messageDialog.open();
    switch (buttonClicked) {
    case 0: // go to preferences
        showPreferenceDialog(true);
        return true;

    case 1: // cancel
        displayNotConnected();
        return false;
    }
    return false;
}

From source file:com.mindquarry.desktop.client.MindClient.java

License:Open Source License

/**
 * Displays an error message and prompts the user to check their credentials
 * in the preferences dialog, or to cancel.
 * /*w  ww .j  a va2 s.c o m*/
 * @param exception
 *            Contains the error message to be displayed.
 * @return True if and only if preferences dialog was shown to user which
 *         means that the credentials were potentially updated.
 */
public boolean handleMalformedURLException(MalformedURLException exception) {
    // create custom error message with the option to open the preferences
    // dialog
    MessageDialog messageDialog = new MessageDialog(getShell(), I18N.getString("Error"), //$NON-NLS-1$
            null,
            I18N.get(
                    "Invalid server URL given: {0}\n\nPlease check your server settings in the preferences dialog.",
                    exception.getLocalizedMessage()),
            MessageDialog.ERROR, new String[] { I18N.getString("Go to preferences"), //$NON-NLS-1$
                    I18N.getString("Cancel") //$NON-NLS-1$
            }, 0);

    int buttonClicked = messageDialog.open();
    switch (buttonClicked) {
    case 0: // go to preferences
        showPreferenceDialog(true);
        return true;

    case 1: // cancel
        displayNotConnected();
        return false;
    }
    return false;
}

From source file:com.mobilesorcery.sdk.ui.MosyncUIPlugin.java

License:Open Source License

protected void checkConfig(final IWorkbench wb) {
    if (!MoSyncTool.getDefault().isValid()) {
        wb.getDisplay().syncExec(new Runnable() {
            public void run() {
                MessageDialog dialog = new MessageDialog(wb.getModalDialogShellProvider().getShell(),
                        "Fatal error", null,
                        MessageFormat.format(
                                "The environment variable MOSYNCDIR has not been properly set, or some other serious error has occurred. (Reason: {0})\n\nMoSync will not work properly. Press Ok to quit, or Cancel to continue anyway.",
                                MoSyncTool.getDefault().validate()),
                        MessageDialog.ERROR,
                        new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
                if (dialog.open() == IDialogConstants.OK_ID) {
                    wb.close();//from w w w.j a v  a 2  s.  c o m
                }
            }
        });
    }
}

From source file:com.mountainminds.eclemma.internal.ui.launching.NoInstrumentedClassesHandler.java

License:Open Source License

public Object handleStatus(IStatus status, final Object source) throws CoreException {

    final Shell parent = EclEmmaUIPlugin.getInstance().getShell();
    String title = UIMessages.NoInstrumentedClassesError_title;
    String message = UIMessages.NoInstrumentedClassesError_message;

    MessageDialog d = new MessageDialog(parent, title, null, message, MessageDialog.ERROR,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
    if (d.open() == 0) {
        parent.getDisplay().asyncExec(new Runnable() {
            public void run() {
                DebugUITools.openLaunchConfigurationDialogOnGroup(parent, new StructuredSelection(source),
                        EclEmmaUIPlugin.ID_COVERAGE_LAUNCH_GROUP);
            }/*from w w w. j a v  a2 s.co  m*/
        });
    }
    return Boolean.FALSE;
}

From source file:com.nokia.carbide.cpp.internal.project.ui.editors.images.MultiImageEditorContext.java

License:Open Source License

/**
 * Save changes to the multi-image source.
 * <p>/* ww w  .  j av a 2s.c  o  m*/
 * If the context was initialized with a null IOperationHistory,
 * the incoming IMultiImageSource is directly modified.  Otherwise,
 * the change is executed and added as an operation to that history. 
 */
public void doSave() {
    if (sourceDisposition == SourceDisposition.FROM_VIEW) {
        // modify through the parent editor's operation history
        if (editorHistory != null) {
            // make the save operation for the parent editor
            IUndoableOperation operation = getEditingOperation();
            try {
                operation.addContext(editorUndoContext);
                editorHistory.execute(operation, null, null);
            } catch (ExecutionException e) {
                ProjectUIPlugin.log(e);
            }
        } else {
            ownedMultiImageSource.set(multiImageSource);
        }
    } else {
        // in this mode, we directly update the view
        while (true) {
            try {
                ownedMultiImageSource.set(multiImageSource);
                view.commit();
                break;
            } catch (IllegalStateException e) {
                // rollback or overwrite?
                ProjectUIPlugin.log(e);
                MessageDialog dialog = new MessageDialog((Shell) editorContext.getAdapter(Shell.class),
                        Messages.getString("MultiImageEditorContext.ConflictingChangesTitle"), //$NON-NLS-1$
                        MessageDialog.getImage(MessageDialog.DLG_IMG_MESSAGE_ERROR),
                        MessageFormat.format(
                                Messages.getString("MultiImageEditorContext.ConflictingChangesMessage"), //$NON-NLS-1$
                                new Object[] { ((IOwnedModel) view.getModel()).getPath() }),
                        MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
                dialog.open();
                view.revert();
            }
        }

        try {
            getMultiImageSourceWorkaround();

            // redraw entire UI
            this.page.dispose();
            createControl(this.parent);
            this.page.setVisible(true);
        } catch (PartInitException e) {
            // just fail -- this is a workaround, after all 
            ProjectUIPlugin.log(e);
        }
    }
}

From source file:com.nokia.carbide.cpp.sysdoc.internal.hover.uitlis.DialogHelper.java

License:Open Source License

public static void displayErrorDialog(final String msg) {
    displayErrorDialog(msg, "Developer Library Hover Help Error", MessageDialog.ERROR);
}

From source file:com.nokia.carbide.search.system.internal.ui.text.ReplaceDialog2.java

License:Open Source License

private int askForSkip(final IFileStore file) {

    String message = Messages.format(SearchMessages.ReadOnlyDialog_message, getFullPath(file).toString());
    String[] buttonLabels = null;
    boolean showSkip = countResources() > 1;
    if (showSkip) {
        String skipLabel = SearchMessages.ReadOnlyDialog_skipFile;
        String skipAllLabel = SearchMessages.ReadOnlyDialog_skipAll;
        buttonLabels = new String[] { skipLabel, skipAllLabel, IDialogConstants.CANCEL_LABEL };
    } else {// ww w . jav a2  s . c o m
        buttonLabels = new String[] { IDialogConstants.CANCEL_LABEL };

    }

    MessageDialog msd = new MessageDialog(getShell(), getShell().getText(), null, message, MessageDialog.ERROR,
            buttonLabels, 0);
    int rc = msd.open();
    switch (rc) {
    case 0:
        return showSkip ? SKIP_FILE : CANCEL;
    case 1:
        return SKIP_ALL;
    default:
        return CANCEL;
    }
}

From source file:com.nokia.s60tools.memspy.ui.UiUtils.java

License:Open Source License

/**
 * Advises used to install MemSpy launcher component and provides necessary action alternatives.
 * @param errorMessage error message//from  w w  w .j  a  v  a2  s . c  o m
 */
private static void adviceUserToInstallLauncherComponent(final String errorMessage) {

    MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(),
            IMemSpyTraceListener.ERROR_MEMSPY, null, errorMessage, MessageDialog.ERROR,
            new String[] { "Install RnD-signed MemSpy Launcher", "Open sis-file's directory in Explorer",
                    "Don't install" },
            1);
    dialog.open();

    String launcherFolder = MemSpyPlugin.getDefault().getMemspyLauncherBinDir();
    String launcherLocation = launcherFolder + File.separatorChar
            + MEM_SPY_LAUNCHER_S60_50_RN_D_SIGNED_SIS_FILE_NAME;

    // if user wants to install launcher:
    if (dialog.getReturnCode() == 0) {
        // find program for xls-filetype
        Program p = Program.findProgram(".sis");
        // if found, launch it.
        if (p != null) {
            // Check that found program was Nokia PC Suite.
            p.execute(launcherLocation);
        } else {
            Status status = new Status(IStatus.ERROR, MemSpyPlugin.PLUGIN_ID, 0,
                    "Unable to locate PC suite or other suitable software for installing .sis -file from computer. You can try installing MemSpy launcher manually from:\n"
                            + launcherLocation,
                    null);
            ErrorDialog.openError(Display.getCurrent().getActiveShell(), "MemSpy Error", null, status);
        }

    }

    // Open directory in explorer
    else if (dialog.getReturnCode() == 1) {
        try {
            String directory = Platform.getConfigurationLocation().getURL().getFile();
            directory = directory.substring(1);
            Runtime.getRuntime().exec("explorer " + launcherFolder);
        } catch (IOException e) {
            Status status = new Status(IStatus.ERROR, MemSpyPlugin.PLUGIN_ID, 0, "Unable to open Explorer",
                    null);
            ErrorDialog.openError(Display.getCurrent().getActiveShell(), IMemSpyTraceListener.ERROR_MEMSPY,
                    null, status);
            e.printStackTrace();
        }
    }

}