Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 96704 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/wizards/datatransfer/TarLeveledStructureProvider.java (-27 / +25 lines)
Lines 58-83 Link Here
58
	}
58
	}
59
59
60
	/**
60
	/**
61
	 * Adds the specified child to the internal collection of the parent's
62
	 * children.
63
	 */
64
	protected void addToChildren(TarEntry parent, TarEntry child) {
65
		List childList = (List) children.get(parent);
66
		if (childList == null) {
67
			childList = new ArrayList();
68
			children.put(parent, childList);
69
		}
70
71
		childList.add(child);
72
	}
73
74
	/**
75
	 * Creates a new container tar entry with the specified name, iff it has not
61
	 * Creates a new container tar entry with the specified name, iff it has not
76
	 * already been created.
62
	 * already been created.
77
	 */
63
	 */
78
	protected void createContainer(IPath pathname) {
64
	protected boolean createContainer(IPath pathname) {
79
		if (directoryEntryCache.containsKey(pathname))
65
		if (directoryEntryCache.containsKey(pathname))
80
			return;
66
			return false;
81
67
82
		TarEntry parent;
68
		TarEntry parent;
83
		if (pathname.segmentCount() == 1)
69
		if (pathname.segmentCount() == 1)
Lines 89-95 Link Here
89
		TarEntry newEntry = new TarEntry(pathname.toString());
75
		TarEntry newEntry = new TarEntry(pathname.toString());
90
		newEntry.setFileType(TarEntry.DIRECTORY);
76
		newEntry.setFileType(TarEntry.DIRECTORY);
91
		directoryEntryCache.put(pathname, newEntry);
77
		directoryEntryCache.put(pathname, newEntry);
92
		addToChildren(parent, newEntry);
78
		List childList = new ArrayList();
79
		children.put(newEntry, childList);
80
81
		List parentChildList = (List) children.get(parent);
82
		parentChildList.add(newEntry);
83
		return true;
93
	}
84
	}
94
85
95
	/**
86
	/**
Lines 104-110 Link Here
104
			parent = (TarEntry) directoryEntryCache.get(pathname
95
			parent = (TarEntry) directoryEntryCache.get(pathname
105
					.removeLastSegments(1));
96
					.removeLastSegments(1));
106
97
107
		addToChildren(parent, entry);
98
		List childList = (List) children.get(parent);
99
		childList.add(entry);
108
	}
100
	}
109
101
110
	/*
102
	/*
Lines 185-205 Link Here
185
	 */
177
	 */
186
	protected void initialize() {
178
	protected void initialize() {
187
		children = new HashMap(1000);
179
		children = new HashMap(1000);
188
180
		
181
		children.put(root, new ArrayList());
189
		Enumeration entries = tarFile.entries();
182
		Enumeration entries = tarFile.entries();
190
		while (entries.hasMoreElements()) {
183
		while (entries.hasMoreElements()) {
191
			TarEntry entry = (TarEntry) entries.nextElement();
184
			TarEntry entry = (TarEntry) entries.nextElement();
192
			if (entry.getFileType() == TarEntry.FILE) {
185
			IPath path = new Path(entry.getName()).addTrailingSeparator();
193
				IPath path = new Path(entry.getName()).addTrailingSeparator();
186
			int pathSegmentCount = path.segmentCount();
194
				int pathSegmentCount = path.segmentCount();
187
			
195
188
			// Ensure the container structure for all levels above this is initialized
196
				for (int i = 1; i < pathSegmentCount; i++)
189
			// Once we hit a higher-level container that's already added we need go no further
197
					createContainer(path.uptoSegment(i));
190
			for (int i = 1; i < pathSegmentCount; i++)
191
				if (!createContainer(path.uptoSegment(i)))
192
					break;
193
			
194
			if (entry.getFileType() == TarEntry.DIRECTORY) 
195
				createContainer(path);
196
			else
198
				createFile(entry);
197
				createFile(entry);
199
			}
200
		}
198
		}
201
	}
199
	}
202
200
	
203
	/*
201
	/*
204
	 * (non-Javadoc) Method declared on IImportStructureProvider
202
	 * (non-Javadoc) Method declared on IImportStructureProvider
205
	 */
203
	 */
(-)src/org/eclipse/ui/internal/wizards/datatransfer/WizardProjectsImportPage.java (-1 / +1 lines)
Lines 831-837 Link Here
831
		monitor.subTask(NLS.bind(
831
		monitor.subTask(NLS.bind(
832
				DataTransferMessages.WizardProjectsImportPage_CheckingMessage,
832
				DataTransferMessages.WizardProjectsImportPage_CheckingMessage,
833
				provider.getLabel(entry)));
833
				provider.getLabel(entry)));
834
		List children = provider.getChildren(entry); //$NON-NLS-1$
834
		List children = provider.getChildren(entry);
835
		if (children == null) {
835
		if (children == null) {
836
			children = new ArrayList(1);
836
			children = new ArrayList(1);
837
		}
837
		}
(-)src/org/eclipse/ui/internal/wizards/datatransfer/ZipLeveledStructureProvider.java (-24 / +24 lines)
Lines 59-84 Link Here
59
	}
59
	}
60
60
61
	/**
61
	/**
62
	 * Adds the specified child to the internal collection of the parent's
63
	 * children.
64
	 */
65
	protected void addToChildren(ZipEntry parent, ZipEntry child) {
66
		List childList = (List) children.get(parent);
67
		if (childList == null) {
68
			childList = new ArrayList();
69
			children.put(parent, childList);
70
		}
71
72
		childList.add(child);
73
	}
74
75
	/**
76
	 * Creates a new container zip entry with the specified name, iff it has not
62
	 * Creates a new container zip entry with the specified name, iff it has not
77
	 * already been created.
63
	 * already been created.
64
	 * @param pathname The path representing the container
65
	 * @return true if an element was created, false if this element already existed
78
	 */
66
	 */
79
	protected void createContainer(IPath pathname) {
67
	protected boolean createContainer(IPath pathname) {
80
		if (directoryEntryCache.containsKey(pathname))
68
		if (directoryEntryCache.containsKey(pathname))
81
			return;
69
			return false;
82
70
83
		ZipEntry parent;
71
		ZipEntry parent;
84
		if (pathname.segmentCount() == 1)
72
		if (pathname.segmentCount() == 1)
Lines 89-95 Link Here
89
77
90
		ZipEntry newEntry = new ZipEntry(pathname.toString());
78
		ZipEntry newEntry = new ZipEntry(pathname.toString());
91
		directoryEntryCache.put(pathname, newEntry);
79
		directoryEntryCache.put(pathname, newEntry);
92
		addToChildren(parent, newEntry);
80
		List childList = new ArrayList();
81
		children.put(newEntry, childList);
82
83
		List parentChildList = (List) children.get(parent);
84
		parentChildList.add(newEntry);
85
		return true;
93
	}
86
	}
94
87
95
	/**
88
	/**
Lines 104-110 Link Here
104
			parent = (ZipEntry) directoryEntryCache.get(pathname
97
			parent = (ZipEntry) directoryEntryCache.get(pathname
105
					.removeLastSegments(1));
98
					.removeLastSegments(1));
106
99
107
		addToChildren(parent, entry);
100
		List childList = (List) children.get(parent);
101
		childList.add(entry);
108
	}
102
	}
109
103
110
	/*
104
	/*
Lines 192-208 Link Here
192
	protected void initialize() {
186
	protected void initialize() {
193
		children = new HashMap(1000);
187
		children = new HashMap(1000);
194
188
189
		children.put(root, new ArrayList());
195
		Enumeration entries = zipFile.entries();
190
		Enumeration entries = zipFile.entries();
196
		while (entries.hasMoreElements()) {
191
		while (entries.hasMoreElements()) {
197
			ZipEntry entry = (ZipEntry) entries.nextElement();
192
			ZipEntry entry = (ZipEntry) entries.nextElement();
198
			if (!entry.isDirectory()) {
193
			IPath path = new Path(entry.getName()).addTrailingSeparator();
199
				IPath path = new Path(entry.getName()).addTrailingSeparator();
194
			int pathSegmentCount = path.segmentCount();
200
				int pathSegmentCount = path.segmentCount();
201
195
202
				for (int i = 1; i < pathSegmentCount; i++)
196
			// Ensure the container structure for all levels above this is initialized
203
					createContainer(path.uptoSegment(i));
197
			// Once we hit a higher-level container that's already added we need go no further
198
			for (int i = 1; i < pathSegmentCount; i++)
199
				if (!createContainer(path.uptoSegment(i)))
200
					break;
201
202
			if (entry.isDirectory())
203
				createContainer(path);
204
			else
204
				createFile(entry);
205
				createFile(entry);
205
			}
206
		}
206
		}
207
	}
207
	}
208
208

Return to bug 96704