List of usage examples for org.eclipse.jdt.core IClasspathEntry CPE_PROJECT
int CPE_PROJECT
To view the source code for org.eclipse.jdt.core IClasspathEntry CPE_PROJECT.
Click Source Link
From source file:org.eclipse.birt.report.designer.internal.ui.ide.adapters.IDEClassPathBlock.java
License:Open Source License
private int getType(IDECPListElement element) { int kind = element.getEntryKind(); if (kind == IClasspathEntry.CPE_VARIABLE) { return VAR_TYPE; } else if (kind == IClasspathEntry.CPE_PROJECT) { return PROJECT_TYPE; } else if (kind == IClasspathEntry.CPE_LIBRARY) { IResource resource = element.getResource(); if (resource instanceof IFile) { return JAR_TYPE; }//from w ww . ja v a2 s .c o m if (resource instanceof IContainer) { return FOL_TYPE; } IPath path = element.getPath(); File file = path.toFile(); if (file.isFile()) { return EXTJAR_TYPE; } else { return ADDFOL_TYPE; } } return UNKNOW_TYPE; }
From source file:org.eclipse.birt.report.designer.internal.ui.ide.adapters.IDEClassPathBlock.java
License:Open Source License
private IDECPListElement[] addProjectDialog() { try {/*from w ww . ja v a 2 s . co m*/ Object[] selectArr = getNotYetRequiredProjects(); new JavaElementComparator().sort(null, selectArr); ListSelectionDialog dialog = new ListSelectionDialog(getShell(), Arrays.asList(selectArr), new ArrayContentProvider(), new ProjectLabelProvider(), Messages.getString("IDEClassPathBlock.ProjectDialog_message")); //$NON-NLS-1$ dialog.setTitle(Messages.getString("IDEClassPathBlock.ProjectDialog_title")); //$NON-NLS-1$ dialog.setHelpAvailable(false); if (dialog.open() == Window.OK) { Object[] result = dialog.getResult(); IDECPListElement[] cpElements = new IDECPListElement[result.length]; for (int i = 0; i < result.length; i++) { IJavaProject curr = ((IJavaProject) result[i]); cpElements[i] = new IDECPListElement(IClasspathEntry.CPE_PROJECT, curr.getPath(), curr.getResource()); } return cpElements; } } catch (JavaModelException e) { return null; } return null; }
From source file:org.eclipse.birt.report.designer.internal.ui.ide.adapters.IDEClassPathBlock.java
License:Open Source License
private Object[] getNotYetRequiredProjects() throws JavaModelException { ArrayList selectable = new ArrayList(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject[] projects = root.getProjects(); for (int i = 0; i < projects.length; i++) { if (isJavaProject(projects[i])) { selectable.add(JavaCore.create(projects[i])); }//from w w w . jav a 2 s.c om } if (isJavaProject(getProject())) { selectable.remove(JavaCore.create(getProject())); } List elements = fLibrariesList.getElements(); for (int i = 0; i < elements.size(); i++) { IDECPListElement curr = (IDECPListElement) elements.get(i); if (curr.getEntryKind() != IClasspathEntry.CPE_PROJECT) { continue; } IJavaProject proj = (IJavaProject) JavaCore.create(curr.getResource()); selectable.remove(proj); } Object[] selectArr = selectable.toArray(); return selectArr; }
From source file:org.eclipse.birt.report.designer.internal.ui.ide.adapters.IDECPListElement.java
License:Open Source License
private IClasspathEntry newClasspathEntry() { IClasspathAttribute[] extraAttributes = new IClasspathAttribute[0]; switch (fEntryKind) { case IClasspathEntry.CPE_SOURCE: return JavaCore.newSourceEntry(fPath, null, null, null, extraAttributes); case IClasspathEntry.CPE_LIBRARY: { return JavaCore.newLibraryEntry(fPath, null, null, null, extraAttributes, isExported()); }// ww w.j av a 2 s . co m case IClasspathEntry.CPE_PROJECT: { return JavaCore.newProjectEntry(fPath, null, false, extraAttributes, isExported()); } case IClasspathEntry.CPE_CONTAINER: { return JavaCore.newContainerEntry(fPath, null, extraAttributes, isExported()); } case IClasspathEntry.CPE_VARIABLE: { return JavaCore.newVariableEntry(fPath, null, null, null, extraAttributes, isExported()); } default: return null; } }
From source file:org.eclipse.birt.report.designer.internal.ui.ide.adapters.IDECPListLabelProvider.java
License:Open Source License
public String getCPListElementText(IDECPListElement cpentry) { IPath path = cpentry.getPath();/* w w w .j a v a 2 s. c o m*/ switch (cpentry.getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: { IResource resource = cpentry.getResource(); if (resource instanceof IContainer) { StringBuffer buf = new StringBuffer(getPathLabel(path, false)); buf.append(' '); buf.append(fClassLabel); if (!resource.exists()) { buf.append(' '); if (cpentry.isMissing()) { buf.append(fMissing); } else { buf.append(fNewLabel); } } return buf.toString(); } else { String label = getPathString(path, resource == null); if (cpentry.isMissing()) { label = label + ' ' + fMissing; } return label; } } case IClasspathEntry.CPE_VARIABLE: { String label = getVariableString(path); if (cpentry.isMissing()) { label = label + ' ' + fMissing; } return label; } case IClasspathEntry.CPE_PROJECT: String label = path.lastSegment(); if (cpentry.isMissing()) { label = label + ' ' + fMissing; } return label; case IClasspathEntry.CPE_SOURCE: { String pathLabel = getPathLabel(path, false); StringBuffer buf = new StringBuffer(pathLabel); IResource resource = cpentry.getResource(); if (resource != null && !resource.exists()) { buf.append(' '); if (cpentry.isMissing()) { buf.append(fMissing); } else { buf.append(fNewLabel); } } else if (cpentry.getOrginalPath() == null) { buf.append(' '); buf.append(fNewLabel); } return buf.toString(); } default: // pass } return Messages.getString("IDECPListLabelProvider.unknown"); //$NON-NLS-1$ }
From source file:org.eclipse.birt.report.designer.internal.ui.ide.adapters.IDECPListLabelProvider.java
License:Open Source License
private Image getCPListElementBaseImage(IDECPListElement cpentry) { switch (cpentry.getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: IResource res = cpentry.getResource(); if (res == null) { if (isArchivePath(cpentry.getPath(), false)) { return ReportPlatformUIImages.getImage(IReportGraphicConstants.ICON_NODE_EXTJAR); } else { return ReportPlatformUIImages.getImage(IReportGraphicConstants.ICON_NODE_EXTFOL); }// w w w.ja v a 2 s . co m } else if (res instanceof IFile) { return ReportPlatformUIImages.getImage(IReportGraphicConstants.ICON_NODE_JAR); } else { return ReportPlatformUIImages.getImage(IReportGraphicConstants.ICON_NODE_FOL); } case IClasspathEntry.CPE_PROJECT: return ReportPlugin.getDefault().getWorkbench().getSharedImages() .getImage(IDE.SharedImages.IMG_OBJ_PROJECT); case IClasspathEntry.CPE_VARIABLE: return ReportPlatformUIImages.getImage(IReportGraphicConstants.ICON_NODE_VARIABLE); default: return null; } }
From source file:org.eclipse.birt.report.designer.internal.ui.ide.adapters.IDEReportClasspathResolver.java
License:Open Source License
private List<String> getAllClassPathFromEntries(List<IClasspathEntry> list) { List<String> retValue = new ArrayList(); IWorkspace space = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = space.getRoot(); for (int i = 0; i < list.size(); i++) { IClasspathEntry curr = list.get(i); boolean inWorkSpace = true; if (space == null || space.getRoot() == null) { inWorkSpace = false;//from w w w. j a v a 2 s .com } IPath path = curr.getPath(); if (curr.getEntryKind() == IClasspathEntry.CPE_VARIABLE) { path = JavaCore.getClasspathVariable(path.segment(0)); } else { path = JavaCore.getResolvedClasspathEntry(curr).getPath(); } if (curr.getEntryKind() == IClasspathEntry.CPE_PROJECT) { if (root.findMember(path) instanceof IProject) { List<String> strs = getProjectClasspath((IProject) root.findMember(path), false, true); for (int j = 0; j < strs.size(); j++) { addToList(retValue, strs.get(j)); } } } else { if (root.findMember(path) == null) { inWorkSpace = false; } if (inWorkSpace) { String absPath = getFullPath(path, root.findMember(path).getProject()); //retValue.add( absPath ); addToList(retValue, absPath); } else { //retValue.add( path.toFile( ).getAbsolutePath( )); addToList(retValue, path.toFile().getAbsolutePath()); } } //strs.add( JavaCore.getResolvedClasspathEntry( entry ).getPath( ).toFile( ).getAbsolutePath( ) ); } return retValue; }
From source file:org.eclipse.birt.report.designer.internal.ui.ide.adapters.IDEReportClasspathResolver.java
License:Open Source License
private List<String> resolveClasspathEntries(IClasspathEntry[] classpathEntries, boolean needExported, IJavaProject project) {/*from w w w. jav a 2 s. c o m*/ ArrayList<String> newClassPath = new ArrayList<String>(); IWorkspace space = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = space.getRoot(); for (int i = 0; i < classpathEntries.length; i++) { IClasspathEntry curr = classpathEntries[i]; if (!needExported && !curr.isExported() && curr.getEntryKind() != IClasspathEntry.CPE_VARIABLE) { continue; } IPath path = curr.getPath(); // if (curr.getEntryKind( ) == IClasspathEntry.CPE_VARIABLE) // { // path = JavaCore.getClasspathVariable( path.segment( 0 ) ); // } // else // { path = JavaCore.getResolvedClasspathEntry(curr).getPath(); // } if (project != null && curr.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { try { IClasspathContainer contianer = JavaCore.getClasspathContainer(path, project); if (contianer != null && contianer.getKind() == IClasspathContainer.K_APPLICATION) { IClasspathEntry[] entrys = contianer.getClasspathEntries(); List<String> list = resolveClasspathEntries(entrys, needExported, project); for (int j = 0; j < list.size(); j++) { addToList(newClassPath, list.get(j)); } } } catch (JavaModelException e) { //do nothing } continue; } if (curr.getEntryKind() == IClasspathEntry.CPE_SOURCE) { path = curr.getOutputLocation(); } if (path == null) { continue; } if (curr.getEntryKind() == IClasspathEntry.CPE_PROJECT) { if (root.findMember(path) instanceof IProject) { List<String> strs = getProjectClasspath((IProject) root.findMember(path), false, false); for (int j = 0; j < strs.size(); j++) { addToList(newClassPath, strs.get(j)); } } } else if (curr.getEntryKind() == IClasspathEntry.CPE_LIBRARY || curr.getEntryKind() == IClasspathEntry.CPE_VARIABLE || curr.getEntryKind() == IClasspathEntry.CPE_SOURCE) { boolean inWorkSpace = true; if (space == null || space.getRoot() == null) { inWorkSpace = false; } if (root.findMember(path) == null) { inWorkSpace = false; } if (inWorkSpace) { String absPath = getFullPath(path, root.findMember(path).getProject()); //URL url = new URL( "file:///" + absPath );//$NON-NLS-1$//file:/ //newClassPath.add( url.getPath( ) ); newClassPath.add(absPath); } else { // newClassPath.add( curr.getPath( ) // .toFile( ) // .toURI( ) // .toURL( ) ); newClassPath.add(path.toFile().getAbsolutePath()); } } } return newClassPath; }
From source file:org.eclipse.buckminster.jdt.internal.ClasspathEmitter.java
License:Open Source License
private static void appendPaths(IJavaModel model, IProject project, String target, List<IPath> path, HashSet<IPath> seenPaths, HashSet<String> seenProjects, boolean atTop) throws CoreException { Logger log = Buckminster.getLogger(); String projectName = project.getName(); if (seenProjects.contains(projectName)) return;/*from ww w . java2s . c o m*/ seenProjects.add(projectName); log.debug("Emitting classpath for project %s...", projectName); //$NON-NLS-1$ IJavaProject javaProject = model.getJavaProject(projectName); IClasspathEntry[] entries; if (javaProject == null || !javaProject.exists()) { // The project may still be a component that exports jar files. // BMClasspathContainer container = new BMClasspathContainer(project, target); entries = container.getClasspathEntries(); log.debug(" not a java project, contains %d entries", Integer.valueOf(entries.length)); //$NON-NLS-1$ } else { entries = (atTop && target != null) ? changeClasspathForTarget(javaProject, target) : javaProject.getResolvedClasspath(false); log.debug(" java project, contains %d entries", Integer.valueOf(entries.length)); //$NON-NLS-1$ } for (IClasspathEntry entry : entries) { IPath entryPath; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: log.debug(" found library with path: %s", entry.getPath()); //$NON-NLS-1$ if (!(atTop || entry.isExported())) { log.debug(" skipping path %s. It's neither at top nor exported", entry.getPath()); //$NON-NLS-1$ continue; } entryPath = entry.getPath(); break; case IClasspathEntry.CPE_SOURCE: entryPath = entry.getOutputLocation(); if (entryPath == null) { // Uses default output location // IJavaProject proj = model.getJavaProject(entry.getPath().segment(0)); if (proj == null) continue; entryPath = proj.getOutputLocation(); } log.debug(" found source with path: %s", entryPath); //$NON-NLS-1$ break; case IClasspathEntry.CPE_PROJECT: projectName = entry.getPath().segment(0); log.debug(" found project: %s", projectName); //$NON-NLS-1$ if (!(atTop || entry.isExported())) { log.debug(" skipping project %s. It's neither at top nor exported", projectName); //$NON-NLS-1$ continue; } IProject conProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); appendPaths(model, conProject, null, path, seenPaths, seenProjects, false); continue; default: throw BuckminsterException.fromMessage(Messages.unexpected_classpath_entry_kind); } IResource folder = ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath); if (folder != null) { log.debug(" path %s is inside workspace, switching to %s", entryPath, folder.getLocation()); //$NON-NLS-1$ entryPath = folder.getLocation(); } if (!seenPaths.contains(entryPath)) { seenPaths.add(entryPath); path.add(entryPath); log.debug(" path %s added", entryPath); //$NON-NLS-1$ } } }
From source file:org.eclipse.buildship.core.workspace.internal.GradleClasspathContainerRuntimeClasspathEntryResolver.java
License:Open Source License
private void collectContainerRuntimeClasspath(IClasspathContainer container, List<IRuntimeClasspathEntry> result, boolean includeExportedEntriesOnly, LaunchConfigurationScope configurationScopes) throws CoreException { for (final IClasspathEntry cpe : container.getClasspathEntries()) { if (!includeExportedEntriesOnly || cpe.isExported()) { if (cpe.getEntryKind() == IClasspathEntry.CPE_LIBRARY && configurationScopes.isEntryIncluded(cpe)) { result.add(JavaRuntime.newArchiveRuntimeClasspathEntry(cpe.getPath())); } else if (cpe.getEntryKind() == IClasspathEntry.CPE_PROJECT) { Optional<IProject> candidate = findAccessibleJavaProject(cpe.getPath().segment(0)); if (candidate.isPresent()) { IJavaProject dependencyProject = JavaCore.create(candidate.get()); IRuntimeClasspathEntry projectRuntimeEntry = JavaRuntime .newProjectRuntimeClasspathEntry(dependencyProject); // add the project entry itself so that the source lookup can find the classes // see https://github.com/eclipse/buildship/issues/383 result.add(projectRuntimeEntry); Collections.addAll(result, JavaRuntime.resolveRuntimeClasspathEntry(projectRuntimeEntry, dependencyProject)); collectContainerRuntimeClasspathIfPresent(dependencyProject, result, true, configurationScopes); }/*from ww w. j ava2 s .c o m*/ } } } }