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 (-135 / +11 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 64-77 Link Here
64
59
65
	private static final String LABEL_SHORT_LOGINS = "Local users enabled:";
60
	private static final String LABEL_SHORT_LOGINS = "Local users enabled:";
66
61
67
	public static final String LABEL_AUTOMATIC_VERSION = "Automatic (Use Validate Settings)";
62
	private static final String LABEL_VERSION = "supported Versions:";
63
64
	private static final String LABEL_VERSION_NUMBER = "2.18 - 3.0";
68
65
69
	private static final String TITLE = "Bugzilla Repository Settings";
66
	private static final String TITLE = "Bugzilla Repository Settings";
70
67
71
	private static final String DESCRIPTION = "Example: https://bugs.eclipse.org/bugs (do not include index.cgi)";
68
	private static final String DESCRIPTION = "Example: https://bugs.eclipse.org/bugs (do not include index.cgi)";
72
69
73
	protected Combo repositoryVersionCombo;
74
75
	protected Button autodetectPlatformOS;
70
	protected Button autodetectPlatformOS;
76
71
77
	protected Combo defaultPlatformCombo;
72
	protected Combo defaultPlatformCombo;
Lines 103-109 Link Here
103
		repositoryLabelEditor.setStringValue(template.label);
98
		repositoryLabelEditor.setStringValue(template.label);
104
		setUrl(template.repositoryUrl);
99
		setUrl(template.repositoryUrl);
105
		// setAnonymous(info.anonymous);
100
		// setAnonymous(info.anonymous);
106
		setBugzillaVersion(template.version);
107
		if (template.characterEncoding != null) {
101
		if (template.characterEncoding != null) {
108
			setEncoding(template.characterEncoding);
102
			setEncoding(template.characterEncoding);
109
		}
103
		}
Lines 115-165 Link Here
115
	protected void createAdditionalControls(Composite parent) {
109
	protected void createAdditionalControls(Composite parent) {
116
		addRepositoryTemplatesToServerUrlCombo();
110
		addRepositoryTemplatesToServerUrlCombo();
117
111
118
		Label repositoryVersionLabel = new Label(parent, SWT.NONE);
112
		Label versionLabel = new Label(parent, SWT.NONE);
119
		repositoryVersionLabel.setText("Repository version: ");
113
		versionLabel.setText(LABEL_VERSION);
120
		repositoryVersionCombo = new Combo(parent, SWT.READ_ONLY);
114
		Label versionLabelNumber = new Label(parent, SWT.NONE);
121
115
		versionLabelNumber.setText(LABEL_VERSION_NUMBER);
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);
116
		Label shortLoginLabel = new Label(parent, SWT.NONE);
164
		shortLoginLabel.setText(LABEL_SHORT_LOGINS);
117
		shortLoginLabel.setText(LABEL_SHORT_LOGINS);
165
		cleanQAContact = new Button(parent, SWT.CHECK | SWT.LEFT);
118
		cleanQAContact = new Button(parent, SWT.CHECK | SWT.LEFT);
Lines 327-364 Link Here
327
		defaultPlatformCombo.setEnabled(!autodetectPlatformOS.getSelection());
280
		defaultPlatformCombo.setEnabled(!autodetectPlatformOS.getSelection());
328
	}
281
	}
329
282
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
283
	@Override
363
	public void applyTo(TaskRepository repository) {
284
	public void applyTo(TaskRepository repository) {
364
		super.applyTo(repository);
285
		super.applyTo(repository);
Lines 384-401 Link Here
384
	}
305
	}
385
306
386
	@Override
307
	@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) {
308
	protected boolean isValidUrl(String name) {
400
		if (name.startsWith(URL_PREFIX_HTTPS) || name.startsWith(URL_PREFIX_HTTP)) {
309
		if (name.startsWith(URL_PREFIX_HTTPS) || name.startsWith(URL_PREFIX_HTTP)) {
401
			try {
310
			try {
Lines 409-440 Link Here
409
318
410
	@Override
319
	@Override
411
	protected Validator getValidator(TaskRepository repository) {
320
	protected Validator getValidator(TaskRepository repository) {
412
321
		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
	}
322
	}
429
323
430
	public class BugzillaValidator extends Validator {
324
	public class BugzillaValidator extends Validator {
431
325
432
		final TaskRepository repository;
326
		final TaskRepository repository;
433
327
434
		private final String[] versions = new String[1];;
328
		public BugzillaValidator(TaskRepository repository) {
435
436
		public BugzillaValidator(TaskRepository repository, String version) {
437
			versions[0] = version;
438
			this.repository = repository;
329
			this.repository = repository;
439
		}
330
		}
440
331
Lines 473-500 Link Here
473
				monitor.beginTask("Validating server settings", IProgressMonitor.UNKNOWN);
364
				monitor.beginTask("Validating server settings", IProgressMonitor.UNKNOWN);
474
				BugzillaClient client = null;
365
				BugzillaClient client = null;
475
366
476
				boolean checkVersion = versions[0] == null;
367
				client = BugzillaClientFactory.createClient(repository);
477
368
				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 {
369
			} finally {
490
				monitor.done();
370
				monitor.done();
491
			}
371
			}
492
		}
372
		}
493
373
494
		public String getResult() {
495
			return versions[0];
496
		}
497
498
	}
374
	}
499
375
500
	@Override
376
	@Override

Return to bug 247220