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/ProjectSetImporter.java (-7 / +83 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 30-41 Link Here
30
import org.eclipse.ui.*;
30
import org.eclipse.ui.*;
31
31
32
public class ProjectSetImporter {
32
public class ProjectSetImporter {
33
	
33
34
	public static IProject[] importProjectSet(String filename, Shell shell, IProgressMonitor monitor) throws InvocationTargetException {
34
	/**
35
	 * Imports a psf file based on a file content. This may be used when psf
36
	 * file is imported from any other location that local filesystem.
37
	 * 
38
	 * @param psfContents
39
	 *            the content of the psf file.
40
	 * @param filename
41
	 *            the name of the source file. This is included in case the
42
	 *            provider needs to deduce relative paths
43
	 * @param shell
44
	 * @param monitor
45
	 * @return list of new projects
46
	 * @throws InvocationTargetException
47
	 */
48
	public static IProject[] importProjectSetFromString(String psfContents,
49
			String filename, Shell shell, IProgressMonitor monitor)
50
			throws InvocationTargetException {
51
		XMLMemento xmlMemento = stringToXMLMemento(psfContents);
52
		return importProjectSet(xmlMemento, filename, shell, monitor);
53
	}
54
55
	/**
56
	 * Imports a psf file.
57
	 * 
58
	 * @param filename
59
	 * @param shell
60
	 * @param monitor
61
	 * @return list of new projects
62
	 * @throws InvocationTargetException
63
	 */
64
	public static IProject[] importProjectSet(String filename, Shell shell,
65
			IProgressMonitor monitor) throws InvocationTargetException {
66
		XMLMemento xmlMemento = filenameToXMLMemento(filename);
67
		return importProjectSet(xmlMemento, filename, shell, monitor);
68
	}
69
70
	private static IProject[] importProjectSet(XMLMemento xmlMemento,
71
			String filename, Shell shell, IProgressMonitor monitor)
72
			throws InvocationTargetException {
35
		try {
73
		try {
36
			XMLMemento xmlMemento = filenameToXMLMemento(filename);
74
37
			String version = xmlMemento.getString("version"); //$NON-NLS-1$
75
			String version = xmlMemento.getString("version"); //$NON-NLS-1$
38
			
76
39
			List newProjects = new ArrayList();
77
			List newProjects = new ArrayList();
40
			if (version.equals("1.0")){ //$NON-NLS-1$
78
			if (version.equals("1.0")){ //$NON-NLS-1$
41
				IProjectSetSerializer serializer = Team.getProjectSetSerializer("versionOneSerializer"); //$NON-NLS-1$
79
				IProjectSetSerializer serializer = Team.getProjectSetSerializer("versionOneSerializer"); //$NON-NLS-1$
Lines 179-185 Link Here
179
			}
217
			}
180
		}
218
		}
181
	}
219
	}
182
	
220
221
	private static XMLMemento stringToXMLMemento(String stringContents)
222
			throws InvocationTargetException {
223
		StringReader reader = null;
224
		try {
225
			reader = new StringReader(stringContents);
226
			return XMLMemento.createReadRoot(reader);
227
		} catch (WorkbenchException e) {
228
			throw new InvocationTargetException(e);
229
		} finally {
230
			if (reader != null) {
231
				reader.close();
232
			}
233
		}
234
	}
235
236
	/**
237
	 * Check if given file is a valid psf file
238
	 * 
239
	 * @param filename
240
	 * @return <code>true</code> is file is a valid psf file
241
	 */
183
	public static boolean isValidProjectSetFile(String filename) {
242
	public static boolean isValidProjectSetFile(String filename) {
184
		try {
243
		try {
185
			return filenameToXMLMemento(filename).getString("version") != null; //$NON-NLS-1$
244
			return filenameToXMLMemento(filename).getString("version") != null; //$NON-NLS-1$
Lines 187-193 Link Here
187
			return false;
246
			return false;
188
		}
247
		}
189
	}
248
	}
190
	
249
250
	/**
251
	 * Check if given string is a valid project set
252
	 * 
253
	 * @param psfContent
254
	 * @return <code>true</code> if psfContent is a valid project set
255
	 */
256
	public static boolean isValidProjectSetString(String psfContent) {
257
		if (psfContent == null) {
258
			return false;
259
		}
260
		try {
261
			return stringToXMLMemento(psfContent).getString("version") != null; //$NON-NLS-1$
262
		} catch (InvocationTargetException e) {
263
			return false;
264
		}
265
	}
266
191
	private static void mergeWorkingSets(IWorkingSet newWs, IWorkingSet oldWs) {
267
	private static void mergeWorkingSets(IWorkingSet newWs, IWorkingSet oldWs) {
192
		IAdaptable[] oldElements = oldWs.getElements();
268
		IAdaptable[] oldElements = oldWs.getElements();
193
		IAdaptable[] newElements = newWs.getElements();
269
		IAdaptable[] newElements = newWs.getElements();
(-)src/org/eclipse/team/internal/ui/TeamUIMessages.java (-1 / +7 lines)
Lines 105-110 Link Here
105
	public static String HistoryPageCompareEditorInput_0;
105
	public static String HistoryPageCompareEditorInput_0;
106
106
107
	public static String ImportProjectSetMainPage_AddToWorkingSet;
107
	public static String ImportProjectSetMainPage_AddToWorkingSet;
108
	public static String ImportProjectSetMainPage_Project_Set_File;
109
	public static String ImportProjectSetMainPage_Project_Set_Url;
108
110
109
	public static String ImportProjectSetMainPage_Browse;
111
	public static String ImportProjectSetMainPage_Browse;
110
	
112
	
Lines 114-119 Link Here
114
	public static String ImportProjectSetDialog_duplicatedWorkingSet_merge;
116
	public static String ImportProjectSetDialog_duplicatedWorkingSet_merge;
115
	public static String ImportProjectSetDialog_duplicatedWorkingSet_skip;
117
	public static String ImportProjectSetDialog_duplicatedWorkingSet_skip;
116
	public static String ImportProjectSetDialog_duplicatedWorkingSet_applyToAll;
118
	public static String ImportProjectSetDialog_duplicatedWorkingSet_applyToAll;
119
	public static String ImportProjectSetDialog_malformed_url;
120
	public static String ImportProjectSetDialog_URLConnecting;
121
	public static String ImportProjectSetDialog_URLFetchingContent;
117
122
118
	public static String information;
123
	public static String information;
119
    
124
    
Lines 310-317 Link Here
310
	public static String ExportProjectSetMainPage_Initial_description;
315
	public static String ExportProjectSetMainPage_Initial_description;
311
	public static String ExportProjectSetMainPage_specifyFile;
316
	public static String ExportProjectSetMainPage_specifyFile;
312
317
313
	public static String ImportProjectSetMainPage_Project_Set_File_Name__2;
314
	public static String ImportProjectSetMainPage_Browse_3;
318
	public static String ImportProjectSetMainPage_Browse_3;
319
	public static String ImportProjectSetMainPage_The_given_URL_cannot_be_loaded;
315
	public static String ImportProjectSetMainPage_The_specified_file_does_not_exist_4;
320
	public static String ImportProjectSetMainPage_The_specified_file_does_not_exist_4;
316
	public static String ImportProjectSetMainPage_You_have_specified_a_folder_5;
321
	public static String ImportProjectSetMainPage_You_have_specified_a_folder_5;
317
	public static String ImportProjectSetMainPage_workingSetNameEmpty;
322
	public static String ImportProjectSetMainPage_workingSetNameEmpty;
Lines 320-325 Link Here
320
	public static String ImportProjectSetMainPage_runInBackground;
325
	public static String ImportProjectSetMainPage_runInBackground;
321
	public static String ImportProjectSetMainPage_jobName;
326
	public static String ImportProjectSetMainPage_jobName;
322
	public static String ImportProjectSetMainPage_specifyFile;
327
	public static String ImportProjectSetMainPage_specifyFile;
328
	public static String ImportProjectSetMainPage_specifyURL;
323
	public static String ImportProjectSetMainPage_selectWorkingSet;
329
	public static String ImportProjectSetMainPage_selectWorkingSet;
324
	public static String ImportProjectSetMainPage_projectSetFileInvalid;
330
	public static String ImportProjectSetMainPage_projectSetFileInvalid;
325
331
(-)src/org/eclipse/team/internal/ui/messages.properties (-1 / +7 lines)
Lines 104-112 Link Here
104
ExportProjectSetMainPage_Initial_description=Define which projects or working sets should be exported into the team project file.
104
ExportProjectSetMainPage_Initial_description=Define which projects or working sets should be exported into the team project file.
105
ExportProjectSetMainPage_specifyFile=Please specify the destination file.
105
ExportProjectSetMainPage_specifyFile=Please specify the destination file.
106
106
107
ImportProjectSetMainPage_Project_Set_File_Name__2=F&ile name:
107
ImportProjectSetMainPage_Project_Set_File=File
108
ImportProjectSetMainPage_Project_Set_Url=URL
108
ImportProjectSetMainPage_Browse_3=B&rowse...
109
ImportProjectSetMainPage_Browse_3=B&rowse...
109
ImportProjectSetMainPage_Browse=Br&owse...
110
ImportProjectSetMainPage_Browse=Br&owse...
111
ImportProjectSetMainPage_The_given_URL_cannot_be_loaded=File from given URL cannot be loaded
110
ImportProjectSetMainPage_The_specified_file_does_not_exist_4=The specified file does not exist
112
ImportProjectSetMainPage_The_specified_file_does_not_exist_4=The specified file does not exist
111
ImportProjectSetMainPage_You_have_specified_a_folder_5=You have specified a folder
113
ImportProjectSetMainPage_You_have_specified_a_folder_5=You have specified a folder
112
ImportProjectSetMainPage_workingSetNameEmpty=The working set name must not be empty
114
ImportProjectSetMainPage_workingSetNameEmpty=The working set name must not be empty
Lines 116-121 Link Here
116
ImportProjectSetMainPage_runInBackground=Run the import in the bac&kground
118
ImportProjectSetMainPage_runInBackground=Run the import in the bac&kground
117
ImportProjectSetMainPage_jobName=Importing project set...
119
ImportProjectSetMainPage_jobName=Importing project set...
118
ImportProjectSetMainPage_specifyFile=Please specify a file to import.
120
ImportProjectSetMainPage_specifyFile=Please specify a file to import.
121
ImportProjectSetMainPage_specifyURL=Please specify an URL to import.
119
ImportProjectSetMainPage_selectWorkingSet=Select a working set.
122
ImportProjectSetMainPage_selectWorkingSet=Select a working set.
120
ImportProjectSetMainPage_projectSetFileInvalid=The specified file is not a valid Team Project Set file.
123
ImportProjectSetMainPage_projectSetFileInvalid=The specified file is not a valid Team Project Set file.
121
ImportProjectSetDialog_duplicatedWorkingSet_title=Working Set Exists
124
ImportProjectSetDialog_duplicatedWorkingSet_title=Working Set Exists
Lines 124-129 Link Here
124
ImportProjectSetDialog_duplicatedWorkingSet_merge=&Merge
127
ImportProjectSetDialog_duplicatedWorkingSet_merge=&Merge
125
ImportProjectSetDialog_duplicatedWorkingSet_skip=&Skip
128
ImportProjectSetDialog_duplicatedWorkingSet_skip=&Skip
126
ImportProjectSetDialog_duplicatedWorkingSet_applyToAll=&Apply to all working sets in this import
129
ImportProjectSetDialog_duplicatedWorkingSet_applyToAll=&Apply to all working sets in this import
130
ImportProjectSetDialog_malformed_url=Malformed URL
131
ImportProjectSetDialog_URLConnecting=Opening connection to the URL
132
ImportProjectSetDialog_URLFetchingContent=Fetching content from the URL
127
133
128
ProjectSetContentHandler_Element_provider_must_be_contained_in_element_psf_4=Element provider must be contained in element psf
134
ProjectSetContentHandler_Element_provider_must_be_contained_in_element_psf_4=Element provider must be contained in element psf
129
ProjectSetContentHandler_Element_project_must_be_contained_in_element_provider_7=Element project must be contained in element provider
135
ProjectSetContentHandler_Element_project_must_be_contained_in_element_provider_7=Element project must be contained in element provider
(-)src/org/eclipse/team/internal/ui/wizards/ExportProjectSetLocationPage.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2008 IBM Corporation and others.
2
 * Copyright (c) 2006, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 91-98 Link Here
91
		inner.setLayoutData(data);
91
		inner.setLayoutData(data);
92
92
93
		fileCombo = createDropDownCombo(inner);
93
		fileCombo = createDropDownCombo(inner);
94
		file = PsfFilenameStore.getSuggestedDefault();
94
		file = PsfFilenameStore.getInstance().getSuggestedDefault();
95
		fileCombo.setItems(PsfFilenameStore.getHistory());
95
		fileCombo.setItems(PsfFilenameStore.getInstance().getHistory());
96
		fileCombo.setText(file);
96
		fileCombo.setText(file);
97
		fileCombo.addListener(SWT.Modify, new Listener() {
97
		fileCombo.addListener(SWT.Modify, new Listener() {
98
			public void handleEvent(Event event) {
98
			public void handleEvent(Event event) {
(-)src/org/eclipse/team/internal/ui/wizards/ImportProjectSetMainPage.java (-10 / +252 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-22 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.lang.reflect.InvocationTargetException;
15
import java.lang.reflect.Method;
16
import java.net.*;
14
17
15
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.resources.ResourcesPlugin;
19
import org.eclipse.core.runtime.*;
16
import org.eclipse.jface.dialogs.Dialog;
20
import org.eclipse.jface.dialogs.Dialog;
17
import org.eclipse.jface.dialogs.IDialogConstants;
21
import org.eclipse.jface.dialogs.IDialogConstants;
22
import org.eclipse.jface.operation.IRunnableWithProgress;
18
import org.eclipse.jface.resource.ImageDescriptor;
23
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.dnd.Clipboard;
26
import org.eclipse.swt.dnd.TextTransfer;
20
import org.eclipse.swt.events.SelectionAdapter;
27
import org.eclipse.swt.events.SelectionAdapter;
21
import org.eclipse.swt.events.SelectionEvent;
28
import org.eclipse.swt.events.SelectionEvent;
22
import org.eclipse.swt.layout.GridData;
29
import org.eclipse.swt.layout.GridData;
Lines 32-47 Link Here
32
	String file = ""; //$NON-NLS-1$
39
	String file = ""; //$NON-NLS-1$
33
	Button browseButton;
40
	Button browseButton;
34
	
41
	
42
	String urlString = ""; //$NON-NLS-1$
43
	Combo urlCombo;
44
	
45
	//input type radios
46
	private Button fileInputButton;
47
	private Button urlInputButton;
48
	
49
	//input type
50
	public static final int InputType_file = 0;
51
	public static final int InputType_URL = 1;
52
	private int inputType = InputType_file;
53
	
35
	private boolean runInBackground = isRunInBackgroundPreferenceOn();
54
	private boolean runInBackground = isRunInBackgroundPreferenceOn();
36
	// a wizard shouldn't be in an error state until the state has been modified by the user
55
	// a wizard shouldn't be in an error state until the state has been modified by the user
37
	private int messageType = NONE;
56
	private int messageType = NONE;
38
	private WorkingSetGroup workingSetGroup; 
57
	private WorkingSetGroup workingSetGroup; 
39
	
58
	
59
	private PsfFilenameStore psfFilenameStore = PsfFilenameStore.getInstance();
60
	private PsfUrlStore psfUrlStore = PsfUrlStore.getInstance();
61
	
40
	public ImportProjectSetMainPage(String pageName, String title, ImageDescriptor titleImage) {
62
	public ImportProjectSetMainPage(String pageName, String title, ImageDescriptor titleImage) {
41
		super(pageName, title, titleImage);
63
		super(pageName, title, titleImage);
42
		setDescription(TeamUIMessages.ImportProjectSetMainPage_description); 
64
		setDescription(TeamUIMessages.ImportProjectSetMainPage_description); 
43
	}
65
	}
44
	
66
	
67
	private void setInputType(int inputTypeSelected){
68
		this.inputType = inputTypeSelected;
69
		//reset the message type and give the user fresh chance to input correct data
70
		messageType = NONE;
71
		//update controls
72
		fileInputButton.setSelection(inputType==InputType_file);
73
		fileCombo.setEnabled(inputType==InputType_file);
74
		browseButton.setEnabled(inputType==InputType_file);
75
		urlInputButton.setSelection(inputType==InputType_URL);
76
		urlCombo.setEnabled(inputType==InputType_URL);
77
		//validate field
78
		if(inputType==InputType_file) updateFileEnablement();
79
		if(inputType==InputType_URL) updateUrlEnablement();
80
		
81
	}
82
	
45
	/*
83
	/*
46
	 * @see IDialogPage#createControl(Composite)
84
	 * @see IDialogPage#createControl(Composite)
47
	 */
85
	 */
Lines 60-80 Link Here
60
		layout.marginWidth = 0;
98
		layout.marginWidth = 0;
61
		inner.setLayout(layout);
99
		inner.setLayout(layout);
62
		
100
		
63
		createLabel(inner, TeamUIMessages.ImportProjectSetMainPage_Project_Set_File_Name__2); 
101
		fileInputButton = new Button(inner, SWT.RADIO);
102
		fileInputButton.setText(TeamUIMessages.ImportProjectSetMainPage_Project_Set_File);
103
		fileInputButton.setEnabled(true);
104
		fileInputButton.addSelectionListener(new SelectionAdapter() {
105
			public void widgetSelected(SelectionEvent e) {
106
				setInputType(InputType_file);
107
			}
108
		});
64
109
65
		fileCombo = createDropDownCombo(inner);
110
		fileCombo = createDropDownCombo(inner);
66
		file = PsfFilenameStore.getSuggestedDefault();
111
		file = psfFilenameStore.getSuggestedDefault();
67
		fileCombo.setItems(PsfFilenameStore.getHistory());
112
		fileCombo.setItems(psfFilenameStore.getHistory());
68
		fileCombo.setText(file);
113
		fileCombo.setText(file);
69
		fileCombo.addListener(SWT.Modify, new Listener() {
114
		fileCombo.addListener(SWT.Modify, new Listener() {
70
			public void handleEvent(Event event) {
115
			public void handleEvent(Event event) {
71
				file = fileCombo.getText();				
116
				file = fileCombo.getText();				
72
				updateEnablement();
117
				updateFileEnablement();
73
			}
118
			}
74
		});
119
		});
75
120
76
		browseButton = new Button(inner, SWT.PUSH);
121
		browseButton = new Button(inner, SWT.PUSH);
77
		browseButton.setText(TeamUIMessages.ImportProjectSetMainPage_Browse_3); 
122
		browseButton.setText(TeamUIMessages.ImportProjectSetMainPage_Browse_3); 
123
		
124
		urlInputButton = new Button(inner, SWT.RADIO);
125
		urlInputButton.setText(TeamUIMessages.ImportProjectSetMainPage_Project_Set_Url);
126
		urlInputButton.addSelectionListener(new SelectionAdapter() {
127
			public void widgetSelected(SelectionEvent e) {
128
				setInputType(InputType_URL);
129
			}
130
		});
131
		urlCombo = createDropDownCombo(inner);
132
		urlString = psfUrlStore.getSuggestedDefault();
133
		urlCombo.setItems(psfUrlStore.getHistory());
134
		urlCombo.setText(urlString);
135
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
136
		gd.horizontalSpan=2;
137
		urlCombo.setLayoutData(gd);
138
		urlCombo.addListener(SWT.Modify, new Listener() {
139
			public void handleEvent(Event event) {
140
				urlString=urlCombo.getText();
141
				updateUrlEnablement();
142
			}
143
		});
144
				
145
		
78
		GridData data = new GridData();
146
		GridData data = new GridData();
79
		data.horizontalAlignment = GridData.FILL;
147
		data.horizontalAlignment = GridData.FILL;
80
		int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
148
		int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
Lines 115-126 Link Here
115
		});
183
		});
116
		
184
		
117
		setControl(composite);
185
		setControl(composite);
118
		updateEnablement();
186
		setDefaultInputType();
119
		Dialog.applyDialogFont(parent);
187
		Dialog.applyDialogFont(parent);
120
		// future messages will be of type error
121
		messageType = ERROR;
122
	}
188
	}
123
189
190
	private void setDefaultInputType(){
191
		//check for clipboard contents
192
		Control c = getControl();
193
		if (c != null) {
194
			Clipboard clipboard= new Clipboard(c.getDisplay());
195
			Object o= clipboard.getContents(TextTransfer.getInstance());
196
			clipboard.dispose();
197
				if (o instanceof String) {
198
					try {
199
						URL url = new URL((String)o);
200
						if(url != null) {
201
							setInputType(InputType_URL);
202
							urlCombo.setText((String)o);
203
							return;
204
						}
205
					} catch (MalformedURLException e) {
206
						// ignore, it's not and URL
207
					}
208
				}
209
		}
210
		setInputType(InputType_file);
211
	}
212
	
124
	private void addWorkingSetSection(Composite composite) {
213
	private void addWorkingSetSection(Composite composite) {
125
		workingSetGroup = new WorkingSetGroup(
214
		workingSetGroup = new WorkingSetGroup(
126
				composite,
215
				composite,
Lines 129-137 Link Here
129
						"org.eclipse.jdt.ui.JavaWorkingSetPage" /* JavaWorkingSetUpdater.ID */}); //$NON-NLS-1$
218
						"org.eclipse.jdt.ui.JavaWorkingSetPage" /* JavaWorkingSetUpdater.ID */}); //$NON-NLS-1$
130
	}
219
	}
131
	
220
	
132
	private void updateEnablement() {
221
	private void updateUrlEnablement() {
222
		boolean complete = false;
223
		setMessage(null);
224
		setErrorMessage(null);
225
226
		if (urlString.length() == 0) {
227
			setMessage(TeamUIMessages.ImportProjectSetMainPage_specifyURL, messageType);
228
			complete = false;
229
		} else {
230
231
			try {
232
				new URL(urlString);
233
				// the URL is correct, we can clear the error message
234
				complete = true;
235
			} catch (MalformedURLException e) {
236
				messageType = ERROR;
237
				setMessage(TeamUIMessages.ImportProjectSetDialog_malformed_url, messageType);
238
				complete = false;
239
			}
240
		}
241
242
		if (complete) {
243
			setErrorMessage(null);
244
			setDescription(TeamUIMessages.ImportProjectSetMainPage_description);
245
		}
246
247
		setPageComplete(complete);
248
	}
249
250
	private void updateFileEnablement() {
133
		boolean complete = false;
251
		boolean complete = false;
134
		setMessage(null);
252
		setMessage(null);
253
		setErrorMessage(null);
135
		
254
		
136
		if (file.length() == 0) {
255
		if (file.length() == 0) {
137
			setMessage(TeamUIMessages.ImportProjectSetMainPage_specifyFile, messageType);
256
			setMessage(TeamUIMessages.ImportProjectSetMainPage_specifyFile, messageType);
Lines 141-154 Link Here
141
			// See if the file exists
260
			// See if the file exists
142
			File f = new File(file);
261
			File f = new File(file);
143
			if (!f.exists()) {
262
			if (!f.exists()) {
263
				messageType = ERROR;
144
				setMessage(TeamUIMessages.ImportProjectSetMainPage_The_specified_file_does_not_exist_4, messageType); 
264
				setMessage(TeamUIMessages.ImportProjectSetMainPage_The_specified_file_does_not_exist_4, messageType); 
145
				setPageComplete(false);
265
				setPageComplete(false);
146
				return;
266
				return;
147
			} else if (f.isDirectory()) {
267
			} else if (f.isDirectory()) {
268
				messageType = ERROR;
148
				setMessage(TeamUIMessages.ImportProjectSetMainPage_You_have_specified_a_folder_5, messageType); 
269
				setMessage(TeamUIMessages.ImportProjectSetMainPage_You_have_specified_a_folder_5, messageType); 
149
				setPageComplete(false);
270
				setPageComplete(false);
150
				return;
271
				return;
151
			} else if (!ProjectSetImporter.isValidProjectSetFile(file)) {
272
			} else if (!ProjectSetImporter.isValidProjectSetFile(file)) {
273
				messageType = ERROR;
152
				setMessage(TeamUIMessages.ImportProjectSetMainPage_projectSetFileInvalid, messageType);
274
				setMessage(TeamUIMessages.ImportProjectSetMainPage_projectSetFileInvalid, messageType);
153
				setPageComplete(false);
275
				setPageComplete(false);
154
				return;
276
				return;
Lines 167-172 Link Here
167
	public String getFileName() {
289
	public String getFileName() {
168
		return file;
290
		return file;
169
	}
291
	}
292
	
293
	public String getUrl(){
294
		return urlString;
295
	}
170
296
171
	public void setVisible(boolean visible) {
297
	public void setVisible(boolean visible) {
172
		super.setVisible(visible);
298
		super.setVisible(visible);
Lines 193-196 Link Here
193
	public boolean isRunInBackgroundOn() {
319
	public boolean isRunInBackgroundOn() {
194
		return runInBackground;
320
		return runInBackground;
195
	}
321
	}
322
	
323
	public int getInputType(){
324
		return inputType;
325
	}
326
	
327
	public String getURLContents() {
328
		final URL url;
329
		try {
330
			url = new URL(urlString);
331
			PsfUrlStore.getInstance().remember(urlString);
332
			final String[] result = new String[1];
333
			try {
334
				getContainer().run(true, true, new IRunnableWithProgress() {
335
					public void run(IProgressMonitor monitor)
336
							throws InvocationTargetException,
337
							InterruptedException {
338
						SubMonitor progress = SubMonitor
339
								.convert(
340
										monitor,
341
										TeamUIMessages.ImportProjectSetDialog_URLConnecting,
342
										100);
343
						try {
344
							URLConnection connection = url.openConnection();
345
							progress.worked(10);
346
							if (monitor.isCanceled())
347
								throw new OperationCanceledException();
348
							setReadTimeout(connection, (60 * 1000));
349
							progress.setTaskName(TeamUIMessages.ImportProjectSetDialog_URLFetchingContent);
350
							String enc = connection.getContentEncoding();
351
							if (enc == null)
352
								enc = ResourcesPlugin.getEncoding();
353
							result[0] = readPsfFromURL(
354
									connection.getInputStream(), enc,
355
									connection.getContentLength(),
356
									progress.newChild(90));
357
						} catch (SocketTimeoutException e) { // timeout
358
							throw new InvocationTargetException(e);
359
						} catch (IOException e) { //cannot load file
360
							throw new InvocationTargetException(e);
361
						}finally{
362
							monitor.done();
363
						}
364
					}
365
				});
366
				
367
				if(ProjectSetImporter.isValidProjectSetString(result[0])){
368
					return result[0];	
369
				}else{
370
					messageType = ERROR;
371
					setMessage(TeamUIMessages.ImportProjectSetMainPage_projectSetFileInvalid, messageType);
372
					setPageComplete(false);
373
					return null;
374
				}
375
				
376
			} catch (OperationCanceledException e) { // ignore
377
			} catch (InvocationTargetException e) { // ignore
378
				messageType = ERROR;
379
				setMessage(TeamUIMessages.ImportProjectSetMainPage_The_given_URL_cannot_be_loaded, messageType);
380
				setPageComplete(false);
381
			} catch (InterruptedException e) { // ignore
382
			}
383
		} catch (MalformedURLException e) {
384
			// ignore as we tested it with modify listener on combo
385
		}
386
		return null;
387
	}
388
	
389
390
	private boolean setReadTimeout(URLConnection connection, int timeout) {
391
		//check if setReadTimeout method is available for current java
392
		//and if it is call it
393
		Method[] methods = connection.getClass().getMethods();
394
		for (int i = 0; i < methods.length; i++) {
395
			if (methods[i].getName().equals("setReadTimeout")) //$NON-NLS-1$
396
				try {
397
					methods[i].invoke(connection, new Object[] {new Integer(timeout)});
398
					return true;
399
				} catch (IllegalArgumentException e) { // ignore
400
				} catch (IllegalAccessException e) { // ignore
401
				} catch (InvocationTargetException e) { // ignore
402
				}
403
		}
404
		return false;
405
	}
406
407
	private String readPsfFromURL(InputStream is, String encoding, int length,
408
			IProgressMonitor monitor) throws IOException {
409
		SubMonitor progress = SubMonitor.convert(monitor);
410
		progress.setWorkRemaining(length);
411
		if (is == null)
412
			return null;
413
		BufferedReader reader = null;
414
		try {
415
			StringBuffer buffer = new StringBuffer();
416
			char[] part = new char[2048];
417
			int read = 0;
418
			reader = new BufferedReader(new InputStreamReader(is, encoding));
419
			while ((read = reader.read(part)) != -1) {
420
				buffer.append(part, 0, read);
421
				progress.worked(2048);
422
				if (progress.isCanceled())
423
					throw new OperationCanceledException();
424
			}
425
426
			return buffer.toString();
427
		} finally {
428
			if (reader != null) {
429
				try {
430
					reader.close();
431
				} catch (IOException ex) {
432
					// silently ignored
433
				}
434
			}
435
		}
436
	}
437
	
196
}
438
}
(-)src/org/eclipse/team/internal/ui/wizards/ImportProjectSetOperation.java (-8 / +49 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2008 IBM Corporation and others.
2
 * Copyright (c) 2007, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 22-30 Link Here
22
import org.eclipse.ui.IWorkingSetManager;
22
import org.eclipse.ui.IWorkingSetManager;
23
23
24
public class ImportProjectSetOperation extends TeamOperation {
24
public class ImportProjectSetOperation extends TeamOperation {
25
25
	
26
	private String psfFileContents;
27
	private String urlString;
26
	private String psfFile;
28
	private String psfFile;
27
	private IWorkingSet[] workingSets;
29
	private IWorkingSet[] workingSets;
30
	
31
	
32
	/**
33
	 * Operation for importing a Team Project Set stored in a String
34
	 * 
35
	 * @param context
36
	 *            a runnable context,
37
	 *            <code>null</null> for running in background
38
	 * @param psfFileContents
39
	 *            the psf file content to load
40
	 * @param urlString
41
	 *            url or path to file loaded into <code>psfFileContents</code>
42
	 * @param workingSets
43
	 *            an array of working sets where imported project should be
44
	 *            added. If a working set doesn't exist it will be created. The
45
	 *            array cannot be <code>null</code>, pass an empty array if you
46
	 *            don't want to add projects to any working set.
47
	 */
48
	public ImportProjectSetOperation(IRunnableContext context,
49
			String psfFileContents, String urlString, IWorkingSet[] workingSets) {
50
		super(context);
51
		this.psfFileContents = psfFileContents;
52
		this.workingSets = workingSets;
53
		this.urlString = urlString;
54
	}
28
55
29
	/**
56
	/**
30
	 * Operation for importing a Team Project Set file
57
	 * Operation for importing a Team Project Set file
Lines 45-62 Link Here
45
		this.psfFile = psfFile;
72
		this.psfFile = psfFile;
46
		this.workingSets = workingSets;
73
		this.workingSets = workingSets;
47
	}
74
	}
75
	
76
	private void runForStringContent(IProgressMonitor monitor) throws InvocationTargetException{
77
		IProject[] newProjects = ProjectSetImporter.importProjectSetFromString(
78
				psfFileContents, urlString, getShell(), monitor);
79
		createWorkingSet(workingSets, newProjects);
80
	}
81
	
82
	private void runForFile(IProgressMonitor monitor) throws InvocationTargetException{
83
		PsfFilenameStore.getInstance().remember(psfFile);
84
		IProject[] newProjects = ProjectSetImporter.importProjectSet(psfFile,
85
				getShell(), monitor);
86
		createWorkingSet(workingSets, newProjects);
87
	}
48
88
49
	/*
89
	/*
50
	 * (non-Javadoc)
90
	 * (non-Javadoc)
51
	 * 
91
	 * 
52
	 * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
92
	 * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
53
	 */
93
	 */
54
	public void run(IProgressMonitor monitor) throws InvocationTargetException,
94
	public void run(IProgressMonitor monitor)
55
			InterruptedException {
95
			throws InvocationTargetException, InterruptedException{
56
		PsfFilenameStore.remember(psfFile);
96
		if(psfFileContents!=null){
57
		IProject[] newProjects = ProjectSetImporter.importProjectSet(psfFile,
97
			runForStringContent(monitor);
58
				getShell(), monitor);
98
		}else{
59
		createWorkingSet(workingSets, newProjects);
99
			runForFile(monitor);
100
		}
60
	}
101
	}
61
102
62
	/*
103
	/*
(-)src/org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard.java (-1 / +1 lines)
Lines 59-65 Link Here
59
					if (path.getFileExtension() == null) {
59
					if (path.getFileExtension() == null) {
60
						filename = filename + ".psf"; //$NON-NLS-1$
60
						filename = filename + ".psf"; //$NON-NLS-1$
61
					}
61
					}
62
					PsfFilenameStore.remember(filename);
62
					PsfFilenameStore.getInstance().remember(filename);
63
					File file = new File(filename);
63
					File file = new File(filename);
64
					File parentFile = file.getParentFile();
64
					File parentFile = file.getParentFile();
65
					if (parentFile != null && !parentFile.exists()) {
65
					if (parentFile != null && !parentFile.exists()) {
(-)src/org/eclipse/team/internal/ui/wizards/ProjectSetImportWizard.java (-5 / +16 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 40-48 Link Here
40
	public boolean performFinish() {
40
	public boolean performFinish() {
41
		final boolean[] result = new boolean[] {false};
41
		final boolean[] result = new boolean[] {false};
42
		try {
42
		try {
43
			ImportProjectSetOperation op = new ImportProjectSetOperation(
43
			ImportProjectSetOperation op;
44
					mainPage.isRunInBackgroundOn() ? null : getContainer(),
44
			if (mainPage.getInputType() == ImportProjectSetMainPage.InputType_URL) {
45
					mainPage.getFileName(), mainPage.getWorkingSets());
45
				String psfContent = mainPage.getURLContents();
46
				if(psfContent==null){
47
					return false;
48
				}
49
				op = new ImportProjectSetOperation(
50
						mainPage.isRunInBackgroundOn() ? null : getContainer(),
51
						psfContent, mainPage.getUrl(), mainPage.getWorkingSets());
52
			} else {
53
				op = new ImportProjectSetOperation(
54
						mainPage.isRunInBackgroundOn() ? null : getContainer(),
55
						mainPage.getFileName(), mainPage.getWorkingSets());
56
			}
46
			op.run();
57
			op.run();
47
			result[0] = true;
58
			result[0] = true;
48
		} catch (InterruptedException e) {
59
		} catch (InterruptedException e) {
Lines 71-76 Link Here
71
	public void init(IWorkbench workbench, IStructuredSelection selection) {
82
	public void init(IWorkbench workbench, IStructuredSelection selection) {
72
		// The code that finds "selection" is broken (it is always empty), so we
83
		// The code that finds "selection" is broken (it is always empty), so we
73
		// must dig for the selection in the workbench.
84
		// must dig for the selection in the workbench.
74
		PsfFilenameStore.setDefaultFromSelection(workbench);
85
		PsfFilenameStore.getInstance().setDefaultFromSelection(workbench);
75
	}
86
	}
76
}
87
}
(-)src/org/eclipse/team/internal/ui/wizards/PsfFilenameStore.java (-77 / +20 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-36 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.util.Vector;
14
15
import org.eclipse.core.resources.IResource;
13
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.resources.IWorkspace;
14
import org.eclipse.core.resources.IWorkspace;
17
import org.eclipse.core.runtime.IAdaptable;
15
import org.eclipse.core.runtime.IAdaptable;
18
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.IPath;
19
import org.eclipse.jface.dialogs.IDialogSettings;
20
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.jface.viewers.ISelection;
21
import org.eclipse.jface.viewers.IStructuredSelection;
18
import org.eclipse.jface.viewers.IStructuredSelection;
22
import org.eclipse.team.internal.ui.TeamUIPlugin;
19
import org.eclipse.ui.*;
23
import org.eclipse.ui.IWorkbench;
20
24
import org.eclipse.ui.IWorkbenchPage;
21
public class PsfFilenameStore extends PsfStore {
25
import org.eclipse.ui.IWorkbenchWindow;
26
27
public class PsfFilenameStore {
28
	// Most recently used filename is first in the array.
29
	// Least recently used filename is at the end of the list.
30
	// When the list overflows, items drop off the end.
31
	private static final int HISTORY_LENGTH = 10;
32
22
33
	private static final String STORE_SECTION = "ImportPSFDialog"; //$NON-NLS-1$
34
	private static final String FILENAMES = "filenames"; //$NON-NLS-1$
23
	private static final String FILENAMES = "filenames"; //$NON-NLS-1$
35
	private static final String PREVIOUS = "previous"; //$NON-NLS-1$
24
	private static final String PREVIOUS = "previous"; //$NON-NLS-1$
36
25
Lines 38-50 Link Here
38
	// This is only a cache; it is not part of the history until the user has used it.
27
	// This is only a cache; it is not part of the history until the user has used it.
39
	private static String _selectedFilename = null;
28
	private static String _selectedFilename = null;
40
29
41
	private static IDialogSettings _section;
30
	private static PsfFilenameStore instance;
31
	
32
	public static PsfFilenameStore getInstance(){
33
		if(instance==null){
34
			instance = new PsfFilenameStore();
35
		}
36
		return instance;
37
	}
42
38
43
	private PsfFilenameStore() {
39
	private PsfFilenameStore() {
44
		// All-static
40
		// Signleton
45
	}
41
	}
46
42
47
	public static void setDefaultFromSelection(IWorkbench workbench) {
43
	public void setDefaultFromSelection(IWorkbench workbench) {
48
		// Scan the workbench for a selected PSF file
44
		// Scan the workbench for a selected PSF file
49
		IWorkbenchWindow wnd = workbench.getActiveWorkbenchWindow();
45
		IWorkbenchWindow wnd = workbench.getActiveWorkbenchWindow();
50
		IWorkbenchPage pg = wnd.getActivePage();
46
		IWorkbenchPage pg = wnd.getActivePage();
Lines 85-157 Link Here
85
		_selectedFilename = path.toOSString();
81
		_selectedFilename = path.toOSString();
86
	}
82
	}
87
83
88
	public static String getSuggestedDefault() {
84
	public String getSuggestedDefault() {
89
		if (_selectedFilename != null) {
85
		if (_selectedFilename != null) {
90
			return _selectedFilename;
86
			return _selectedFilename;
91
		}
87
		}
92
		return getPrevious();
88
		return getPrevious();
93
	}
89
	}
94
90
95
	private static String getPrevious() {
91
	protected String getPreviousTag() {
96
		IDialogSettings section = getSettingsSection();
92
		return PREVIOUS;
97
		String retval = section.get(PREVIOUS);
98
		if (retval == null) {
99
			retval = ""; //$NON-NLS-1$
100
		}
101
		return retval;
102
	}
93
	}
103
94
104
	public static String[] getHistory() {
95
	protected String getListTag() {
105
		IDialogSettings section = getSettingsSection();
96
		return FILENAMES;
106
		String[] arr = section.getArray(FILENAMES);
107
		if (arr == null) {
108
			arr = new String[0];
109
		}
110
		return arr;
111
	}
97
	}
112
98
113
	public static void remember(String filename) {
99
	
114
		Vector filenames = createVector(getHistory());
115
		if (filenames.contains(filename)) {
116
			// The item is in the list. Remove it and add it back at the
117
			// beginning. If it already was at the beginning this will be a
118
			// waste of time, but it's not even measurable so I don't care.
119
			filenames.remove(filename);
120
		}
121
		// Most recently used filename goes to the beginning of the list
122
		filenames.add(0, filename);
123
124
		// Forget any overflowing items
125
		while (filenames.size() > HISTORY_LENGTH) {
126
			filenames.remove(HISTORY_LENGTH);
127
		}
128
129
		// Make it an array
130
		String[] arr = (String[]) filenames.toArray(new String[filenames.size()]);
131
132
		IDialogSettings section = getSettingsSection();
133
		section.put(FILENAMES, arr);
134
		section.put(PREVIOUS, filename);
135
	}
136
137
	private static Vector createVector(Object[] arr) {
138
		Vector v = new Vector();
139
		for (int ix = 0; ix < arr.length; ++ix) {
140
			v.add(ix, arr[ix]);
141
		}
142
		return v;
143
	}
144
145
	private static IDialogSettings getSettingsSection() {
146
		if (_section != null)
147
			return _section;
148
149
		IDialogSettings settings = TeamUIPlugin.getPlugin().getDialogSettings();
150
		_section = settings.getSection(STORE_SECTION);
151
		if (_section != null)
152
			return _section;
153
154
		_section = settings.addNewSection(STORE_SECTION);
155
		return _section;
156
	}
157
}
100
}
(-)src/org/eclipse/team/internal/ui/wizards/PsfStore.java (+95 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ui.wizards;
12
13
import java.util.Vector;
14
15
import org.eclipse.jface.dialogs.IDialogSettings;
16
import org.eclipse.team.internal.ui.TeamUIPlugin;
17
18
public abstract class PsfStore {
19
	// Most recently used filename is first in the array.
20
	// Least recently used filename is at the end of the list.
21
	// When the list overflows, items drop off the end.
22
	private static final int HISTORY_LENGTH = 10;
23
24
	private static final String STORE_SECTION = "ImportPSFDialog"; //$NON-NLS-1$
25
	
26
	private static IDialogSettings _section;
27
	
28
	protected abstract String getPreviousTag();
29
	protected abstract String getListTag();
30
	
31
	public abstract String getSuggestedDefault();
32
	
33
	protected String getPrevious() {
34
		IDialogSettings section = getSettingsSection();
35
		String retval = section.get(getPreviousTag());
36
		if (retval == null) {
37
			retval = ""; //$NON-NLS-1$
38
		}
39
		return retval;
40
	}
41
42
	public String[] getHistory() {
43
		IDialogSettings section = getSettingsSection();
44
		String[] arr = section.getArray(getListTag());
45
		if (arr == null) {
46
			arr = new String[0];
47
		}
48
		return arr;
49
	}
50
51
	public void remember(String filename) {
52
		Vector filenames = createVector(getHistory());
53
		if (filenames.contains(filename)) {
54
			// The item is in the list. Remove it and add it back at the
55
			// beginning. If it already was at the beginning this will be a
56
			// waste of time, but it's not even measurable so I don't care.
57
			filenames.remove(filename);
58
		}
59
		// Most recently used filename goes to the beginning of the list
60
		filenames.add(0, filename);
61
62
		// Forget any overflowing items
63
		while (filenames.size() > HISTORY_LENGTH) {
64
			filenames.remove(HISTORY_LENGTH);
65
		}
66
67
		// Make it an array
68
		String[] arr = (String[]) filenames.toArray(new String[filenames.size()]);
69
70
		IDialogSettings section = getSettingsSection();
71
		section.put(getListTag(), arr);
72
		section.put(getPreviousTag(), filename);
73
	}
74
75
	private Vector createVector(Object[] arr) {
76
		Vector v = new Vector();
77
		for (int ix = 0; ix < arr.length; ++ix) {
78
			v.add(ix, arr[ix]);
79
		}
80
		return v;
81
	}
82
83
	private IDialogSettings getSettingsSection() {
84
		if (_section != null)
85
			return _section;
86
87
		IDialogSettings settings = TeamUIPlugin.getPlugin().getDialogSettings();
88
		_section = settings.getSection(STORE_SECTION);
89
		if (_section != null)
90
			return _section;
91
92
		_section = settings.addNewSection(STORE_SECTION);
93
		return _section;
94
	}
95
}
(-)src/org/eclipse/team/internal/ui/wizards/PsfUrlStore.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ui.wizards;
12
13
/**
14
 * Stores URL history for importing project sets window.
15
 * 
16
 */
17
public class PsfUrlStore extends PsfStore {
18
19
	private static final String URLS = "urls"; //$NON-NLS-1$
20
	private static final String PREVIOUS = "previous_url"; //$NON-NLS-1$
21
22
	private static PsfUrlStore instance;
23
24
	public static PsfUrlStore getInstance() {
25
		if (instance == null) {
26
			instance = new PsfUrlStore();
27
		}
28
		return instance;
29
	}
30
31
	private PsfUrlStore() {
32
		// signleton
33
	}
34
35
	protected String getPreviousTag() {
36
		return PREVIOUS;
37
	}
38
39
	protected String getListTag() {
40
		return URLS;
41
	}
42
43
	public String getSuggestedDefault() {
44
		return getPrevious();
45
	}
46
47
}

Return to bug 162608