Search in sources :

Example 6 with ElementListSelectionDialog

use of org.eclipse.ui.dialogs.ElementListSelectionDialog in project bndtools by bndtools.

the class ProjectLaunchTabPiece method doBrowseProject.

void doBrowseProject() {
    ElementListSelectionDialog dialog = new ElementListSelectionDialog(launchTargetTxt.getShell(), new WorkbenchLabelProvider());
    dialog.setTitle("Project Selection");
    dialog.setMessage("Select a project to constrain your search.");
    List<IProject> projects = loadProjects();
    dialog.setElements(projects.toArray());
    if (Window.OK == dialog.open()) {
        IProject selected = (IProject) dialog.getFirstResult();
        launchTargetTxt.setText(selected.getName());
    }
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) IProject(org.eclipse.core.resources.IProject)

Example 7 with ElementListSelectionDialog

use of org.eclipse.ui.dialogs.ElementListSelectionDialog 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

ElementListSelectionDialog (org.eclipse.ui.dialogs.ElementListSelectionDialog)7 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)3 IDebugModelPresentation (org.eclipse.debug.ui.IDebugModelPresentation)3 IProject (org.eclipse.core.resources.IProject)1 EObject (org.eclipse.emf.ecore.EObject)1 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)1 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 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Image (org.eclipse.swt.graphics.Image)1 Label (org.eclipse.swt.widgets.Label)1 Link (org.eclipse.swt.widgets.Link)1 Shell (org.eclipse.swt.widgets.Shell)1 WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)1