|
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 |
} |