Search in sources :

Example 1 with JavaElementLabelProvider

use of org.eclipse.jdt.ui.JavaElementLabelProvider in project bndtools by bndtools.

the class NewTypeWizardPage method choosePackage.

// selection dialogs
/**
     * Opens a selection dialog that allows to select a package.
     *
     * @return returns the selected package or <code>null</code> if the dialog has been canceled. The caller typically
     *         sets the result to the package input field.
     *         <p>
     *         Clients can override this method if they want to offer a different dialog.
     *         </p>
     * @since 3.2
     */
protected IPackageFragment choosePackage() {
    IPackageFragmentRoot froot = getPackageFragmentRoot();
    IJavaElement[] packages = null;
    try {
        if (froot != null && froot.exists()) {
            packages = froot.getChildren();
        }
    } catch (JavaModelException e) {
        JavaPlugin.log(e);
    }
    if (packages == null) {
        packages = new IJavaElement[0];
    }
    ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT));
    dialog.setIgnoreCase(false);
    dialog.setTitle(NewWizardMessages.NewTypeWizardPage_ChoosePackageDialog_title);
    dialog.setMessage(NewWizardMessages.NewTypeWizardPage_ChoosePackageDialog_description);
    dialog.setEmptyListMessage(NewWizardMessages.NewTypeWizardPage_ChoosePackageDialog_empty);
    dialog.setElements(packages);
    dialog.setHelpAvailable(false);
    IPackageFragment pack = getPackageFragment();
    if (pack != null) {
        dialog.setInitialSelections(new Object[] { pack });
    }
    if (dialog.open() == Window.OK) {
        return (IPackageFragment) dialog.getFirstResult();
    }
    return null;
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) JavaModelException(org.eclipse.jdt.core.JavaModelException) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) JavaElementLabelProvider(org.eclipse.jdt.ui.JavaElementLabelProvider) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot)

Aggregations

IJavaElement (org.eclipse.jdt.core.IJavaElement)1 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)1 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 JavaElementLabelProvider (org.eclipse.jdt.ui.JavaElementLabelProvider)1 ElementListSelectionDialog (org.eclipse.ui.dialogs.ElementListSelectionDialog)1