|
Lines 19-34
Link Here
|
| 19 |
import org.eclipse.mylar.internal.core.util.MylarStatusHandler; |
19 |
import org.eclipse.mylar.internal.core.util.MylarStatusHandler; |
| 20 |
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector; |
20 |
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector; |
| 21 |
import org.eclipse.mylar.provisional.tasklist.TaskRepository; |
21 |
import org.eclipse.mylar.provisional.tasklist.TaskRepository; |
|
|
22 |
import org.eclipse.mylar.provisional.tasklist.TaskRepositoryManager; |
| 22 |
import org.eclipse.swt.SWT; |
23 |
import org.eclipse.swt.SWT; |
| 23 |
import org.eclipse.swt.events.SelectionAdapter; |
24 |
import org.eclipse.swt.events.SelectionAdapter; |
| 24 |
import org.eclipse.swt.events.SelectionEvent; |
25 |
import org.eclipse.swt.events.SelectionEvent; |
| 25 |
import org.eclipse.swt.events.SelectionListener; |
26 |
import org.eclipse.swt.events.SelectionListener; |
| 26 |
import org.eclipse.swt.layout.FillLayout; |
27 |
import org.eclipse.swt.layout.FillLayout; |
|
|
28 |
import org.eclipse.swt.layout.GridData; |
| 27 |
import org.eclipse.swt.layout.GridLayout; |
29 |
import org.eclipse.swt.layout.GridLayout; |
| 28 |
import org.eclipse.swt.widgets.Button; |
30 |
import org.eclipse.swt.widgets.Button; |
| 29 |
import org.eclipse.swt.widgets.Combo; |
31 |
import org.eclipse.swt.widgets.Combo; |
| 30 |
import org.eclipse.swt.widgets.Composite; |
32 |
import org.eclipse.swt.widgets.Composite; |
| 31 |
import org.eclipse.swt.widgets.Group; |
|
|
| 32 |
import org.eclipse.swt.widgets.Label; |
33 |
import org.eclipse.swt.widgets.Label; |
| 33 |
import org.eclipse.swt.widgets.Text; |
34 |
import org.eclipse.swt.widgets.Text; |
| 34 |
import org.eclipse.ui.IWorkbench; |
35 |
import org.eclipse.ui.IWorkbench; |
|
Lines 38-43
Link Here
|
| 38 |
*/ |
39 |
*/ |
| 39 |
public abstract class AbstractRepositorySettingsPage extends WizardPage { |
40 |
public abstract class AbstractRepositorySettingsPage extends WizardPage { |
| 40 |
|
41 |
|
|
|
42 |
protected static final String LABEL_LABEL = "Label: "; |
| 43 |
|
| 41 |
protected static final String LABEL_SERVER = "Server: "; |
44 |
protected static final String LABEL_SERVER = "Server: "; |
| 42 |
|
45 |
|
| 43 |
protected static final String LABEL_USER = "User Name: "; |
46 |
protected static final String LABEL_USER = "User Name: "; |
|
Lines 48-55
Link Here
|
| 48 |
|
51 |
|
| 49 |
protected static final String URL_PREFIX_HTTP = "http://"; |
52 |
protected static final String URL_PREFIX_HTTP = "http://"; |
| 50 |
|
53 |
|
|
|
54 |
|
| 51 |
private AbstractRepositoryConnector connector; |
55 |
private AbstractRepositoryConnector connector; |
| 52 |
|
56 |
|
|
|
57 |
protected Combo repositoryLabelCombo; |
| 58 |
|
| 53 |
protected StringFieldEditor serverUrlEditor; |
59 |
protected StringFieldEditor serverUrlEditor; |
| 54 |
|
60 |
|
| 55 |
protected StringFieldEditor userNameEditor; |
61 |
protected StringFieldEditor userNameEditor; |
|
Lines 98-103
Link Here
|
| 98 |
FillLayout layout = new FillLayout(); |
104 |
FillLayout layout = new FillLayout(); |
| 99 |
container.setLayout(layout); |
105 |
container.setLayout(layout); |
| 100 |
|
106 |
|
|
|
107 |
new Label(container, SWT.NONE).setText(LABEL_LABEL); |
| 108 |
|
| 109 |
repositoryLabelCombo = new Combo(container, SWT.DROP_DOWN); |
| 110 |
GridDataFactory.swtDefaults().grab(true, false).applyTo(repositoryLabelCombo); |
| 111 |
|
| 101 |
serverUrlEditor = new StringFieldEditor("", LABEL_SERVER, StringFieldEditor.UNLIMITED, container) { |
112 |
serverUrlEditor = new StringFieldEditor("", LABEL_SERVER, StringFieldEditor.UNLIMITED, container) { |
| 102 |
|
113 |
|
| 103 |
@Override |
114 |
@Override |
|
Lines 117-122
Link Here
|
| 117 |
|
128 |
|
| 118 |
if (needsAnonymousLogin()) { |
129 |
if (needsAnonymousLogin()) { |
| 119 |
anonymousButton = new Button(container, SWT.CHECK); |
130 |
anonymousButton = new Button(container, SWT.CHECK); |
|
|
131 |
GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).applyTo(anonymousButton); |
| 132 |
|
| 120 |
anonymousButton.setText("Anonymous Access"); |
133 |
anonymousButton.setText("Anonymous Access"); |
| 121 |
anonymousButton.addSelectionListener(new SelectionListener() { |
134 |
anonymousButton.addSelectionListener(new SelectionListener() { |
| 122 |
public void widgetSelected(SelectionEvent e) { |
135 |
public void widgetSelected(SelectionEvent e) { |
|
Lines 129-136
Link Here
|
| 129 |
} |
142 |
} |
| 130 |
}); |
143 |
}); |
| 131 |
|
144 |
|
| 132 |
Label anonymousLabel = new Label(container, SWT.NONE); |
145 |
// Label anonymousLabel = new Label(container, SWT.NONE); |
| 133 |
anonymousLabel.setText(""); |
146 |
// anonymousLabel.setText(""); |
| 134 |
} |
147 |
} |
| 135 |
|
148 |
|
| 136 |
userNameEditor = new StringFieldEditor("", LABEL_USER, StringFieldEditor.UNLIMITED, container); |
149 |
userNameEditor = new StringFieldEditor("", LABEL_USER, StringFieldEditor.UNLIMITED, container); |
|
Lines 139-144
Link Here
|
| 139 |
oldUsername = repository.getUserName(); |
152 |
oldUsername = repository.getUserName(); |
| 140 |
oldPassword = repository.getPassword(); |
153 |
oldPassword = repository.getPassword(); |
| 141 |
try { |
154 |
try { |
|
|
155 |
String repositoryLabel = repository.getProperty(TaskRepositoryManager.PROPERTY_LABEL); |
| 156 |
if(repositoryLabel!=null && repositoryLabel.length()>0) { |
| 157 |
repositoryLabelCombo.add(repositoryLabel); |
| 158 |
repositoryLabelCombo.select(0); |
| 159 |
} |
| 142 |
serverUrlEditor.setStringValue(repository.getUrl()); |
160 |
serverUrlEditor.setStringValue(repository.getUrl()); |
| 143 |
userNameEditor.setStringValue(repository.getUserName()); |
161 |
userNameEditor.setStringValue(repository.getUserName()); |
| 144 |
passwordEditor.setStringValue(repository.getPassword()); |
162 |
passwordEditor.setStringValue(repository.getPassword()); |
|
Lines 185-205
Link Here
|
| 185 |
createAdditionalControls(container); |
203 |
createAdditionalControls(container); |
| 186 |
|
204 |
|
| 187 |
if (needsEncoding()) { |
205 |
if (needsEncoding()) { |
| 188 |
Composite encodingContainer = new Composite(container, SWT.NONE); |
206 |
Label encodingLabel = new Label(container, SWT.HORIZONTAL); |
| 189 |
encodingContainer.setLayout(new GridLayout()); |
207 |
encodingLabel.setText("Character Encoding:"); |
| 190 |
GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).applyTo(encodingContainer); |
208 |
GridDataFactory.fillDefaults().align(SWT.TOP, SWT.DEFAULT).applyTo(encodingLabel); |
| 191 |
|
209 |
|
| 192 |
Group encodingGroup = new Group(encodingContainer, SWT.FLAT); |
210 |
Composite encodingContainer = new Composite(container, SWT.NONE); |
| 193 |
encodingGroup.setText("Character Encoding"); |
211 |
GridLayout gridLayout = new GridLayout(2, false); |
| 194 |
encodingGroup.setLayout(new GridLayout(2, false)); |
212 |
gridLayout.marginWidth = 0; |
| 195 |
defaultEncoding = new Button(encodingGroup, SWT.RADIO); |
213 |
gridLayout.marginHeight = 0; |
|
|
214 |
encodingContainer.setLayout(gridLayout); |
| 215 |
|
| 216 |
defaultEncoding = new Button(encodingContainer, SWT.RADIO); |
| 217 |
defaultEncoding.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); |
| 196 |
defaultEncoding.setText("Default (" + TaskRepository.DEFAULT_CHARACTER_ENCODING + ")"); |
218 |
defaultEncoding.setText("Default (" + TaskRepository.DEFAULT_CHARACTER_ENCODING + ")"); |
| 197 |
defaultEncoding.setSelection(true); |
219 |
defaultEncoding.setSelection(true); |
| 198 |
GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).applyTo(defaultEncoding); |
|
|
| 199 |
|
220 |
|
| 200 |
final Button otherEncoding = new Button(encodingGroup, SWT.RADIO); |
221 |
final Button otherEncoding = new Button(encodingContainer, SWT.RADIO); |
| 201 |
otherEncoding.setText("Other:"); |
222 |
otherEncoding.setText("Other:"); |
| 202 |
otherEncodingCombo = new Combo(encodingGroup, SWT.READ_ONLY); |
223 |
otherEncodingCombo = new Combo(encodingContainer, SWT.READ_ONLY); |
| 203 |
for (String encoding : Charset.availableCharsets().keySet()) { |
224 |
for (String encoding : Charset.availableCharsets().keySet()) { |
| 204 |
if (!encoding.equals(TaskRepository.DEFAULT_CHARACTER_ENCODING)) { |
225 |
if (!encoding.equals(TaskRepository.DEFAULT_CHARACTER_ENCODING)) { |
| 205 |
otherEncodingCombo.add(encoding); |
226 |
otherEncodingCombo.add(encoding); |
|
Lines 220-226
Link Here
|
| 220 |
} |
241 |
} |
| 221 |
} |
242 |
} |
| 222 |
}); |
243 |
}); |
| 223 |
|
244 |
|
| 224 |
if (repository != null) { |
245 |
if (repository != null) { |
| 225 |
try { |
246 |
try { |
| 226 |
String repositoryEncoding = repository.getCharacterEncoding(); |
247 |
String repositoryEncoding = repository.getCharacterEncoding(); |
|
Lines 242-247
Link Here
|
| 242 |
} |
263 |
} |
| 243 |
|
264 |
|
| 244 |
validateServerButton = new Button(container, SWT.PUSH); |
265 |
validateServerButton = new Button(container, SWT.PUSH); |
|
|
266 |
GridDataFactory.swtDefaults().span(2, SWT.DEFAULT).grab(false, false).applyTo(validateServerButton); |
| 245 |
validateServerButton.setText("Validate Settings"); |
267 |
validateServerButton.setText("Validate Settings"); |
| 246 |
validateServerButton.addSelectionListener(new SelectionAdapter() { |
268 |
validateServerButton.addSelectionListener(new SelectionAdapter() { |
| 247 |
|
269 |
|
|
Lines 283-288
Link Here
|
| 283 |
|
305 |
|
| 284 |
protected abstract boolean isValidUrl(String name); |
306 |
protected abstract boolean isValidUrl(String name); |
| 285 |
|
307 |
|
|
|
308 |
public String getRepositoryLabel() { |
| 309 |
return repositoryLabelCombo.getText(); |
| 310 |
} |
| 311 |
|
| 286 |
public String getServerUrl() { |
312 |
public String getServerUrl() { |
| 287 |
return serverUrlEditor.getStringValue(); |
313 |
return serverUrlEditor.getStringValue(); |
| 288 |
} |
314 |
} |
|
Lines 304-311
Link Here
|
| 304 |
} |
330 |
} |
| 305 |
|
331 |
|
| 306 |
/** |
332 |
/** |
| 307 |
* Exposes StringFieldEditor.refreshValidState() TODO: is there a better |
333 |
* Exposes StringFieldEditor.refreshValidState() |
| 308 |
* way? |
334 |
* |
|
|
335 |
* TODO: is there a better way? |
| 309 |
*/ |
336 |
*/ |
| 310 |
private static class RepositoryStringFieldEditor extends StringFieldEditor { |
337 |
private static class RepositoryStringFieldEditor extends StringFieldEditor { |
| 311 |
public RepositoryStringFieldEditor(String name, String labelText, int style, Composite parent) { |
338 |
public RepositoryStringFieldEditor(String name, String labelText, int style, Composite parent) { |
|
Lines 382-388
Link Here
|
| 382 |
|
409 |
|
| 383 |
TaskRepository repository = new TaskRepository(connector.getRepositoryType(), getServerUrl(), getVersion(), |
410 |
TaskRepository repository = new TaskRepository(connector.getRepositoryType(), getServerUrl(), getVersion(), |
| 384 |
getCharacterEncoding(), ""); |
411 |
getCharacterEncoding(), ""); |
| 385 |
|
412 |
repository.setRepositoryLabel(getRepositoryLabel()); |
| 386 |
repository.setAuthenticationCredentials(getUserName(), getPassword()); |
413 |
repository.setAuthenticationCredentials(getUserName(), getPassword()); |
| 387 |
return repository; |
414 |
return repository; |
| 388 |
} |
415 |
} |