Java Code Examples for org.eclipse.ui.dialogs.ElementTreeSelectionDialog#getResult()

The following examples show how to use org.eclipse.ui.dialogs.ElementTreeSelectionDialog#getResult() . 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: TestabilityLaunchConfigurationTab.java    From testability-explorer with Apache License 2.0 5 votes vote down vote up
private void setUpWhitelistPackagesDialog() {
  IJavaProject project = getSelectedProject();
  ElementTreeSelectionDialog dialog =
      new ElementTreeSelectionDialog(getControl().getShell(),
          new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_BASICS),
          new JavaPackageElementContentProvider());
  dialog.setInput(project);
  dialog.addFilter(new ViewerFilter() {

    @Override
    public boolean select(Viewer viewer, Object parentElement, Object element) {
      if (element instanceof IPackageFragment) {
        return !((IPackageFragment) element).getElementName().equals("");
      }
      if (element instanceof ICompilationUnit) {
        return false;
      }
      return true;
    }
    
  });
  dialog.setMessage("Choose packages to whitelist:");

  if (dialog.open() == Window.OK) {
    Object[] results = dialog.getResult();
    String[] stringArray = new String[results.length];
    for (int i = 0; i < results.length; i++) {
      if (results[i] instanceof IJavaElement) {
        stringArray[i] = ((IJavaElement) results[i]).getElementName();
      }
    }
    whiteListList.add(stringArray);
    setTabDirty();
  }
}
 
Example 2
Source File: JarManifestWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected void handleManifestFileBrowseButtonPressed() {
	ElementTreeSelectionDialog dialog= createWorkspaceFileSelectionDialog(JarPackagerMessages.JarManifestWizardPage_manifestSelectionDialog_title, JarPackagerMessages.JarManifestWizardPage_manifestSelectionDialog_message);
	if (fJarPackage.isManifestAccessible())
		dialog.setInitialSelections(new IResource[] {fJarPackage.getManifestFile()});
	if (dialog.open() ==  Window.OK) {
		Object[] resources= dialog.getResult();
		if (resources.length != 1)
			setErrorMessage(JarPackagerMessages.JarManifestWizardPage_error_onlyOneManifestMustBeSelected);
		else {
			setErrorMessage(""); //$NON-NLS-1$
			fJarPackage.setManifestLocation(((IResource)resources[0]).getFullPath());
			fManifestFileText.setText(fJarPackage.getManifestLocation().toString());
		}
	}
}