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.android.ide.eclipse.adt.AdtPlugin.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.)/*  w  ww .  ja va2s .  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 AdtPlugin#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 AdtPlugin#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 = AdtPlugin.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;
                    }

                    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;
                        }
                    }
                }
            });
        }

        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();
            if (disp == null) {
                return;
            }
            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) {
                            AdtPlugin.log(ignore, "Failed to execute command %s", cmdId);
                        }
                    }
                }
            });
        }

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

From source file:com.android.ide.eclipse.auidt.AdtPlugin.java

License:Open Source License

/**
 * Checks the location of the SDK is valid and if it is, grab the SDK API version
 * from the SDK./*from www.j ava  2 s  . com*/
 * @return false if the location is not correct.
 */
private boolean checkSdkLocationAndId() {
    String sdkLocation = AdtPrefs.getPrefs().getOsSdkFolder();
    if (sdkLocation == null || sdkLocation.length() == 0) {
        return false;
    }

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

        @Override
        public boolean handleError(Solution solution, String message) {
            displayMessage(solution, message, MessageDialog.ERROR);
            return false;
        }

        @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) {
                        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;
                    }

                    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;
                        }
                    }
                }
            });
        }

        private void openSdkManager() {
            // Windows only: open the standalone external SDK Manager since we know
            // that ADT on Windows is bound to be locking some SDK folders.
            if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_WINDOWS) {
                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();
            if (disp == null) {
                return;
            }
            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) {
                            AdtPlugin.log(ignore, "Failed to execute command %s", cmdId);
                        }
                    }
                }
            });
        }

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

From source file:com.aptana.ide.debug.internal.ui.InstallDebuggerPromptStatusHandler.java

License:Open Source License

/**
 * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object)
 *///from  www  . jav  a2s .  com
public Object handleStatus(IStatus status, Object source) throws CoreException {
    Shell shell = DebugUiPlugin.getActiveWorkbenchShell();
    String title = Messages.InstallDebuggerPromptStatusHandler_InstallDebuggerExtension;

    if ("install".equals(source)) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_AcceptExtensionInstallation_Quit);
        return null;
    } else if ("postinstall".equals(source)) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_Quit);
        return null;
    } else if ("nopdm".equals(source)) { //$NON-NLS-1$
        MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                title, null, Messages.InstallDebuggerPromptStatusHandler_PDMNotInstalled, MessageDialog.WARNING,
                new String[] { StringUtils.ellipsify(Messages.InstallDebuggerPromptStatusHandler_Download),
                        CoreStrings.CONTINUE, CoreStrings.CANCEL, CoreStrings.HELP },
                0);
        switch (md.open()) {
        case 0:
            WorkbenchHelper.launchBrowser("http://www.aptana.com/pro/pdm.php", "org.eclipse.ui.browser.ie"); //$NON-NLS-1$ //$NON-NLS-2$
            /* continue */
        case 1:
            return new Boolean(true);
        case 3:
            WorkbenchHelper.launchBrowser("http://www.aptana.com/docs/index.php/Installing_the_IE_debugger"); //$NON-NLS-1$
            return new Boolean(true);
        default:
            break;
        }
        return null;
    } else if (source instanceof String && ((String) source).startsWith("quit_")) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_BrowserIsRunning,
                        new String[] { ((String) source).substring(5) }));
        return null;
    } else if (source instanceof String && ((String) source).startsWith("installed_")) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstalled,
                        new String[] { ((String) source).substring(10) }));
        return null;
    } else if (source instanceof String && ((String) source).startsWith("warning_")) { //$NON-NLS-1$
        MessageDialog.openWarning(shell, title, ((String) source).substring(8));
        return null;
    } else if (source instanceof String && ((String) source).startsWith("failed_")) { //$NON-NLS-1$
        MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                title, null,
                MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstallFailed,
                        new Object[] { ((String) source).substring(7) }),
                MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL, CoreStrings.HELP }, 0);
        while (true) {
            switch (md.open()) {
            case IDialogConstants.OK_ID:
                return null;
            default:
                break;
            }
            WorkbenchHelper.launchBrowser(((String) source).indexOf("Internet Explorer") != -1 //$NON-NLS-1$
                    ? "http://www.aptana.com/docs/index.php/Installing_the_IE_debugger" //$NON-NLS-1$
                    : "http://www.aptana.com/docs/index.php/Installing_the_JavaScript_debugger"); //$NON-NLS-1$
        }
    }
    IPreferenceStore store = DebugUiPlugin.getDefault().getPreferenceStore();

    String pref = store.getString(IDebugUIConstants.PREF_INSTALL_DEBUGGER);
    if (pref != null) {
        if (pref.equals(MessageDialogWithToggle.ALWAYS)) {
            return new Boolean(true);
        }
    }
    String message = StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionNotInstalled,
            new String[] { (String) source });

    MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message,
            MessageDialog.INFORMATION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, CoreStrings.HELP }, 2, null,
            false);
    dialog.setPrefKey(IDebugUIConstants.PREF_INSTALL_DEBUGGER);
    dialog.setPrefStore(store);

    while (true) {
        switch (dialog.open()) {
        case IDialogConstants.YES_ID:
            return new Boolean(true);
        case IDialogConstants.NO_ID:
            return new Boolean(false);
        default:
            break;
        }
        WorkbenchHelper.launchBrowser(((String) source).indexOf("Internet Explorer") != -1 //$NON-NLS-1$
                ? "http://www.aptana.com/docs/index.php/Installing_the_IE_debugger" //$NON-NLS-1$
                : "http://www.aptana.com/docs/index.php/Installing_the_JavaScript_debugger"); //$NON-NLS-1$
    }
}

From source file:com.aptana.js.debug.ui.internal.InstallDebuggerPromptStatusHandler.java

License:Open Source License

/**
 * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object)
 *///from   ww  w  .j a  v a 2s  .  c  o  m
public Object handleStatus(IStatus status, Object source) throws CoreException {
    Shell shell = UIUtils.getActiveShell();
    String title = Messages.InstallDebuggerPromptStatusHandler_InstallDebuggerExtension;

    if ("install".equals(source)) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_AcceptExtensionInstallation_Quit);
        return null;
    } else if ("postinstall".equals(source)) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_Quit);
        return null;
    } else if ("nopdm".equals(source)) { //$NON-NLS-1$
        MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                title, null, Messages.InstallDebuggerPromptStatusHandler_PDMNotInstalled, MessageDialog.WARNING,
                new String[] { StringUtil.ellipsify(Messages.InstallDebuggerPromptStatusHandler_Download),
                        CoreStrings.CONTINUE, CoreStrings.CANCEL, CoreStrings.HELP },
                0);
        switch (md.open()) {
        case 0:
            WorkbenchBrowserUtil.launchExternalBrowser(URL_INSTALL_PDM, "org.eclipse.ui.browser.ie"); //$NON-NLS-1$
            return Boolean.TRUE;
        case 1:
            return Boolean.TRUE;
        case 3:
            WorkbenchBrowserUtil.launchExternalBrowser(URL_DOCS_INSTALL_IE_DEBUGGER);
            return Boolean.TRUE;
        default:
            break;
        }
        return null;
    } else if (source instanceof String && ((String) source).startsWith("quit_")) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title, MessageFormat.format(
                Messages.InstallDebuggerPromptStatusHandler_BrowserIsRunning, ((String) source).substring(5)));
        return null;
    } else if (source instanceof String && ((String) source).startsWith("installed_")) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstalled,
                        ((String) source).substring(10)));
        return null;
    } else if (source instanceof String && ((String) source).startsWith("warning_")) { //$NON-NLS-1$
        MessageDialog.openWarning(shell, title, ((String) source).substring(8));
        return null;
    } else if (source instanceof String && ((String) source).startsWith("failed_")) { //$NON-NLS-1$
        MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                title, null,
                MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstallFailed,
                        new Object[] { ((String) source).substring(7) }),
                MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL, CoreStrings.HELP }, 0);
        while (true) {
            switch (md.open()) {
            case IDialogConstants.OK_ID:
                return null;
            default:
                break;
            }
            String urlString = (((String) source).indexOf("Internet Explorer") != -1) //$NON-NLS-1$
                    ? URL_DOCS_INSTALL_IE_DEBUGGER
                    : URL_DOCS_INSTALL_DEBUGGER;
            WorkbenchBrowserUtil.launchExternalBrowser(urlString);
        }
    }
    IPreferenceStore store = JSDebugUIPlugin.getDefault().getPreferenceStore();

    String pref = store.getString(IJSDebugUIConstants.PREF_INSTALL_DEBUGGER);
    if (pref != null) {
        if (pref.equals(MessageDialogWithToggle.ALWAYS)) {
            return Boolean.TRUE;
        }
    }
    String message = MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionNotInstalled,
            (String) source);

    MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message,
            MessageDialog.INFORMATION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, CoreStrings.HELP }, 2, null,
            false);
    dialog.setPrefKey(IJSDebugUIConstants.PREF_INSTALL_DEBUGGER);
    dialog.setPrefStore(store);

    while (true) {
        switch (dialog.open()) {
        case IDialogConstants.YES_ID:
            return Boolean.TRUE;
        case IDialogConstants.NO_ID:
            return Boolean.FALSE;
        default:
            break;
        }
        String urlString = (((String) source).indexOf("Internet Explorer") != -1) //$NON-NLS-1$
                ? URL_DOCS_INSTALL_IE_DEBUGGER
                : URL_DOCS_INSTALL_DEBUGGER;
        WorkbenchBrowserUtil.launchExternalBrowser(urlString);
    }
}

From source file:com.aptana.portal.ui.browser.AbstractPortalBrowserEditor.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    try {//from  w ww  .j  av a2  s. com
        browserViewer = createBrowserViewer(parent);
        final Browser browserControl = (Browser) browserViewer.getBrowser();
        browser = new BrowserWrapper(browserControl);

        // Add a listener for new browser windows. If new ones are opened, close it and open in an external
        // browser
        browserControl.addOpenWindowListener(new OpenWindowListener() {
            public void open(WindowEvent event) {
                Browser newBrowser = event.browser;
                final BrowserViewer browserContainer = new BrowserViewer(browserControl.getShell(),
                        browserControl.getStyle());
                event.browser = browserContainer.getBrowser();

                // Close the new browser window that was opened by previous listener
                newBrowser.getShell().close();
                event.required = true; // avoid opening new windows.

                if (newBrowser != browserControl) {
                    LocationAdapter locationAdapter = new LocationAdapter() {

                        public void changing(LocationEvent event) {
                            final String url = event.location;
                            if (!StringUtil.isEmpty(url)) {
                                WorkbenchBrowserUtil.openURL(url);
                            }
                            // The location change listener has to be removed as it might
                            // be triggered again when we open new browser editor tab.
                            browserContainer.getBrowser().removeLocationListener(this);
                        }
                    };
                    browserContainer.getBrowser().addLocationListener(locationAdapter);
                }
            }
        });

        browser.setJavascriptEnabled(true);

        // Usually, we would just listen to a location change. However, since IE
        // does not
        // behave well with notifying us when hitting refresh (F5), we have to
        // do it on
        // a title change (which should work for all browsers)
        browser.addTitleListener(new PortalTitleListener());

        // Register a location listener anyway, just to make sure that the
        // functions are
        // removed when we have a location change.
        // The title-listener will place them back in when the TitleEvent is
        // fired.
        browser.addProgressListener(new ProgressAdapter() {
            public void completed(ProgressEvent event) {
                browser.addLocationListener(new LocationAdapter() {
                    public void changed(LocationEvent event) {
                        // browser.removeLocationListener(this);
                        refreshBrowserRegistration();

                    }
                });
            }
        });
        browser.setUrl(initialURL);
        // Register this browser to receive notifications from any
        // Browser-Notifier that was
        // added to do so through the browserInteractions extension point.
        BrowserNotifier.getInstance().registerBrowser(getSite().getId(), browser);
    } catch (Throwable e) {
        // Open a dialog pointing user at docs for workaround
        HyperlinkMessageDialog dialog = new HyperlinkMessageDialog(UIUtils.getActiveShell(),
                Messages.AbstractPortalBrowserEditor_ErrorTitle, null,
                Messages.AbstractPortalBrowserEditor_ErrorMsg, MessageDialog.ERROR,
                new String[] { IDialogConstants.OK_LABEL }, 0, null) {
            @Override
            protected void openLink(SelectionEvent e) {
                WorkbenchBrowserUtil.launchExternalBrowser(BROWSER_DOCS);
            }
        };
        dialog.open();
    }
}

From source file:com.aptana.portal.ui.dispatch.configurationProcessors.PythonInstallProcessor.java

License:Open Source License

/**
 * Do the PYTHON installation./*from   ww w  .  j  av a 2  s.c om*/
 * 
 * @param progressMonitor
 * @return A status indication of the process success or failure.
 */
protected IStatus install(IProgressMonitor progressMonitor) {
    if (downloadedPaths == null || downloadedPaths[0] == null) {
        String failureMessge = Messages.InstallProcessor_couldNotLocateInstaller;
        String err = NLS.bind(Messages.InstallProcessor_failedToInstall, PYTHON);
        displayMessageInUIThread(MessageDialog.ERROR, Messages.InstallProcessor_installationErrorTitle,
                err + ' ' + failureMessge);
        return new Status(IStatus.ERROR, PortalUIPlugin.PLUGIN_ID, err + ' ' + failureMessge);
    }
    SubMonitor subMonitor = SubMonitor.convert(progressMonitor, Messages.InstallProcessor_installerProgressInfo,
            IProgressMonitor.UNKNOWN);
    final Map<String, Object> installationAttributes = new HashMap<String, Object>();
    try {
        subMonitor.beginTask(NLS.bind(Messages.InstallProcessor_installingTaskName, PYTHON),
                IProgressMonitor.UNKNOWN);
        final String[] installDir = new String[1];
        Job installRubyDialog = new UIJob("Ruby installer options") //$NON-NLS-1$
        {
            @Override
            public IStatus runInUIThread(IProgressMonitor monitor) {
                PythonInstallerOptionsDialog dialog = new PythonInstallerOptionsDialog();
                if (dialog.open() == Window.OK) {
                    installationAttributes.putAll(dialog.getAttributes());
                    return Status.OK_STATUS;
                } else {
                    return Status.CANCEL_STATUS;
                }
            }
        };
        installRubyDialog.schedule();
        try {
            installRubyDialog.join();
        } catch (InterruptedException e) {
        }
        IStatus result = installRubyDialog.getResult();
        if (!result.isOK()) {
            return result;
        }

        IStatus status = installPYTHON(installationAttributes);
        if (!status.isOK()) {
            return status;
        }
        IdeLog.logInfo(PortalUIPlugin.getDefault(), MessageFormat.format(
                "Successfully installed PYTHON into {0}. PYTHON installation completed.", installDir[0])); //$NON-NLS-1$
        // note that we called the finalizeInstallation from the installPYTHON Job.
        return Status.OK_STATUS;
    } catch (Exception e) {
        IdeLog.logError(PortalUIPlugin.getDefault(), "Error while installing PYTHON", e); //$NON-NLS-1$
        return new Status(IStatus.ERROR, PortalUIPlugin.PLUGIN_ID,
                NLS.bind(Messages.InstallProcessor_errorWhileInstalling, PYTHON));
    } finally {
        subMonitor.done();
    }
}

From source file:com.aptana.portal.ui.dispatch.configurationProcessors.RubyInstallProcessor.java

License:Open Source License

/**
 * Install Ruby and DevKit./*from ww w  .  ja  v a2s.co  m*/
 * 
 * @param progressMonitor
 * @return
 */
protected IStatus install(IProgressMonitor progressMonitor) {
    if (downloadedPaths == null || downloadedPaths[0] == null) {
        String failureMessge = Messages.InstallProcessor_couldNotLocateInstaller;
        if (downloadedPaths != null && downloadedPaths[0] != null) {
            failureMessge = NLS.bind(Messages.InstallProcessor_couldNotLocatePackage, DEVKIT);
        }
        String err = NLS.bind(Messages.InstallProcessor_failedToInstall, RUBY);
        displayMessageInUIThread(MessageDialog.ERROR, Messages.InstallProcessor_installationErrorTitle,
                err + ' ' + failureMessge);
        return new Status(IStatus.ERROR, PortalUIPlugin.PLUGIN_ID, err + ' ' + failureMessge);
    }
    SubMonitor subMonitor = SubMonitor.convert(progressMonitor, Messages.InstallProcessor_installerProgressInfo,
            IProgressMonitor.UNKNOWN);
    try {
        subMonitor.beginTask(NLS.bind(Messages.InstallProcessor_installingTaskName, RUBY),
                IProgressMonitor.UNKNOWN);
        final String[] installDir = new String[1];
        Job installRubyDialog = new UIJob("Ruby installer options") //$NON-NLS-1$
        {
            @Override
            public IStatus runInUIThread(IProgressMonitor monitor) {
                RubyInstallerOptionsDialog dialog = new RubyInstallerOptionsDialog();
                if (dialog.open() == Window.OK) {
                    installDir[0] = dialog.getInstallDir();
                    return Status.OK_STATUS;
                } else {
                    return Status.CANCEL_STATUS;
                }
            }
        };
        installRubyDialog.schedule();
        try {
            installRubyDialog.join();
        } catch (InterruptedException e) {
        }
        IStatus result = installRubyDialog.getResult();
        if (!result.isOK()) {
            return result;
        }

        IStatus status = installRuby(installDir[0]);
        if (!status.isOK()) {
            return status;
        }
        IdeLog.logInfo(PortalUIPlugin.getDefault(), "Successfully installed Ruby into " + installDir[0]); //$NON-NLS-1$
        // Ruby was installed successfully. Now we need to extract DevKit into the Ruby dir and change its
        // configurations to match the installation location.

        // TODO - We need to fix the DevKit installation. The DevKit team changed their installation way recently...

        // status = installDevKit(installDir[0]);
        // if (!status.isOK())
        // {
        // displayMessageInUIThread(MessageDialog.ERROR, Messages.InstallProcessor_installationErrorTitle, status
        // .getMessage());
        // return status;
        // }
        finalizeInstallation(installDir[0]);
        // PortalUIPlugin.logInfo(
        //               "Successfully installed DevKit into " + installDir[0] + ". Ruby installation completed.", null); //$NON-NLS-1$ //$NON-NLS-2$
        return Status.OK_STATUS;
    } catch (Exception e) {
        IdeLog.logError(PortalUIPlugin.getDefault(), "Error while installing Ruby", e); //$NON-NLS-1$
        return new Status(IStatus.ERROR, PortalUIPlugin.PLUGIN_ID,
                NLS.bind(Messages.InstallProcessor_errorWhileInstalling, RUBY));
    } finally {
        subMonitor.done();
    }
}

From source file:com.aptana.portal.ui.dispatch.configurationProcessors.XAMPPInstallProcessor.java

License:Open Source License

/**
 * Do the XAMPP installation.//  w w  w . j a  v  a2  s  .c o  m
 * 
 * @param progressMonitor
 * @return A status indication of the process success or failure.
 */
protected IStatus install(IProgressMonitor progressMonitor) {
    if (downloadedPaths == null || downloadedPaths[0] == null) {
        String failureMessge = Messages.InstallProcessor_couldNotLocateInstaller;
        String err = NLS.bind(Messages.InstallProcessor_failedToInstall, XAMPP);
        displayMessageInUIThread(MessageDialog.ERROR, Messages.InstallProcessor_installationErrorTitle,
                err + ' ' + failureMessge);
        return new Status(IStatus.ERROR, PortalUIPlugin.PLUGIN_ID, err + ' ' + failureMessge);
    }
    SubMonitor subMonitor = SubMonitor.convert(progressMonitor, Messages.InstallProcessor_installerProgressInfo,
            IProgressMonitor.UNKNOWN);
    final Map<String, Object> installationAttributes = new HashMap<String, Object>();
    try {
        subMonitor.beginTask(NLS.bind(Messages.InstallProcessor_installingTaskName, XAMPP),
                IProgressMonitor.UNKNOWN);
        final String[] installDir = new String[1];
        Job installRubyDialog = new UIJob("Ruby installer options") //$NON-NLS-1$
        {
            @Override
            public IStatus runInUIThread(IProgressMonitor monitor) {
                XAMPPInstallerOptionsDialog dialog = new XAMPPInstallerOptionsDialog();
                if (dialog.open() == Window.OK) {
                    installationAttributes.putAll(dialog.getAttributes());
                    return Status.OK_STATUS;
                } else {
                    return Status.CANCEL_STATUS;
                }
            }
        };
        installRubyDialog.schedule();
        try {
            installRubyDialog.join();
        } catch (InterruptedException e) {
        }
        IStatus result = installRubyDialog.getResult();
        if (!result.isOK()) {
            return result;
        }

        IStatus status = installXAMPP(installationAttributes);
        if (!status.isOK()) {
            return status;
        }
        IdeLog.logInfo(PortalUIPlugin.getDefault(),
                "Successfully installed XAMPP into " + installDir[0] + ". XAMPP installation completed."); //$NON-NLS-1$ //$NON-NLS-2$
        // note that we called the finalizeInstallation from the installXAMPP Job.
        return Status.OK_STATUS;
    } catch (Exception e) {
        IdeLog.logError(PortalUIPlugin.getDefault(), "Error while installing XAMPP", e); //$NON-NLS-1$
        return new Status(IStatus.ERROR, PortalUIPlugin.PLUGIN_ID,
                NLS.bind(Messages.InstallProcessor_errorWhileInstalling, XAMPP));
    } finally {
        subMonitor.done();
    }
}

From source file:com.aptana.rcp.DelayedEventsProcessor.java

License:Open Source License

private void openFile(Display display, final String path) {
    display.asyncExec(new Runnable() {
        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) {
                    String msg = NLS.bind(IDEWorkbenchMessages.OpenDelayedFileAction_message_noWindow, path);
                    MessageDialog.open(MessageDialog.ERROR, window.getShell(),
                            IDEWorkbenchMessages.OpenDelayedFileAction_title, msg, SWT.SHEET);
                }// w w  w  .j  a v a  2  s .  c  o  m
                try {
                    IDE.openInternalEditorOnFileStore(page, fileStore);
                    Shell shell = window.getShell();
                    if (shell != null) {
                        if (shell.getMinimized())
                            shell.setMinimized(false);
                        shell.forceActive();
                    }
                } catch (PartInitException e) {
                    String msg = NLS.bind(IDEWorkbenchMessages.OpenDelayedFileAction_message_errorOnOpen,
                            fileStore.getName());
                    CoreException eLog = new PartInitException(e.getMessage());
                    IDEWorkbenchPlugin.log(msg, new Status(IStatus.ERROR, IDEApplication.PLUGIN_ID, msg, eLog));
                    MessageDialog.open(MessageDialog.ERROR, window.getShell(),
                            IDEWorkbenchMessages.OpenDelayedFileAction_title, msg, SWT.SHEET);
                }
            } else {
                String msg = NLS.bind(IDEWorkbenchMessages.OpenDelayedFileAction_message_fileNotFound, path);
                MessageDialog.open(MessageDialog.ERROR, window.getShell(),
                        IDEWorkbenchMessages.OpenDelayedFileAction_title, msg, SWT.SHEET);
            }
        }
    });
}

From source file:com.architexa.org.eclipse.gef.ui.palette.customize.PaletteCustomizerDialog.java

License:Open Source License

/**
 * This is the method that is called everytime the selection in the outline
 * (treeviewer) changes.  /*from   w  w  w.j av a 2s  . co m*/
 */
protected void handleOutlineSelectionChanged() {
    PaletteEntry entry = getSelectedPaletteEntry();

    if (activeEntry == entry) {
        return;
    }

    if (errorMessage != null) {
        MessageDialog dialog = new MessageDialog(getShell(), PaletteMessages.ERROR, null,
                PaletteMessages.ABORT_PAGE_FLIPPING_MESSAGE + "\n" + errorMessage, //$NON-NLS-1$
                MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
        dialog.open();
        treeviewer.addPostSelectionChangedListener(pageFlippingPreventer);
    } else {
        setActiveEntry(entry);
    }
    updateActions();
}