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

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

Introduction

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

Prototype

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

Source Link

Document

Convenience method to open a simple Yes/No question dialog.

Usage

From source file:dk.dtu.imm.esculapauml.gui.topcased.observer.SimulationObserver.java

License:Open Source License

@Override
public boolean booleanChoice(int typeOfDecision, boolean defaultValue, Object data) {
    if (DECISION_TERMINATE_SIMULATION == typeOfDecision) {
        return MessageDialog.openQuestion(modeler.getSite().getShell(), "EsculapaUML simulation",
                "Number of events exceeded threshold of " + data.toString()
                        + ". Do you want to stop the simulation?");
    }//from w w w .  j  a v  a2s .c om
    return defaultValue;
}

From source file:e4.handler.E4TemplatePreferencePage.java

License:Open Source License

private void edit(TemplatePersistenceData data) {
    Template oldTemplate = data.getTemplate();
    Template newTemplate = editTemplate(new Template(oldTemplate), true, true);
    if (newTemplate != null) {

        if (!newTemplate.getName().equals(oldTemplate.getName()) && MessageDialog.openQuestion(getShell(),
                TemplatesMessages.TemplatePreferencePage_question_create_new_title,
                TemplatesMessages.TemplatePreferencePage_question_create_new_message)) {
            data = new TemplatePersistenceData(newTemplate, true);
            fTemplateStore.add(data);//from w w w .  j ava  2  s.  c o m
            fTableViewer.refresh();
        } else {
            data.setTemplate(newTemplate);
            fTableViewer.refresh(data);
        }
        selectionChanged1();
        fTableViewer.setChecked(data, data.isEnabled());
        fTableViewer.setSelection(new StructuredSelection(data));
    }
}

From source file:e4.handler.E4TemplatePreferencePage.java

License:Open Source License

private boolean confirmOverwrite(File file) {
    return MessageDialog.openQuestion(getShell(), TemplatesMessages.TemplatePreferencePage_export_exists_title,
            NLSUtility.format(TemplatesMessages.TemplatePreferencePage_export_exists_message,
                    file.getAbsolutePath()));
}

From source file:eclox.ui.action.BuildActionDelegate.java

License:Open Source License

/**
 * Prompts the user to create a new doxyfile.
 *
 * @return   a doxyfile, or null if none.
 *///from   w  w w  . j  av a  2s.c  o  m
private static IFile askUserToCreateDoxyfile() {
    IFile doxyfile = null;
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    boolean wantDoxyfile = MessageDialog.openQuestion(shell, "No Doxyfile Found",
            "No doxyfile has been found in opened projects.\n\nDo you want to create a new doxyfile now ?");

    if (wantDoxyfile) {
        NewDoxyfileWizard wizard = new NewDoxyfileWizard();
        ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
                .getSelection();
        IStructuredSelection strcSelection = (selection != null && selection instanceof IStructuredSelection)
                ? (IStructuredSelection) selection
                : new StructuredSelection();

        wizard.init(PlatformUI.getWorkbench(), strcSelection);

        WizardDialog wizardDialog = new WizardDialog(shell, wizard);

        wizardDialog.open();
        doxyfile = wizard.getDoxyfile();
    }

    return doxyfile;
}

From source file:eclox.ui.Plugin.java

License:Open Source License

/**
 * Asks the user if he wants to edit doxygen configuration after a failed
 * doxygen invocation.//from   www.  ja v a 2 s  . co  m
 * 
 * @return   @c true if doxygen configuration has been edited, @c false otherwise
 */
public static boolean editPreferencesAfterDoxygenInvocationFailed() {
    Shell shell = plugin.getWorkbench().getActiveWorkbenchWindow().getShell();

    // Asks the user if he wants to edit the preferences to solve the problem.
    boolean editionWanted = MessageDialog.openQuestion(shell, "Doxygen Not Found",
            "Eclox was not able to run doxygen. Doxygen is either missing or eclox is not properly configured to use it.\n\nWould you like to edit preferences now ?");
    if (!editionWanted) {
        return false;
    }

    // Allows the user to edit the preferences and eventually launch doxygen again.
    String[] filter = { eclox.core.ui.PreferencePage.ID };
    int edited = PreferencesUtil.createPreferenceDialogOn(shell, eclox.core.ui.PreferencePage.ID, filter, null)
            .open();

    return edited == Window.OK;
}

From source file:edu.cornell.gobii.gdi.forms.UserInfoPrompter.java

License:Apache License

public boolean promptYesNo(final String arg0) {

    Display.getDefault().syncExec(new Runnable() {
        public void run() {
            yesNoResult = MessageDialog.openQuestion(Display.getDefault().getActiveShell(),
                    "SSH Question Dialog", arg0);
        }//from w ww  .j  a  va 2 s. c  om
    });

    return yesNoResult;
}

From source file:edu.pitt.dbmi.odie.ui.editors.analysis.ProposalsSection.java

License:Apache License

private void hookMyListeners() {
    ontologyTree.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {

        @Override/*  w w  w  .  j a v a2s. c  om*/
        public void selectionChanged(SelectionChangedEvent event) {
            if (ontologyTree.getViewer().getSelection().isEmpty()) {
                remButton.setEnabled(false);
                //               noteButton.setEnabled(false);
            } else {
                remButton.setEnabled(true);
                List<IClass> items = ((StructuredSelection) ontologyTree.getViewer().getSelection()).toList();
                if (items.size() == 1) {
                    //                  bioportalButton.setEnabled(true);
                    IClass cl = items.get(0);

                    //                  noteButton.setEnabled(!GeneralUtils.isProxyClass(cl));
                } else {
                    //                  noteButton.setEnabled(false);
                }

            }

        }
    });

    addButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            handleSelection();

        }

        private void handleSelection() {
            GeneralUtils
                    .addToProposalOntologyWithDialog(((AnalysisEditorInput) editor.getEditorInput()).analysis);
            ontologyTree.refresh();
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleSelection();
        }
    });

    remButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            handleSelection();

        }

        private void handleSelection() {
            if (ontologyTree.getViewer().getSelection().isEmpty())
                return;

            List<IClass> items = ((StructuredSelection) ontologyTree.getViewer().getSelection()).toList();

            String itemNames = "";
            if (items.size() > 0)
                itemNames = "the selected concepts";
            else
                itemNames = "'" + (items.get(0)).getName() + "'";

            IOntology ontology = items.get(0).getOntology();
            if (MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "Remove Concept",
                    "Are you sure you want to remove " + itemNames)) {
                for (IClass item : items)
                    item.delete();

                try {
                    ontology.save();
                    Analysis analysis = ((AnalysisEditorInput) editor.getEditorInput()).getAnalysis();
                    GeneralUtils.refreshProposalLexicalSet(analysis);
                    ontologyTree.refresh();
                } catch (IOntologyException e) {
                    e.printStackTrace();
                    GeneralUtils.showErrorDialog("Error", e.getMessage());
                }
            }
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleSelection();
        }

    });

    shareButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {

        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            final Shell dialog = new Shell(GeneralUtils.getShell(), SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
            dialog.setText("Share");
            dialog.setLayout(new GridLayout(3, true));

            final Label label = new Label(dialog, SWT.NONE);
            label.setText("Select the community to contribute to");
            GridData gd = new GridData();
            gd.horizontalSpan = 3;
            gd.horizontalAlignment = SWT.LEFT;
            label.setLayoutData(gd);

            Button bioportalButton = new Button(dialog, SWT.PUSH);
            bioportalButton.setText("Bioportal");
            gd = new GridData();
            gd.horizontalAlignment = SWT.CENTER;
            bioportalButton.setLayoutData(gd);

            Button neuroLexButton = new Button(dialog, SWT.PUSH);
            neuroLexButton.setText("NeuroLex Wiki");
            gd = new GridData();
            gd.horizontalAlignment = SWT.CENTER;
            neuroLexButton.setLayoutData(gd);

            Button buttonCancel = new Button(dialog, SWT.PUSH);
            buttonCancel.setText("Cancel");
            gd = new GridData();
            gd.horizontalAlignment = SWT.CENTER;
            buttonCancel.setLayoutData(gd);

            dialog.pack();

            Aesthetics.centerDialog(dialog);

            neuroLexButton.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (MessageDialog.openQuestion(GeneralUtils.getShell(), "Share on NeuroLex Wiki",
                            "Do you want to create a new wiki page for the concept in the NeuroLex Wiki?")) {

                        List<IClass> items = ((StructuredSelection) ontologyTree.getViewer().getSelection())
                                .toList();
                        if (items.size() > 0) {
                            IClass newc = items.get(0);
                            String urlString = ODIEConstants.NEUROLEX_WIKI_CREATE_PAGE_PREFIX + newc.getName();
                            try {
                                GeneralUtils.openURL(new URL(urlString));
                            } catch (MalformedURLException e1) {
                                // TODO Auto-generated catch block
                                e1.printStackTrace();
                            }
                        }
                        dialog.close();
                    }

                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                    // TODO Auto-generated method stub

                }
            });

            buttonCancel.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    dialog.close();

                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                    // TODO Auto-generated method stub

                }
            });

            bioportalButton.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                    handleSelection();
                    dialog.close();

                }

                private void handleSelection() {
                    if (ontologyTree.getViewer().getSelection().isEmpty()) {
                        GeneralUtils.showErrorDialog("No Concept Selected",
                                "Please select a new proposal concept to be suggested in the Bioportal Note");
                        return;
                    }

                    List<IClass> items = ((StructuredSelection) ontologyTree.getViewer().getSelection())
                            .toList();
                    if (items.size() > 0) {
                        IClass newc = items.get(0);
                        String bpURIStr = (String) newc
                                .getPropertyValue(newc.getOntology().getProperty(IProperty.RDFS_IS_DEFINED_BY));
                        if (bpURIStr != null) {
                            GeneralUtils.showErrorDialog("Concept already in Bioportal", newc.getName()
                                    + " is already part of an existing Bioportal "
                                    + "ontology. Please select a newly created concept to be submitted as a Bioportal note");
                            return;
                        }
                        IProperty p = newc.getOntology().getProperty(ODIEConstants.BIOPORTAL_NOTE_ID_PROPERTY);
                        IProperty op = newc.getOntology()
                                .getProperty(ODIEConstants.BIOPORTAL_ONTOLOGY_ID_PROPERTY);
                        if (p != null) {
                            String noteid = (String) newc.getPropertyValue(p);
                            String ontologyid = (String) newc.getPropertyValue(op);
                            if (noteid != null && ontologyid != null) {
                                MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(),
                                        "Bioportal note already exists", null,
                                        "A bioportal note was previously created for this concept.",
                                        MessageDialog.INFORMATION,
                                        new String[] { "View in Bioportal", IDialogConstants.OK_LABEL }, 0);
                                int index = dialog.open();
                                if (index == 0) {
                                    String url = BioPortalRepository.DEFAULT_BIOPORTAL_URL + ontologyid
                                            + "/?noteid=" + noteid;
                                    try {
                                        GeneralUtils.openURL(new URL(url));
                                    } catch (MalformedURLException e) {
                                        e.printStackTrace();
                                    }
                                }
                                return;
                            }
                        }

                        Analysis analysis = ((AnalysisEditorInput) editor.getEditorInput()).getAnalysis();

                        MiddleTier mt = Activator.getDefault().getMiddleTier();

                        BioportalNewProposalNoteWizard wizard = new BioportalNewProposalNoteWizard(analysis,
                                newc);

                        WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);

                        dialog.open();
                    }
                }

                @Override
                public void widgetSelected(SelectionEvent e) {
                    handleSelection();
                    dialog.close();
                }

            });

            dialog.open();
        }

    });

    exportButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            handleSelection();

        }

        private void handleSelection() {
            GeneralUtils.exportOntologyToCSVWithDialog((IOntology) ontologyTree.getViewer().getInput());
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleSelection();
        }
    });
}

From source file:edu.rice.cs.drjava.plugins.eclipse.views.InteractionsView.java

License:BSD License

/**
 * Shows a modal dialog to confirm an operation.
 * @param title Title of the dialog box/*  ww w. j  a  va2 s  .  c  o m*/
 * @param msg Message to display
 * @return Whether the user clicked yes or not
 */
public boolean showConfirmDialog(final String title, final String msg) {
    return MessageDialog.openQuestion(_styledText.getShell(), title, msg);
}

From source file:edu.toronto.cs.se.mmint.mid.ui.MIDDialogs.java

License:Open Source License

public static boolean getBooleanInput(String dialogTitle, String dialogMessage) {

    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

    return MessageDialog.openQuestion(shell, dialogTitle, dialogMessage);
}

From source file:edu.tsinghua.lumaqq.ui.helper.MenuHelper.java

License:Open Source License

/**
 * ???/*www  . j  a v a  2 s  .  c  o m*/
 */
private void initDiskMenu() {
    diskMenu = new CMenu();
    // 
    final CMenuItem miRefresh = new CMenuItem(diskMenu, SWT.PUSH);
    miRefresh.setImage(res.getImage(Resources.icoRefresh));
    miRefresh.setText(disk_tooltip_refresh);
    miRefresh.addSelectionListener(new ISelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            Object obj = diskMenu.getData();
            main.getDiskManager().refresh(obj);
            main.getDiskViewer().refresh();
        }
    });
    // 
    final CMenuItem miShare = new CMenuItem(diskMenu, SWT.PUSH);
    miShare.setText(disk_tooltip_set_share);
    miShare.addSelectionListener(new ISelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            Directory dir = (Directory) diskMenu.getData();
            DiskShareDialog dialog = new DiskShareDialog(main, dir);
            dialog.open();
        }
    });
    // separator
    new CMenuItem(diskMenu, SWT.SEPARATOR);
    // 
    final CMenuItem miUpload = new CMenuItem(diskMenu, SWT.PUSH);
    miUpload.setImage(res.getImage(Resources.icoDiskUpload));
    miUpload.setText(disk_tooltip_upload);
    miUpload.addSelectionListener(new ISelectionListener() {
        public void widgetSelected(SelectionEvent e) {
        }
    });
    // 
    final CMenuItem miDownload = new CMenuItem(diskMenu, SWT.PUSH);
    miDownload.setImage(res.getImage(Resources.icoDiskDownload));
    miDownload.setText(disk_tooltip_download);
    miDownload.addSelectionListener(new ISelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            main.onDiskDownload(new StructuredSelection(diskMenu.getData()));
        }
    });
    // separator
    new CMenuItem(diskMenu, SWT.SEPARATOR);
    // 
    final CMenuItem miDelete = new CMenuItem(diskMenu, SWT.PUSH);
    miDelete.setText(disk_tooltip_delete);
    miDelete.addSelectionListener(new ISelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            Object obj = diskMenu.getData();
            if (obj instanceof Directory) {
                Directory dir = (Directory) obj;
                if (dir.isSystemDir()) {
                    MessageDialog.openWarning(main.getShell(), message_box_common_warning_title,
                            disk_hint_cannot_delete_system_dir);
                    return;
                }
            }
            String msg = null;
            if (obj instanceof Integer)
                msg = NLS.bind(disk_hint_confirm_delete, String.valueOf(obj));
            else if (obj instanceof File)
                msg = NLS.bind(disk_hint_confirm_delete, ((File) obj).name);
            else if (obj instanceof Directory)
                msg = NLS.bind(disk_hint_confirm_delete, ((Directory) obj).name);
            else
                return;

            if (MessageDialog.openQuestion(main.getShell(), message_box_common_question_title, msg)) {
                if (obj instanceof Integer)
                    main.getDiskJobQueue().addJob(new DeleteJob((Integer) obj));
                else if (obj instanceof File)
                    main.getDiskJobQueue().addJob(new DeleteJob((File) obj));
                else
                    main.getDiskJobQueue().addJob(new DeleteJob((Directory) obj));
            }
        }
    });
    // separator
    new CMenuItem(diskMenu, SWT.SEPARATOR);
    // ???
    final CMenuItem miRename = new CMenuItem(diskMenu, SWT.PUSH);
    miRename.setText(disk_tooltip_rename);
    miRename.addSelectionListener(new ISelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            Object obj = diskMenu.getData();
            boolean renameFile = obj instanceof File;
            InputDialog dialog = new InputDialog(main.getShell(), "Rename", disk_hint_input_new_name,
                    renameFile ? ((File) obj).name : ((Directory) obj).name, new IInputValidator() {
                        public String isValid(String newText) {
                            if (!newText.equals(""))
                                return null;
                            else
                                return disk_hint_name_cannot_null;
                        }
                    });
            if (dialog.open() == IDialogConstants.OK_ID) {
                if (renameFile)
                    main.getDiskJobQueue().addJob(new RenameJob((File) obj, dialog.getValue()));
                else
                    main.getDiskJobQueue().addJob(new RenameJob((Directory) obj, dialog.getValue()));
            }
        }
    });
    // 
    final CMenuItem miNewFolder = new CMenuItem(diskMenu, SWT.PUSH);
    miNewFolder.setText(disk_tooltip_new_directory);
    miNewFolder.addSelectionListener(new ISelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            Object obj = diskMenu.getData();
            int parentId = (obj instanceof Integer) ? 0 : ((Directory) obj).id;
            InputDialog dialog = new InputDialog(main.getShell(), "New", disk_hint_input_new_name, null,
                    new IInputValidator() {
                        public String isValid(String newText) {
                            if (!newText.equals(""))
                                return null;
                            else
                                return disk_hint_name_cannot_null;
                        }
                    });
            if (dialog.open() == IDialogConstants.OK_ID) {
                main.getDiskJobQueue().addJob(new CreateDirectoryJob(dialog.getValue(), parentId));
            }
        }
    });

    // ??
    diskMenu.addMenuListener(new IMenuListener() {
        public void menuShown(MenuEvent e) {
            Object obj = diskMenu.getData();
            if (obj == null) {
                miRefresh.setEnabled(false);
                miDownload.setEnabled(false);
                miUpload.setEnabled(false);
                miRename.setEnabled(false);
                miDelete.setEnabled(false);
                miShare.setEnabled(false);
            } else {
                if (obj instanceof Integer)
                    miRefresh.setEnabled(true);
                else if (obj instanceof Directory) {
                    Directory dir = (Directory) obj;
                    switch (dir.id) {
                    case QQ.QQ_DISK_DIR_MY_FAVORITE:
                    case QQ.QQ_DISK_DIR_MY_ALBUM:
                        miRefresh.setEnabled(true);
                        break;
                    default:
                        miRefresh.setEnabled(false);
                        break;
                    }
                } else
                    miRefresh.setEnabled(false);

                miDownload.setEnabled(obj instanceof File);
                miShare.setEnabled(obj instanceof Directory && ((Directory) obj).owner == main.getMyModel().qq);
                miUpload.setEnabled(
                        obj instanceof Directory && main.getDiskManager().isChildCreatable((Directory) obj)
                                || obj instanceof Integer && (Integer) obj == DiskContentProvider.MY_DISK);
                miRename.setEnabled(obj instanceof File && ((File) obj).owner == main.getMyModel().qq
                        || obj instanceof Directory && ((Directory) obj).owner == main.getMyModel().qq
                                && !((Directory) obj).isSystemDir());
                miDelete.setEnabled(obj instanceof File && ((File) obj).owner == main.getMyModel().qq
                        || obj instanceof Directory && ((Directory) obj).owner == main.getMyModel().qq
                        || obj instanceof Integer && (Integer) obj > 10000);
                if (obj instanceof Directory) {
                    miNewFolder.setEnabled(main.getDiskManager().isChildCreatable((Directory) obj));
                } else if (obj instanceof Integer) {
                    miNewFolder.setEnabled((Integer) obj == DiskContentProvider.MY_DISK);
                } else
                    miNewFolder.setEnabled(false);
            }
        }
    });
}