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 81895 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/wizards/datatransfer/messages.properties (+2 lines)
Lines 83-88 Link Here
83
WizardProjectsImportPage_ArchiveSelectTitle=Select &archive file:
83
WizardProjectsImportPage_ArchiveSelectTitle=Select &archive file:
84
WizardProjectsImportPage_SelectArchiveDialogTitle=Select archive containing the projects to import
84
WizardProjectsImportPage_SelectArchiveDialogTitle=Select archive containing the projects to import
85
WizardProjectsImportPage_ProjectsListTitle=&Projects:
85
WizardProjectsImportPage_ProjectsListTitle=&Projects:
86
WizardProjectsImportPage_ProjectNameColumnHeader=Project Name
87
WizardProjectsImportPage_ProjectParentColumnHeader=Parent Container
86
WizardProjectsImportPage_ProcessingMessage=Processing results
88
WizardProjectsImportPage_ProcessingMessage=Processing results
87
WizardProjectsImportPage_SelectDialogTitle=Select root directory of the projects to import
89
WizardProjectsImportPage_SelectDialogTitle=Select root directory of the projects to import
88
WizardProjectsImportPage_SearchingMessage=Searching for projects
90
WizardProjectsImportPage_SearchingMessage=Searching for projects
(-)src/org/eclipse/ui/internal/wizards/datatransfer/DataTransferMessages.java (+2 lines)
Lines 78-83 Link Here
78
	public static String WizardExternalProjectImportPage_description;
78
	public static String WizardExternalProjectImportPage_description;
79
	public static String WizardExternalProjectImportPage_notAProject;
79
	public static String WizardExternalProjectImportPage_notAProject;
80
	public static String WizardProjectsImportPage_ProjectsListTitle;
80
	public static String WizardProjectsImportPage_ProjectsListTitle;
81
	public static String WizardProjectsImportPage_ProjectNameColumnHeader;
82
	public static String WizardProjectsImportPage_ProjectParentColumnHeader;
81
	public static String WizardProjectsImportPage_ProcessingMessage;
83
	public static String WizardProjectsImportPage_ProcessingMessage;
82
	public static String WizardProjectsImportPage_SelectDialogTitle;
84
	public static String WizardProjectsImportPage_SelectDialogTitle;
83
	public static String WizardProjectsImportPage_SearchingMessage;
85
	public static String WizardProjectsImportPage_SearchingMessage;
(-)src/org/eclipse/ui/internal/wizards/datatransfer/WizardProjectsImportPage.java (-9 / +51 lines)
Lines 38-43 Link Here
38
import org.eclipse.swt.events.SelectionEvent;
38
import org.eclipse.swt.events.SelectionEvent;
39
import org.eclipse.swt.events.TraverseEvent;
39
import org.eclipse.swt.events.TraverseEvent;
40
import org.eclipse.swt.events.TraverseListener;
40
import org.eclipse.swt.events.TraverseListener;
41
import org.eclipse.swt.graphics.Image;
41
import org.eclipse.swt.layout.GridData;
42
import org.eclipse.swt.layout.GridData;
42
import org.eclipse.swt.layout.GridLayout;
43
import org.eclipse.swt.layout.GridLayout;
43
import org.eclipse.swt.widgets.Button;
44
import org.eclipse.swt.widgets.Button;
Lines 46-51 Link Here
46
import org.eclipse.swt.widgets.FileDialog;
47
import org.eclipse.swt.widgets.FileDialog;
47
import org.eclipse.swt.widgets.Label;
48
import org.eclipse.swt.widgets.Label;
48
import org.eclipse.swt.widgets.Text;
49
import org.eclipse.swt.widgets.Text;
50
import org.eclipse.swt.widgets.Tree;
51
import org.eclipse.swt.widgets.TreeColumn;
49
52
50
import org.eclipse.core.runtime.CoreException;
53
import org.eclipse.core.runtime.CoreException;
51
import org.eclipse.core.runtime.IPath;
54
import org.eclipse.core.runtime.IPath;
Lines 72-79 Link Here
72
import org.eclipse.jface.viewers.CheckStateChangedEvent;
75
import org.eclipse.jface.viewers.CheckStateChangedEvent;
73
import org.eclipse.jface.viewers.CheckboxTreeViewer;
76
import org.eclipse.jface.viewers.CheckboxTreeViewer;
74
import org.eclipse.jface.viewers.ICheckStateListener;
77
import org.eclipse.jface.viewers.ICheckStateListener;
78
import org.eclipse.jface.viewers.ILabelProviderListener;
79
import org.eclipse.jface.viewers.ITableLabelProvider;
75
import org.eclipse.jface.viewers.ITreeContentProvider;
80
import org.eclipse.jface.viewers.ITreeContentProvider;
76
import org.eclipse.jface.viewers.LabelProvider;
77
import org.eclipse.jface.viewers.Viewer;
81
import org.eclipse.jface.viewers.Viewer;
78
import org.eclipse.jface.viewers.ViewerComparator;
82
import org.eclipse.jface.viewers.ViewerComparator;
79
import org.eclipse.jface.wizard.WizardPage;
83
import org.eclipse.jface.wizard.WizardPage;
Lines 119-124 Link Here
119
		String projectName;
123
		String projectName;
120
124
121
		Object parent;
125
		Object parent;
126
		String parentName;
122
127
123
		int level;
128
		int level;
124
129
Lines 156-161 Link Here
156
		private void setProjectName() {
162
		private void setProjectName() {
157
			try {
163
			try {
158
				if (projectArchiveFile != null) {
164
				if (projectArchiveFile != null) {
165
					String label = structureProvider.getFullPath(projectArchiveFile);
166
					int sepIndex = label.lastIndexOf('/');
167
					if (sepIndex == -1) {
168
						// there is no parent, so we will just use the empty string
169
						parentName = ""; //$NON-NLS-1$
170
					} else {
171
						parentName = label.substring(0, sepIndex);
172
					}
159
					InputStream stream = structureProvider
173
					InputStream stream = structureProvider
160
							.getContents(projectArchiveFile);
174
							.getContents(projectArchiveFile);
161
					if (stream != null) {
175
					if (stream != null) {
Lines 173-178 Link Here
173
						projectName= path.segment(path.segmentCount() - 2);
187
						projectName= path.segment(path.segmentCount() - 2);
174
					}
188
					}
175
				} else {
189
				} else {
190
					parentName = projectSystemFile.getParent();
176
					IPath path = new Path(projectSystemFile.getPath());
191
					IPath path = new Path(projectSystemFile.getPath());
177
					// if the file is in the default location, use the directory
192
					// if the file is in the default location, use the directory
178
					// name as the project name
193
					// name as the project name
Lines 240-245 Link Here
240
					projectName,
255
					projectName,
241
					nameFromDescription); 
256
					nameFromDescription); 
242
		}
257
		}
258
		
259
		/**
260
		 * Gets the name of the project's containing parent.
261
		 * @return the project's container
262
		 * @since 3.4
263
		 */
264
		public String getParentName() {
265
			return parentName;
266
		}
243
	}
267
	}
244
	
268
	
245
269
Lines 375-380 Link Here
375
		GridData listData = new GridData(GridData.GRAB_HORIZONTAL
399
		GridData listData = new GridData(GridData.GRAB_HORIZONTAL
376
				| GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
400
				| GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
377
		projectsList.getControl().setLayoutData(listData);
401
		projectsList.getControl().setLayoutData(listData);
402
		Tree projectsTree = projectsList.getTree();
403
		projectsTree.setHeaderVisible(true);
404
		// create a column for the project and its parent container
405
		TreeColumn projectColumn = new TreeColumn(projectsTree, SWT.LEAD);
406
		projectColumn.setWidth(150);
407
		projectColumn.setText(DataTransferMessages.WizardProjectsImportPage_ProjectNameColumnHeader);
408
		TreeColumn parentColumn = new TreeColumn(projectsTree, SWT.LEAD);
409
		parentColumn.setWidth(200);
410
		parentColumn.setText(DataTransferMessages.WizardProjectsImportPage_ProjectParentColumnHeader);
378
411
379
		projectsList.setContentProvider(new ITreeContentProvider() {
412
		projectsList.setContentProvider(new ITreeContentProvider() {
380
413
Lines 435-448 Link Here
435
468
436
		});
469
		});
437
470
438
		projectsList.setLabelProvider(new LabelProvider() {
471
		projectsList.setLabelProvider(new ITableLabelProvider() {
439
			/*
472
			public Image getColumnImage(Object element, int columnIndex) {
440
			 * (non-Javadoc)
473
				return null;
441
			 * 
474
			}
442
			 * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
475
			public String getColumnText(Object element, int columnIndex) {
443
			 */
476
				if (columnIndex == 0) {
444
			public String getText(Object element) {
477
					return ((ProjectRecord) element).getProjectName();
445
				return ((ProjectRecord) element).getProjectLabel();
478
				}
479
				return ((ProjectRecord) element).getParentName();
480
			}
481
			public void addListener(ILabelProviderListener listener) {
482
			}
483
			public void dispose() {
484
			}
485
			public boolean isLabelProperty(Object element, String property) {
486
				return false;
487
			}
488
			public void removeListener(ILabelProviderListener listener) {
446
			}
489
			}
447
		});
490
		});
448
491
(-)Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingProjectsWizardTest.java (+18 lines)
Lines 145-150 Link Here
145
			WizardProjectsImportPage wpip = getNewWizard();
145
			WizardProjectsImportPage wpip = getNewWizard();
146
			HashSet projects = new HashSet();
146
			HashSet projects = new HashSet();
147
			projects.add("HelloWorld");
147
			projects.add("HelloWorld");
148
			HashSet projectParents = new HashSet();
149
			projectParents.add("HelloWorld");
148
150
149
			wpip.getProjectFromDirectoryRadio().setSelection((false)); // We
151
			wpip.getProjectFromDirectoryRadio().setSelection((false)); // We
150
																		// want
152
																		// want
Lines 156-167 Link Here
156
158
157
			ProjectRecord[] selectedProjects = wpip.getValidProjects();
159
			ProjectRecord[] selectedProjects = wpip.getValidProjects();
158
			ArrayList projectNames = new ArrayList();
160
			ArrayList projectNames = new ArrayList();
161
			ArrayList parentNames = new ArrayList();
159
			for (int i = 0; i < selectedProjects.length; i++) {
162
			for (int i = 0; i < selectedProjects.length; i++) {
160
				projectNames.add(selectedProjects[i].getProjectName());
163
				projectNames.add(selectedProjects[i].getProjectName());
164
				parentNames.add(selectedProjects[i].getParentName());
161
			}
165
			}
162
166
163
			assertTrue("Not all projects were found correctly in zip",
167
			assertTrue("Not all projects were found correctly in zip",
164
					projectNames.containsAll(projects));
168
					projectNames.containsAll(projects));
169
			assertTrue("Not all project parent names were extracted correctly from zip",
170
					parentNames.containsAll(projectParents));
165
		} catch (IOException e) {
171
		} catch (IOException e) {
166
			fail(e.toString());
172
			fail(e.toString());
167
		}
173
		}
Lines 175-180 Link Here
175
			WizardProjectsImportPage wpip = getNewWizard();
181
			WizardProjectsImportPage wpip = getNewWizard();
176
			HashSet projects = new HashSet();
182
			HashSet projects = new HashSet();
177
			projects.add("HelloWorld");
183
			projects.add("HelloWorld");
184
			HashSet projectParents = new HashSet();
185
			projectParents.add("HelloWorld");
178
186
179
			wpip.getProjectFromDirectoryRadio().setSelection((false)); // We
187
			wpip.getProjectFromDirectoryRadio().setSelection((false)); // We
180
																		// want
188
																		// want
Lines 185-197 Link Here
185
			wpip.updateProjectsList(archiveFile.getPath());
193
			wpip.updateProjectsList(archiveFile.getPath());
186
194
187
			ProjectRecord[] selectedProjects = wpip.getValidProjects();
195
			ProjectRecord[] selectedProjects = wpip.getValidProjects();
196
			ArrayList parentNames = new ArrayList();
188
			ArrayList projectNames = new ArrayList();
197
			ArrayList projectNames = new ArrayList();
189
			for (int i = 0; i < selectedProjects.length; i++) {
198
			for (int i = 0; i < selectedProjects.length; i++) {
190
				projectNames.add(selectedProjects[i].getProjectName());
199
				projectNames.add(selectedProjects[i].getProjectName());
200
				parentNames.add(selectedProjects[i].getParentName());
191
			}
201
			}
192
202
193
			assertTrue("Not all projects were found correctly in tar",
203
			assertTrue("Not all projects were found correctly in tar",
194
					projectNames.containsAll(projects));
204
					projectNames.containsAll(projects));
205
			assertTrue("Not all project parent names were extracted correctly from tar",
206
					parentNames.containsAll(projectParents));
195
		} catch (IOException e) {
207
		} catch (IOException e) {
196
			fail(e.toString());
208
			fail(e.toString());
197
		}
209
		}
Lines 204-221 Link Here
204
			WizardProjectsImportPage wpip = getNewWizard();
216
			WizardProjectsImportPage wpip = getNewWizard();
205
			HashSet projects = new HashSet();
217
			HashSet projects = new HashSet();
206
			projects.add("HelloWorld");
218
			projects.add("HelloWorld");
219
			HashSet projectParents = new HashSet();
220
			projectParents.add(wsPath.toOSString());
207
			// We're importing a directory
221
			// We're importing a directory
208
			wpip.getProjectFromDirectoryRadio().setSelection((true));
222
			wpip.getProjectFromDirectoryRadio().setSelection((true));
209
			wpip.updateProjectsList(wsPath.toOSString());
223
			wpip.updateProjectsList(wsPath.toOSString());
210
224
211
			ProjectRecord[] selectedProjects = wpip.getValidProjects();
225
			ProjectRecord[] selectedProjects = wpip.getValidProjects();
212
			ArrayList projectNames = new ArrayList();
226
			ArrayList projectNames = new ArrayList();
227
			ArrayList parentNames = new ArrayList();
213
			for (int i = 0; i < selectedProjects.length; i++) {
228
			for (int i = 0; i < selectedProjects.length; i++) {
214
				projectNames.add(selectedProjects[i].getProjectName());
229
				projectNames.add(selectedProjects[i].getProjectName());
230
				parentNames.add(selectedProjects[i].getParentName());
215
			}
231
			}
216
232
217
			assertTrue("Not all projects were found correctly in directory",
233
			assertTrue("Not all projects were found correctly in directory",
218
					projectNames.containsAll(projects));
234
					projectNames.containsAll(projects));
235
			assertTrue("Not all project parents were extracted correctly from directory",
236
					parentNames.containsAll(projectParents));
219
		} catch (IOException e) {
237
		} catch (IOException e) {
220
			fail(e.toString());
238
			fail(e.toString());
221
		}
239
		}

Return to bug 81895