Java Code Examples for org.eclipse.ui.dialogs.ElementListSelectionDialog#setInitialSelections()

The following examples show how to use org.eclipse.ui.dialogs.ElementListSelectionDialog#setInitialSelections() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractLauncherTab.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
protected IProject chooseXdsProject() {
    ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
    dialog.setTitle(Messages.LauncherTabMain_ProjectSelection); 
    dialog.setMessage(Messages.LauncherTabMain_SelectXdsProject+':');

    dialog.setElements(ProjectUtils.getXdsProjects().toArray());

    IProject currentProject = getCurrentXdsProject();
    if (currentProject != null) {
        dialog.setInitialSelections(new Object[] { currentProject });
    }
    if (dialog.open() == Window.OK) {			
        return (IProject) dialog.getFirstResult();
    }		
    return null;		
}
 
Example 2
Source File: SimpleListSelectionDialog.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
private SimpleListSelectionDialog(
		Shell shell, 
		String title, 
		String message, 
		Image image,
		ITextProvider iTextProvider,
		Object[] items, 
		Object initialSelection) 
{
	this.image = image;
	this.iTextProvider = iTextProvider;
	if (shell == null) {
		shell = SwtUtils.getDefaultShell();
	}
	dialog= new ElementListSelectionDialog(shell, new SimpleLabelProvider());
	dialog.setTitle(title); 
	dialog.setMessage(message);
	dialog.setElements(items);
	if (initialSelection != null) {
		dialog.setInitialSelections(new Object[] { initialSelection });
	}
}
 
Example 3
Source File: NewSourceFolderWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private IJavaProject chooseProject() {
	IJavaProject[] projects;
	try {
		projects= JavaCore.create(fWorkspaceRoot).getJavaProjects();
	} catch (JavaModelException e) {
		JavaPlugin.log(e);
		projects= new IJavaProject[0];
	}

	ILabelProvider labelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT);
	ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
	dialog.setTitle(NewWizardMessages.NewSourceFolderWizardPage_ChooseProjectDialog_title);
	dialog.setMessage(NewWizardMessages.NewSourceFolderWizardPage_ChooseProjectDialog_description);
	dialog.setElements(projects);
	dialog.setInitialSelections(new Object[] { fCurrJProject });
	dialog.setHelpAvailable(false);
	if (dialog.open() == Window.OK) {
		return (IJavaProject) dialog.getFirstResult();
	}
	return null;
}
 
Example 4
Source File: ProjectField.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
protected IProject chooseProject() throws OperationCancellation {
	Shell shell = button.getShell();
	ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new WorkbenchLabelProvider());
	dialog.setTitle(LangUIMessages.projectField_chooseProject_title);
	dialog.setMessage(LangUIMessages.projectField_chooseProject_message);

	try {
		final IProject[] projects = getDialogChooseElements(); 
		dialog.setElements(projects);
	} catch (CoreException ce) {
		EclipseCore.logStatus(ce);
	}
	
	final IProject project = getProject();
	if (project != null && project.isOpen()) {
		dialog.setInitialSelections(new Object[] { project });
	}
	
	if (dialog.open() == Window.OK) {
		return (IProject) dialog.getFirstResult();
	}
	throw new OperationCancellation();
}
 
Example 5
Source File: GWTCompileDialog.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private IJavaProject chooseProject() {
  IJavaProject[] javaProjects;

  try {
    javaProjects = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();
  } catch (JavaModelException e) {
    GWTPluginLog.logError(e);
    javaProjects = new IJavaProject[0];
  }

  // Filter the list to only show GWT projects
  List<IJavaProject> gwtProjects = new ArrayList<IJavaProject>();
  for (IJavaProject javaProject : javaProjects) {
    if (GWTNature.isGWTProject(javaProject.getProject())) {
      gwtProjects.add(javaProject);
    }
  }

  ILabelProvider labelProvider = new JavaElementLabelProvider(
      JavaElementLabelProvider.SHOW_DEFAULT);
  ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
  dialog.setTitle("Project Selection");
  dialog.setMessage("Choose a project to compile");
  dialog.setElements(gwtProjects.toArray(new IJavaProject[0]));
  dialog.setInitialSelections(new Object[] {JavaCore.create(project)});

  dialog.setHelpAvailable(false);
  if (dialog.open() == Window.OK) {
    return (IJavaProject) dialog.getFirstResult();
  }
  return null;
}
 
Example 6
Source File: NewHostPageWizardPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private IJavaProject chooseProject() {
  IJavaProject[] projects;
  try {
    projects = JavaCore.create(Util.getWorkspaceRoot()).getJavaProjects();
  } catch (JavaModelException e) {
    JavaPlugin.log(e);
    projects = new IJavaProject[0];
  }

  // Filter the list to only show GWT projects
  List<IJavaProject> gwtProjects = new ArrayList<IJavaProject>();
  for (IJavaProject project : projects) {
    if (GWTNature.isGWTProject(project.getProject())) {
      gwtProjects.add(project);
    }
  }

  // TODO: refactor this into utility function
  ILabelProvider labelProvider = new JavaElementLabelProvider(
      JavaElementLabelProvider.SHOW_DEFAULT);
  ElementListSelectionDialog dialog = new ElementListSelectionDialog(
      getShell(), labelProvider);
  dialog.setTitle("Project Selection");
  dialog.setMessage("Choose a project for the new HTML page");
  dialog.setElements(gwtProjects.toArray(new IJavaProject[0]));
  dialog.setInitialSelections(new Object[] {getJavaProject()});
  dialog.setHelpAvailable(false);
  if (dialog.open() == Window.OK) {
    return (IJavaProject) dialog.getFirstResult();
  }
  return null;
}
 
Example 7
Source File: NewTypeWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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;
}