@Override public IStorage getStorage(IProgressMonitor monitor) throws TeamException { if (resource.getType() == IResource.FILE) { return (IFile)resource; } return null; }
public static IFile getFile(ICompilationUnit cu) { IResource resource = cu.getResource(); if (resource != null && resource.getType() == IResource.FILE) { return (IFile) resource; } else { return null; } }
/** * Sets the resource that we are searching for aliases for. */ public void setSearchAlias(IResource aliasResource) { this.aliasType = aliasResource.getType(); this.searchPath = aliasResource.getFullPath(); } }
/** * Obtains the scheduling rule from the appropriate factories for a copy operation. */ @Override public ISchedulingRule copyRule(IResource source, IResource destination) { if (source.getType() == IResource.ROOT || destination.getType() == IResource.ROOT) return root; //source is not modified, destination is created return factoryFor(destination).copyRule(source, destination); }
/** * Obtains the scheduling rule from the appropriate factories for a copy operation. */ @Override public ISchedulingRule copyRule(IResource source, IResource destination) { if (source.getType() == IResource.ROOT || destination.getType() == IResource.ROOT) return root; //source is not modified, destination is created return factoryFor(destination).copyRule(source, destination); }
/** * Convenience constructor for creating a simple folder diff * that consists of a resource and a kind only. It is equivalent to * <code>ResourceDiff(resource, kind, 0, null, null)<code> * @param resource a resource * @param kind the kind of change (ADDED, REMOVED or CHANGED) */ public ResourceDiff(IResource resource, int kind) { this(resource, kind, 0, null, null); Assert.isTrue(resource.getType() != IResource.FILE); }
protected int compareNames(IResource resource1, IResource resource2) { if (resource1.getType() == IResource.FOLDER && resource2.getType() == IResource.FOLDER) { return collator.compare(resource1.getProjectRelativePath().toString(), resource2.getProjectRelativePath().toString()); } return super.compareNames(resource1, resource2); } };
/** * Returns the path of the file in which to save the sync information for * the given resource. Should only be called for the workspace root and * projects. */ public IPath getSyncInfoLocationFor(IResource resource) { Assert.isNotNull(resource); Assert.isLegal(resource.getType() == IResource.ROOT || resource.getType() == IResource.PROJECT); return locationFor(resource).append(F_SYNCINFO); }
private IResource getResourceChild(IResource parent, String childName, boolean isContainer) { if (parent.getType() == IResource.FILE) { return null; } if (isContainer) { return ((IContainer) parent).getFolder(new Path(null, childName)); } else { return ((IContainer) parent).getFile(new Path(null, childName)); } }
private static List<IResource> getReadonlyFiles(IResource[] resources) { List<IResource> readOnlyFiles= new ArrayList<>(); for (IResource resource : resources) { ResourceAttributes resourceAttributes= resource.getResourceAttributes(); if (resource.getType() == IResource.FILE && resourceAttributes != null && resourceAttributes.isReadOnly()) readOnlyFiles.add(resource); } return readOnlyFiles; }
/** * Returns the legacy, pre-4.4.1, path of the snapshot file. The name of the legacy snapshot * file is ".snap". Should only be called for the workspace root. */ public IPath getLegacySnapshotLocationFor(IResource resource) { Assert.isNotNull(resource); Assert.isLegal(resource.getType() == IResource.ROOT); return metaAreaLocation.append(F_SNAP); }
/** * Obtains the scheduling rule from the appropriate factory for a refresh operation. */ @Override public ISchedulingRule refreshRule(IResource resource) { if (resource.getType() == IResource.ROOT) return root; return factoryFor(resource).refreshRule(resource); }
private boolean canPasteSimpleProjects(TransferData[] availableDataTypes) { IResource[] resources= getClipboardResources(availableDataTypes); if (resources == null || resources.length == 0) return false; for (int i= 0; i < resources.length; i++) { if (resources[i].getType() != IResource.PROJECT || ! ((IProject)resources[i]).isOpen()) return false; } return true; } }
private IFile getFile(ICompilationUnit unit) { unit= unit.getPrimary(); IResource resource= unit.getResource(); if (resource != null && resource.getType() == IResource.FILE) return (IFile)resource; return null; }
/** * Returns true if this resource represents the project description file, and * false otherwise. */ protected boolean isProjectDescriptionFile(IResource resource) { return resource.getType() == IResource.FILE && resource.getFullPath().segmentCount() == 2 && resource.getName().equals(IProjectDescription.DESCRIPTION_FILE_NAME); }
@Override public boolean visit(IResourceDelta delta) throws CoreException { IResource resource = delta.getResource(); if (!resource.isDerived()) { if (resource.getType() != IResource.FILE) { return KEEP_SEARCHING; } savedResourceFound = notOnlyMarkersChanged(delta); } return STOP_SEARCHING; }
@Override public boolean isBuildFile(IResource resource) { return resource != null && resource.getProject() != null && resource.getType() == IResource.FILE && resource.getName().equals("pom.xml") //Check pom.xml is at the root of the project && resource.getProject().equals(resource.getParent()); }
protected boolean hasDecendantConflicts(Object elementOrPath) { IResource resource = getResource(elementOrPath); IResourceDiffTree tree = getDiffTree(elementOrPath); if (tree != null && resource != null) { int depth = getTraversalCalculator().getLayoutDepth(resource, internalGetPath(elementOrPath)); if (depth == IResource.DEPTH_INFINITE || resource.getType() == IResource.FILE) return tree.getProperty(resource.getFullPath(), IDiffTree.P_HAS_DESCENDANT_CONFLICTS); return tree.hasMatchingDiffs(getTraversalCalculator().getTraversals(resource, internalGetPath(elementOrPath)), CONFLICT_FILTER); } return super.hasDecendantConflicts(elementOrPath); }