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

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

Introduction

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

Prototype

public static boolean openConfirm(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a simple confirm (OK/Cancel) dialog.

Usage

From source file:com.generalrobotix.ui.view.GrxServerManagerView.java

License:Open Source License

private void removeServerBtn(TabFolder folder) {
    int index = folder.getSelectionIndex();
    Vector<ProcessInfo> vecServerInfo = serverManager_.getServerInfo();

    String mes = MessageBundle.get("GrxServerManagerView.dialog.message.remove"); //$NON-NLS-1$
    mes = NLS.bind(mes, new String[] { vecTabItem_.elementAt(index).getText() });

    // ?  //from w  w  w.jav  a  2s . c o  m
    if (MessageDialog.openConfirm(composite_.getShell(),
            MessageBundle.get("GrxServerManagerView.dialog.title.remove"), //$NON-NLS-1$
            mes)) {
        vecTabItem_.elementAt(index).getControl().dispose();
        folder.getItem(index).dispose();
        vecTabItem_.remove(index);
        vecServerInfo.remove(index);
    }
}

From source file:com.github.ko2ic.plugin.eclipse.taggen.core.ui.components.dialog.AsyncMessageDialog.java

License:Open Source License

public static void openConfirm(final Shell shell, final String title, final String msg) {
    shell.getDisplay().asyncExec(new Runnable() {
        @Override/*from   ww  w. j a v a 2  s.  c om*/
        public void run() {
            MessageDialog.openConfirm(shell, title, msg);
        }
    });
}

From source file:com.github.sdbg.debug.ui.internal.actions.GlobalVariablesFilterAction.java

License:Open Source License

@Override
public void runWithEvent(IAction action, Event event) {
    if (action.isChecked()) {
        if (!MessageDialog.openConfirm(view.getViewSite().getShell(), "Warning",
                "Vizualizing global variables can significantly slow down the debugger.\nWould you like to still shown them?")) {
            return;
        }//from w ww  . j a  v a  2s  . c  om
    }

    super.runWithEvent(action, event);
}

From source file:com.github.sdbg.debug.ui.internal.SDBGDebugUserAgentManager.java

License:Open Source License

private boolean askUserAllows(final InetAddress remoteAddress, final String agent) {
    final boolean[] result = new boolean[1];

    Display.getDefault().syncExec(new Runnable() {
        @Override//from   w ww .j  a v a2  s  .co  m
        public void run() {
            Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

            // Move the app to the foreground. Otherwise the dialog can be missed.
            shell.forceActive();

            result[0] = MessageDialog.openConfirm(shell, "Allow Remote Device Connection",
                    "Allow a remote device from " + remoteAddress.getHostAddress()
                            + " to connect to and run your Dart applications?\n\n" + agent);
        }
    });

    return result[0];
}

From source file:com.google.appraise.eclipse.core.AppraisePluginReviewClient.java

License:Open Source License

private boolean displayWriteWarning(final String message) {
    final AtomicBoolean result = new AtomicBoolean(false);
    Display.getDefault().syncExec(new Runnable() {
        @Override/*from   ww w  . j  a v  a  2 s .co m*/
        public void run() {
            result.set(MessageDialog.openConfirm(null, "Appraise Review Plugin", message));
        }
    });
    return result.get();
}

From source file:com.google.code.t4eclipse.tools.action.AnalysisMenuAction.java

License:Open Source License

public void run(IAction action) {
    if (c == null || c.isDisposed()) {
        return;//www  .j ava2  s . c  o  m
    }
    if (!c.isVisible() || !c.isEnabled() || c.getMenu() == null) {
        MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Confirm",
                "This control is not visible or not enabled or has no menu!\n");
        return;
    }
    int itemCount = c.getMenu().getItemCount();
    if (itemCount == 0) {
        MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Confirm",
                "This control's menu has no menu items now!\n"
                        + "Control's menu item may be constructed during menu show,\n"
                        + "Please check control's menu first on eclispe ui ! ");

        return;

    }

    try {
        IViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
                .showView("com.google.code.t4eclipse.tools.view.MenuAnalyzerView");
        if (view != null && view instanceof MenuAnalyzerView) {
            MenuAnalyzerView ma = (MenuAnalyzerView) view;
            ma.update(this.c);
        }
    } catch (PartInitException e) {
        //do nothing
    }

}

From source file:com.google.code.t4eclipse.tools.view.ActivePartControlView.java

License:Open Source License

@Override
public void createPartControl(Composite root) {
    root.setLayout(new FillLayout());
    sashForm = new SashForm(root, SWT.HORIZONTAL);

    treeViewerComposite = new Composite(sashForm, SWT.NONE);
    infoSashText = new Text(sashForm, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);

    // Composite composite = new Composite(parent, SWT.NONE); // in method
    // use parent
    GridLayout layout = new GridLayout();
    layout.horizontalSpacing = 0;/*w  w  w .ja va 2s  .  co  m*/
    layout.verticalSpacing = 0;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 1;
    treeViewerComposite.setLayout(layout);
    treeViewerComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    headText = new Text(treeViewerComposite, SWT.SINGLE | SWT.READ_ONLY);

    headText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    createViewer(treeViewerComposite);

    sashForm.setWeights(new int[] { 6, 4 });

    getSite().setSelectionProvider(viewer);
    final MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);

    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {
        public void menuAboutToShow(IMenuManager manager) {
            if (ActivePartControlView.this.part != null
                    && ActivePartControlView.this.part instanceof IViewPart) {

                manager.add(new Separator());
                Action openToolBarAction = new Action() {
                    @SuppressWarnings("hiding")
                    @Override
                    public void run() {

                        ToolBar bar = MenuUtility.getviewToolBar(ActivePartControlView.this.part);

                        if (bar.getItems() == null || bar.getItemCount() == 0) {
                            MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Confirm",
                                    "No View toolBar action contributed in this view!\n");

                        }

                        else {
                            try {
                                IViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                                        .getActivePage()
                                        .showView("com.google.code.t4eclipse.tools.view.ToolBarAnalyzerView");
                                if (view != null && view instanceof ToolBarAnalyzerView) {
                                    ToolBarAnalyzerView ma = (ToolBarAnalyzerView) view;
                                    ma.update(bar);
                                }
                            } catch (PartInitException e) {
                                e.printStackTrace();
                            }
                        }

                    }
                };

                openToolBarAction.setText("Analyze View Toolbar");

                Action openViewMenuAction = new Action() {
                    @SuppressWarnings("hiding")
                    @Override
                    public void run() {

                        Menu menu = MenuUtility.getViewMenu(ActivePartControlView.this.part);
                        if (menu == null || menu.getItemCount() == 0) {
                            MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Confirm",
                                    "No View menu action contributed in this view\n"
                                            + "Or the menu is not showed before!\n"
                                            + "Please mannually show the toolbar menu before analyze it\n"
                                            + " if toolbar menu exists for the view " + "");
                        }
                        if (menu != null) {
                            try {
                                IViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                                        .getActivePage()
                                        .showView("com.google.code.t4eclipse.tools.view.MenuAnalyzerView");
                                if (view != null && view instanceof MenuAnalyzerView) {
                                    MenuAnalyzerView ma = (MenuAnalyzerView) view;
                                    ma.update(menu);
                                }
                            } catch (PartInitException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                };

                openViewMenuAction.setText("Analyze View Menu");
                manager.add(openToolBarAction);

                manager.add(openViewMenuAction);
                manager.add(new Separator());
            }

        }
    });
    Menu menu = menuMgr.createContextMenu(this.viewer.getTree());

    this.viewer.getTree().setMenu(menu);
    getSite().registerContextMenu(menuMgr, this.viewer);

    view = this;

    listener = new IPartListener() {

        public void partOpened(IWorkbenchPart aPart) {
            //do nothing
        }

        public void partDeactivated(IWorkbenchPart aPart) {
            //do nothing
        }

        public void partClosed(IWorkbenchPart aPart) {

            if (aPart != null && !(aPart instanceof ActivePartControlView)) {
                if (aPart == ActivePartControlView.this.part) {
                    ActivePartControlView.this.cleanContent();
                }
            }
        }

        public void partBroughtToTop(IWorkbenchPart aPart) {
            //do nothing
        }

        public void partActivated(IWorkbenchPart aPart) {
            //do nothing
        }
    };

    sashForm.setMaximizedControl(treeViewerComposite);
}

From source file:com.google.dart.tools.debug.ui.internal.DartDebugUserAgentManager.java

License:Open Source License

private boolean askUserAllows(final InetAddress remoteAddress, final String agent) {
    final boolean[] result = new boolean[1];

    Display.getDefault().syncExec(new Runnable() {
        @Override/*  w  w  w. j  ava 2  s .  c  o m*/
        public void run() {
            result[0] = MessageDialog.openConfirm(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    "Allow Remote Device Connection",
                    "Allow a remote device from " + remoteAddress.getHostAddress()
                            + " to connect to and run your Dart applications?\n\n" + agent);
        }
    });

    return result[0];
}

From source file:com.google.dart.tools.ui.internal.util.DirectoryVerification.java

License:Open Source License

public static boolean validateOpenDirectoryLocation(Shell shell, File directory) {
    IStatus status = getOpenDirectoryLocationStatus(directory);

    if (status.getSeverity() == IStatus.ERROR) {
        MessageDialog.openError(shell, "Unable to Open Directory", status.getMessage());

        return false;
    } else if (status.getSeverity() == IStatus.WARNING) {
        return MessageDialog.openConfirm(shell, "Confirm Open Directory",
                status.getMessage() + "\nAre you sure you want to open this directory?");
    }//from   ww w .  j a v  a 2s  .  com

    return status.isOK();
}

From source file:com.google.dart.tools.update.core.internal.jobs.InstallUpdateAction.java

License:Open Source License

@Override
public void run() {

    if (resourcesNeedSaving()) {

        //prompt to save dirty editors
        if (!MessageDialog.openConfirm(getShell(), UpdateJobMessages.InstallUpdateAction_confirm_save_title,
                UpdateJobMessages.InstallUpdateAction_confirm_save_msg)) {
            return;
        }/*from w  w w  .j  a v  a  2  s.c o m*/

        //attempt to close dirty editors
        if (!PlatformUI.getWorkbench().saveAllEditors(false)) {
            MessageDialog.openError(getShell(), UpdateJobMessages.InstallUpdateAction_errorTitle,
                    UpdateJobMessages.InstallUpdateAction_error_in_save);
            return;
        }
    }

    try {
        applyUpdate();
        restart();
    } catch (Throwable th) {
        UpdateCore.logError(th);
        MessageDialog.openError(getShell(), UpdateJobMessages.InstallUpdateAction_errorTitle,
                NLS.bind(UpdateJobMessages.InstallUpdateAction_errorMessage, th.getMessage()));
    }
}