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.easotope.client.core.ModalMessageWithViewChange.java

License:Open Source License

private synchronized void raiseErrorPrivate(final Shell shell, final EPartService partService,
        final MPerspective perspective, final MPart part, final String message) {
    list.add(list.size(), new ModalParameters(shell, partService, perspective, part, MessageDialog.ERROR,
            Messages.modalMessage_genericErrorTitle, message));

    if (list.size() == 1) {
        raise();/*from  w ww .j  a  v a  2s  . co m*/
    }
}

From source file:org.easotope.client.dialog.LoginDialog.java

License:Open Source License

@Override
public void processorDatabaseError(Processor processor, final String message) {
    shell.getDisplay().syncExec(new Runnable() {
        @Override/*from  ww  w  .  j  ava2s  .c  o m*/
        public void run() {
            try {
                String string = MessageFormat.format(Messages.dialog_login_databaseError, message);
                MessageDialog.open(MessageDialog.ERROR, shell, Messages.dialog_login_databaseErrorTitle, string,
                        SWT.NONE);
                System.exit(0);

            } catch (Exception e) {
                Log.getInstance().log(Level.INFO, this, "unexpected exception", e);
                PotentialGraphicsMethodsShared.reportErrorToUser(shell.getDisplay(), e);
            }
        }
    });
}

From source file:org.easotope.client.handler.QuitHandler.java

License:Open Source License

public static boolean quitLogic(Shell shell, MApplication application, EModelService modelService) {
    TreeSet<String> dirtyParts = new TreeSet<String>();

    for (MPart part : modelService.findElements(application, null, MPart.class, null)) {
        if (part.isDirty() && part.isVisible()) {
            dirtyParts.add(part.getLocalizedLabel());
        }//from  ww  w .  ja  v  a 2s.com
    }

    if (!dirtyParts.isEmpty()) {
        String list = "";

        for (String dirtyPart : dirtyParts) {
            list += list.isEmpty() ? "" : ", ";
            list += dirtyPart;
        }

        String message = MessageFormat.format(Messages.quitHandler_error, new Object[] { list });
        MessageDialog.open(MessageDialog.ERROR, shell, Messages.quitHandler_title, message, SWT.SHEET);
        return false;
    }

    return true;
}

From source file:org.easotope.client.LifeCycleManager.java

License:Open Source License

@PostContextCreate
public void postContextCreate() {
    if (display.getDeviceData().tracking) {
        Sleak.start(display);//from  w w w .j  a  v a 2s . c om
    }

    if (!Platform.isMacOs()) {
        String topDir = null;

        try {
            topDir = TopDir.getPathToTopDir();
        } catch (Exception e) {
            // ignore
        }

        Log.getInstance().openLogFile(topDir);
    }

    Log.getInstance().addLogTerminateListener(this);
    Log.getInstance().log(Level.INFO, "Java version " + System.getProperty("java.version"));
    Log.getInstance().log(Level.INFO, "Available processors " + Runtime.getRuntime().availableProcessors());
    Log.getInstance().log(Level.INFO, "Total memory " + Runtime.getRuntime().totalMemory());
    Log.getInstance().log(Level.INFO, "Max memory " + Runtime.getRuntime().maxMemory());
    Log.getInstance().log(Level.INFO, "Free memory " + Runtime.getRuntime().freeMemory());

    String dbType = ApplicationPreferences.get(Key.DbType);

    if (dbType == null || dbType.isEmpty()) {
        WizardDialog wizardDialog = new WizardDialog(null, new DatabaseWizard(true));
        if (wizardDialog.open() == Window.CANCEL) {
            // No workbench exists at this point so just bail.
            System.exit(0);
        }

    } else {
        ProcessorManager.ProcessorTypes configType = ProcessorManager.ProcessorTypes.valueOf(dbType);
        Processor processor = null;

        switch (configType) {
        case SERVER:
            String host = ApplicationPreferences.get(Key.Param1);
            String port = ApplicationPreferences.get(Key.Param2);
            processor = new ServerProcessor(host, Integer.parseInt(port));
            break;

        case FOLDER:
            String path = ApplicationPreferences.get(Key.Param1);
            processor = new FolderProcessor(path, false, false);
            break;
        }

        ProcessorManager.getInstance().installProcessor(processor, false);

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // do nothing
        }
    }

    while (LoginInfoCache.getInstance().getAuthenticationObjects() == null) {
        LoginDialog loginDialog = new LoginDialog();
        LoginDialog.Status status = loginDialog.open();

        switch (status) {
        case CANCEL:
            // No workbench exists at this point so just bail.
            System.exit(0);

        case OK:
            break;

        case NEW_DB:
            new WizardDialog(null, new DatabaseWizard(false)).open();
        }
    }

    LoginInfoCache.getInstance().addListener(this);
    ProcessorManager.getInstance().getProcessor().addListener(this);
    ProcessorManager.getInstance().getProcessor().addEventListener(this);

    int serverVersion = VersionInfo.getInstance().getServerVersion();
    int clientVersion = SystemProperty.getVersion();

    boolean versionsDoNotMatch = (serverVersion > clientVersion)
            ? VersionInfo.getInstance().isServerDeniesConnection()
            : (serverVersion < SystemProperty.getOldestCompatVersion()
                    || serverVersion > SystemProperty.getVersion());

    if (versionsDoNotMatch) {
        String message = Messages.lifecycle_versionMismatch;
        MessageDialog dialog = new MessageDialog(null, Messages.lifecycle_versionMismatchTitle, null, message,
                MessageDialog.ERROR,
                new String[] { Messages.lifecycle_downloadNewVersion, IDialogConstants.OK_LABEL }, 0);
        int button = dialog.open();

        if (button == 0) {
            String url = MessageFormat.format(Messages.lifecycle_bestClientForServerRedirect,
                    String.valueOf(serverVersion));
            Program.launch(url);
        }

        // No workbench exists at this point so just bail.
        System.exit(0);
    }

    if (LoginInfoCache.getInstance().getPreferences().getCheckForUpdates()) {
        boolean usingServer = ProcessorManager.getInstance().getProcessor() instanceof ServerProcessor;
        new DownloadVersionInfo(display, serverVersion, usingServer).start();
    }
}

From source file:org.easotope.client.LifeCycleManager.java

License:Open Source License

@Override
public void processorConnectionDropped(Processor processor) {
    display.syncExec(new Runnable() {
        @Override/*from w ww .  j  a  v a  2  s. c  o  m*/
        public void run() {
            try {
                MessageDialog.open(MessageDialog.ERROR, shell, Messages.lifecycle_lostConnectionTitle,
                        Messages.lifecycle_lostConnection, SWT.NONE);

                if (workbench != null) {
                    workbench.close();
                } else {
                    System.exit(0);
                }

            } catch (Exception e) {
                Log.getInstance().log(Level.INFO, this, "unexpected exception", e);
                PotentialGraphicsMethodsShared.reportErrorToUser(shell.getDisplay(), e);
            }
        }
    });
}

From source file:org.easotope.client.LifeCycleManager.java

License:Open Source License

@Override
public void processorDatabaseError(Processor processor, final String message) {
    display.syncExec(new Runnable() {
        @Override//from  ww w .ja v a 2  s  .  co  m
        public void run() {
            try {
                String string = MessageFormat.format(Messages.lifecycle_databaseError, message);
                MessageDialog.open(MessageDialog.ERROR, shell, Messages.lifecycle_databaseErrorTitle, string,
                        SWT.NONE);

                if (workbench != null) {
                    workbench.close();
                } else {
                    System.exit(0);
                }

            } catch (Exception e) {
                Log.getInstance().log(Level.INFO, this, "unexpected exception", e);
                PotentialGraphicsMethodsShared.reportErrorToUser(shell.getDisplay(), e);
            }
        }
    });
}

From source file:org.easotope.client.LifeCycleManager.java

License:Open Source License

@Override
public void logTerminate(String timestamp, String source, final String message, String stackTrace) {
    display.syncExec(new Runnable() {
        @Override/* ww  w.ja  v  a  2  s  . c o  m*/
        public void run() {
            try {
                String string = MessageFormat.format(Messages.lifecycle_terminalError, message);
                MessageDialog.open(MessageDialog.ERROR, shell, Messages.lifecycle_terminalErrorTitle, string,
                        SWT.NONE);

                if (workbench != null) {
                    workbench.close();
                } else {
                    System.exit(0);
                }

            } catch (Exception e) {
                Log.getInstance().log(Level.INFO, this, "unexpected exception", e);
                PotentialGraphicsMethodsShared.reportErrorToUser(shell.getDisplay(), e);
            }
        }
    });
}

From source file:org.eclipse.acceleo.ide.ui.launching.strategy.AcceleoPluginLaunchingStrategy.java

License:Open Source License

/**
 * {@inheritDoc}/*from www .java2s . com*/
 * 
 * @throws CoreException
 * @see org.eclipse.acceleo.ide.ui.launching.strategy.IAcceleoLaunchingStrategy#launch(org.eclipse.debug.core.ILaunchConfiguration,
 *      java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
 * @since 0.8
 */
@SuppressWarnings("deprecation")
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
        throws CoreException {
    final IProject project = getProject(configuration);
    if (project == null) {
        return;
    }

    AcceleoDebugger debugger = null;
    Profiler profiler = null;
    boolean profiling = configuration.getAttribute(IAcceleoLaunchConfigurationConstants.ATTR_COMPUTE_PROFILING,
            false);

    if ("debug".equals(mode)) { //$NON-NLS-1$
        debugger = new AcceleoDebugger(project);
        for (IDebugTarget target : launch.getDebugTargets()) {
            launch.removeDebugTarget(target);
        }
        launch.addDebugTarget(new AcceleoDebugTarget(launch, debugger));
        AcceleoEvaluationVisitor.setDebug(debugger);
        debugger.start();
    } else if (AcceleoPreferences.isProfilerEnabled() || profiling) {
        profiler = new Profiler();
        AcceleoEngineUtils.setProfiler(profiler);
        launch.addProcess(new AcceleoProcess(launch));
    } else {
        launch.addProcess(new AcceleoProcess(launch));
    }
    boolean traceability = computeTraceability(configuration);
    if (traceability) {
        switchTraceability(true);
    }
    try {
        final String model = getModelPath(configuration);
        final String target = getTargetPath(configuration);
        String message;
        if (model.length() == 0) {
            message = AcceleoUIMessages.getString("AcceleoLaunchDelegate.MissingModel", configuration //$NON-NLS-1$
                    .getName());
        } else if (target.length() == 0) {
            message = AcceleoUIMessages.getString("AcceleoLaunchDelegate.MissingTarget", configuration //$NON-NLS-1$
                    .getName());
        } else {
            message = null;
        }
        if (message != null) {
            AcceleoUIActivator.getDefault().getLog()
                    .log(new Status(IStatus.ERROR, AcceleoUIActivator.PLUGIN_ID, message));

            final String dialogMessage = message;
            Display.getDefault().asyncExec(new Runnable() {
                public void run() {
                    Shell parentShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                    String dialogTitle = AcceleoUIMessages
                            .getString("AcceleoPluginLaunchingStrategy.ErrorDialogTitle"); //$NON-NLS-1$
                    String[] dialogButtonLabels = new String[] { AcceleoUIMessages
                            .getString("AcceleoPluginLaunchingStrategy.ErrorDialogOkButton"), }; //$NON-NLS-1$
                    MessageDialog messageDialog = new MessageDialog(parentShell, dialogTitle, null,
                            dialogMessage, MessageDialog.ERROR, dialogButtonLabels, 0);
                    messageDialog.open();
                }
            });
        } else {
            IPath targetPath = new Path(target);
            IContainer container;
            if (targetPath.segmentCount() == 1) {
                container = ResourcesPlugin.getWorkspace().getRoot().getProject(targetPath.lastSegment());
            } else if (targetPath.segmentCount() > 1) {
                container = ResourcesPlugin.getWorkspace().getRoot().getFolder(targetPath);
            } else {
                container = null;
            }
            if (container instanceof IFolder && !container.exists()) {
                ((IFolder) container).create(true, true, monitor);
            } else if (container instanceof IProject && !container.exists()) {
                ((IProject) container).create(monitor);
                ((IProject) container).open(monitor);
                container.refreshLocal(IResource.DEPTH_INFINITE, monitor);
            }
            if (container != null) {
                final String qualifiedName = getMainType(configuration);
                File targetFolder = null;
                try {
                    if (container.isVirtual()) {
                        AcceleoUIActivator.log(
                                AcceleoUIMessages.getString("AcceleoPluginLaunchStrategy.VirtualFolder"), true); //$NON-NLS-1$
                    } else {
                        targetFolder = container.getLocation().toFile();
                    }
                } catch (NoSuchMethodError e) {
                    // Eclipse 3.5 does not have "isVirtual"
                    targetFolder = container.getLocation().toFile();
                }
                final List<String> args = getArguments(configuration);

                if (targetFolder != null) {
                    launch(project, qualifiedName, model, targetFolder, args, monitor);
                    container.refreshLocal(IResource.DEPTH_INFINITE, monitor);
                }

            }
        }
    } finally {
        if (traceability) {
            switchTraceability(false);
        }
        if ("debug".equals(mode)) { //$NON-NLS-1$
            AcceleoEvaluationVisitor.setDebug(null);
            if (debugger != null) {
                debugger.end();
            }
        } else if (profiling) {
            saveProfileModel(configuration, AcceleoEvaluationVisitor.getProfiler(), monitor);
            AcceleoEvaluationVisitor.setProfile(null);
        }
    }
}

From source file:org.eclipse.acute.AcutePlugin.java

License:Open Source License

public static void showError(String title, String message) {
    Display.getDefault().asyncExec(() -> {
        MessageDialog dialog = new MessageDialog(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, message,
                MessageDialog.ERROR, 0, IDialogConstants.OK_LABEL);
        dialog.setBlockOnOpen(false);/*from  www  .  java 2  s .  c  om*/
        dialog.open();
    });
}

From source file:org.eclipse.andmore.AndmoreAndroidPlugin.java

License:Open Source License

/**
 * Checks the location of the SDK in the prefs is valid.
 * If it is not, display a warning dialog to the user and try to display
 * some useful link to fix the situation (setup the preferences, perform an
 * update, etc.)//from w w w  . j a  v  a2 s  .  c o m
 *
 * @return True if the SDK location points to an SDK.
 *  If false, the user has already been presented with a modal dialog explaining that.
 */
public boolean checkSdkLocationAndId() {
    String sdkLocation = AdtPrefs.getPrefs().getOsSdkFolder();

    return checkSdkLocationAndId(sdkLocation, new CheckSdkErrorHandler() {
        private String mTitle = "Android SDK";

        /**
         * Handle an error, which is the case where the check did not find any SDK.
         * This returns false to {@link AndmoreAndroidPlugin#checkSdkLocationAndId()}.
         */
        @Override
        public boolean handleError(Solution solution, String message) {
            displayMessage(solution, message, MessageDialog.ERROR);
            return false;
        }

        /**
         * Handle an warning, which is the case where the check found an SDK
         * but it might need to be repaired or is missing an expected component.
         *
         * This returns true to {@link AndmoreAndroidPlugin#checkSdkLocationAndId()}.
         */
        @Override
        public boolean handleWarning(Solution solution, String message) {
            displayMessage(solution, message, MessageDialog.WARNING);
            return true;
        }

        private void displayMessage(final Solution solution, final String message, final int dialogImageType) {
            final Display disp = getDisplay();
            disp.asyncExec(new Runnable() {
                @Override
                public void run() {
                    Shell shell = disp.getActiveShell();
                    if (shell == null) {
                        shell = AndmoreAndroidPlugin.getShell();
                    }
                    if (shell == null) {
                        return;
                    }

                    String customLabel = null;
                    switch (solution) {
                    case OPEN_ANDROID_PREFS:
                        customLabel = "Open Preferences";
                        break;
                    case OPEN_P2_UPDATE:
                        customLabel = "Check for Updates";
                        break;
                    case OPEN_SDK_MANAGER:
                        customLabel = "Open SDK Manager";
                        break;
                    default:
                        break;
                    }

                    String btnLabels[] = new String[customLabel == null ? 1 : 2];
                    btnLabels[0] = customLabel;
                    btnLabels[btnLabels.length - 1] = IDialogConstants.CLOSE_LABEL;

                    MessageDialog dialog = new MessageDialog(shell, // parent
                            mTitle, null, // dialogTitleImage
                            message, dialogImageType, btnLabels, btnLabels.length - 1);
                    int index = dialog.open();

                    if (customLabel != null && index == 0) {
                        switch (solution) {
                        case OPEN_ANDROID_PREFS:
                            openAndroidPrefs();
                            break;
                        case OPEN_P2_UPDATE:
                            openP2Update();
                            break;
                        case OPEN_SDK_MANAGER:
                            openSdkManager();
                            break;
                        default:
                            break;
                        }
                    }
                }
            });
        }

        private void openSdkManager() {
            // Open the standalone external SDK Manager since we know
            // that ADT on Windows is bound to be locking some SDK folders.
            //
            // Also when this is invoked because SdkManagerAction.run() fails, this
            // test will fail and we'll fallback on using the internal one.
            if (SdkManagerAction.openExternalSdkManager()) {
                return;
            }

            // Otherwise open the regular SDK Manager bundled within ADT
            if (!SdkManagerAction.openAdtSdkManager()) {
                // We failed because the SDK location is undefined. In this case
                // let's open the preferences instead.
                openAndroidPrefs();
            }
        }

        private void openP2Update() {
            Display disp = getDisplay();

            disp.asyncExec(new Runnable() {
                @Override
                public void run() {
                    String cmdId = "org.eclipse.equinox.p2.ui.sdk.update"; //$NON-NLS-1$
                    IWorkbench wb = PlatformUI.getWorkbench();
                    if (wb == null) {
                        return;
                    }

                    ICommandService cs = (ICommandService) wb.getService(ICommandService.class);
                    IHandlerService is = (IHandlerService) wb.getService(IHandlerService.class);
                    if (cs == null || is == null) {
                        return;
                    }

                    Command cmd = cs.getCommand(cmdId);
                    if (cmd != null && cmd.isDefined()) {
                        try {
                            is.executeCommand(cmdId, null/*event*/);
                        } catch (Exception ignore) {
                            AndmoreAndroidPlugin.log(ignore, "Failed to execute command %s", cmdId);
                        }
                    }
                }
            });
        }

        private void openAndroidPrefs() {
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getDisplay().getActiveShell(),
                    "org.eclipse.andmore.preferences.main", //$NON-NLS-1$ preferencePageId
                    null, // displayedIds
                    null); // data
            dialog.open();
        }
    });
}