/** * Creates an element for the given resource. * @param resource the resource */ public LocalResourceTypedElement(IResource resource) { super(resource); exists = resource.exists(); }
public static boolean isRenameAvailable(final IResource resource) { if (resource == null) { return false; } if (!resource.exists()) { return false; } if (!resource.isAccessible()) { return false; } return true; }
public static boolean isRenameAvailable(final IResource resource) { if (resource == null) return false; if (!resource.exists()) return false; if (!resource.isAccessible()) return false; return true; }
public static boolean isRenameAvailable(final IResource resource) { if (resource == null) return false; if (!resource.exists()) return false; if (!resource.isAccessible()) return false; return true; }
public static void removeTasksFor(IResource resource) { try { if (resource != null && resource.exists()) resource.deleteMarkers(IJavaModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE); } catch (CoreException e) { // assume there were no problems } }
protected IResource findOriginalResource(IPath partialPath) { for (int i = 0, l = this.sourceLocations.length; i < l; i++) { ClasspathMultiDirectory sourceLocation = this.sourceLocations[i]; if (sourceLocation.hasIndependentOutputFolder) { IResource originalResource = sourceLocation.sourceFolder.getFile(partialPath); if (originalResource.exists()) return originalResource; } } return null; }
private boolean existsInSameLocation(IResource directory, EclipseSourceDirectory sourceFolder) { if (!directory.exists()) { return false; } if (directory.isLinked()) { return hasSameLocationAs(directory, sourceFolder); } return true; }
public static boolean isDeleteAvailable(final IResource resource) { if (!resource.exists() || resource.isPhantom()) { return false; } if (resource.getType() == IResource.ROOT || resource.getType() == IResource.PROJECT) { return false; } return true; }
/** * Returns if a CU can be edited. */ public static boolean isEditable(ICompilationUnit cu) { Assert.isNotNull(cu); IResource resource= cu.getPrimary().getResource(); return (resource.exists() && !resource.getResourceAttributes().isReadOnly()); }
public static boolean isDeleteAvailable(final IResource resource) { if (!resource.exists() || resource.isPhantom()) return false; if (resource.getType() == IResource.ROOT || resource.getType() == IResource.PROJECT) return false; return true; }
/** * Update the cached timestamp of the resource. */ void updateTimestamp() { if (getResource().exists()) timestamp = getResource().getLocalTimeStamp(); else exists = false; }
public static boolean isDeleteAvailable(final IResource resource) { if (!resource.exists() || resource.isPhantom()) return false; if (resource.getType() == IResource.ROOT || resource.getType() == IResource.PROJECT) return false; return true; }
protected void copyResource(IResource source, IResource destination) throws CoreException { IPath destPath = destination.getFullPath(); try { source.copy(destPath, IResource.FORCE | IResource.DERIVED, null); } catch (CoreException e) { // handle the case when the source resource is deleted source.refreshLocal(0, null); if (!source.exists()) return; // source resource was deleted so skip it throw e; } Util.setReadOnly(destination, false); // just in case the original was read only }
protected void copyResource(IResource source, IResource destination) throws CoreException { IPath destPath = destination.getFullPath(); try { source.copy(destPath, IResource.FORCE | IResource.DERIVED, null); } catch (CoreException e) { // handle the case when the source resource is deleted source.refreshLocal(0, null); if (!source.exists()) return; // source resource was deleted so skip it throw e; } Util.setReadOnly(destination, false); // just in case the original was read only }
protected void copyResource(IResource source, IResource destination) throws CoreException { IPath destPath = destination.getFullPath(); try { source.copy(destPath, IResource.FORCE | IResource.DERIVED, null); } catch (CoreException e) { // handle the case when the source resource is deleted source.refreshLocal(0, null); if (!source.exists()) return; // source resource was deleted so skip it throw e; } Util.setReadOnly(destination, false); // just in case the original was read only }
private static void checkExistence(RefactoringStatus status, IResource element) { if (element == null) { status.addFatalError(RefactoringCoreMessages.ResourceChange_error_no_input); } else if (!element.exists()) { status.addFatalError(Messages.format(RefactoringCoreMessages.ResourceChange_error_does_not_exist, BasicElementLabels.getPathLabel(element.getFullPath(), false))); } }
protected ISchedulingRule getSchedulingRule() { IResource resource = getElementToProcess().getResource(); if (resource == null) return null; IWorkspace workspace = resource.getWorkspace(); if (resource.exists()) { return workspace.getRuleFactory().modifyRule(resource); } else { return workspace.getRuleFactory().createRule(resource); } } /**
/** * Creates a child node for a location in the file system. Does nothing and returns null if the location does not correspond to a valid file/folder. */ protected UnifiedTreeNode createChildNodeFromFileSystem(UnifiedTreeNode parent, IFileInfo info) { IPath childPath = parent.getResource().getFullPath().append(info.getName()); int type = info.isDirectory() ? IResource.FOLDER : IResource.FILE; IResource target = getWorkspace().newResource(childPath, type); return createNode(target, null, info, target.exists()); }
/** * Creates a child node for a location in the file system. Does nothing and returns null if the location does not correspond to a valid file/folder. */ protected UnifiedTreeNode createChildNodeFromFileSystem(UnifiedTreeNode parent, IFileInfo info) { IPath childPath = parent.getResource().getFullPath().append(info.getName()); int type = info.isDirectory() ? IResource.FOLDER : IResource.FILE; IResource target = getWorkspace().newResource(childPath, type); return createNode(target, null, info, target.exists()); }
protected void addRootToQueue() { //don't refresh in closed projects if (!root.getProject().isAccessible()) return; IFileStore store = ((Resource) root).getStore(); IFileInfo fileInfo = fileTree != null ? fileTree.getFileInfo(store) : store.fetchInfo(); UnifiedTreeNode node = createNode(root, store, fileInfo, root.exists()); if (node.existsInFileSystem() || node.existsInWorkspace()) addElementToQueue(node); }