use of org.eclipse.jdt.core.IPackageFragmentRoot in project che by eclipse.
the class JavaNavigation method getPackageFragmentRootContent.
public List<JarEntry> getPackageFragmentRootContent(IJavaProject project, int hash) throws JavaModelException {
IPackageFragmentRoot packageFragmentRoot = getPackageFragmentRoot(project, hash);
if (packageFragmentRoot == null) {
return NO_ENTRIES;
}
Object[] rootContent = getPackageFragmentRootContent(packageFragmentRoot);
return convertToJarEntry(rootContent, packageFragmentRoot);
}
use of org.eclipse.jdt.core.IPackageFragmentRoot in project che by eclipse.
the class JavaNavigation method getHierarchicalPackageParent.
public Object getHierarchicalPackageParent(IPackageFragment child) {
String name = child.getElementName();
IPackageFragmentRoot parent = (IPackageFragmentRoot) child.getParent();
int index = name.lastIndexOf('.');
if (index != -1) {
String realParentName = name.substring(0, index);
IPackageFragment element = parent.getPackageFragment(realParentName);
if (element.exists()) {
try {
if (fFoldPackages && isEmpty(element) && findSinglePackageChild(element, parent.getChildren()) != null) {
return getHierarchicalPackageParent(element);
}
} catch (JavaModelException e) {
// ignore
}
return element;
}
/*else { // bug 65240
IResource resource= element.getResource();
if (resource != null) {
return resource;
}
}*/
}
// }
return parent;
}
use of org.eclipse.jdt.core.IPackageFragmentRoot in project che by eclipse.
the class CopyModifications method copy.
public void copy(IPackageFragment pack, CopyArguments javaArgs, CopyArguments resourceArgs) throws CoreException {
add(pack, javaArgs, null);
ResourceMapping mapping = JavaElementResourceMapping.create(pack);
if (mapping != null) {
add(mapping, resourceArgs, null);
}
IPackageFragmentRoot javaDestination = (IPackageFragmentRoot) javaArgs.getDestination();
if (javaDestination.getResource() == null)
return;
IPackageFragment newPack = javaDestination.getPackageFragment(pack.getElementName());
// the new name yet, so we use the current package name.
if (!pack.hasSubpackages() && (!newPack.exists() || pack.equals(newPack))) {
// we can do a simple move
IContainer resourceDestination = newPack.getResource().getParent();
createIncludingParents(resourceDestination);
getResourceModifications().addCopyDelta(pack.getResource(), resourceArgs);
} else {
IContainer resourceDestination = (IContainer) newPack.getResource();
createIncludingParents(resourceDestination);
CopyArguments arguments = new CopyArguments(resourceDestination, resourceArgs.getExecutionLog());
IResource[] resourcesToCopy = collectResourcesOfInterest(pack);
for (int i = 0; i < resourcesToCopy.length; i++) {
IResource toCopy = resourcesToCopy[i];
getResourceModifications().addCopyDelta(toCopy, arguments);
}
}
}
use of org.eclipse.jdt.core.IPackageFragmentRoot in project che by eclipse.
the class MoveModifications method move.
public void move(IPackageFragment pack, MoveArguments args) throws CoreException {
add(pack, args, null);
if (pack.getResource() == null)
return;
IPackageFragmentRoot javaDestination = (IPackageFragmentRoot) args.getDestination();
if (javaDestination.getResource() == null)
return;
IPackageFragment newPack = javaDestination.getPackageFragment(pack.getElementName());
if (!pack.hasSubpackages() && !newPack.exists()) {
// we can do a simple move
IContainer resourceDestination = newPack.getResource().getParent();
createIncludingParents(resourceDestination);
getResourceModifications().addMove(pack.getResource(), new MoveArguments(resourceDestination, args.getUpdateReferences()));
} else {
IContainer resourceSource = (IContainer) pack.getResource();
IContainer resourceDestination = (IContainer) newPack.getResource();
createIncludingParents(resourceDestination);
MoveArguments arguments = new MoveArguments(resourceDestination, args.getUpdateReferences());
IResource[] resourcesToMove = collectResourcesOfInterest(pack);
Set<IResource> allMembers = new HashSet<IResource>(Arrays.asList(resourceSource.members()));
for (int i = 0; i < resourcesToMove.length; i++) {
IResource toMove = resourcesToMove[i];
getResourceModifications().addMove(toMove, arguments);
allMembers.remove(toMove);
}
for (Iterator<IResource> iter = allMembers.iterator(); iter.hasNext(); ) {
IResource element = iter.next();
if (element instanceof IFile) {
getResourceModifications().addDelete(element);
iter.remove();
}
}
if (allMembers.isEmpty()) {
getResourceModifications().addDelete(resourceSource);
}
}
}
use of org.eclipse.jdt.core.IPackageFragmentRoot in project che by eclipse.
the class ReorgUtils method isArchiveOrExternalMember.
public static boolean isArchiveOrExternalMember(IJavaElement[] elements) {
for (int i = 0; i < elements.length; i++) {
IJavaElement element = elements[i];
IPackageFragmentRoot root = (IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
if (root != null && (root.isArchive() || root.isExternal()))
return true;
}
return false;
}
Aggregations