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

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java (-161 / +7 lines)
Lines 21-29 Link Here
21
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.core.runtime.NullProgressMonitor;
23
import org.eclipse.core.runtime.NullProgressMonitor;
24
import org.eclipse.core.runtime.Status;
25
import org.eclipse.jface.operation.IRunnableWithProgress;
24
import org.eclipse.jface.operation.IRunnableWithProgress;
26
import org.eclipse.mylyn.commons.core.StatusHandler;
27
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
25
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
28
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientFactory;
26
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientFactory;
29
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
27
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
Lines 31-38 Link Here
31
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaStatus;
29
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaStatus;
32
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
30
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
33
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
31
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
34
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BugzillaServerVersion;
35
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin;
36
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
32
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
37
import org.eclipse.mylyn.tasks.core.RepositoryTemplate;
33
import org.eclipse.mylyn.tasks.core.RepositoryTemplate;
38
import org.eclipse.mylyn.tasks.core.TaskRepository;
34
import org.eclipse.mylyn.tasks.core.TaskRepository;
Lines 40-46 Link Here
40
import org.eclipse.swt.SWT;
36
import org.eclipse.swt.SWT;
41
import org.eclipse.swt.events.SelectionAdapter;
37
import org.eclipse.swt.events.SelectionAdapter;
42
import org.eclipse.swt.events.SelectionEvent;
38
import org.eclipse.swt.events.SelectionEvent;
43
import org.eclipse.swt.events.SelectionListener;
44
import org.eclipse.swt.layout.GridLayout;
39
import org.eclipse.swt.layout.GridLayout;
45
import org.eclipse.swt.widgets.Button;
40
import org.eclipse.swt.widgets.Button;
46
import org.eclipse.swt.widgets.Combo;
41
import org.eclipse.swt.widgets.Combo;
Lines 58-76 Link Here
58
53
59
	private static final String TOOLTIP_AUTODETECTION_DISABLED = "Available once repository has been created.";
54
	private static final String TOOLTIP_AUTODETECTION_DISABLED = "Available once repository has been created.";
60
55
61
	//private static final String TOOLTIP_CACHED_CONFIGURATION = "Use for repositories that explicitly state that they support this customization.";
62
63
	//private static final String LABEL_CACHED_CONFIGURATION = "Cached configuration:";
64
65
	private static final String LABEL_SHORT_LOGINS = "Local users enabled:";
56
	private static final String LABEL_SHORT_LOGINS = "Local users enabled:";
66
57
67
	public static final String LABEL_AUTOMATIC_VERSION = "Automatic (Use Validate Settings)";
58
	private static final String LABEL_VERSION_NUMBER = "2.18 - 3.0";
68
59
69
	private static final String TITLE = "Bugzilla Repository Settings";
60
	private static final String TITLE = "Bugzilla Repository Settings";
70
61
71
	private static final String DESCRIPTION = "Example: https://bugs.eclipse.org/bugs (do not include index.cgi)";
62
	private static final String DESCRIPTION = "Supports Bugzilla " + LABEL_VERSION_NUMBER
72
63
			+ "\nExample: https://bugs.eclipse.org/bugs (do not include index.cgi)";
73
	protected Combo repositoryVersionCombo;
74
64
75
	protected Button autodetectPlatformOS;
65
	protected Button autodetectPlatformOS;
76
66
Lines 80-87 Link Here
80
70
81
	private Button cleanQAContact;
71
	private Button cleanQAContact;
82
72
83
	//private Button cachedConfigButton;
84
85
	private RepositoryConfiguration repositoryConfiguration = null;
73
	private RepositoryConfiguration repositoryConfiguration = null;
86
74
87
	private String platform = null;
75
	private String platform = null;
Lines 103-109 Link Here
103
		repositoryLabelEditor.setStringValue(template.label);
91
		repositoryLabelEditor.setStringValue(template.label);
104
		setUrl(template.repositoryUrl);
92
		setUrl(template.repositoryUrl);
105
		// setAnonymous(info.anonymous);
93
		// setAnonymous(info.anonymous);
106
		setBugzillaVersion(template.version);
107
		if (template.characterEncoding != null) {
94
		if (template.characterEncoding != null) {
108
			setEncoding(template.characterEncoding);
95
			setEncoding(template.characterEncoding);
109
		}
96
		}
Lines 115-165 Link Here
115
	protected void createAdditionalControls(Composite parent) {
102
	protected void createAdditionalControls(Composite parent) {
116
		addRepositoryTemplatesToServerUrlCombo();
103
		addRepositoryTemplatesToServerUrlCombo();
117
104
118
		Label repositoryVersionLabel = new Label(parent, SWT.NONE);
119
		repositoryVersionLabel.setText("Repository version: ");
120
		repositoryVersionCombo = new Combo(parent, SWT.READ_ONLY);
121
122
		repositoryVersionCombo.add(LABEL_AUTOMATIC_VERSION);
123
124
		for (BugzillaServerVersion version : BugzillaServerVersion.values()) {
125
			repositoryVersionCombo.add(version.toString());
126
		}
127
		if (repository != null && repositoryVersionCombo.indexOf(repository.getVersion()) >= 0) {
128
			repositoryVersionCombo.select(repositoryVersionCombo.indexOf(repository.getVersion()));
129
		} else {
130
131
			int defaultIndex = repositoryVersionCombo.indexOf(IBugzillaConstants.SERVER_VERSION_DEFAULT.toString());
132
			if (defaultIndex != -1) {
133
				repositoryVersionCombo.select(defaultIndex);
134
				setVersion(IBugzillaConstants.SERVER_VERSION_DEFAULT.toString());
135
			} else {
136
				defaultIndex = repositoryVersionCombo.getItemCount() - 1;
137
			}
138
			repositoryVersionCombo.select(defaultIndex);
139
			setVersion(repositoryVersionCombo.getItem(defaultIndex));
140
			isPageComplete();
141
			if (getWizard() != null) {
142
				getWizard().getContainer().updateButtons();
143
			}
144
		}
145
146
		repositoryVersionCombo.addSelectionListener(new SelectionListener() {
147
148
			public void widgetSelected(SelectionEvent e) {
149
				if (repositoryVersionCombo.getSelectionIndex() >= 0) {
150
					setVersion(repositoryVersionCombo.getItem(repositoryVersionCombo.getSelectionIndex()));
151
					isPageComplete();
152
					if (getWizard() != null) {
153
						getWizard().getContainer().updateButtons();
154
					}
155
				}
156
			}
157
158
			public void widgetDefaultSelected(SelectionEvent e) {
159
				// ignore
160
			}
161
		});
162
163
		Label shortLoginLabel = new Label(parent, SWT.NONE);
105
		Label shortLoginLabel = new Label(parent, SWT.NONE);
164
		shortLoginLabel.setText(LABEL_SHORT_LOGINS);
106
		shortLoginLabel.setText(LABEL_SHORT_LOGINS);
165
		cleanQAContact = new Button(parent, SWT.CHECK | SWT.LEFT);
107
		cleanQAContact = new Button(parent, SWT.CHECK | SWT.LEFT);
Lines 168-186 Link Here
168
			cleanQAContact.setSelection(shortLogin);
110
			cleanQAContact.setSelection(shortLogin);
169
		}
111
		}
170
112
171
//		Label cachedConfigLabel = new Label(parent, SWT.NONE);
172
//		cachedConfigLabel.setText(LABEL_CACHED_CONFIGURATION);
173
//		cachedConfigLabel.setToolTipText(TOOLTIP_CACHED_CONFIGURATION);
174
//		cachedConfigButton = new Button(parent, SWT.CHECK | SWT.LEFT);
175
//		if (repository != null) {
176
//			boolean isCached = true;
177
//			String oldTimestamp = repository.getProperty(IBugzillaConstants.PROPERTY_CONFIGTIMESTAMP);
178
//			if (oldTimestamp != null && oldTimestamp.equals(IBugzillaConstants.TIMESTAMP_NOT_AVAILABLE)) {
179
//				isCached = false;
180
//			}
181
//			cachedConfigButton.setSelection(isCached);
182
//		}
183
184
		if (null != repository) {
113
		if (null != repository) {
185
			repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository.getRepositoryUrl());
114
			repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(repository.getRepositoryUrl());
186
			platform = repository.getProperty(IBugzillaConstants.BUGZILLA_DEF_PLATFORM);
115
			platform = repository.getProperty(IBugzillaConstants.BUGZILLA_DEF_PLATFORM);
Lines 327-364 Link Here
327
		defaultPlatformCombo.setEnabled(!autodetectPlatformOS.getSelection());
256
		defaultPlatformCombo.setEnabled(!autodetectPlatformOS.getSelection());
328
	}
257
	}
329
258
330
	public void setBugzillaVersion(String version) {
331
		if (version == null) {
332
			repositoryVersionCombo.select(0);
333
		} else {
334
			int i = repositoryVersionCombo.indexOf(version.toString());
335
			if (i != -1) {
336
				repositoryVersionCombo.select(i);
337
				setVersion(version);
338
			} else {
339
				for (IBugzillaConstants.BugzillaServerVersion serverVersion : IBugzillaConstants.BugzillaServerVersion.values()) {
340
					if (version.startsWith(serverVersion.toString())) {
341
						i = repositoryVersionCombo.indexOf(serverVersion.toString());
342
						if (i != -1) {
343
							repositoryVersionCombo.select(i);
344
							setVersion(serverVersion.toString());
345
							break;
346
						}
347
					}
348
				}
349
				if (i == -1) {
350
					StatusHandler.log(new Status(IStatus.INFO, BugzillaUiPlugin.ID_PLUGIN,
351
							"Could not resolve repository version: " + version));
352
					i = repositoryVersionCombo.indexOf(IBugzillaConstants.SERVER_VERSION_DEFAULT.toString());
353
					if (i != -1) {
354
						repositoryVersionCombo.select(i);
355
						setVersion(IBugzillaConstants.SERVER_VERSION_DEFAULT.toString());
356
					}
357
				}
358
			}
359
		}
360
	}
361
362
	@Override
259
	@Override
363
	public void applyTo(TaskRepository repository) {
260
	public void applyTo(TaskRepository repository) {
364
		super.applyTo(repository);
261
		super.applyTo(repository);
Lines 366-377 Link Here
366
				String.valueOf(cleanQAContact.getSelection()));
263
				String.valueOf(cleanQAContact.getSelection()));
367
		repository.setProperty(IBugzillaConstants.BUGZILLA_LANGUAGE_SETTING, languageSettingCombo.getText());
264
		repository.setProperty(IBugzillaConstants.BUGZILLA_LANGUAGE_SETTING, languageSettingCombo.getText());
368
265
369
//		if (cachedConfigButton.getSelection()) {
370
//			repository.setProperty(IBugzillaConstants.PROPERTY_CONFIGTIMESTAMP, "");
371
//		} else {
372
//			repository.setProperty(IBugzillaConstants.PROPERTY_CONFIGTIMESTAMP,
373
//					IBugzillaConstants.TIMESTAMP_NOT_AVAILABLE);
374
//		}
375
		if (!autodetectPlatformOS.getSelection()) {
266
		if (!autodetectPlatformOS.getSelection()) {
376
			repository.setProperty(IBugzillaConstants.BUGZILLA_DEF_PLATFORM,
267
			repository.setProperty(IBugzillaConstants.BUGZILLA_DEF_PLATFORM,
377
					String.valueOf(defaultPlatformCombo.getItem(defaultPlatformCombo.getSelectionIndex())));
268
					String.valueOf(defaultPlatformCombo.getItem(defaultPlatformCombo.getSelectionIndex())));
Lines 384-401 Link Here
384
	}
275
	}
385
276
386
	@Override
277
	@Override
387
	public boolean isPageComplete() {
388
		boolean erg = super.isPageComplete();
389
		if (erg) {
390
			if (getVersion().compareTo(LABEL_AUTOMATIC_VERSION) == 0) {
391
				setErrorMessage("Validate Settings or select repository version under Additional Settings section.");
392
				erg = false;
393
			}
394
		}
395
		return erg;
396
	}
397
398
	@Override
399
	protected boolean isValidUrl(String name) {
278
	protected boolean isValidUrl(String name) {
400
		if (name.startsWith(URL_PREFIX_HTTPS) || name.startsWith(URL_PREFIX_HTTP)) {
279
		if (name.startsWith(URL_PREFIX_HTTPS) || name.startsWith(URL_PREFIX_HTTP)) {
401
			try {
280
			try {
Lines 409-440 Link Here
409
288
410
	@Override
289
	@Override
411
	protected Validator getValidator(TaskRepository repository) {
290
	protected Validator getValidator(TaskRepository repository) {
412
291
		return new BugzillaValidator(repository);
413
		if (repositoryVersionCombo.getSelectionIndex() != 0) {
414
			return new BugzillaValidator(repository,
415
					repositoryVersionCombo.getItem(repositoryVersionCombo.getSelectionIndex()));
416
		} else {
417
			return new BugzillaValidator(repository, null);
418
		}
419
	}
420
421
	@Override
422
	protected void applyValidatorResult(Validator validator) {
423
		super.applyValidatorResult(validator);
424
425
		if (((BugzillaValidator) validator).getResult() != null && ((BugzillaValidator) validator).getResult() != null) {
426
			setBugzillaVersion(((BugzillaValidator) validator).getResult());
427
		}
428
	}
292
	}
429
293
430
	public class BugzillaValidator extends Validator {
294
	public class BugzillaValidator extends Validator {
431
295
432
		final TaskRepository repository;
296
		final TaskRepository repository;
433
297
434
		private final String[] versions = new String[1];;
298
		public BugzillaValidator(TaskRepository repository) {
435
436
		public BugzillaValidator(TaskRepository repository, String version) {
437
			versions[0] = version;
438
			this.repository = repository;
299
			this.repository = repository;
439
		}
300
		}
440
301
Lines 473-500 Link Here
473
				monitor.beginTask("Validating server settings", IProgressMonitor.UNKNOWN);
334
				monitor.beginTask("Validating server settings", IProgressMonitor.UNKNOWN);
474
				BugzillaClient client = null;
335
				BugzillaClient client = null;
475
336
476
				boolean checkVersion = versions[0] == null;
337
				client = BugzillaClientFactory.createClient(repository);
477
338
				client.validate(monitor);
478
				if (versions != null) {
479
					client = BugzillaClientFactory.createClient(repository);
480
					client.validate(monitor);
481
				}
482
				if (checkVersion && client != null) {
483
					RepositoryConfiguration config = client.getRepositoryConfiguration();
484
					if (config != null) {
485
						versions[0] = config.getInstallVersion();
486
					}
487
				}
488
489
			} finally {
339
			} finally {
490
				monitor.done();
340
				monitor.done();
491
			}
341
			}
492
		}
342
		}
493
343
494
		public String getResult() {
495
			return versions[0];
496
		}
497
498
	}
344
	}
499
345
500
	@Override
346
	@Override

Return to bug 247220