Example usage for org.eclipse.jface.dialogs MessageDialog openError

List of usage examples for org.eclipse.jface.dialogs MessageDialog openError

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog openError.

Prototype

public static void openError(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a standard error dialog.

Usage

From source file:com.android.sdkuilib.internal.repository.UpdaterData.java

License:Apache License

/**
 * Check if any error occurred during initialization.
 * If it did, display an error message.//from   w w  w. j  a v  a 2  s.  c om
 *
 * @return True if an error occurred, false if we should continue.
 */
public boolean checkIfInitFailed() {
    if (mAvdManagerInitError != null) {
        String example;
        if (SdkConstants.currentPlatform() == SdkConstants.PLATFORM_WINDOWS) {
            example = "%USERPROFILE%"; //$NON-NLS-1$
        } else {
            example = "~"; //$NON-NLS-1$
        }

        String error = String.format("The AVD manager normally uses the user's profile directory to store "
                + "AVD files. However it failed to find the default profile directory. " + "\n"
                + "To fix this, please set the environment variable ANDROID_SDK_HOME to "
                + "a valid path such as \"%s\".", example);

        // We may not have any UI. Only display a dialog if there's a window shell available.
        if (mWindowShell != null) {
            MessageDialog.openError(mWindowShell, "Android Virtual Devices Manager", error);
        } else {
            mSdkLog.error(null /* Throwable */, "%s", error); //$NON-NLS-1$
        }

        return true;
    }
    return false;
}

From source file:com.android.sdkuilib.internal.widgets.AvdSelector.java

License:Apache License

private void onDelete() {
    final AvdInfo avdInfo = getTableSelection();

    // get the current Display
    final Display display = mTable.getDisplay();

    // check if the AVD is running
    if (mAvdManager.isAvdRunning(avdInfo)) {
        display.asyncExec(new Runnable() {
            @Override/*from w ww  . java2 s  .c o m*/
            public void run() {
                Shell shell = display.getActiveShell();
                MessageDialog.openError(shell, "Delete Android Virtual Device", String.format(
                        "The Android Virtual Device '%1$s' is currently running in an emulator and cannot be deleted.",
                        avdInfo.getName()));
            }
        });
        return;
    }

    // Confirm you want to delete this AVD
    final boolean[] result = new boolean[1];
    display.syncExec(new Runnable() {
        @Override
        public void run() {
            Shell shell = display.getActiveShell();
            result[0] = MessageDialog.openQuestion(shell, "Delete Android Virtual Device", String.format(
                    "Please confirm that you want to delete the Android Virtual Device named '%s'. This operation cannot be reverted.",
                    avdInfo.getName()));
        }
    });

    if (result[0] == false) {
        return;
    }

    // log for this action.
    ILogger log = mSdkLog;
    if (log == null || log instanceof MessageBoxLog) {
        // If the current logger is a message box, we use our own (to make sure
        // to display errors right away and customize the title).
        log = new MessageBoxLog(String.format("Result of deleting AVD '%s':", avdInfo.getName()), display,
                false /*logErrorsOnly*/);
    }

    // delete the AVD
    boolean success = mAvdManager.deleteAvd(avdInfo, log);

    // display the result
    if (log instanceof MessageBoxLog) {
        ((MessageBoxLog) log).displayResult(success);
    }

    if (success) {
        refresh(false /*reload*/);
    }
}

From source file:com.android.sdkuilib.internal.widgets.MessageBoxLog.java

License:Apache License

/**
 * Displays the log if anything was captured.
 * <p/>/*from   w  ww  . j a va  2s. c  o  m*/
 * @param success Used only when the logger was constructed with <var>logErrorsOnly</var>==true.
 * In this case the dialog will only be shown either if success if false or some errors
 * where captured.
 */
@Override
public void displayResult(final boolean success) {
    if (logMessages.size() > 0) {
        final StringBuilder sb = new StringBuilder(mMessage + "\n\n");
        for (String msg : logMessages) {
            if (msg.length() > 0) {
                if (msg.charAt(0) != '\n') {
                    int n = sb.length();
                    if (n > 0 && sb.charAt(n - 1) != '\n') {
                        sb.append('\n');
                    }
                }
                sb.append(msg);
            }
        }

        // display the message
        // dialog box only run in ui thread..
        if (mDisplay != null && !mDisplay.isDisposed()) {
            mDisplay.asyncExec(new Runnable() {
                @Override
                public void run() {
                    // This is typically displayed at the end, so make sure the UI
                    // instances are not disposed.
                    Shell shell = null;
                    if (mDisplay != null && !mDisplay.isDisposed()) {
                        shell = mDisplay.getActiveShell();
                    }
                    if (shell == null || shell.isDisposed()) {
                        return;
                    }
                    // Use the success icon if the call indicates success.
                    // However just use the error icon if the logger was only recording errors.
                    if (success && !mLogErrorsOnly) {
                        MessageDialog.openInformation(shell, "Android Virtual Devices Manager", sb.toString());
                    } else {
                        MessageDialog.openError(shell, "Android Virtual Devices Manager", sb.toString());

                    }
                }
            });
        }
    }
}

From source file:com.android.uiautomator.actions.ScreenshotAction.java

License:Apache License

@Override
public void run() {
    if (!DebugBridge.isInitialized()) {
        MessageDialog.openError(mViewer.getShell(), "Error obtaining Device Screenshot",
                "Unable to connect to adb. Check if adb is installed correctly.");
        return;//from w  w w  . ja  va2 s . c  o m
    }

    final IDevice device = pickDevice();
    if (device == null) {
        return;
    }

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(mViewer.getShell());
    try {
        dialog.run(true, false, new IRunnableWithProgress() {
            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                UiAutomatorResult result = null;
                try {
                    result = UiAutomatorHelper.takeSnapshot(device, monitor, mCompressed);
                } catch (UiAutomatorException e) {
                    monitor.done();
                    showError(e.getMessage(), e);
                    return;
                }

                mViewer.setModel(result.model, result.uiHierarchy, result.screenshot);
                monitor.done();
            }
        });
    } catch (Exception e) {
        showError("Unexpected error while obtaining UI hierarchy", e);
    }
}

From source file:com.android.uiautomator.actions.ScreenshotAction.java

License:Apache License

private IDevice pickDevice() {
    List<IDevice> devices = DebugBridge.getDevices();
    if (devices.size() == 0) {
        MessageDialog.openError(mViewer.getShell(), "Error obtaining Device Screenshot",
                "No Android devices were detected by adb.");
        return null;
    } else if (devices.size() == 1) {
        return devices.get(0);
    } else {/*  ww  w  .  ja v  a 2  s  .  c om*/
        DevicePickerDialog dlg = new DevicePickerDialog(mViewer.getShell(), devices);
        if (dlg.open() != Window.OK) {
            return null;
        }
        return dlg.getSelectedDevice();
    }
}

From source file:com.antimatterstudios.esftp.actions.Selection.java

License:Open Source License

/**
 * Opens an error dialog with the specified message.
 * @param message the message to display.
 *///from w  w w . j a  v  a  2  s. co  m
void showError(String message) {
    MessageDialog.openError(m_shell, "Error Deploying", "Error while deploying file.\nCause:" + message);
}

From source file:com.antimatterstudios.esftp.ui.ConsoleDisplayMgr.java

License:Open Source License

private void showError(String msg) {
    Shell sh = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    MessageDialog.openError(sh, "Error", msg);
}

From source file:com.apicloud.authentication.splashHandlers.APICloudSplashHandler.java

License:Open Source License

private void handleButtonOKWidgetSelected() {
    String username = userNameText.getText().getText().toLowerCase();
    String password = passWordText.getText().getText();
    String ip = ipText.getText().getText();
    if ((username.length() > 0) && (password.length() > 0)) {
        if (checkIp(ip))
            fAuthenticated = login(username, password, ip.isEmpty() ? IP : ip, false, "0");
    } else {/* www .java  2s . co m*/
        setEnabled(true);
        MessageDialog.openError(getSplash(), Messages.ApicloudSplashHandler_VALIDATE_ERROR,
                Messages.ApicloudSplashHandler_USERNAME_OR_PASSWORD_VALIDATE_ERROR);
    }
}

From source file:com.apicloud.authentication.splashHandlers.APICloudSplashHandler.java

License:Open Source License

private boolean showErrorMessage(String title, String message) {
    setEnabled(true);/*w w  w .  j ava  2  s.com*/
    MessageDialog.openError(getSplash(), title, message);
    AuthenticActivator.getDefault().getLog()
            .log(new Status(IStatus.ERROR, AuthenticActivator.PLUGIN_ID, 0, title + message, null));
    return false;
}

From source file:com.apicloud.authentication.splashHandlers.APICloudSplashHandler.java

License:Open Source License

private void addSvnToView(final String ip, final String userName, final String cookie) {
    final Runnable r = new Runnable() {
        public void run() {
            try {
                String url = "http://" + ip + ":80/getSvnList?useDomain";
                String message = ConnectionUtil.sendPostRequest(url, ConnectionUtil.encodeGetSVNParam(userName),
                        cookie);/*  w  w w  .j  a  v  a2 s . c o m*/
                JSONObject json;
                json = new JSONObject(message);
                String status = json.getString("status");
                if (status.equals("0")) {
                    MessageDialog.openError(getSplash(), Messages.ApicloudSplashHandler_ERROR,
                            Messages.ApicloudSplashHandler_SVN_ERROR);

                } else {
                    JSONArray body = json.getJSONArray("body");
                    SVNProviderPlugin provider = SVNProviderPlugin.getPlugin();
                    if (provider == null) {
                        System.err.println("svn delete error");
                    }
                    for (ISVNRepositoryLocation location : provider.getRepositories()
                            .getKnownRepositories(new NullProgressMonitor())) {
                        try {
                            provider.getRepositories().disposeRepository(location);
                        } catch (SVNException e) {
                            e.printStackTrace();
                        }
                    }
                    for (int i = 0; i < body.length(); i++) {
                        SVNUtil.addSVNToView((String) body.get(i));
                    }
                }
            } catch (JSONException e1) {
                e1.printStackTrace();
            }
        }
    };

    StartupRunnable startupRunnable = new StartupRunnable() {

        public void runWithException() throws Throwable {
            r.run();

        }
    };
    getSplash().getDisplay().asyncExec(startupRunnable);

}