1 11 package org.eclipse.debug.core.sourcelookup.containers; 12 13 import org.eclipse.core.resources.IFile; 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.debug.core.DebugPlugin; 16 import org.eclipse.debug.core.sourcelookup.ISourceContainerType; 17 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; 18 19 28 public class ArchiveSourceContainer extends AbstractSourceContainer { 29 30 private IFile fFile; 31 private boolean fDetectRoot; 32 private ExternalArchiveSourceContainer fDelegateContainer; 33 34 38 public static final String TYPE_ID = DebugPlugin.getUniqueIdentifier() + ".containerType.archive"; 40 55 public ArchiveSourceContainer(IFile archive, boolean detectRootPath) { 56 fFile = archive; 57 fDetectRoot = detectRootPath; 58 if (archive.exists() && archive.getLocation() != null) { 59 fDelegateContainer = new ExternalArchiveSourceContainer(archive.getLocation().toOSString(), detectRootPath); 60 } 61 } 62 63 66 public String getName() { 67 return fFile.getName(); 68 } 69 70 75 public IFile getFile() { 76 return fFile; 77 } 78 79 82 public ISourceContainerType getType() { 83 return getSourceContainerType(TYPE_ID); 84 } 85 86 89 public boolean equals(Object obj) { 90 return obj instanceof ArchiveSourceContainer && 91 ((ArchiveSourceContainer)obj).getName().equals(getName()); 92 } 93 94 97 public int hashCode() { 98 return getName().hashCode(); 99 } 100 101 104 public Object [] findSourceElements(String name) throws CoreException { 105 ExternalArchiveSourceContainer container = getDelegateContainer(); 106 if (container != null) { 107 return container.findSourceElements(name); 108 } 109 return EMPTY; 110 } 111 112 118 private ExternalArchiveSourceContainer getDelegateContainer() { 119 return fDelegateContainer; 120 } 121 124 public void init(ISourceLookupDirector director) { 125 super.init(director); 126 if (fDelegateContainer != null) { 127 fDelegateContainer.init(director); 128 } 129 } 130 133 public void dispose() { 134 super.dispose(); 135 if (fDelegateContainer != null) { 136 fDelegateContainer.dispose(); 137 } 138 } 139 140 148 public boolean isDetectRoot() { 149 return fDetectRoot; 150 } 151 } 152 | Popular Tags |