1 11 package org.eclipse.core.internal.resources; 12 13 import java.io.DataInputStream ; 14 import java.io.IOException ; 15 import java.util.ArrayList ; 16 import java.util.List ; 17 import org.eclipse.core.internal.events.BuilderPersistentInfo; 18 import org.eclipse.core.internal.utils.Messages; 19 import org.eclipse.core.internal.utils.Policy; 20 import org.eclipse.core.internal.watson.ElementTree; 21 import org.eclipse.core.resources.IProject; 22 import org.eclipse.core.resources.IResourceStatus; 23 import org.eclipse.core.runtime.CoreException; 24 import org.eclipse.core.runtime.IProgressMonitor; 25 26 34 public class WorkspaceTreeReader_2 extends WorkspaceTreeReader_1 { 35 36 public WorkspaceTreeReader_2(Workspace workspace) { 37 super(workspace); 38 } 39 40 protected int getVersion() { 41 return ICoreConstants.WORKSPACE_TREE_VERSION_2; 42 } 43 44 47 protected void readBuildersPersistentInfo(IProject project, DataInputStream input, List builders, IProgressMonitor monitor) throws IOException { 48 monitor = Policy.monitorFor(monitor); 49 try { 50 int builderCount = input.readInt(); 51 for (int i = 0; i < builderCount; i++) { 52 BuilderPersistentInfo info = readBuilderInfo(project, input, i); 53 int n = input.readInt(); 55 IProject[] projects = new IProject[n]; 56 for (int j = 0; j < n; j++) 57 projects[j] = workspace.getRoot().getProject(input.readUTF()); 58 info.setInterestingProjects(projects); 59 builders.add(info); 60 } 61 } finally { 62 monitor.done(); 63 } 64 } 65 66 69 public void readTree(IProject project, DataInputStream input, IProgressMonitor monitor) throws CoreException { 70 monitor = Policy.monitorFor(monitor); 71 String message; 72 try { 73 message = Messages.resources_reading; 74 monitor.beginTask(message, 10); 75 76 77 List infos = new ArrayList (5); 78 readBuildersPersistentInfo(project, input, infos, Policy.subMonitorFor(monitor, 1)); 79 80 81 ElementTree[] trees = readTrees(project.getFullPath(), input, Policy.subMonitorFor(monitor, 8)); 82 83 84 linkBuildersToTrees(infos, trees, 0, Policy.subMonitorFor(monitor, 1)); 85 86 } catch (IOException e) { 87 message = Messages.resources_readProjectTree; 88 throw new ResourceException(IResourceStatus.FAILED_READ_METADATA, null, message, e); 89 } finally { 90 monitor.done(); 91 } 92 } 93 } 94 | Popular Tags |