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

Collapse All | Expand All

(-)src/org/eclipse/team/internal/ui/wizards/ProjectSetImportWizard.java (-6 / +13 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ui.wizards;
11
package org.eclipse.team.internal.ui.wizards;
12
12
13
import java.io.IOException;
14
import java.io.InputStream;
13
import java.lang.reflect.InvocationTargetException;
15
import java.lang.reflect.InvocationTargetException;
14
16
15
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.resources.IProject;
Lines 45-56 Link Here
45
		try {
47
		try {
46
			getContainer().run(true, true, new WorkspaceModifyOperation(null) {
48
			getContainer().run(true, true, new WorkspaceModifyOperation(null) {
47
				public void execute(IProgressMonitor monitor) throws InvocationTargetException {
49
				public void execute(IProgressMonitor monitor) throws InvocationTargetException {
48
					String psfFile = mainPage.getFileName();
50
					try {
49
					PsfFilenameStore.remember(psfFile);
51
						String psfFile = mainPage.getFileName();
50
					IProject[] newProjects= ProjectSetImporter.importProjectSet(psfFile, getShell(), monitor);
52
						InputStream is = mainPage.getInputStream();
51
					if (workingSetName != null)
53
						PsfFilenameStore.remember(psfFile);
52
						createWorkingSet(workingSetName, newProjects);
54
						IProject[] newProjects= ProjectSetImporter.importProjectSet(is, getShell(), monitor);
53
					result[0] = true;
55
						if (workingSetName != null)
56
							createWorkingSet(workingSetName, newProjects);
57
						result[0] = true;
58
					} catch (IOException e) {
59
						throw new InvocationTargetException(e);
60
					}
54
				}
61
				}
55
			});
62
			});
56
		} catch (InterruptedException e) {
63
		} catch (InterruptedException e) {
(-)src/org/eclipse/team/internal/ui/wizards/ImportProjectSetMainPage.java (-19 / +85 lines)
Lines 10-25 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ui.wizards;
11
package org.eclipse.team.internal.ui.wizards;
12
12
13
import java.io.File;
13
import java.io.*;
14
import java.net.MalformedURLException;
15
import java.net.URL;
14
16
15
import org.eclipse.core.resources.ResourcesPlugin;
17
import org.eclipse.core.resources.ResourcesPlugin;
16
import org.eclipse.jface.dialogs.Dialog;
18
import org.eclipse.jface.dialogs.Dialog;
17
import org.eclipse.jface.dialogs.IDialogConstants;
19
import org.eclipse.jface.dialogs.IDialogConstants;
20
import org.eclipse.jface.layout.GridDataFactory;
18
import org.eclipse.jface.resource.ImageDescriptor;
21
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.jface.window.Window;
22
import org.eclipse.jface.window.Window;
20
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.events.SelectionAdapter;
24
import org.eclipse.swt.events.*;
22
import org.eclipse.swt.events.SelectionEvent;
23
import org.eclipse.swt.graphics.Point;
25
import org.eclipse.swt.graphics.Point;
24
import org.eclipse.swt.layout.GridData;
26
import org.eclipse.swt.layout.GridData;
25
import org.eclipse.swt.layout.GridLayout;
27
import org.eclipse.swt.layout.GridLayout;
Lines 29-37 Link Here
29
import org.eclipse.ui.PlatformUI;
31
import org.eclipse.ui.PlatformUI;
30
32
31
public class ImportProjectSetMainPage extends TeamWizardPage {
33
public class ImportProjectSetMainPage extends TeamWizardPage {
34
	private Button fileRadio;
32
	Combo fileCombo;
35
	Combo fileCombo;
33
	String file = ""; //$NON-NLS-1$
36
	String file = ""; //$NON-NLS-1$
37
	private URL url;
38
	private Button fileBrowseButton;
34
	Button browseButton;
39
	Button browseButton;
40
	private Button urlRadio;
41
	private Text urlText;
35
	Button addToWorkingSet;
42
	Button addToWorkingSet;
36
	Text workingSetField;
43
	Text workingSetField;
37
	
44
	
Lines 39-44 Link Here
39
	private String workingSetName = ""; //$NON-NLS-1$
46
	private String workingSetName = ""; //$NON-NLS-1$
40
	
47
	
41
	private boolean haveBrowsed;
48
	private boolean haveBrowsed;
49
	private boolean fileSelected;
42
	
50
	
43
	// constants
51
	// constants
44
	//private static final int SIZING_TEXT_FIELD_WIDTH = 80;
52
	//private static final int SIZING_TEXT_FIELD_WIDTH = 80;
Lines 66-72 Link Here
66
		layout.marginWidth = 0;
74
		layout.marginWidth = 0;
67
		inner.setLayout(layout);
75
		inner.setLayout(layout);
68
		
76
		
69
		createLabel(inner, TeamUIMessages.ImportProjectSetMainPage_Project_Set_File_Name__2); 
77
		fileRadio = new Button(inner, SWT.RADIO);
78
		fileRadio.setText(TeamUIMessages.ImportProjectSetMainPage_Project_Set_File_Name__2);
79
		fileRadio.setSelection(true);
70
80
71
		fileCombo = createDropDownCombo(inner);
81
		fileCombo = createDropDownCombo(inner);
72
		file = PsfFilenameStore.getSuggestedDefault();
82
		file = PsfFilenameStore.getSuggestedDefault();
Lines 79-92 Link Here
79
			}
89
			}
80
		});
90
		});
81
91
82
		browseButton = new Button(inner, SWT.PUSH);
92
		fileBrowseButton = new Button(inner, SWT.PUSH);
83
		browseButton.setText(TeamUIMessages.ImportProjectSetMainPage_Browse_3); 
93
		fileBrowseButton.setText(TeamUIMessages.ImportProjectSetMainPage_Browse_3); 
84
		GridData data = new GridData();
94
		GridData data = new GridData();
85
		data.horizontalAlignment = GridData.FILL;
95
		data.horizontalAlignment = GridData.FILL;
86
		int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
96
		int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
87
		data.widthHint = Math.max(widthHint, browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
97
		data.widthHint = Math.max(widthHint, fileBrowseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
88
		browseButton.setLayoutData(data);
98
		fileBrowseButton.setLayoutData(data);
89
		browseButton.addListener(SWT.Selection, new Listener() {
99
		fileBrowseButton.addListener(SWT.Selection, new Listener() {
90
			public void handleEvent(Event event) {
100
			public void handleEvent(Event event) {
91
				FileDialog d = new FileDialog(getShell());
101
				FileDialog d = new FileDialog(getShell());
92
				d.setFilterExtensions(new String[] {"*.psf", "*"}); //$NON-NLS-1$ //$NON-NLS-2$
102
				d.setFilterExtensions(new String[] {"*.psf", "*"}); //$NON-NLS-1$ //$NON-NLS-2$
Lines 109-114 Link Here
109
			}
119
			}
110
		});
120
		});
111
121
122
		urlRadio = new Button(inner, SWT.RADIO);
123
		urlRadio.setText(TeamUIMessages.ImportProjectSetMainPage_Project_Set_File_URL);
124
		
125
		urlText = new Text(inner, SWT.SINGLE | SWT.BORDER);
126
		urlText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
127
		urlText.addModifyListener(new ModifyListener() {
128
129
			public void modifyText(ModifyEvent e) {
130
				updateEnablement();
131
			}
132
			
133
		});
134
		
135
		SelectionListener radioEnablement = new SelectionAdapter() {
136
			
137
			public void widgetSelected(SelectionEvent e) {
138
				updateEnablement();
139
			}
140
			
141
		};
142
		fileRadio.addSelectionListener(radioEnablement);
143
		urlRadio.addSelectionListener(radioEnablement);
144
		
145
		Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
146
		separator.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
147
112
		addWorkingSetSection(composite);
148
		addWorkingSetSection(composite);
113
		setControl(composite);
149
		setControl(composite);
114
		updateEnablement();
150
		updateEnablement();
Lines 190-213 Link Here
190
		boolean complete;
226
		boolean complete;
191
		setMessage(null);
227
		setMessage(null);
192
		
228
		
229
		fileSelected = fileRadio.getSelection();
230
		fileCombo.setEnabled(fileSelected);
231
		fileBrowseButton.setEnabled(fileSelected);
232
		urlText.setEnabled(!fileSelected);
233
		
193
		workingSetField.setEnabled(addToWorkingSet.getSelection());
234
		workingSetField.setEnabled(addToWorkingSet.getSelection());
194
		browseButton.setEnabled(addToWorkingSet.getSelection());
235
		browseButton.setEnabled(addToWorkingSet.getSelection());
195
		
236
		
196
		if (file.length() == 0) {
237
		if (fileSelected) {
197
			setPageComplete(false);
238
			// Check file selection
198
			return;
239
			if (file.length() == 0) {
240
				setPageComplete(false);
241
				return;
242
			} else {
243
				// See if the file exists
244
				File f = new File(file);
245
				if (!f.exists()) {
246
					setMessage(TeamUIMessages.ImportProjectSetMainPage_The_specified_file_does_not_exist_4, ERROR); 
247
					setPageComplete(false);
248
					return;
249
				} else if (f.isDirectory()) {
250
					setMessage(TeamUIMessages.ImportProjectSetMainPage_You_have_specified_a_folder_5, ERROR); 
251
					setPageComplete(false);
252
					return;
253
				} 
254
			}
199
		} else {
255
		} else {
200
			// See if the file exists
256
			// Check URL selection
201
			File f = new File(file);
257
			if (urlText.getText().trim().equals("")) { //$NON-NLS-1$
202
			if (!f.exists()) {
203
				setMessage(TeamUIMessages.ImportProjectSetMainPage_The_specified_file_does_not_exist_4, ERROR); 
204
				setPageComplete(false);
258
				setPageComplete(false);
259
				setMessage(TeamUIMessages.ImportProjectSetMainPage_Inform_file_URL, ERROR);
205
				return;
260
				return;
206
			} else if (f.isDirectory()) {
261
			}
207
				setMessage(TeamUIMessages.ImportProjectSetMainPage_You_have_specified_a_folder_5, ERROR); 
262
			try {
263
				url = new URL(urlText.getText().trim());
264
			} catch (MalformedURLException e) {
208
				setPageComplete(false);
265
				setPageComplete(false);
266
				setMessage(TeamUIMessages.ImportProjectSetMainPage_URL_is_not_valid, ERROR);
209
				return;
267
				return;
210
			} 
268
			}
211
		}
269
		}
212
		
270
		
213
		//If add to working set checkbox selected and the user has not selected
271
		//If add to working set checkbox selected and the user has not selected
Lines 225-230 Link Here
225
	public String getFileName() {
283
	public String getFileName() {
226
		return file;
284
		return file;
227
	}
285
	}
286
	
287
	public InputStream getInputStream() throws IOException {
288
		if (fileSelected) {
289
			return new FileInputStream(file);
290
		}
291
		return url.openStream();
292
	}
228
293
229
	public void setVisible(boolean visible) {
294
	public void setVisible(boolean visible) {
230
		super.setVisible(visible);
295
		super.setVisible(visible);
Lines 240-243 Link Here
240
		if (!createWorkingSet) return null;
305
		if (!createWorkingSet) return null;
241
		return workingSetName;
306
		return workingSetName;
242
	}
307
	}
308
243
}
309
}
(-)src/org/eclipse/team/internal/ui/messages.properties (+3 lines)
Lines 98-103 Link Here
98
ImportProjectSetMainPage_createWorkingSetLabel=&Create a working set containing the imported projects
98
ImportProjectSetMainPage_createWorkingSetLabel=&Create a working set containing the imported projects
99
ImportProjectSetMainPage_workingSetLabel=&Working Set Name:
99
ImportProjectSetMainPage_workingSetLabel=&Working Set Name:
100
ImportProjectSetMainPage_AddToWorkingSet=&Add the imported team project set to a working set
100
ImportProjectSetMainPage_AddToWorkingSet=&Add the imported team project set to a working set
101
ImportProjectSetMainPage_Inform_file_URL=Inform the .psf file URL
102
ImportProjectSetMainPage_URL_is_not_valid=The URL is not valid
101
103
102
ProjectSetContentHandler_Element_provider_must_be_contained_in_element_psf_4=Element provider must be contained in element psf
104
ProjectSetContentHandler_Element_provider_must_be_contained_in_element_psf_4=Element provider must be contained in element psf
103
ProjectSetContentHandler_Element_project_must_be_contained_in_element_provider_7=Element project must be contained in element provider
105
ProjectSetContentHandler_Element_project_must_be_contained_in_element_provider_7=Element project must be contained in element provider
Lines 125-130 Link Here
125
ImportProjectSetMainPage_allFiles=All Files (*.*)
127
ImportProjectSetMainPage_allFiles=All Files (*.*)
126
ImportProjectSetAction_0=An error occurred importing this project set.
128
ImportProjectSetAction_0=An error occurred importing this project set.
127
ImportProjectSetMainPage_Project_Set_Files_2=Team Project Set Files (*.psf)
129
ImportProjectSetMainPage_Project_Set_Files_2=Team Project Set Files (*.psf)
130
ImportProjectSetMainPage_Project_Set_File_URL=&URL:
128
ExportProjectSetMainPage__File_name__1=&File name:
131
ExportProjectSetMainPage__File_name__1=&File name:
129
ExportProjectSetMainPage_WorkspaceButton=W&orkspace
132
ExportProjectSetMainPage_WorkspaceButton=W&orkspace
130
ExportProjectSetMainPage_ExportWorkingSets=Export working sets
133
ExportProjectSetMainPage_ExportWorkingSets=Export working sets
(-)src/org/eclipse/team/internal/ui/TeamUIMessages.java (+6 lines)
Lines 99-104 Link Here
99
99
100
	public static String ImportProjectSetMainPage_Browse;
100
	public static String ImportProjectSetMainPage_Browse;
101
101
102
	public static String ImportProjectSetMainPage_Inform_file_URL;
103
104
	public static String ImportProjectSetMainPage_Project_Set_File_URL;
105
106
	public static String ImportProjectSetMainPage_URL_is_not_valid;
107
102
	public static String information;
108
	public static String information;
103
    
109
    
104
	public static String ConfigureProjectAction_configureProject;
110
	public static String ConfigureProjectAction_configureProject;
(-)src/org/eclipse/team/internal/ui/ProjectSetImporter.java (-1 / +15 lines)
Lines 25-33 Link Here
25
public class ProjectSetImporter {
25
public class ProjectSetImporter {
26
	
26
	
27
	public static IProject[] importProjectSet(String filename, Shell shell, IProgressMonitor monitor) throws InvocationTargetException {
27
	public static IProject[] importProjectSet(String filename, Shell shell, IProgressMonitor monitor) throws InvocationTargetException {
28
		try {
29
			return importProjectSet(new FileInputStream(filename), filename, shell, monitor);
30
		} catch (FileNotFoundException e) {
31
			throw new InvocationTargetException(e);
32
		}
33
	}
34
35
	public static IProject[] importProjectSet(InputStream is, Shell shell, IProgressMonitor monitor)
36
			throws InvocationTargetException {
37
		return importProjectSet(is, null, shell, monitor);
38
	}
39
40
	private static IProject[] importProjectSet(InputStream is, String filename, Shell shell,
41
			IProgressMonitor monitor) throws InvocationTargetException {
28
		InputStreamReader reader = null;
42
		InputStreamReader reader = null;
29
		try {
43
		try {
30
			reader = new InputStreamReader(new FileInputStream(filename), "UTF-8"); //$NON-NLS-1$
44
			reader = new InputStreamReader(is, "UTF-8"); //$NON-NLS-1$
31
			
45
			
32
			XMLMemento xmlMemento = XMLMemento.createReadRoot(reader);
46
			XMLMemento xmlMemento = XMLMemento.createReadRoot(reader);
33
			String version = xmlMemento.getString("version"); //$NON-NLS-1$
47
			String version = xmlMemento.getString("version"); //$NON-NLS-1$

Return to bug 162608