List of usage examples for org.eclipse.jdt.core IClasspathEntry CPE_CONTAINER
int CPE_CONTAINER
To view the source code for org.eclipse.jdt.core IClasspathEntry CPE_CONTAINER.
Click Source Link
From source file:org.eclipse.ajdt.core.AspectJCorePreferences.java
License:Open Source License
private static void addAttribute(IJavaProject jp, IClasspathEntry entry, IClasspathAttribute attr) { try {/*from w w w .j a v a2s . co m*/ IClasspathEntry[] cp = jp.getRawClasspath(); for (int i = 0; i < cp.length; i++) { if (cp[i].equals(entry)) { IClasspathAttribute[] attributes = cp[i].getExtraAttributes(); IClasspathAttribute[] newattrib = new IClasspathAttribute[attributes.length + 1]; System.arraycopy(attributes, 0, newattrib, 0, attributes.length); newattrib[attributes.length] = attr; switch (cp[i].getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: cp[i] = JavaCore.newLibraryEntry(cp[i].getPath(), cp[i].getSourceAttachmentPath(), cp[i].getSourceAttachmentRootPath(), cp[i].getAccessRules(), newattrib, cp[i].isExported()); break; case IClasspathEntry.CPE_VARIABLE: cp[i] = JavaCore.newVariableEntry(cp[i].getPath(), cp[i].getSourceAttachmentPath(), cp[i].getSourceAttachmentRootPath(), cp[i].getAccessRules(), newattrib, cp[i].isExported()); break; case IClasspathEntry.CPE_CONTAINER: cp[i] = JavaCore.newContainerEntry(cp[i].getPath(), cp[i].getAccessRules(), newattrib, cp[i].isExported()); break; case IClasspathEntry.CPE_PROJECT: cp[i] = JavaCore.newProjectEntry(cp[i].getPath(), cp[i].getAccessRules(), true, newattrib, cp[i].isExported()); break; } } } jp.setRawClasspath(cp, null); } catch (JavaModelException e) { } }
From source file:org.eclipse.ajdt.core.AspectJCorePreferences.java
License:Open Source License
public static void removeAttribute(IJavaProject jp, IClasspathEntry entry, IClasspathAttribute attr) { try {/*w w w .jav a 2 s . co m*/ IClasspathEntry[] cp = jp.getRawClasspath(); for (int i = 0; i < cp.length; i++) { if (cp[i].equals(entry)) { IClasspathAttribute[] attributes = cp[i].getExtraAttributes(); IClasspathAttribute[] newattrib = new IClasspathAttribute[attributes.length - 1]; int count = 0; for (int j = 0; j < attributes.length; j++) { if (!attributes[j].getName().equals(attr.getName())) { newattrib[count++] = attributes[j]; } } switch (cp[i].getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: cp[i] = JavaCore.newLibraryEntry(cp[i].getPath(), cp[i].getSourceAttachmentPath(), cp[i].getSourceAttachmentRootPath(), cp[i].getAccessRules(), newattrib, cp[i].isExported()); break; case IClasspathEntry.CPE_VARIABLE: cp[i] = JavaCore.newVariableEntry(cp[i].getPath(), cp[i].getSourceAttachmentPath(), cp[i].getSourceAttachmentRootPath(), cp[i].getAccessRules(), newattrib, cp[i].isExported()); break; case IClasspathEntry.CPE_CONTAINER: cp[i] = JavaCore.newContainerEntry(cp[i].getPath(), cp[i].getAccessRules(), newattrib, cp[i].isExported()); break; case IClasspathEntry.CPE_PROJECT: cp[i] = JavaCore.newProjectEntry(cp[i].getPath(), cp[i].getAccessRules(), true, newattrib, cp[i].isExported()); break; } } } jp.setRawClasspath(cp, null); } catch (JavaModelException e) { } }
From source file:org.eclipse.ajdt.core.AspectJCorePreferences.java
License:Open Source License
/** * Remove all occurrences of an attribute * @param javaProject/*from w w w .j a v a 2 s.c om*/ * @param attribute */ private static void removeAttribute(IJavaProject javaProject, IClasspathAttribute attribute) { try { IClasspathEntry[] cp = javaProject.getRawClasspath(); boolean changed = false; for (int i = 0; i < cp.length; i++) { IClasspathAttribute[] attributes = cp[i].getExtraAttributes(); boolean found = false; for (int j = 0; !found && (j < attributes.length); j++) { if (attributes[j].getName().equals(attribute.getName())) { found = true; } } if (found) { changed = true; IClasspathAttribute[] newattrib = new IClasspathAttribute[attributes.length - 1]; int count = 0; for (int j = 0; j < attributes.length; j++) { if (!attributes[j].getName().equals(attribute.getName())) { newattrib[count++] = attributes[j]; } } switch (cp[i].getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: cp[i] = JavaCore.newLibraryEntry(cp[i].getPath(), cp[i].getSourceAttachmentPath(), cp[i].getSourceAttachmentRootPath(), cp[i].getAccessRules(), newattrib, cp[i].isExported()); break; case IClasspathEntry.CPE_VARIABLE: cp[i] = JavaCore.newVariableEntry(cp[i].getPath(), cp[i].getSourceAttachmentPath(), cp[i].getSourceAttachmentRootPath(), cp[i].getAccessRules(), newattrib, cp[i].isExported()); break; case IClasspathEntry.CPE_CONTAINER: cp[i] = JavaCore.newContainerEntry(cp[i].getPath(), cp[i].getAccessRules(), newattrib, cp[i].isExported()); break; case IClasspathEntry.CPE_PROJECT: cp[i] = JavaCore.newProjectEntry(cp[i].getPath(), cp[i].getAccessRules(), true, newattrib, cp[i].isExported()); break; } } } if (changed) { javaProject.setRawClasspath(cp, null); } } catch (JavaModelException e) { } }
From source file:org.eclipse.ajdt.core.AspectJCorePreferences.java
License:Open Source License
private static void addEntryToJavaBuildPath(IJavaProject jp, IClasspathAttribute attribute, String path, int eKind) { IClasspathAttribute[] attributes = new IClasspathAttribute[] { attribute }; try {// ww w . j a va2 s . c o m IClasspathEntry[] originalCP = jp.getRawClasspath(); IClasspathEntry[] newCP = new IClasspathEntry[originalCP.length + 1]; IClasspathEntry cp = null; if (eKind == IClasspathEntry.CPE_LIBRARY) { cp = JavaCore.newLibraryEntry(new Path(path), null, null, new IAccessRule[0], attributes, false); } else if (eKind == IClasspathEntry.CPE_VARIABLE) { cp = JavaCore.newVariableEntry(new Path(path), null, null, new IAccessRule[0], attributes, false); } else if (eKind == IClasspathEntry.CPE_CONTAINER) { cp = JavaCore.newContainerEntry(new Path(path), null, attributes, false); } else if (eKind == IClasspathEntry.CPE_PROJECT) { cp = JavaCore.newProjectEntry(new Path(path), null, true, attributes, false); } // Update the raw classpath with the new entry. if (cp != null) { System.arraycopy(originalCP, 0, newCP, 0, originalCP.length); newCP[originalCP.length] = cp; jp.setRawClasspath(newCP, new NullProgressMonitor()); } } catch (JavaModelException e) { } catch (NumberFormatException e) { } }
From source file:org.eclipse.ajdt.core.AspectJCorePreferences.java
License:Open Source License
private static String toEntryKind(String entryStr) { int entry = 0; if (entryStr.equals("SOURCE")) { //$NON-NLS-1$ entry = IClasspathEntry.CPE_SOURCE; } else if (entryStr.equals("LIBRARY")) { //$NON-NLS-1$ entry = IClasspathEntry.CPE_LIBRARY; } else if (entryStr.equals("PROJECT")) { //$NON-NLS-1$ entry = IClasspathEntry.CPE_PROJECT; } else if (entryStr.equals("VARIABLE")) { //$NON-NLS-1$ entry = IClasspathEntry.CPE_VARIABLE; } else if (entryStr.equals("CONTAINER")) { //$NON-NLS-1$ entry = IClasspathEntry.CPE_CONTAINER; }//w ww. j a v a2 s . c om return new Integer(entry).toString(); }
From source file:org.eclipse.ajdt.internal.buildpath.AJBuildPathAction.java
License:Open Source License
protected boolean shouldAskForClasspathRestrictions(IClasspathEntry entry) { return entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER; }
From source file:org.eclipse.ajdt.internal.buildpath.UpdateAspectpathRestriction.java
License:Open Source License
public void selectionChanged(IAction action, ISelection sel) { boolean enable = false; if (sel instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) sel; Object element = selection.getFirstElement(); try {/*from w w w . ja va 2s . c o m*/ if (element instanceof IPackageFragmentRoot) { IPackageFragmentRoot root = (IPackageFragmentRoot) element; project = root.getJavaProject().getProject(); cpEntry = root.getRawClasspathEntry(); if (cpEntry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { fileName = root.getElementName(); enable = AspectJCorePreferences.isOnAspectpath(cpEntry); } else { fileName = null; cpEntry = null; project = null; enable = false; } } else { enable = false; } } catch (JavaModelException e) { } action.setEnabled(enable); } }
From source file:org.eclipse.ajdt.internal.buildpath.UpdateInpathRestriction.java
License:Open Source License
public void selectionChanged(IAction action, ISelection sel) { boolean enable = false; if (sel instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) sel; Object element = selection.getFirstElement(); try {/*from w w w . j a va 2 s . c om*/ if (element instanceof IPackageFragmentRoot) { IPackageFragmentRoot root = (IPackageFragmentRoot) element; project = root.getJavaProject().getProject(); cpEntry = root.getRawClasspathEntry(); if (cpEntry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { fileName = root.getElementName(); enable = AspectJCorePreferences.isOnInpath(cpEntry); } else { fileName = null; cpEntry = null; project = null; enable = false; } } else { enable = false; } } catch (JavaModelException e) { } action.setEnabled(enable); } }
From source file:org.eclipse.ajdt.internal.core.ajde.CoreOutputLocationManager.java
License:Open Source License
private void handleClassPathEntry(IJavaProject jp, IClasspathEntry cpe) throws JavaModelException { switch (cpe.getEntryKind()) { case IClasspathEntry.CPE_CONTAINER: IClasspathContainer container = JavaCore.getClasspathContainer(cpe.getPath(), jp); if (container != null && container.getKind() != IClasspathContainer.K_DEFAULT_SYSTEM) { IClasspathEntry[] cpes = container.getClasspathEntries(); for (int i = 0; i < cpes.length; i++) { handleClassPathEntry(jp, cpes[i]); }/*from w w w . j a v a 2s .c o m*/ } break; case IClasspathEntry.CPE_LIBRARY: File libFile = pathToFile(cpe.getPath()); if (libFile.isDirectory()) { // ignore jar files if (libFile != null && !binFolderToProject.containsKey(libFile)) { binFolderToProject.put(libFile, jp.getProject()); } } break; case IClasspathEntry.CPE_PROJECT: IJavaProject jpClasspath = pathToProject(cpe.getPath()); if (jpClasspath != null) { mapProject(jpClasspath); } break; case IClasspathEntry.CPE_SOURCE: File outFile = pathToFile( cpe.getOutputLocation() == null ? jp.getOutputLocation() : cpe.getOutputLocation()); if (outFile != null && !binFolderToProject.containsKey(outFile)) { binFolderToProject.put(outFile, jp.getProject()); } break; case IClasspathEntry.CPE_VARIABLE: IClasspathEntry cpeResolved = JavaCore.getResolvedClasspathEntry(cpe); if (cpeResolved != null) { handleClassPathEntry(jp, cpeResolved); } break; } }
From source file:org.eclipse.ajdt.internal.launching.LaunchConfigurationManagementUtils.java
License:Open Source License
/** * Update the aspect path for launch configurations relating to the given * project// w w w.j a va 2s . com * * @param project - * the project * @param existingAspectPathEntries - * current aspect path * @param newAspectPathEntries - * new aspect path */ public static void updateAspectPaths(IJavaProject project, List existingAspectPathEntries, List newAspectPathEntries) { try { String projectName = project.getElementName(); List configs = getLaunchConfigsForProject(projectName); for (Iterator iter = configs.iterator(); iter.hasNext();) { ILaunchConfiguration configuration = (ILaunchConfiguration) iter.next(); IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedRuntimeClasspath(configuration); List entriesAsList = new ArrayList(Arrays.asList(entries)); for (Iterator iterator = existingAspectPathEntries.iterator(); iterator.hasNext();) { IClasspathEntry entryToRemove = ((CPListElement) iterator.next()).getClasspathEntry(); for (Iterator iterator2 = entriesAsList.iterator(); iterator2.hasNext();) { IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) iterator2.next(); if (entry.getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) { if (entryToRemove.equals(entry.getClasspathEntry())) { iterator2.remove(); break; } } } } for (Iterator iterator = newAspectPathEntries.iterator(); iterator.hasNext();) { IClasspathEntry newEntry = ((CPListElement) iterator.next()).getClasspathEntry(); if (newEntry.getEntryKind() != IClasspathEntry.CPE_CONTAINER) { entriesAsList.add(new RuntimeClasspathEntry(newEntry)); } else { IClasspathContainer container = JavaCore.getClasspathContainer(newEntry.getPath(), project); if (container != null) { IClasspathEntry[] containerEntries = container.getClasspathEntries(); for (int i = 0; i < containerEntries.length; i++) { entriesAsList.add(new RuntimeClasspathEntry(containerEntries[i])); } } } } IRuntimeClasspathEntry[] updatedEntries = (IRuntimeClasspathEntry[]) entriesAsList .toArray(new IRuntimeClasspathEntry[0]); updateConfigurationClasspath(configuration, updatedEntries); } } catch (CoreException cEx) { AJLog.log(cEx.getMessage()); } }