Example usage for org.eclipse.jface.dialogs IDialogConstants OK_LABEL

List of usage examples for org.eclipse.jface.dialogs IDialogConstants OK_LABEL

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants OK_LABEL.

Prototype

String OK_LABEL

To view the source code for org.eclipse.jface.dialogs IDialogConstants OK_LABEL.

Click Source Link

Document

The label for OK buttons.

Usage

From source file:de.walware.statet.nico.ui.util.ToolMessageDialog.java

License:Open Source License

public static boolean openConfirm(final ToolProcess tool, final Shell parent, final String title,
        final String message) {
    final ToolMessageDialog dialog = new ToolMessageDialog(tool, parent, title, null, message, QUESTION,
            new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
    return (dialog.open() == 0);
}

From source file:descent.internal.ui.dialogs.ListDialog.java

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {
    if (!fAddCancelButton)
        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    else/*from ww w. ja  v a2  s  .c om*/
        super.createButtonsForButtonBar(parent);
}

From source file:descent.internal.ui.text.java.CompletionProposalComputerRegistry.java

License:Open Source License

/**
 * Log the status and inform the user about a misbehaving extension.
 * //from   w w w.  j av  a  2  s.c om
 * @param descriptor the descriptor of the misbehaving extension
 * @param status a status object that will be logged
 */
void informUser(CompletionProposalComputerDescriptor descriptor, IStatus status) {
    JavaPlugin.log(status);
    String title = JavaTextMessages.CompletionProposalComputerRegistry_error_dialog_title;
    CompletionProposalCategory category = descriptor.getCategory();
    IContributor culprit = descriptor.getContributor();
    Set affectedPlugins = getAffectedContributors(category, culprit);

    final String avoidHint;
    final String culpritName = culprit == null ? null : culprit.getName();
    if (affectedPlugins.isEmpty())
        avoidHint = Messages.format(JavaTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHint,
                new Object[] { culpritName, category.getDisplayName() });
    else
        avoidHint = Messages.format(
                JavaTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning,
                new Object[] { culpritName, category.getDisplayName(), toString(affectedPlugins) });

    String message = status.getMessage();
    // inlined from MessageDialog.openError
    MessageDialog dialog = new MessageDialog(JavaPlugin.getActiveWorkbenchShell(), title,
            null /* default image */, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL },
            0) {
        protected Control createCustomArea(Composite parent) {
            Link link = new Link(parent, SWT.NONE);
            link.setText(avoidHint);
            link.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    PreferencesUtil.createPreferenceDialogOn(getShell(),
                            "descent.ui.preferences.CodeAssistPreferenceAdvanced", null, null).open(); //$NON-NLS-1$
                }
            });
            GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
            gridData.widthHint = this.getMinimumMessageWidth();
            link.setLayoutData(gridData);
            return link;
        }
    };
    dialog.open();
}

From source file:descent.ui.actions.FormatAllAction.java

License:Open Source License

public void run(IStructuredSelection selection) {
    ICompilationUnit[] cus = getCompilationUnits(selection);
    if (cus.length == 0) {
        MessageDialog.openInformation(getShell(), ActionMessages.FormatAllAction_EmptySelection_title,
                ActionMessages.FormatAllAction_EmptySelection_description);
        return;// w  ww  . j a  v  a2s. c o  m
    }
    if (cus.length > 1) {
        int returnCode = OptionalMessageDialog.open("FormatAll", //$NON-NLS-1$
                getShell(), ActionMessages.FormatAllAction_noundo_title, null,
                ActionMessages.FormatAllAction_noundo_message, MessageDialog.WARNING,
                new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
        if (returnCode != OptionalMessageDialog.NOT_SHOWN && returnCode != Window.OK)
            return;
    }

    IStatus status = Resources.makeCommittable(getResources(cus), getShell());
    if (!status.isOK()) {
        ErrorDialog.openError(getShell(), ActionMessages.FormatAllAction_failedvalidateedit_title,
                ActionMessages.FormatAllAction_failedvalidateedit_message, status);
        return;
    }

    runOnMultiple(cus);
}

From source file:edu.iastate.cs.boa.ui.dialogs.InputSelectionDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(final Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);

    combo.setFocus();/*www. ja va  2  s  . co  m*/
    if (value != null)
        combo.setText(value);
}

From source file:edu.kit.joana.ui.ifc.sdg.gui.views.LatticeDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    if (fAddCancelButton) {
        createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true);
    }/*ww  w .  j  a  v a 2 s .  c  om*/
}

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

License:Apache License

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

        @Override//from w  w w  . j av  a  2s  .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.umd.cs.eclipse.courseProjectManager.PasswordDialog.java

License:Apache License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    // create OK and Cancel buttons by default
    okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    if (password != null) {
        passwordText.setText(password);//from   ww  w . j a v a 2s. c om
        passwordText.selectAll();
    }

    usernameText.setFocus();
    if (username != null) {
        usernameText.setText(username);
        usernameText.selectAll();
    }
}

From source file:edu.umd.cs.eclipse.courseProjectManager.SubmitUserDialog.java

License:Apache License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    // create OK and Cancel buttons by default
    okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);

    userDataText.setFocus();// w w  w  .j a  v a2s .c  o  m
    if (userData != null) {
        userDataText.setText(userData);
        userDataText.selectAll();
    }
}

From source file:es.axios.udig.spatialoperations.internal.ui.dialogs.CreateNewLayerDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    this.okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    this.cancelButton = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);

}