/** * Check wheter the output location of the <code>IPackageFragmentRoot</code> * is <code>null</code>. If this holds, then the root * does use the default output folder. * * @param root the root to examine the output location for * @return <code>true</code> if the root uses the default output folder, <code>false * </code> otherwise. * @throws JavaModelException */ public static boolean hasDefaultOutputFolder(IPackageFragmentRoot root) throws JavaModelException { return root.getRawClasspathEntry().getOutputLocation() == null; }
/** * Check whether the output location of the <code>IPackageFragmentRoot</code> * is <code>null</code>. If this holds, then the root * does use the default output folder. * * @param root the root to examine the output location for * @return <code>true</code> if the root uses the default output folder, <code>false * </code> otherwise. * @throws JavaModelException */ public static boolean hasDefaultOutputFolder(IPackageFragmentRoot root) throws JavaModelException { return root.getRawClasspathEntry().getOutputLocation() == null; }
/** * Check whether the output location of the <code>IPackageFragmentRoot</code> * is <code>null</code>. If this holds, then the root * does use the default output folder. * * @param root the root to examine the output location for * @return <code>true</code> if the root uses the default output folder, <code>false * </code> otherwise. * @throws JavaModelException */ public static boolean hasDefaultOutputFolder(IPackageFragmentRoot root) throws JavaModelException { return root.getRawClasspathEntry().getOutputLocation() == null; }
protected Object[] getPackageFragmentRoots(final IJavaProject project) throws JavaModelException { final Set set= new HashSet(); final IPackageFragmentRoot[] roots= project.getPackageFragmentRoots(); for (int offset= 0; offset < roots.length; offset++) { if (JarImportWizard.isValidClassPathEntry(roots[offset].getRawClasspathEntry())) set.add(roots[offset]); } return set.toArray(); }
public static boolean isJRELibrary(IPackageFragmentRoot root) { try { IPath path = root.getRawClasspathEntry().getPath(); if (path.equals(new Path(JavaRuntime.JRE_CONTAINER)) || path.equals(new Path(JavaRuntime.JRELIB_VARIABLE))) { return true; } } catch (JavaModelException e) { } return false; }
public static boolean isJRELibrary(IPackageFragmentRoot root) { try { IPath path = root.getRawClasspathEntry().getPath(); if (path.equals(new Path(JavaRuntime.JRE_CONTAINER)) || path.equals(new Path(JavaRuntime.JRELIB_VARIABLE))) { return true; } } catch (JavaModelException e) { } return false; }
private boolean ignoreDelta(IJavaElementDelta delta) { try { IJavaElement element = delta.getElement(); if (element instanceof IPackageFragmentRoot) { IPackageFragmentRoot root = (IPackageFragmentRoot)element; IClasspathEntry entry = root.getRawClasspathEntry(); if (entry != null && entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) return true; } } catch (JavaModelException e) { } return false; }
private boolean ignoreDelta(IJavaElementDelta delta) { try { IJavaElement element = delta.getElement(); if (element instanceof IPackageFragmentRoot) { IPackageFragmentRoot root = (IPackageFragmentRoot) element; IClasspathEntry entry = root.getRawClasspathEntry(); if (entry != null && entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) return true; } } catch (JavaModelException e) { } return false; }
@Override protected Object[] getPackageFragmentRoots(final IJavaProject project) throws JavaModelException { final Set<IPackageFragmentRoot> set= new HashSet<>(); final IPackageFragmentRoot[] roots= project.getPackageFragmentRoots(); for (int offset= 0; offset < roots.length; offset++) { IPackageFragmentRoot root= roots[offset]; IClasspathEntry entry= root.getRawClasspathEntry(); if (JarImportWizard.isValidClassPathEntry(entry) && root.getResolvedClasspathEntry().getReferencingEntry() == null) set.add(root); } return set.toArray(); }
private static boolean isJreContainerElement(final IPackageFragmentRoot root) throws JavaModelException { final IClasspathEntry entry = root.getRawClasspathEntry(); if (entry.getEntryKind() != IClasspathEntry.CPE_CONTAINER) { return false; } final String type = entry.getPath().segment(0); return JavaRuntime.JRE_CONTAINER.equals(type); }
@Override protected Object[] getPackageFragmentRoots(final IJavaProject project) throws JavaModelException { final Set<IPackageFragmentRoot> set= new HashSet<>(); final IPackageFragmentRoot[] roots= project.getPackageFragmentRoots(); for (int offset= 0; offset < roots.length; offset++) { IPackageFragmentRoot root= roots[offset]; IClasspathEntry entry= root.getRawClasspathEntry(); if (JarImportWizard.isValidClassPathEntry(entry) && root.getResolvedClasspathEntry().getReferencingEntry() == null) set.add(root); } return set.toArray(); }
protected void executeOperation() throws JavaModelException { IPackageFragmentRoot root = (IPackageFragmentRoot)getElementToProcess(); IClasspathEntry rootEntry = root.getRawClasspathEntry(); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); // copy resource if (!root.isExternal() && (this.updateModelFlags & IPackageFragmentRoot.NO_RESOURCE_MODIFICATION) == 0) { copyResource(root, rootEntry, workspaceRoot); } // update classpath if needed if ((this.updateModelFlags & IPackageFragmentRoot.DESTINATION_PROJECT_CLASSPATH) != 0) { addEntryToClasspath(rootEntry, workspaceRoot); } } protected void copyResource(
protected void executeOperation() throws JavaModelException { IPackageFragmentRoot root = (IPackageFragmentRoot)getElementToProcess(); IClasspathEntry rootEntry = root.getRawClasspathEntry(); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); // copy resource if (!root.isExternal() && (this.updateModelFlags & IPackageFragmentRoot.NO_RESOURCE_MODIFICATION) == 0) { copyResource(root, rootEntry, workspaceRoot); } // update classpath if needed if ((this.updateModelFlags & IPackageFragmentRoot.DESTINATION_PROJECT_CLASSPATH) != 0) { addEntryToClasspath(rootEntry, workspaceRoot); } } protected void copyResource(
protected void executeOperation() throws JavaModelException { IPackageFragmentRoot root = (IPackageFragmentRoot)getElementToProcess(); IClasspathEntry rootEntry = root.getRawClasspathEntry(); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); // copy resource if (!root.isExternal() && (this.updateModelFlags & IPackageFragmentRoot.NO_RESOURCE_MODIFICATION) == 0) { copyResource(root, rootEntry, workspaceRoot); } // update classpath if needed if ((this.updateModelFlags & IPackageFragmentRoot.DESTINATION_PROJECT_CLASSPATH) != 0) { addEntryToClasspath(rootEntry, workspaceRoot); } } protected void copyResource(
protected void executeOperation() throws JavaModelException { IPackageFragmentRoot root = (IPackageFragmentRoot)getElementToProcess(); IClasspathEntry rootEntry = root.getRawClasspathEntry(); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); // copy resource if (!root.isExternal() && (this.updateModelFlags & IPackageFragmentRoot.NO_RESOURCE_MODIFICATION) == 0) { copyResource(root, rootEntry, workspaceRoot); } // update classpath if needed if ((this.updateModelFlags & IPackageFragmentRoot.DESTINATION_PROJECT_CLASSPATH) != 0) { addEntryToClasspath(rootEntry, workspaceRoot); } } protected void copyResource(
@Override protected void executeOperation() throws JavaModelException { IPackageFragmentRoot root = (IPackageFragmentRoot)getElementToProcess(); IClasspathEntry rootEntry = root.getRawClasspathEntry(); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); // copy resource if (!root.isExternal() && (this.updateModelFlags & IPackageFragmentRoot.NO_RESOURCE_MODIFICATION) == 0) { copyResource(root, rootEntry, workspaceRoot); } // update classpath if needed if ((this.updateModelFlags & IPackageFragmentRoot.DESTINATION_PROJECT_CLASSPATH) != 0) { addEntryToClasspath(rootEntry, workspaceRoot); } } protected void copyResource(
protected void executeOperation() throws JavaModelException { IPackageFragmentRoot root = (IPackageFragmentRoot)getElementToProcess(); IClasspathEntry rootEntry = root.getRawClasspathEntry(); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); // copy resource if (!root.isExternal() && (this.updateModelFlags & IPackageFragmentRoot.NO_RESOURCE_MODIFICATION) == 0) { copyResource(root, rootEntry, workspaceRoot); } // update classpath if needed if ((this.updateModelFlags & IPackageFragmentRoot.DESTINATION_PROJECT_CLASSPATH) != 0) { addEntryToClasspath(rootEntry, workspaceRoot); } } protected void copyResource(
/** * Handle all fragment roots that are on the classpath and not a source folder. */ private boolean shouldHandle(IPackageFragmentRoot root) { try { boolean result = !JavaRuntime.newDefaultJREContainerPath().isPrefixOf(root.getRawClasspathEntry().getPath()); result &= (root.isArchive() || root.isExternal()); return result; } catch (JavaModelException ex) { if (!ex.isDoesNotExist()) log.error(ex.getMessage(), ex); return false; } }
private IResource getClassfilesLocation(IPackageFragmentRoot root) throws CoreException { // For binary roots the underlying resource directly points to class files: if (root.getKind() == IPackageFragmentRoot.K_BINARY) { return root.getResource(); } // For source roots we need to find the corresponding output folder: IPath path = root.getRawClasspathEntry().getOutputLocation(); if (path == null) { path = root.getJavaProject().getOutputLocation(); } return root.getResource().getWorkspace().getRoot().findMember(path); }
public static IContainer getOutputContainer(IProject project, IPackageFragmentRoot sourceContainer) { try { IJavaProject jProject = JavaCore.create(project); IPath outputPath = sourceContainer.getRawClasspathEntry().getOutputLocation(); if (outputPath == null) { if (jProject.getOutputLocation().segmentCount() == 1) return project; return project.getFolder(jProject.getOutputLocation().removeFirstSegments(1)); } return project.getFolder(outputPath.removeFirstSegments(1)); } catch (Exception e) { } return null; }