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.amitinside.mqtt.client.kura.dialog.ConnectionSettingsDialog.java

License:Apache License

public static void openDialogBox(final Shell shell, final IKuraMQTTClient mqttClient, final IEventBroker broker,
        final UISynchronize synchronize, final MWindow window) {
    final ConnectionSettingsDialog dialog = new ConnectionSettingsDialog(shell, broker, synchronize, window);

    retriveAllTheTestServers(window);/*from  ww  w  .ja  va 2  s . co m*/

    dialog.create();

    if (mqttClient != null) {
        dialog.setMqttServerAddress(mqttClient.getHost());
        dialog.setClientId(mqttClient.getClientId());
        ConnectionSettingsDialog.mqttClient = mqttClient;
    }

    if (dialog.open() == Window.OK) {
        if ("".equals(dialog.getMqttServerAddress()) || (dialog.getMqttServerAddress() == null)) {
            openError(shell, "Error in MQTT Server Address", "MQTT Server Address can't be empty");
            return;
        }

        if ("".equals(dialog.getClientId()) || (dialog.getClientId() == null)) {
            openError(shell, "Error in Client ID", "Client ID can't be empty");
            return;
        }

        if (mqttClient == null) {
            if (!("".equals(mqttServerUsername) || "".equals(mqttServerPassword))) {
                ConnectionSettingsDialog.mqttClient = new KuraMQTTClient.Builder().setHost(mqttServerAddress)
                        .setPort(mqttServerPort).setClientId(clientId).setUsername(mqttServerUsername)
                        .setPassword(mqttServerPassword).build();
            } else {
                ConnectionSettingsDialog.mqttClient = new KuraMQTTClient.Builder().setHost(mqttServerAddress)
                        .setPort(mqttServerPort).setClientId(clientId).build();
            }

        }

        synchronize.asyncExec(new Runnable() {
            @Override
            public void run() {
                boolean status = false;
                try {
                    status = ConnectionSettingsDialog.mqttClient.connect();
                } catch (final Exception e) {
                    MessageDialog.openError(shell, "Connection Problem",
                            "Something bad happened to the connection");
                    return;
                }

                if (status) {
                    broker.post(CONNECTED_EVENT_TOPIC,
                            new Object[] { mqttServerAddress, clientId, ConnectionSettingsDialog.mqttClient });
                } else {
                    broker.post(DISCONNECTED_EVENT_TOPIC, new Object[] { mqttServerAddress, clientId });
                }
            }
        });
    }

}

From source file:com.amzi.prolog.debug.core.internal.RemoteListener.java

License:Open Source License

public boolean p_debug_error() {
    long list;/*from  w w  w .j  a  va 2  s .  co m*/
    Properties errProps;
    String message, lineno, file;

    try {
        synchronized (ls) {
            list = ls.GetParm(1);
            errProps = Utils.prologListToProperties(ls, list, 100000);
        }
    } catch (LSException ex) {
        return false;
    }

    message = errProps.getProperty("message");
    message += "\nPredicate: " + errProps.getProperty("predicate");
    message += "\nError Code: " + errProps.getProperty("rc");
    file = errProps.getProperty("file");
    if (file != null)
        message += "\nFile: " + file;
    lineno = errProps.getProperty("line");
    if (lineno != null)
        message += "\nLine #: " + lineno;

    final String fmessage = message;

    // Display.getCurrent() is null! so use this instead
    Display.getDefault().asyncExec(new Runnable() {
        public void run() {
            MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", fmessage);
        }
    });

    return true;
}

From source file:com.amzi.prolog.debug.core.internal.RemoteListener.java

License:Open Source License

public void displayError(Exception ex) {
    //      if (terminating) return;

    String message, location;// w  w  w.  j  a  va 2  s  .  c  om

    if (ex instanceof LSException) {
        synchronized (ex) {
            LSException lex = (LSException) ex;
            if (lex.GetType() == LSException.READ) {
                message = "LogicServer Read Error\n";
                message += lex.getMessage();
                message += "\nline: " + lex.GetLineno();
                message += "\nfile: " + lex.GetReadFileName();
                location = lex.GetReadBuffer();
                message += "\nread buffer: " + location;
            } else {
                message = "LogicServer Exception\n";
                message += lex.getMessage();
                location = lex.GetCallStack();
            }
        }
    } else {
        message = ex.getClass().getName() + " Exception\n";
        message += ex.getMessage();
    }

    final String fmessage = message;

    // Display.getCurrent() is null! so use this instead
    Display.getDefault().asyncExec(new Runnable() {
        public void run() {
            MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", fmessage);
        }
    });
}

From source file:com.amzi.prolog.debug.core.internal.RemoteListener.java

License:Open Source License

public void displayError(String errText) {
    //      if (terminating) return;

    String message;//from  w w w.  j av  a  2s . c  o m

    message = errText;

    final String fmessage = message;

    // Display.getCurrent() is null! so use this instead
    Display.getDefault().asyncExec(new Runnable() {
        public void run() {
            MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", fmessage);
        }
    });
}

From source file:com.amzi.prolog.ui.actions.AboutActionDelegate.java

public void run(IAction action) {
    String edition, license, version, amziDir;

    LogicServer ls = new LogicServer();
    try {//from  w  ww  .ja va2 s . c o m
        synchronized (ls) {
            ls.Init("");

            /*//         InetAddress hostname[] = InetAddress.getAllByName( InetAddress.getLocalHost().getHostAddress() );
            //         String computer = hostname[0].getHostName();
                     String computer = "Computer Name: ";
                     try {
                        computer += InetAddress.getLocalHost().getHostName();
                     } catch (UnknownHostException ex) {
                        computer = "unknown";
                     } */

            amziDir = PrologCorePlugin.getAmziDir();
            ls.Load(amziDir + "abin" + System.getProperty("file.separator") + "acmp.xpl");
            version = "Version: " + ls.GetVersion();
            ls.Close();
        }

        license = "Open Source Edition   ";

        MessageDialog.openInformation(shell, "Amzi! Prolog + Logic Server",
                version + "\n" + "Running from AMZI_DIR=" + amziDir + "\n\n" + license);
    } catch (LSException ex) {
        // Always close the LogicServer
        try {
            ls.Close();
            System.gc();
        } catch (LSException ex2) {
        }
        MessageDialog.openError(shell, "Error",
                "AMZI_DIR is not set correctly or is not on your system PATH environment variable.");
    }

}

From source file:com.android.ddms.UIThread.java

License:Apache License

/**
 * Create SWT objects and drive the user interface event loop.
 * @param ddmsParentLocation location of the folder that contains ddms.
 *//*  w  w w. ja va2  s.c  om*/
public void runUI(String ddmsParentLocation) {
    Display.setAppName(APP_NAME);
    mDisplay = Display.getDefault();
    final Shell shell = new Shell(mDisplay, SWT.SHELL_TRIM);

    // create the image loaders for DDMS and DDMUILIB
    mDdmUiLibLoader = ImageLoader.getDdmUiLibLoader();

    shell.setImage(ImageLoader.getLoader(this.getClass()).loadImage(mDisplay, "ddms-128.png", //$NON-NLS-1$
            100, 50, null));

    Log.setLogOutput(new ILogOutput() {
        @Override
        public void printAndPromptLog(final LogLevel logLevel, final String tag, final String message) {
            Log.printLog(logLevel, tag, message);
            // dialog box only run in UI thread..
            mDisplay.asyncExec(new Runnable() {
                @Override
                public void run() {
                    Shell activeShell = mDisplay.getActiveShell();
                    if (logLevel == LogLevel.ERROR) {
                        MessageDialog.openError(activeShell, tag, message);
                    } else {
                        MessageDialog.openWarning(activeShell, tag, message);
                    }
                }
            });
        }

        @Override
        public void printLog(LogLevel logLevel, String tag, String message) {
            Log.printLog(logLevel, tag, message);
        }
    });

    // set the handler for hprof dump
    ClientData.setHprofDumpHandler(new HProfHandler(shell));
    ClientData.setMethodProfilingHandler(new MethodProfilingHandler(shell));

    // [try to] ensure ADB is running
    // in the new SDK, adb is in the platform-tools, but when run from the command line
    // in the Android source tree, then adb is next to ddms.
    String adbLocation;
    if (ddmsParentLocation != null && ddmsParentLocation.length() != 0) {
        // check if there's a platform-tools folder
        File platformTools = new File(new File(ddmsParentLocation).getParent(), "platform-tools"); //$NON-NLS-1$
        if (platformTools.isDirectory()) {
            adbLocation = platformTools.getAbsolutePath() + File.separator + SdkConstants.FN_ADB;
        } else {
            // we're in the Android source tree, then adb is in $ANDROID_HOST_OUT/bin/adb
            String androidOut = System.getenv("ANDROID_HOST_OUT");
            if (androidOut != null) {
                adbLocation = androidOut + File.separator + "bin" + File.separator + SdkConstants.FN_ADB;
            } else {
                adbLocation = SdkConstants.FN_ADB;
            }
        }
    } else {
        adbLocation = SdkConstants.FN_ADB;
    }

    AndroidDebugBridge.init(true /* debugger support */);
    AndroidDebugBridge.createBridge(adbLocation, true /* forceNewBridge */);

    // we need to listen to client change to be notified of client status (profiling) change
    AndroidDebugBridge.addClientChangeListener(this);

    shell.setText("Dalvik Debug Monitor");
    setConfirmClose(shell);
    createMenus(shell);
    createWidgets(shell);

    shell.pack();
    setSizeAndPosition(shell);
    shell.open();

    Log.d("ddms", "UI is up");

    while (!shell.isDisposed()) {
        if (!mDisplay.readAndDispatch())
            mDisplay.sleep();
    }
    if (useOldLogCatView()) {
        mLogPanel.stopLogCat(true);
    }

    mDevicePanel.dispose();
    for (TablePanel panel : mPanels) {
        if (panel != null) {
            panel.dispose();
        }
    }

    ImageLoader.dispose();

    mDisplay.dispose();
    Log.d("ddms", "UI is down");
}

From source file:com.android.ddms.UIThread.java

License:Apache License

public void displayError(final String msg) {
    try {/*from  w w w. j a  va  2  s . c  o  m*/
        mDisplay.syncExec(new Runnable() {
            @Override
            public void run() {
                MessageDialog.openError(mDisplay.getActiveShell(), "Error", msg);
            }
        });
    } catch (SWTException swte) {
        if (!mDisplay.isDisposed())
            throw swte;
    }
}

From source file:com.android.ddmuilib.DevicePanel.java

License:Apache License

public void toggleMethodProfiling() {
    if (mCurrentClient == null) {
        return;//from  w  ww. ja va2 s.c  o  m
    }

    try {
        toggleMethodProfiling(mCurrentClient);
    } catch (IOException e) {
        MessageDialog.openError(mTree.getShell(), "Method Profiling",
                "Unexpected I/O error while starting/stopping profiling: "
                        + Throwables.getRootCause(e).getMessage());
    }
}

From source file:com.android.ddmuilib.EmulatorControlPanel.java

License:Apache License

/**
 * Processes the result of a command sent to the console.
 * @param result the result of the command.
 *///w  ww  .  j a v a2  s.  co  m
private boolean processCommandResult(final String result) {
    if (result != EmulatorConsole.RESULT_OK) {
        try {
            mParent.getDisplay().asyncExec(new Runnable() {
                @Override
                public void run() {
                    if (mParent.isDisposed() == false) {
                        MessageDialog.openError(mParent.getShell(), "Emulator Console", result);
                    }
                }
            });
        } catch (SWTException e) {
            // we're quitting, just ignore
        }

        return false;
    }

    return true;
}

From source file:com.android.ddmuilib.handler.BaseFileHandler.java

License:Apache License

/**
 * Display an error message./*w ww.j a v a  2 s . co  m*/
 * <p/>This will call about to {@link Display} to run this in an async {@link Runnable} in the
 * UI Thread. This is safe to be called from a non-UI Thread.
 * @param format the string to display
 * @param args the string arguments
 */
protected void displayErrorInUiThread(final String format, final Object... args) {
    mParentShell.getDisplay().asyncExec(new Runnable() {
        @Override
        public void run() {
            MessageDialog.openError(mParentShell, getDialogTitle(), String.format(format, args));
        }
    });
}