org.eclipse.ui.dialogs.ElementListSelectionDialog Java Examples

The following examples show how to use org.eclipse.ui.dialogs.ElementListSelectionDialog. 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: DotnetTestTab.java    From aCute with Eclipse Public License 2.0 6 votes vote down vote up
private void displayClassSelectorDialog() {

		ElementListSelectionDialog dialog = new ElementListSelectionDialog(classBrowseButton.getShell(),
				new LabelProvider());
		dialog.setTitle(Messages.DotnetTestTab_classSelection_title);
		dialog.setMessage(Messages.DotnetTestTab_classSelection_message);
		dialog.setElements(testMethods.keySet().toArray());
		dialog.open();
		String selected = (String) dialog.getFirstResult();
		if (selected != null) {
			methodBrowseButton.setEnabled(true);
			methodLabel.setEnabled(true);
			methodText.setEnabled(true);
			classText.setText(selected);
			setDirty(true);
			updateLaunchConfigurationDialog();
		}
	}
 
Example #2
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 #3
Source File: AbstractLaunchShortcut.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * COPIED/MODIFIED from AntLaunchShortcut
 */
protected ILaunchConfiguration chooseConfig(List<ILaunchConfiguration> configs) {
    if (configs.isEmpty()) {
        return null;
    }
    ILabelProvider labelProvider = DebugUITools.newDebugModelPresentation();
    ElementListSelectionDialog dialog = new ElementListSelectionDialog(Display.getDefault().getActiveShell(),
            labelProvider);
    dialog.setElements(configs.toArray(new ILaunchConfiguration[configs.size()]));
    dialog.setTitle("Pick a Python configuration");
    dialog.setMessage("Choose a python configuration to run");
    dialog.setMultipleSelection(false);
    int result = dialog.open();
    labelProvider.dispose();
    if (result == Window.OK) {
        return (ILaunchConfiguration) dialog.getFirstResult();
    } else {
        return null;
    }
}
 
Example #4
Source File: AbstractSarlLaunchShortcut.java    From sarl with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a configuration from the given collection of configurations that should be launched,
 * or {@code null} to cancel. Default implementation opens a selection dialog that allows
 * the user to choose one of the specified launch configurations.  Returns the chosen configuration,
 * or {@code null} if the user cancels.
 *
 * @param configList list of configurations to choose from.
 * @return configuration to launch or {@code null} to cancel.
 */
@SuppressWarnings("static-method")
protected ILaunchConfiguration chooseConfiguration(List<ILaunchConfiguration> configList) {
	final IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
	final ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
	dialog.setElements(configList.toArray());
	dialog.setTitle(Messages.AbstractSarlLaunchShortcut_0);
	dialog.setMessage(Messages.AbstractSarlLaunchShortcut_1);
	dialog.setMultipleSelection(false);
	final int result = dialog.open();
	labelProvider.dispose();
	if (result == Window.OK) {
		return (ILaunchConfiguration) dialog.getFirstResult();
	}
	return null;
}
 
Example #5
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 #6
Source File: SelectionConverter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Shows a dialog for resolving an ambiguous Java element. Utility method that can be called by subclasses.
 *
 * @param elements the elements to select from
 * @param shell the parent shell
 * @param title the title of the selection dialog
 * @param message the message of the selection dialog
 * @return returns the selected element or <code>null</code> if the dialog has been cancelled
 */
public static IJavaElement selectJavaElement(IJavaElement[] elements, Shell shell, String title, String message) {
	int nResults= elements.length;
	if (nResults == 0)
		return null;
	if (nResults == 1)
		return elements[0];

	int flags= JavaElementLabelProvider.SHOW_DEFAULT | JavaElementLabelProvider.SHOW_QUALIFIED | JavaElementLabelProvider.SHOW_ROOT;

	ElementListSelectionDialog dialog= new ElementListSelectionDialog(shell, new JavaElementLabelProvider(flags));
	dialog.setTitle(title);
	dialog.setMessage(message);
	dialog.setElements(elements);

	if (dialog.open() == Window.OK) {
		return (IJavaElement) dialog.getFirstResult();
	}
	return null;
}
 
Example #7
Source File: LaunchConfigurationUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns a configuration from the given collection of configurations that
 * should be launched, or <code>null</code> to cancel. Default implementation
 * opens a selection dialog that allows the user to choose one of the
 * specified launch configurations. Returns the chosen configuration, or
 * <code>null</code> if the user cancels.
 * 
 * @param configList list of configurations to choose from
 * @return configuration to launch or <code>null</code> to cancel
 */
public static ILaunchConfiguration chooseConfiguration(
    List<ILaunchConfiguration> configList, Shell shell) {
  IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
  try {
    ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell,
        labelProvider);
    dialog.setElements(configList.toArray());
    dialog.setTitle("Choose a launch configuration:");
    dialog.setMessage("More than one launch configuration is applicable; please choose one:");
    dialog.setMultipleSelection(false);
    int result = dialog.open();
    if (result == Window.OK) {
      return (ILaunchConfiguration) dialog.getFirstResult();
    }
    return null;
  } finally {
    labelProvider.dispose();
  }
}
 
Example #8
Source File: DotnetTestTab.java    From aCute with Eclipse Public License 2.0 6 votes vote down vote up
private void displayMethodSelectorDialog() {
	ElementListSelectionDialog dialog = new ElementListSelectionDialog(classBrowseButton.getShell(),
			new LabelProvider());
	dialog.setTitle(NLS.bind(Messages.DotnetTestTab_methodSelection_title, classText.getText()));
	dialog.setMessage(Messages.DotnetTestTab_methodSelection_message);
	List<String> methods = testMethods.get(classText.getText());
	if(methods!=null) {
		dialog.setElements(methods.toArray());
	}
	dialog.open();
	String selected = (String) dialog.getFirstResult();
	if (selected != null) {
		methodText.setText(selected);
		setDirty(true);
		updateLaunchConfigurationDialog();
	}
}
 
Example #9
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 #10
Source File: TestabilityLaunchConfigurationTab.java    From testability-explorer with Apache License 2.0 6 votes vote down vote up
private void setUpBrowseProjectDialog() {
  ILabelProvider projectLabelProvider = new BrowseProjectLabelProvider();

  IJavaProject[] javaProjects = javaProjectHelper.getJavaProjects();

  ElementListSelectionDialog dialog =
      new ElementListSelectionDialog(getControl().getShell(), projectLabelProvider);
  dialog.setMessage("Choose a project to run testability on:");

  if (javaProjects != null) {
    dialog.setElements(javaProjects);
  }

  if (dialog.open() == Window.OK) {
    IJavaProject project = (IJavaProject) dialog.getFirstResult();
    projectText.setText(project.getElementName());
    setTabDirty();
  }
}
 
Example #11
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 #12
Source File: CdtProjectFieldEditor.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected String changePressed() {
	ElementListSelectionDialog dialog =
		new ElementListSelectionDialog(getShell(), new LabelProvider());
	dialog.setTitle("CDT project selection");
	dialog.setMessage("Select an open CDT project:");
	dialog.setElements(CdtUtils.getCDTProjects().stream().map(p -> p.getName()).toArray());
	dialog.open();
	Object[] result = dialog.getResult();
	if (result != null && result.length > 0 && result[0] instanceof String) {
		return (String) result[0];
	}
	return null;
}
 
Example #13
Source File: ControlUtils.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T> T setElementsAndOpenDialog(ElementListSelectionDialog elementListDialog, Object[] elements)
		throws OperationCancellation {
	elementListDialog.setElements(elements);
	int result = elementListDialog.open();
	if(result != Window.OK) {
		throw new OperationCancellation();
	}
	
	return (T) elementListDialog.getFirstResult();
}
 
Example #14
Source File: BaseLaunchShortcut.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected ILaunchConfiguration chooseConfiguration(Indexable<ILaunchConfiguration> configs) 
		throws OperationCancellation {
	IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
	try {
		ElementListSelectionDialog dialog = new ElementListSelectionDialog(getActiveShell(), labelProvider);
		dialog.setTitle(LangUIMessages.LaunchShortcut_selectLaunch_title);
		dialog.setMessage(LangUIMessages.LaunchShortcut_selectLaunch_message);
		
		dialog.setMultipleSelection(false);
		return ControlUtils.setElementsAndOpenDialog(dialog, configs);
	} finally {
		labelProvider.dispose();
	}
}
 
Example #15
Source File: BaseLaunchShortcut.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected ILaunchable chooseLaunchable(ILaunchable[] launchTargets) throws OperationCancellation {
	ElementListSelectionDialog dialog = new ElementListSelectionDialog(getActiveShell(), 
		createLaunchTargetLabelProvider());
	dialog.setTitle(LangUIMessages.LaunchShortcut_selectLaunchableToLaunch);
	dialog.setMessage(LangUIMessages.LaunchShortcut_selectLaunchableToLaunch);
	
	return ControlUtils.setElementsAndOpenDialog(dialog, launchTargets);
}
 
Example #16
Source File: PySourceLocatorBase.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Ask the user to select one file of the given list of files (if some is available)
 *
 * @param files the files available for selection.
 * @return the selected file (from the files passed) or null if there was no file available for
 * selection or if the user canceled it.
 */
private IFile selectWorkspaceFile(final IFile[] files) {
    if (files == null || files.length == 0) {
        return null;
    }
    if (files.length == 1) {
        return files[0];
    }
    final List<IFile> selected = new ArrayList<IFile>();

    Runnable r = new Runnable() {
        @Override
        public void run() {
            Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new PyFileLabelProvider());
            dialog.setElements(files);
            dialog.setTitle("Select Workspace File");
            dialog.setMessage("File may be matched to multiple files in the workspace.");
            if (dialog.open() == Window.OK) {
                selected.add((IFile) dialog.getFirstResult());
            }
        }

    };
    if (Display.getCurrent() == null) { //not ui-thread
        Display.getDefault().syncExec(r);
    } else {
        r.run();
    }
    if (selected.size() > 0) {
        return selected.get(0);
    }
    return null;
}
 
Example #17
Source File: CordovaPluginSelectionPage.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private void createProjectGroup(Composite container) {
	Group grpProject = new Group(container, SWT.NONE);
	grpProject.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	grpProject.setText("Project");
	grpProject.setLayout(new GridLayout(3, false));
	Label lblProject = new Label(grpProject, SWT.NONE);
	lblProject.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	lblProject.setText("Project:");
	
	textProject = new Text(grpProject, SWT.BORDER);
	textProject.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	textProject.addListener(SWT.Modify, new Listener() {
		
		@Override
		public void handleEvent(Event event) {
			boolean isValidProject = isValidProject(textProject.getText());
			setPageComplete(validatePage());
			if(isValidProject && getPluginSourceType() == PLUGIN_SOURCE_REGISTRY){
				updateProjectOnViewer();
			}
		}
	});
	
	
	Button btnProjectBrowse = new Button(grpProject, SWT.NONE);
	btnProjectBrowse.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			ElementListSelectionDialog es = new ElementListSelectionDialog(getShell(), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
			es.setElements(HybridCore.getHybridProjects().toArray());
			es.setTitle("Project Selection");
			es.setMessage("Select a project to run");
			if (es.open() == Window.OK) {			
				HybridProject project = (HybridProject) es.getFirstResult();
				textProject.setText(project.getProject().getName());
			}		
		}
	});
	btnProjectBrowse.setText("Browse...");
}
 
Example #18
Source File: InitFinishMessageDialog.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@Override
protected Control createMessageArea(Composite composite) {
    // create image
    Image image = getImage();
    if (image != null) {
        imageLabel = new Label(composite, SWT.NULL);
        image.setBackground(imageLabel.getBackground());
        imageLabel.setImage(image);
        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).applyTo(imageLabel);
    }
    Link link = new Link(composite, SWT.WRAP);
    link.setText("Local runtime serview has been started, totally installed bundles: <a href=\"#\">" + bundlesName.length
            + "</a>.");

    link.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ElementListSelectionDialog report = new ElementListSelectionDialog(getShell(), new LabelProvider());
            report.setTitle("Installed bundles:");
            report.setMessage("Search bundle (? = any character, * = any string):");
            report.setElements(bundlesName);
            report.open();
        }
    });
    return composite;
}
 
Example #19
Source File: AbstractSarlScriptInteractiveSelector.java    From sarl with Apache License 2.0 5 votes vote down vote up
/**
 * Prompts the user to select an element from the given element types.
 *
 * @param elements the element types to choose from.
 * @return the selected element or {@code null} if none.
 */
private ElementDescription chooseElement(List<ElementDescription> elements) {
	final ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(),
			new LabelProvider());
	dialog.setElements(elements.toArray());
	dialog.setTitle(MessageFormat.format(Messages.AbstractSarlScriptInteractiveSelector_3, getElementLabel()));
	dialog.setMessage(MessageFormat.format(Messages.AbstractSarlScriptInteractiveSelector_3,
			getElementLongLabel()));
	dialog.setMultipleSelection(false);
	final int result = dialog.open();
	if (result == Window.OK) {
		return (ElementDescription) dialog.getFirstResult();
	}
	return null;
}
 
Example #20
Source File: AddImportOnSelectionAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public TypeNameMatch chooseImport(TypeNameMatch[] results, String containerName) {
	int nResults= results.length;

	if (nResults == 0) {
		return null;
	} else if (nResults == 1) {
		return results[0];
	}

	if (containerName.length() != 0) {
		for (int i= 0; i < nResults; i++) {
			TypeNameMatch curr= results[i];
			if (containerName.equals(curr.getTypeContainerName())) {
				return curr;
			}
		}
	}
	fIsShowing= true;
	ElementListSelectionDialog dialog= new ElementListSelectionDialog(fShell, new TypeNameMatchLabelProvider(TypeNameMatchLabelProvider.SHOW_FULLYQUALIFIED)) {
		@Override
		protected FilteredList createFilteredList(Composite parent) {
			FilteredList filteredList= super.createFilteredList(parent);
			filteredList.setComparator(ADD_IMPORT_COMPARATOR);
			return filteredList;
		}
	};
	dialog.setTitle(JavaEditorMessages.AddImportOnSelection_dialog_title);
	dialog.setMessage(JavaEditorMessages.AddImportOnSelection_dialog_message);
	dialog.setElements(results);
	if (dialog.open() == Window.OK) {
		fIsShowing= false;
		TypeNameMatch result= (TypeNameMatch) dialog.getFirstResult();
		QualifiedTypeNameHistory.remember(result.getFullyQualifiedName());
		return result;
	}
	fIsShowing= false;
	return null;
}
 
Example #21
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;
}
 
Example #22
Source File: FindAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IJavaElement findType(ICompilationUnit cu, boolean silent) {
	IType[] types= null;
	try {
		types= cu.getAllTypes();
	} catch (JavaModelException ex) {
		if (JavaModelUtil.isExceptionToBeLogged(ex))
			ExceptionHandler.log(ex, SearchMessages.JavaElementAction_error_open_message);
		if (silent)
			return RETURN_WITHOUT_BEEP;
		else
			return null;
	}
	if (types.length == 1 || (silent && types.length > 0))
		return types[0];
	if (silent)
		return RETURN_WITHOUT_BEEP;
	if (types.length == 0)
		return null;
	String title= SearchMessages.JavaElementAction_typeSelectionDialog_title;
	String message = SearchMessages.JavaElementAction_typeSelectionDialog_message;
	int flags= (JavaElementLabelProvider.SHOW_DEFAULT);

	ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider(flags));
	dialog.setTitle(title);
	dialog.setMessage(message);
	dialog.setElements(types);

	if (dialog.open() == Window.OK)
		return (IType)dialog.getFirstResult();
	else
		return RETURN_WITHOUT_BEEP;
}
 
Example #23
Source File: NLSAccessorConfigurationDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void browseForPropertyFile() {
	ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider());
	dialog.setIgnoreCase(false);
	dialog.setTitle(NLSUIMessages.NLSAccessorConfigurationDialog_Property_File_Selection);
	dialog.setMessage(NLSUIMessages.NLSAccessorConfigurationDialog_Choose_the_property_file);
	dialog.setElements(createFileListInput());
	dialog.setFilter('*' + NLSRefactoring.PROPERTY_FILE_EXT);
	if (dialog.open() == Window.OK) {
		IFile selectedFile= (IFile) dialog.getFirstResult();
		if (selectedFile != null)
			fResourceBundleFile.setText(selectedFile.getName());
	}
}
 
Example #24
Source File: PackageSelectionStringButtonAdapter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void changeControlPressed(DialogField field) {
	IPackageFragmentRoot root= fPackageSelectionField.getSelectedFragmentRoot();

	IJavaElement[] packages= null;
	try {
		if (root != null && root.exists()) {
			packages= root.getChildren();
		}
	} catch (JavaModelException e) {
		// no need to react
	}

	if (packages == null) {
		packages= new IJavaElement[0];
	}

	ElementListSelectionDialog dialog= new ElementListSelectionDialog(field.getLabelControl(null).getShell(),
		new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT));
	dialog.setIgnoreCase(true);

	dialog.setTitle(fTitle);
	dialog.setMessage(fMessage);
	dialog.setEmptyListMessage(fEmtpyListMessage);
	dialog.setElements(packages);

	// TODO initial selection
	//    List selection = new ArrayList();
	//    selection.add(fPackageSelectionField.fPackageSelection.getPackageFragment());
	//    dialog.setInitialElementSelections(selection);

	if (dialog.open() == Window.OK) {
		IPackageFragment fragment= (IPackageFragment)dialog.getFirstResult();
		fPackageSelectionField.setSelected(fragment);
	}
}
 
Example #25
Source File: PackageBrowseAdapter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void changeControlPressed(DialogField field) {
	ElementListSelectionDialog dialog= new ElementListSelectionDialog(
		Display.getCurrent().getActiveShell(), new JavaElementLabelProvider());
       dialog.setIgnoreCase(false);
       dialog.setTitle(NLSUIMessages.PackageBrowseAdapter_package_selection);
       dialog.setMessage(NLSUIMessages.PackageBrowseAdapter_choose_package);
       dialog.setElements(createPackageListInput(fCu, null));
       if (dialog.open() == Window.OK) {
       	IPackageFragment selectedPackage= (IPackageFragment)dialog.getFirstResult();
       	if (selectedPackage != null) {
       		fReceiver.setPackage(selectedPackage);
       	}
       }
}
 
Example #26
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 #27
Source File: NewModuleWizardPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private IPackageFragment choosePackage() {
  IPackageFragmentRoot root = getPackageFragmentRoot();
  IJavaElement[] packages = null;
  try {
    if (root != null && root.exists()) {
      packages = root.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);

  if (dialog.open() == Window.OK) {
    return (IPackageFragment) dialog.getFirstResult();
  }
  return null;
}
 
Example #28
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 #29
Source File: BrowserSelectionDialog.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Opens the dialog for the user to choose a browser.
 * 
 * @param initialSelection optional
 * @return the selected browser, or <code>null</code> if the dialog was
 *         canceled
 */
public static IBrowserDescriptor chooseBrowser(Shell shell,
    IBrowserDescriptor initialSelection) {

  ElementListSelectionDialog dialog = new BrowserSelectionDialog(shell,
      initialSelection);

  if (dialog.open() == Window.OK) {
    return (IBrowserDescriptor) dialog.getFirstResult();
  }

  return null;
}
 
Example #30
Source File: WinOptionsTab.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite comp = new Composite(parent, SWT.NONE);
	setControl(comp);
	comp.setLayout(new GridLayout(1, false));

	Group projectGroup = new Group(comp, SWT.NONE);
	projectGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
			false, 1, 1));
	projectGroup.setText(Messages.WinOptionsTab_ProjectGroup);
	projectGroup.setLayout(new GridLayout(3, false));

	Label projectLabel = new Label(projectGroup, SWT.NONE);
	projectLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
			false, 1, 1));
	projectLabel.setText(Messages.WinOptionsTab_ProjectLabel);

	projectText = new Text(projectGroup, SWT.BORDER);
	projectText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
			false, 1, 1));
	projectText.addListener(SWT.Modify, dirtyListener);

	Button browseButton = new Button(projectGroup, SWT.NONE);
	browseButton.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			ElementListSelectionDialog dialog = new ElementListSelectionDialog(
					getShell(), WorkbenchLabelProvider
							.getDecoratingWorkbenchLabelProvider());
			dialog.setTitle(Messages.WinOptionsTab_ProjectSelection);
			dialog.setMessage(Messages.WinOptionsTab_SelectonDesc);
			dialog.setElements(HybridCore.getHybridProjects().toArray());
			if (dialog.open() == Window.OK) {
				HybridProject project = (HybridProject) dialog
						.getFirstResult();
				projectText.setText(project.getProject().getName());
			}
		}
	});
	browseButton.setText(Messages.WinOptionsTab_BrowseLabel);

	Group emulatorGroup = new Group(comp, SWT.NONE);
	emulatorGroup.setLayout(new GridLayout(2, false));
	emulatorGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
			false, 1, 1));
	emulatorGroup.setText(Messages.WinOptionsTab_EmulatorGroup);

	Label deviceLabel = new Label(emulatorGroup, SWT.NONE);
	deviceLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
			false, 1, 1));
	deviceLabel.setText(Messages.WinOptionsTab_DeviceName);

	devicesCombo = new Combo(emulatorGroup, SWT.READ_ONLY);
	devicesCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
			false, 1, 1));
	devicesCombo.addListener(SWT.Selection, dirtyListener);

	if (devices != null && !devices.isEmpty()) {
		devicesCombo.add(DEFAULT_EMULATOR);
	}
}