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

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

Introduction

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

Prototype

public void setBlockOnOpen(boolean shouldBlock) 

Source Link

Document

Sets whether the open method should block until the window closes.

Usage

From source file:org.eclipse.gyrex.admin.ui.internal.widgets.NonBlockingMessageDialogs.java

License:Open Source License

private static void open(final int kind, final Shell parent, final String title, final String message,
        final DialogCallback callback) {
    final String[] buttonLabels = getButtonLabels(kind);
    final MessageDialog dialog = new MessageDialog(parent, title, null, message, kind, buttonLabels, 0) {
        /** serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override//  ww w .j av a 2  s . c om
        public boolean close() {
            final boolean result = super.close();
            if (callback != null) {
                callback.dialogClosed(getReturnCode());
            }
            return result;
        }

        @Override
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }
    };
    dialog.setBlockOnOpen(false);
    dialog.open();
}

From source file:org.eclipse.jdt.internal.debug.ui.actions.TerminateEvaluationAction.java

License:Open Source License

public void run(IAction action) {
    if (fThread == null) {
        return;/* w ww.j  av  a  2 s.c  o m*/
    }
    DebugPlugin.getDefault().addDebugEventListener(this);
    Thread timerThread = new Thread(new Runnable() {
        public void run() {
            fTerminated = false;
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                return;
            }
            if (!fTerminated) {
                fTerminated = true;
                final Display display = JDIDebugUIPlugin.getStandardDisplay();
                display.asyncExec(new Runnable() {
                    public void run() {
                        MessageDialog dialog = new MessageDialog(display.getActiveShell(),
                                ActionMessages.TerminateEvaluationActionTerminate_Evaluation_1, null,
                                ActionMessages.TerminateEvaluationActionAttempts_to_terminate_an_evaluation_can_only_stop_a_series_of_statements__The_currently_executing_statement__such_as_a_method_invocation__cannot_be_interrupted__2,
                                MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0);
                        dialog.setBlockOnOpen(false);
                        dialog.open();
                    }
                });
            }
        }
    });
    timerThread.setDaemon(true);
    timerThread.start();
    try {
        fThread.terminateEvaluation();
    } catch (DebugException exception) {
        JDIDebugUIPlugin.statusDialog(exception.getStatus());
    }
}

From source file:org.eclipse.rap.examples.pages.MessageDialogUtil.java

License:Open Source License

private static void open(int kind, Shell parent, String title, String message, final DialogCallback callback) {
    String[] buttonLabels = getButtonLabels(kind);
    MessageDialog dialog = new MessageDialog(parent, title, null, message, kind, buttonLabels, 0) {
        @Override/* w  w w.  j  a  va2  s . c  om*/
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }

        @Override
        public boolean close() {
            boolean result = super.close();
            if (callback != null) {
                callback.dialogClosed(getReturnCode());
            }
            return result;
        }
    };
    dialog.setBlockOnOpen(false);
    dialog.open();
}

From source file:org.eclipse.wst.common.frameworks.internal.ui.SaveHandlerUI.java

License:Open Source License

protected boolean promptUserToSaveReadOnly(IFile aFile) {

    String[] buttonStrings = { WTPCommonPlugin.getResourceString("Yes_UI_"), //$NON-NLS-1$
            WTPCommonPlugin.getResourceString("Yes_To_All_UI_"), WTPCommonPlugin.getResourceString("No_UI_") }; //$NON-NLS-2$ = "No" //$NON-NLS-1$ = "Yes To All"  = "Yes"
    String title = WTPCommonPlugin.getResourceString("Saving_Read-Only_File_UI_"); //$NON-NLS-1$ = "Saving Read-Only File"
    String message = WTPCommonPlugin.getResourceString("2concat_INFO_", (new Object[] { aFile.getFullPath() })); //$NON-NLS-1$ = "The file {0} is read-only and cannot be saved.  Would you like to make it editable and save anyway?"

    final MessageDialog dialog = new MessageDialog(getParentShellForDialog(), title, null, // accept
            // the
            // default
            // window
            // icon
            message, MessageDialog.QUESTION, buttonStrings, 0); // Yes is the default

    final int[] ret = new int[1];
    getDisplay().syncExec(new Runnable() {
        public void run() {
            dialog.setBlockOnOpen(true);
            ret[0] = dialog.open();/*w ww.ja  v a 2s.com*/
        }
    });

    switch (ret[0]) {
    case 0: {
        return true;
    }
    case 1: {
        isYesToAll = true;
        return true;
    }
    case 2: {
        return false;
    }
    }
    return false;
}

From source file:org.jboss.ide.eclipse.as.classpath.ui.ClasspathUIPlugin.java

License:Open Source License

public static void alert(String string) {
    MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            Messages.ClasspathUIPlugin_ALERT, Display.getDefault().getSystemImage(SWT.ICON_INFORMATION), string,
            MessageDialog.INFORMATION, new String[] { Messages.ClasspathUIPlugin_OK, }, 0);

    dialog.setBlockOnOpen(true);
    dialog.open();//  w  ww .j  a  v a2  s.  c  o  m
}

From source file:org.jboss.ide.eclipse.as.classpath.ui.ClasspathUIPlugin.java

License:Open Source License

public static void error(String string) {
    MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            Messages.ClasspathUIPlugin_ERROR, Display.getDefault().getSystemImage(SWT.ICON_ERROR), string,
            MessageDialog.ERROR, new String[] { Messages.ClasspathUIPlugin_OK, }, 0);

    dialog.setBlockOnOpen(true);
    dialog.open();/*  w w  w  .j av a2s  .c  o m*/
}

From source file:org.jboss.ide.eclipse.as.classpath.ui.ClasspathUIPlugin.java

License:Open Source License

public static void warn(String string) {
    MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            Messages.ClasspathUIPlugin_WARNING, Display.getDefault().getSystemImage(SWT.ICON_WARNING), string,
            MessageDialog.WARNING, new String[] { Messages.ClasspathUIPlugin_OK, }, 0);

    dialog.setBlockOnOpen(true);
    dialog.open();/*from   w w  w  .j a  v a  2s  .  c o m*/
}

From source file:org.libreoffice.ide.eclipse.core.internal.model.SDK.java

License:LGPL

/**
 * {@inheritDoc}/*from   w  ww  .j a v a  2  s . co m*/
 */
@Override
public Process runToolWithEnv(IProject pProject, IOOo pOOo, String pShellCommand, String[] pEnv,
        IProgressMonitor pMonitor) {

    Process process = null;

    try {
        if (null != pOOo) {

            // Get the environment variables and copy them. Needs Java 1.5
            String[] sysEnv = SystemHelper.getSystemEnvironement();

            String[] vars = mergeVariables(sysEnv, pEnv);

            vars = updateEnvironment(vars, pOOo);

            // Run only if the OS and ARCH are valid for the SDK
            if (null != vars) {
                File projectFile = pProject.getLocation().toFile();
                process = SystemHelper.runTool(pShellCommand, vars, projectFile);
            }
        }

    } catch (IOException e) {
        // Error while launching the process

        MessageDialog dialog = new MessageDialog(
                OOEclipsePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
                Messages.getString("SDK.PluginError"), //$NON-NLS-1$
                null, Messages.getString("SDK.ProcessError"), //$NON-NLS-1$
                MessageDialog.ERROR, new String[] { Messages.getString("SDK.Ok") }, 0); //$NON-NLS-1$
        dialog.setBlockOnOpen(true);
        dialog.create();
        dialog.open();

    } catch (SecurityException e) {
        // SubProcess creation unauthorized

        MessageDialog dialog = new MessageDialog(
                OOEclipsePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
                Messages.getString("SDK.PluginError"), //$NON-NLS-1$
                null, Messages.getString("SDK.ProcessError"), //$NON-NLS-1$
                MessageDialog.ERROR, new String[] { Messages.getString("SDK.Ok") }, 0); //$NON-NLS-1$
        dialog.setBlockOnOpen(true);
        dialog.create();
        dialog.open();
    } catch (Exception e) {
        PluginLogger.error(e.getMessage(), null);
    }

    return process;
}

From source file:org.openoffice.ide.eclipse.core.internal.model.SDK.java

License:LGPL

/**
 * {@inheritDoc}/*from  www. j  av  a 2 s . c om*/
 */
public Process runToolWithEnv(IProject pProject, IOOo pOOo, String pShellCommand, String[] pEnv,
        IProgressMonitor pMonitor) {

    Process process = null;

    try {
        if (null != pOOo) {

            // Get the environment variables and copy them. Needs Java 1.5
            String[] sysEnv = SystemHelper.getSystemEnvironement();

            String[] vars = mergeVariables(sysEnv, pEnv);

            vars = updateEnvironment(vars, pOOo);

            // Run only if the OS and ARCH are valid for the SDK
            if (null != vars) {
                File projectFile = pProject.getLocation().toFile();
                process = SystemHelper.runTool(pShellCommand, vars, projectFile);
            }
        }

    } catch (IOException e) {
        // Error while launching the process 

        MessageDialog dialog = new MessageDialog(
                OOEclipsePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
                Messages.getString("SDK.PluginError"), //$NON-NLS-1$
                null, Messages.getString("SDK.ProcessError"), //$NON-NLS-1$
                MessageDialog.ERROR, new String[] { Messages.getString("SDK.Ok") }, 0); //$NON-NLS-1$
        dialog.setBlockOnOpen(true);
        dialog.create();
        dialog.open();

    } catch (SecurityException e) {
        // SubProcess creation unauthorized

        MessageDialog dialog = new MessageDialog(
                OOEclipsePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
                Messages.getString("SDK.PluginError"), //$NON-NLS-1$
                null, Messages.getString("SDK.ProcessError"), //$NON-NLS-1$
                MessageDialog.ERROR, new String[] { Messages.getString("SDK.Ok") }, 0); //$NON-NLS-1$
        dialog.setBlockOnOpen(true);
        dialog.create();
        dialog.open();
    } catch (Exception e) {
        PluginLogger.error(e.getMessage(), null);
    }

    return process;
}

From source file:pl.robakowski.repository.Repository.java

License:Open Source License

@Override
public List<JSONObject> getNextResults(final IProgressMonitor monitor) {
    moreResults = false;/*from   w ww.  j ava2 s.c  o m*/
    List<JSONObject> list = new ArrayList<JSONObject>(30);
    if (!checkRuntime()) {
        sync.asyncExec(new Runnable() {
            @Override
            public void run() {
                MessageDialog dialog = new MessageDialog(shell, "Wrong paths", null,
                        "Invalid path to PHP or composer.phar", MessageDialog.ERROR, new String[] { "OK" }, 0);
                dialog.setBlockOnOpen(true);
                dialog.open();
                Map<String, String> params = new HashMap<String, String>();
                params.put("preferencePageId", "pl.robakowski.composer.plugin.page1");
                ParameterizedCommand command = commandService.createCommand("org.eclipse.ui.window.preferences",
                        params);
                handlerService.executeHandler(command);
            }
        });
        return list;
    }

    writeJson(json);

    try {
        final Process exec = new ProcessBuilder().command(phpPath, composerPath, "search", query).start();
        Thread killer = new Thread() {

            private boolean terminated(Process exec) {
                try {
                    exec.exitValue();
                    return true;
                } catch (IllegalThreadStateException e) {
                    return false;
                }
            }

            @Override
            public void run() {
                while (!terminated(exec)) {
                    if (monitor.isCanceled()) {
                        exec.destroy();
                    }
                    try {
                        Thread.sleep(50);
                    } catch (InterruptedException e) {
                    }
                }
            };
        };
        killer.start();
        BufferedReader reader = new BufferedReader(new InputStreamReader(exec.getInputStream()));
        String line;
        while ((line = reader.readLine()) != null) {
            int space = line.indexOf(' ');
            String name = line.substring(0, space);
            String repository = line.substring(space + 1);
            JSONObject obj = new JSONObject();
            obj.put("name", name);
            obj.put("description", repository);
            list.add(obj);
        }
        exec.waitFor();
    } catch (Exception e) {
        e.printStackTrace();
    }

    return list;
}