1 11 package org.eclipse.core.internal.localstore; 12 13 import java.util.Iterator ; 14 import org.eclipse.core.filesystem.*; 15 import org.eclipse.core.internal.resources.Resource; 16 import org.eclipse.core.resources.IResource; 17 18 public class UnifiedTreeNode implements ILocalStoreConstants { 19 protected UnifiedTreeNode child; 20 protected boolean existsWorkspace; 21 protected IFileInfo fileInfo; 22 protected IResource resource; 23 protected IFileStore store; 24 protected UnifiedTree tree; 25 26 public UnifiedTreeNode(UnifiedTree tree, IResource resource, IFileStore store, IFileInfo fileInfo, boolean existsWorkspace) { 27 this.tree = tree; 28 this.resource = resource; 29 this.store = store; 30 this.fileInfo = fileInfo; 31 this.existsWorkspace = existsWorkspace; 32 } 33 34 public boolean existsInFileSystem() { 35 return fileInfo != null && fileInfo.exists(); 36 } 37 38 public boolean existsInWorkspace() { 39 return existsWorkspace; 40 } 41 42 45 public Iterator getChildren() { 46 return tree.getChildren(this); 47 } 48 49 protected UnifiedTreeNode getFirstChild() { 50 return child; 51 } 52 53 public long getLastModified() { 54 return fileInfo == null ? 0 : fileInfo.getLastModified(); 55 } 56 57 public int getLevel() { 58 return tree.getLevel(); 59 } 60 61 65 public String getLocalName() { 66 return fileInfo == null ? null : fileInfo.getName(); 67 } 68 69 public IResource getResource() { 70 return resource; 71 } 72 73 76 public IFileStore getStore() { 77 if (store == null) 79 store = ((Resource) resource).getStore(); 80 return store; 81 } 82 83 public boolean isFolder() { 84 return fileInfo == null ? false : fileInfo.isDirectory(); 85 } 86 87 public boolean isSymbolicLink() { 88 return fileInfo == null ? false : fileInfo.getAttribute(EFS.ATTRIBUTE_SYMLINK); 89 } 90 91 public void removeChildrenFromTree() { 92 tree.removeNodeChildrenFromQueue(this); 93 } 94 95 98 public void reuse(UnifiedTree aTree, IResource aResource, IFileStore aStore, IFileInfo info, boolean existsInWorkspace) { 99 this.tree = aTree; 100 this.child = null; 101 this.resource = aResource; 102 this.store = aStore; 103 this.fileInfo = info; 104 this.existsWorkspace = existsInWorkspace; 105 } 106 107 public void setExistsWorkspace(boolean exists) { 108 this.existsWorkspace = exists; 109 } 110 111 protected void setFirstChild(UnifiedTreeNode child) { 112 this.child = child; 113 } 114 115 public void setResource(IResource resource) { 116 this.resource = resource; 117 } 118 119 public String toString() { 120 String s = resource == null ? "null" : resource.getFullPath().toString(); return "Node: " + s; } 123 } 124 | Popular Tags |