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 150677
Collapse All | Expand All

(-)src/org/eclipse/mylar/internal/tasks/ui/wizards/AbstractRepositorySettingsPage.java (-8 / +14 lines)
Lines 87-92 Link Here
87
87
88
	private boolean needsEncoding;
88
	private boolean needsEncoding;
89
89
90
	private Composite container;
91
90
	public AbstractRepositorySettingsPage(String title, String description, AbstractRepositoryConnector connector) {
92
	public AbstractRepositorySettingsPage(String title, String description, AbstractRepositoryConnector connector) {
91
		super(title);
93
		super(title);
92
		super.setTitle(title);
94
		super.setTitle(title);
Lines 99-105 Link Here
99
	}
101
	}
100
102
101
	public void createControl(Composite parent) {
103
	public void createControl(Composite parent) {
102
		final Composite container = new Composite(parent, SWT.NULL);
104
		container = new Composite(parent, SWT.NULL);
103
		FillLayout layout = new FillLayout();
105
		FillLayout layout = new FillLayout();
104
		container.setLayout(layout);
106
		container.setLayout(layout);
105
107
Lines 132-139 Link Here
132
			anonymousButton.setText("Anonymous Access");
134
			anonymousButton.setText("Anonymous Access");
133
			anonymousButton.addSelectionListener(new SelectionListener() {
135
			anonymousButton.addSelectionListener(new SelectionListener() {
134
				public void widgetSelected(SelectionEvent e) {
136
				public void widgetSelected(SelectionEvent e) {
135
					boolean selected = anonymousButton.getSelection();
137
					setAnonymous(anonymousButton.getSelection());
136
					updateAnonymousButton(selected, container);
137
				}
138
				}
138
139
139
				public void widgetDefaultSelected(SelectionEvent e) {
140
				public void widgetDefaultSelected(SelectionEvent e) {
Lines 172-180 Link Here
172
		if (needsAnonymousLogin()) {
173
		if (needsAnonymousLogin()) {
173
			// do this after username and password widgets have been intialized
174
			// do this after username and password widgets have been intialized
174
			if (repository != null) {
175
			if (repository != null) {
175
				anonymousButton.setSelection(isAnonymousAccess());
176
				setAnonymous(isAnonymousAccess());
176
			}
177
			}
177
			updateAnonymousButton(anonymousButton.getSelection(), container);
178
		}
178
		}
179
179
180
		// TODO: put this back if we can't get the info from all connectors
180
		// TODO: put this back if we can't get the info from all connectors
Lines 283-289 Link Here
283
		}
283
		}
284
	}
284
	}
285
285
286
	private void updateAnonymousButton(boolean selected, Composite parent) {
286
	public void setAnonymous(boolean selected) {
287
		if (!needsAnonymousLogin) {
288
			return;
289
		}
290
291
		anonymousButton.setSelection(selected);
292
		
287
		if (selected) {
293
		if (selected) {
288
			oldUsername = userNameEditor.getStringValue();
294
			oldUsername = userNameEditor.getStringValue();
289
			oldPassword = ((StringFieldEditor) passwordEditor).getStringValue();
295
			oldPassword = ((StringFieldEditor) passwordEditor).getStringValue();
Lines 294-301 Link Here
294
			((StringFieldEditor) passwordEditor).setStringValue(oldPassword);
300
			((StringFieldEditor) passwordEditor).setStringValue(oldPassword);
295
		}
301
		}
296
302
297
		userNameEditor.setEnabled(!selected, parent);
303
		userNameEditor.setEnabled(!selected, container);
298
		((StringFieldEditor) passwordEditor).setEnabled(!selected, parent);
304
		((StringFieldEditor) passwordEditor).setEnabled(!selected, container);
299
	}
305
	}
300
306
301
	protected abstract void createAdditionalControls(Composite parent);
307
	protected abstract void createAdditionalControls(Composite parent);
(-)src/org/eclipse/mylar/internal/trac/ui/wizard/TracRepositorySettingsPage.java (-2 / +51 lines)
Lines 27-32 Link Here
27
import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
27
import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
28
import org.eclipse.mylar.tasks.ui.AbstractRepositoryConnector;
28
import org.eclipse.mylar.tasks.ui.AbstractRepositoryConnector;
29
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.events.SelectionAdapter;
30
import org.eclipse.swt.events.SelectionEvent;
31
import org.eclipse.swt.events.SelectionEvent;
31
import org.eclipse.swt.events.SelectionListener;
32
import org.eclipse.swt.events.SelectionListener;
32
import org.eclipse.swt.widgets.Combo;
33
import org.eclipse.swt.widgets.Combo;
Lines 46-51 Link Here
46
47
47
	private Combo accessTypeCombo;
48
	private Combo accessTypeCombo;
48
49
50
	private static TracRepositoryInfo[] REPOSITORY_TEMPLATES = { new TracRepositoryInfo("Edgewall",
51
			"http://trac.edgewall.org", true, Version.TRAC_0_9),
52
	// new TracRepositoryInfo("Mylar Trac Client",
53
	// "http://mylar.eclipse.org/mylar-trac-client", true, Version.XML_RPC),
54
	};
55
49
	/** Supported access types. */
56
	/** Supported access types. */
50
	private Version[] versions;
57
	private Version[] versions;
51
58
Lines 58-63 Link Here
58
	}
65
	}
59
66
60
	protected void createAdditionalControls(final Composite parent) {
67
	protected void createAdditionalControls(final Composite parent) {
68
		for (TracRepositoryInfo info : REPOSITORY_TEMPLATES) {
69
			repositoryLabelCombo.add(info.label);
70
		}
71
		repositoryLabelCombo.addSelectionListener(new SelectionAdapter() {
72
			@Override
73
			public void widgetSelected(SelectionEvent e) {
74
				String text = repositoryLabelCombo.getText();
75
				for (TracRepositoryInfo info : REPOSITORY_TEMPLATES) {
76
					if (info.label.equals(text)) {
77
						setUrl(info.url);
78
						setAnonymous(info.anonymous);
79
						setTracVersion(info.version);
80
						getContainer().updateButtons();
81
						return;
82
					}
83
				}
84
			}
85
		});
86
61
		Label accessTypeLabel = new Label(parent, SWT.NONE);
87
		Label accessTypeLabel = new Label(parent, SWT.NONE);
62
		accessTypeLabel.setText("Access Type: ");
88
		accessTypeLabel.setText("Access Type: ");
63
		accessTypeCombo = new Combo(parent, SWT.READ_ONLY);
89
		accessTypeCombo = new Combo(parent, SWT.READ_ONLY);
Lines 153-160 Link Here
153
				}
179
				}
154
			});
180
			});
155
181
156
			MessageDialog.openInformation(null, MylarTracPlugin.TITLE_MESSAGE_DIALOG,
182
			if (username.length() > 0) {
157
					"Authentication credentials are valid.");
183
				MessageDialog.openInformation(null, MylarTracPlugin.TITLE_MESSAGE_DIALOG,
184
						"Authentication credentials are valid.");
185
			} else {
186
				MessageDialog.openInformation(null, MylarTracPlugin.TITLE_MESSAGE_DIALOG, "Repository is valid.");
187
			}
158
188
159
			if (result[0] != null) {
189
			if (result[0] != null) {
160
				setTracVersion(result[0]);
190
				setTracVersion(result[0]);
Lines 178-181 Link Here
178
		super.getWizard().getContainer().updateButtons();
208
		super.getWizard().getContainer().updateButtons();
179
	}
209
	}
180
210
211
	private static class TracRepositoryInfo {
212
213
		final String label;
214
215
		final String url;
216
217
		final boolean anonymous;
218
219
		final Version version;
220
221
		public TracRepositoryInfo(String label, String url, boolean anonymous, Version version) {
222
			this.label = label;
223
			this.url = url;
224
			this.anonymous = anonymous;
225
			this.version = version;
226
		}
227
228
	}
229
181
}
230
}

Return to bug 150677