Java Code Examples for org.eclipse.jdt.core.IClasspathEntry#CPE_LIBRARY

The following examples show how to use org.eclipse.jdt.core.IClasspathEntry#CPE_LIBRARY . 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: UserLibraryPreferencePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void doAdd(List<Object> list) {
	if (canAdd(list)) {
		CPUserLibraryElement parentLibrary = getSingleSelectedLibrary(list);
		
		IPath selection= getWorkbenchWindowSelection();
		
		IPath selectedPaths[] = BuildPathDialogAccess.chooseJAREntries(this.getShell(), selection, new IPath[0]);
		
		if (selectedPaths != null) {
			List<CPListElement> elements = new ArrayList<CPListElement>();
			for (int i= 0; i < selectedPaths.length; i++) {
				CPListElement cpElement = new CPListElement(parentLibrary, fDummyProject, IClasspathEntry.CPE_LIBRARY, selectedPaths[i], null);
				cpElement.setAttribute(CPListElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(cpElement));
				cpElement.setAttribute(CPListElement.JAVADOC, BuildPathSupport.guessJavadocLocation(cpElement));
				
				elements.add(cpElement);
				
				parentLibrary.add(cpElement);
			}
			fLibraryList.refresh(parentLibrary);
			fLibraryList.selectElements(new StructuredSelection(elements));
			fLibraryList.expandElement(parentLibrary, 2);
		}
	}
}
 
Example 2
Source File: JavaModelUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the classpath entry of the given package fragment root. This is the raw entry, except
 * if the root is a referenced library, in which case it's the resolved entry.
 * 
 * @param root a package fragment root
 * @return the corresponding classpath entry
 * @throws JavaModelException if accessing the entry failed
 * @since 3.6
 */
public static IClasspathEntry getClasspathEntry(IPackageFragmentRoot root) throws JavaModelException {
	IClasspathEntry rawEntry= root.getRawClasspathEntry();
	int rawEntryKind= rawEntry.getEntryKind();
	switch (rawEntryKind) {
		case IClasspathEntry.CPE_LIBRARY:
		case IClasspathEntry.CPE_VARIABLE:
		case IClasspathEntry.CPE_CONTAINER: // should not happen, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=305037
			if (root.isArchive() && root.getKind() == IPackageFragmentRoot.K_BINARY) {
				IClasspathEntry resolvedEntry= root.getResolvedClasspathEntry();
				if (resolvedEntry.getReferencingEntry() != null)
					return resolvedEntry;
				else
					return rawEntry;
			}
	}
	return rawEntry;
}
 
Example 3
Source File: LibrariesWorkbookPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private CPListElement[] openExternalClassFolderDialog(CPListElement existing) {
	if (existing == null) {
		IPath[] selected= BuildPathDialogAccess.chooseExternalClassFolderEntries(getShell());
		if (selected != null) {
			ArrayList<CPListElement> res= new ArrayList<CPListElement>();
			for (int i= 0; i < selected.length; i++) {
				res.add(new CPListElement(fCurrJProject, IClasspathEntry.CPE_LIBRARY, selected[i], null));
			}
			return res.toArray(new CPListElement[res.size()]);
		}
	} else {
		IPath configured= BuildPathDialogAccess.configureExternalClassFolderEntries(getShell(), existing.getPath());
		if (configured != null) {
			return new CPListElement[] { new CPListElement(fCurrJProject, IClasspathEntry.CPE_LIBRARY, configured, null) };
		}
	}
	return null;
}
 
Example 4
Source File: BuildPathDialogAccess.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Shows the UI for configuring a javadoc location attribute of the classpath entry. <code>null</code> is returned
 * if the user cancels the dialog. The dialog does not apply any changes.
 *
 * @param shell The parent shell for the dialog.
 * @param initialEntry The entry to edit. The kind of the classpath entry must be either
 * <code>IClasspathEntry.CPE_LIBRARY</code> or <code>IClasspathEntry.CPE_VARIABLE</code>.
 * @return Returns the resulting classpath entry containing a potentially modified javadoc location attribute
 * The resulting entry can be used to replace the original entry on the classpath.
 * Note that the dialog does not make any changes on the passed entry nor on the classpath that
 * contains it.
 *
 * @since 3.1
 */
public static IClasspathEntry configureJavadocLocation(Shell shell, IClasspathEntry initialEntry) {
	if (initialEntry == null) {
		throw new IllegalArgumentException();
	}
	int entryKind= initialEntry.getEntryKind();
	if (entryKind != IClasspathEntry.CPE_LIBRARY && entryKind != IClasspathEntry.CPE_VARIABLE) {
		throw new IllegalArgumentException();
	}

	URL location= JavaUI.getLibraryJavadocLocation(initialEntry);
	JavadocLocationDialog dialog=  new JavadocLocationDialog(shell, BasicElementLabels.getPathLabel(initialEntry.getPath(), false), location);
	if (dialog.open() == Window.OK) {
		CPListElement element= CPListElement.createFromExisting(initialEntry, null);
		URL res= dialog.getResult();
		element.setAttribute(CPListElement.JAVADOC, res != null ? res.toExternalForm() : null);
		return element.getClasspathEntry();
	}
	return null;
}
 
Example 5
Source File: JavadocContentAccess2.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static String getSourceAttachmentEncoding(IPackageFragmentRoot root) throws JavaModelException {
	String encoding= ResourcesPlugin.getEncoding();
	IClasspathEntry entry= root.getRawClasspathEntry();

	if (entry != null) {
		int kind= entry.getEntryKind();
		if (kind == IClasspathEntry.CPE_LIBRARY || kind == IClasspathEntry.CPE_VARIABLE) {
			IClasspathAttribute[] extraAttributes= entry.getExtraAttributes();
			for (int i= 0; i < extraAttributes.length; i++) {
				IClasspathAttribute attrib= extraAttributes[i];
				if (IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING.equals(attrib.getName())) {
					return attrib.getValue();
				}
			}
		}
	}

	return encoding;
}
 
Example 6
Source File: JavadocContentAccess2.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static String getSourceAttachmentEncoding(IPackageFragmentRoot root) throws JavaModelException {
	String encoding = ResourcesPlugin.getEncoding();
	IClasspathEntry entry = root.getRawClasspathEntry();

	if (entry != null) {
		int kind = entry.getEntryKind();
		if (kind == IClasspathEntry.CPE_LIBRARY || kind == IClasspathEntry.CPE_VARIABLE) {
			IClasspathAttribute[] extraAttributes = entry.getExtraAttributes();
			for (int i = 0; i < extraAttributes.length; i++) {
				IClasspathAttribute attrib = extraAttributes[i];
				if (IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING.equals(attrib.getName())) {
					return attrib.getValue();
				}
			}
		}
	}

	return encoding;
}
 
Example 7
Source File: HoverHandlerTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testHoverOnPackageWithNewJavadoc() throws Exception {
	// See org.eclipse.jdt.ls.tests/testresources/java-doc/readme.txt to generate the remote javadoc
	importProjects("eclipse/remote-javadoc");
	project = WorkspaceHelper.getProject("remote-javadoc");

	// First we need to attach our custom Javadoc to java-doc-0.0.1-SNAPSHOT.jar
	IJavaProject javaProject = JavaCore.create(project);
	IClasspathEntry[] classpath = javaProject.getRawClasspath();
	List<IClasspathEntry> newClasspath = new ArrayList<>(classpath.length);

	for (IClasspathEntry cpe : classpath) {
		if (cpe.getEntryKind() == IClasspathEntry.CPE_LIBRARY && cpe.getPath().lastSegment().equals("java-doc-0.0.1-SNAPSHOT.jar")) {
			String javadocPath = new File("testresources/java-doc/apidocs").getAbsoluteFile().toURI().toString();
			IClasspathAttribute atts[] = new IClasspathAttribute[] { JavaCore.newClasspathAttribute("javadoc_location", javadocPath) };
			IClasspathEntry newCpe = JavaCore.newLibraryEntry(cpe.getPath(), null, null, null, atts, false);
			newClasspath.add(newCpe);
		} else {
			newClasspath.add(cpe);
		}
	}

	javaProject.setRawClasspath(newClasspath.toArray(new IClasspathEntry[classpath.length]), monitor);

	handler = new HoverHandler(preferenceManager);
	//given
	//Hovers on the java.sql import
	String payload = createHoverRequest("src/main/java/foo/bar/Bar.java", 2, 14);
	TextDocumentPositionParams position = getParams(payload);

	//when
	Hover hover = handler.hover(position, monitor);
	assertNotNull(hover);
	String javadoc = hover.getContents().getLeft().get(1).getLeft();
	//Javadoc was read from file://.../org.eclipse.jdt.ls.tests/testresources/java-doc/apidocs/bar/foo/package-summary.html
	assertTrue(javadoc.contains("this doc is powered by **HTML5**"));
	assertFalse(javadoc.contains("----"));//no table nonsense

}
 
Example 8
Source File: WebAppProjectValidator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private boolean validateBuildClasspath(IJavaProject javaProject)
    throws CoreException {
  IPath webInfLibFolderLocation = null;

  IFolder webInfLibFolder = WebAppUtilities.getWebInfOut(getProject()).getFolder(
      "lib");

  if (webInfLibFolder.exists()) {
    webInfLibFolderLocation = webInfLibFolder.getLocation();
  }

  IClasspathEntry[] rawClasspaths = javaProject.getRawClasspath();
  boolean isOk = true;
  List<IPath> excludedJars = WebAppProjectProperties.getJarsExcludedFromWebInfLib(javaProject.getProject());

  for (IClasspathEntry rawClasspath : rawClasspaths) {
    rawClasspath = JavaCore.getResolvedClasspathEntry(rawClasspath);
    if (rawClasspath.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
      IPath entryPath = ResourceUtils.resolveToAbsoluteFileSystemPath(rawClasspath.getPath());
      if (excludedJars.contains(entryPath)) {
        continue;
      }

      if (webInfLibFolderLocation == null
          || !webInfLibFolderLocation.isPrefixOf(entryPath)) {
        MarkerUtilities.createQuickFixMarker(PROBLEM_MARKER_ID,
            ProjectStructureOrSdkProblemType.JAR_OUTSIDE_WEBINF_LIB,
            entryPath.toPortableString(), javaProject.getProject(),
            entryPath.toOSString());
        isOk = false;
      }
    }
  }

  return isOk;
}
 
Example 9
Source File: JavaDocLocations.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static URL getJavadocBaseLocation(IJavaElement element) throws JavaModelException {
	if (element.getElementType() == IJavaElement.JAVA_PROJECT) {
		return getProjectJavadocLocation((IJavaProject) element);
	}

	IPackageFragmentRoot root= JavaModelUtil.getPackageFragmentRoot(element);
	if (root == null) {
		return null;
	}

	if (root.getKind() == IPackageFragmentRoot.K_BINARY) {
		IClasspathEntry entry= root.getResolvedClasspathEntry();
		URL javadocLocation= getLibraryJavadocLocation(entry);
		if (javadocLocation != null) {
			return getLibraryJavadocLocation(entry);
		}
		entry= root.getRawClasspathEntry();
		switch (entry.getEntryKind()) {
			case IClasspathEntry.CPE_LIBRARY:
			case IClasspathEntry.CPE_VARIABLE:
				return getLibraryJavadocLocation(entry);
			default:
				return null;
		}
	} else {
		return getProjectJavadocLocation(root.getJavaProject());
	}
}
 
Example 10
Source File: CPListElement.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static void insert(CPListElement element, List<CPListElement> cpList) {
	int length= cpList.size();
	CPListElement[] elements= cpList.toArray(new CPListElement[length]);
	int i= 0;
	while (i < length && elements[i].getEntryKind() != element.getEntryKind()) {
		i++;
	}
	if (i < length) {
		i++;
		while (i < length && elements[i].getEntryKind() == element.getEntryKind()) {
			i++;
		}
		cpList.add(i, element);
		return;
	}

	switch (element.getEntryKind()) {
	case IClasspathEntry.CPE_SOURCE:
		cpList.add(0, element);
		break;
	case IClasspathEntry.CPE_CONTAINER:
	case IClasspathEntry.CPE_LIBRARY:
	case IClasspathEntry.CPE_PROJECT:
	case IClasspathEntry.CPE_VARIABLE:
	default:
		cpList.add(element);
		break;
	}
}
 
Example 11
Source File: BuildPathsBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private int getPageIndex(int entryKind) {
	switch (entryKind) {
		case IClasspathEntry.CPE_CONTAINER:
		case IClasspathEntry.CPE_LIBRARY:
		case IClasspathEntry.CPE_VARIABLE:
			return 2;
		case IClasspathEntry.CPE_PROJECT:
			return 1;
		case IClasspathEntry.CPE_SOURCE:
			return 0;
	}
	return 0;
}
 
Example 12
Source File: DialogPackageExplorer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
          try {
              if (element instanceof IFile) {
                  IFile file= (IFile) element;
                  if (file.getName().equals(".classpath") || file.getName().equals(".project")) //$NON-NLS-1$//$NON-NLS-2$
                      return false;
              } else if (element instanceof IPackageFragmentRoot) {
                  IClasspathEntry cpe= ((IPackageFragmentRoot)element).getRawClasspathEntry();
                  if (cpe == null || cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER || cpe.getEntryKind() == IClasspathEntry.CPE_LIBRARY || cpe.getEntryKind() == IClasspathEntry.CPE_VARIABLE)
                      return false;
              } else if (element instanceof PackageFragmentRootContainer) {
              	return false;
              } else if (element instanceof IPackageFragment) {
			IPackageFragment fragment= (IPackageFragment)element;
              	if (fragment.isDefaultPackage() && !fragment.hasChildren())
              		return false;
              } else if (element instanceof IFolder) {
              	IFolder folder= (IFolder)element;
              	if (folder.getName().startsWith(".")) //$NON-NLS-1$
              		return false;
              }
          } catch (JavaModelException e) {
              JavaPlugin.log(e);
          }
          /*if (element instanceof IPackageFragmentRoot) {
              IPackageFragmentRoot root= (IPackageFragmentRoot)element;
              if (root.getElementName().endsWith(".jar") || root.getElementName().endsWith(".zip")) //$NON-NLS-1$ //$NON-NLS-2$
                  return false;
          }*/
          return /*super.select(viewer, parentElement, element) &&*/ fOutputFolderFilter.select(viewer, parentElement, element);
      }
 
Example 13
Source File: JavaElementUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param root the package fragment root
 * @return array of projects that have the specified root on their classpath
 * @throws JavaModelException if getting the raw classpath or all Java projects fails
 */
public static IJavaProject[] getReferencingProjects(IPackageFragmentRoot root) throws JavaModelException {
	IClasspathEntry cpe= root.getRawClasspathEntry();
	if (cpe.getEntryKind() == IClasspathEntry.CPE_LIBRARY)
		cpe= root.getResolvedClasspathEntry();
	IJavaProject[] allJavaProjects= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();
	List<IJavaProject> result= new ArrayList<IJavaProject>(allJavaProjects.length);
	for (int i= 0; i < allJavaProjects.length; i++) {
		IJavaProject project= allJavaProjects[i];
		IPackageFragmentRoot[] roots= project.findPackageFragmentRoots(cpe);
		if (roots.length > 0)
			result.add(project);
	}
	return result.toArray(new IJavaProject[result.size()]);
}
 
Example 14
Source File: ClasspathEntry.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Answers an ID which is used to distinguish entries during package
 * fragment root computations
 */
public String rootID(){

	if (this.rootID == null) {
		switch(this.entryKind){
			case IClasspathEntry.CPE_LIBRARY :
				this.rootID = "[LIB]"+this.path;  //$NON-NLS-1$
				break;
			case IClasspathEntry.CPE_PROJECT :
				this.rootID = "[PRJ]"+this.path;  //$NON-NLS-1$
				break;
			case IClasspathEntry.CPE_SOURCE :
				this.rootID = "[SRC]"+this.path;  //$NON-NLS-1$
				break;
			case IClasspathEntry.CPE_VARIABLE :
				this.rootID = "[VAR]"+this.path;  //$NON-NLS-1$
				break;
			case IClasspathEntry.CPE_CONTAINER :
				this.rootID = "[CON]"+this.path;  //$NON-NLS-1$
				break;
			default :
				this.rootID = "";  //$NON-NLS-1$
				break;
		}
	}
	return this.rootID;
}
 
Example 15
Source File: JavaDocLocations.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static URL getJavadocBaseLocation(IJavaElement element) throws JavaModelException {
	if (element.getElementType() == IJavaElement.JAVA_PROJECT) {
		return getProjectJavadocLocation((IJavaProject) element);
	}

	IPackageFragmentRoot root = JavaModelUtil.getPackageFragmentRoot(element);
	if (root == null) {
		return null;
	}

	if (root.getKind() == IPackageFragmentRoot.K_BINARY) {
		IClasspathEntry entry = root.getResolvedClasspathEntry();
		URL javadocLocation = getLibraryJavadocLocation(entry);
		if (javadocLocation != null) {
			return getLibraryJavadocLocation(entry);
		}
		entry = root.getRawClasspathEntry();
		switch (entry.getEntryKind()) {
			case IClasspathEntry.CPE_LIBRARY:
			case IClasspathEntry.CPE_VARIABLE:
				return getLibraryJavadocLocation(entry);
			default:
				return null;
		}
	} else {
		return getProjectJavadocLocation(root.getJavaProject());
	}
}
 
Example 16
Source File: ClasspathModifier.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean isExternalArchiveOrLibrary(CPListElement entry) {
	if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY || entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
		if (entry.getResource() instanceof IFolder) {
			return false;
		}
		return true;
	}
	return false;
}
 
Example 17
Source File: Importer.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Make sure all the relevant backoffice jars are exported
 * 
 * @param monitor
 * @param javaProject
 * @throws JavaModelException
 */
private void fixBackofficeJars(IProgressMonitor monitor, IJavaProject javaProject) throws JavaModelException
{
	if (javaProject.getProject().getName().equalsIgnoreCase("backoffice"))
	{
		List<IClasspathEntry> entries = new LinkedList<IClasspathEntry>();
		IClasspathEntry[] classPathEntries = javaProject.getRawClasspath();
		boolean change = false;
		for (IClasspathEntry classpathEntry : classPathEntries) {
			// fix jar files
			if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
				if (classpathEntry.getPath().toString().contains("/backoffice/web/webroot/WEB-INF/lib/backoffice-core-") || 
						classpathEntry.getPath().toString().contains("/backoffice/web/webroot/WEB-INF/lib/backoffice-widgets-") ||
						classpathEntry.getPath().toString().contains("/backoffice/web/webroot/WEB-INF/lib/cockpitframework-") ||
						classpathEntry.getPath().toString().contains("/backoffice/web/webroot/WEB-INF/lib/cockpitcore-") ||
						classpathEntry.getPath().toString().contains("/backoffice/web/webroot/WEB-INF/lib/cockpittesting-") ||
						classpathEntry.getPath().toString().contains("/backoffice/web/webroot/WEB-INF/lib/cockpitwidgets-") ||
						classpathEntry.getPath().toString().contains("/backoffice/web/webroot/WEB-INF/lib/cockpit-") ||
						classpathEntry.getPath().toString().contains("/backoffice/web/webroot/WEB-INF/lib/zk") ||
						classpathEntry.getPath().toString().contains("/backoffice/web/webroot/WEB-INF/lib/zul-") ||
						classpathEntry.getPath().toString().contains("/backoffice/web/webroot/WEB-INF/lib/zcommon-"))
				{
					if (!classpathEntry.isExported())
					{
						change = true;
						IClasspathEntry clonedEntry = JavaCore.newLibraryEntry(classpathEntry.getPath(), classpathEntry.getSourceAttachmentPath(), classpathEntry.getSourceAttachmentRootPath(), classpathEntry.getAccessRules(), classpathEntry.getExtraAttributes(), true);
						entries.add(clonedEntry);
						continue;
					}			
				}
			}
			entries.add(classpathEntry);	
		}
		if (change)
		{
			FixProjectsUtils.setClasspath(entries.toArray(new IClasspathEntry[entries.size()]), javaProject, monitor);	
		}
	}
}
 
Example 18
Source File: IDEClassPathBlock.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void editElementEntry( IDECPListElement elem )
{
	IDECPListElement[] res = null;

	switch ( elem.getEntryKind( ) )
	{
		case IClasspathEntry.CPE_LIBRARY :
			IResource resource = elem.getResource( );
			if ( resource == null )
			{
				File file = elem.getPath( ).toFile( );
				if ( file.isDirectory( ) )
				{
					res = openExternalClassFolderDialog( elem );
				}
				else
				{
					res = openExtJarFileDialog( elem );
				}
			}
			else if ( resource.getType( ) == IResource.FILE )
			{
				res = openJarFileDialog( elem );
			}
			break;
		case IClasspathEntry.CPE_VARIABLE :
			res = openVariableSelectionDialog( elem );
			break;
	}
	if ( res != null && res.length > 0 )
	{
		IDECPListElement curr = res[0];
		curr.setExported( elem.isExported( ) );
		// curr.setAttributesFromExisting(elem);
		fLibrariesList.replaceElement( elem, curr );
		if ( elem.getEntryKind( ) == IClasspathEntry.CPE_VARIABLE )
		{
			fLibrariesList.refresh( );
		}
	}

}
 
Example 19
Source File: LibrariesWorkbookPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private void editElementEntry(CPListElement elem) {
	CPListElement[] res= null;

	switch (elem.getEntryKind()) {
	case IClasspathEntry.CPE_CONTAINER:
		res= openContainerSelectionDialog(elem);
		break;
	case IClasspathEntry.CPE_LIBRARY:
		IResource resource= elem.getResource();
		if (resource == null) {
			File file= elem.getPath().toFile();
			if (file.isDirectory()) {
				res= openExternalClassFolderDialog(elem);
			} else {
				res= openExtJarFileDialog(elem);
			}
		} else if (resource.getType() == IResource.FOLDER) {
			if (resource.exists()) {
				res= openClassFolderDialog(elem);
			} else {
				res= openNewClassFolderDialog(elem);
			}
		} else if (resource.getType() == IResource.FILE) {
			res= openJarFileDialog(elem);
		}
		break;
	case IClasspathEntry.CPE_VARIABLE:
		res= openVariableSelectionDialog(elem);
		break;
	}
	if (res != null && res.length > 0) {
		CPListElement curr= res[0];
		curr.setExported(elem.isExported());
		curr.setAttributesFromExisting(elem);
		fLibrariesList.replaceElement(elem, curr);
		if (elem.getEntryKind() == IClasspathEntry.CPE_VARIABLE) {
			fLibrariesList.refresh();
		}
	}

}
 
Example 20
Source File: LibrariesWorkbookPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public boolean isEntryKind(int kind) {
	return kind == IClasspathEntry.CPE_LIBRARY || kind == IClasspathEntry.CPE_VARIABLE || kind == IClasspathEntry.CPE_CONTAINER;
}