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

(-)src/org/eclipse/mylar/provisional/tasklist/TaskRepository.java (+8 lines)
Lines 231-236 Link Here
231
		this.properties.put(TaskRepositoryManager.PROPERTY_SYNCTIMESTAMP, syncTime);
231
		this.properties.put(TaskRepositoryManager.PROPERTY_SYNCTIMESTAMP, syncTime);
232
	}
232
	}
233
233
234
	public void setRepositoryLabel(String repositoryLabel) {
235
		this.properties.put(TaskRepositoryManager.PROPERTY_LABEL, repositoryLabel);
236
	}
237
238
	public String getRepositoryLabel() {
239
		return this.properties.get(TaskRepositoryManager.PROPERTY_LABEL);
240
	}
241
	
234
	public Map<String, String> getProperties() {
242
	public Map<String, String> getProperties() {
235
		return this.properties;
243
		return this.properties;
236
	}
244
	}
(-)src/org/eclipse/mylar/provisional/tasklist/TaskRepositoryManager.java (+2 lines)
Lines 51-56 Link Here
51
51
52
	public static final String PROPERTY_URL = "url";
52
	public static final String PROPERTY_URL = "url";
53
53
54
	public static final String PROPERTY_LABEL = "label";
55
54
	public static final String PROPERTY_DELIM = ":";
56
	public static final String PROPERTY_DELIM = ":";
55
57
56
	public static final String PROPERTY_MIGRATION060 = "migration060";
58
	public static final String PROPERTY_MIGRATION060 = "migration060";
(-)src/org/eclipse/mylar/internal/tasklist/ui/wizards/AbstractRepositorySettingsPage.java (-17 / +44 lines)
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
	}
(-)src/org/eclipse/mylar/internal/sandbox/web/WebRepositorySettingsPage.java (-4 / +80 lines)
Lines 20-25 Link Here
20
import org.eclipse.mylar.internal.tasklist.ui.wizards.AbstractRepositorySettingsPage;
20
import org.eclipse.mylar.internal.tasklist.ui.wizards.AbstractRepositorySettingsPage;
21
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector;
21
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector;
22
import org.eclipse.mylar.provisional.tasklist.TaskRepository;
22
import org.eclipse.mylar.provisional.tasklist.TaskRepository;
23
import org.eclipse.swt.events.SelectionEvent;
24
import org.eclipse.swt.events.SelectionListener;
23
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Composite;
24
26
25
/**
27
/**
Lines 34-45 Link Here
34
	protected StringFieldEditor taskPrefixUrlEditor;
36
	protected StringFieldEditor taskPrefixUrlEditor;
35
	protected StringFieldEditor newTaskUrlEditor;
37
	protected StringFieldEditor newTaskUrlEditor;
36
	
38
	
39
	private static WebRepositoryInfo[] REPOSITORY_TEMPLATES = {
40
			new WebRepositoryInfo(
41
					"Subclipse (IssueZilla)",
42
					// "http://subclipse.tigris.org/issues/buglist.cgi?issue_status=NEW&issue_status=STARTED&issue_status=REOPENED&order=Issue+Number",
43
					"http://subclipse.tigris.org/issues/",
44
					"http://subclipse.tigris.org/issues/enter_bug.cgi?component=subclipse",
45
					"http://subclipse.tigris.org/issues/show_bug.cgi?id="),
46
			new WebRepositoryInfo(
47
					"GlasFish (IssueZilla)",
48
					// "https://glassfish.dev.java.net/issues/buglist.cgi?component=glassfish&issue_status=NEW&issue_status=STARTED&issue_status=REOPENED&order=Issue+Number",
49
					"https://glassfish.dev.java.net/servlets/ProjectIssues",
50
					"https://glassfish.dev.java.net/issues/enter_bug.cgi?issue_type=DEFECT",
51
					"https://glassfish.dev.java.net/issues/show_bug.cgi?id="),
52
			new WebRepositoryInfo("Spring Framework (Jira)", 
53
					"http://opensource.atlassian.com/projects/spring/browse/SPR",
54
					"http://opensource.atlassian.com/projects/spring/secure/CreateIssue!default.jspa",
55
					"http://opensource.atlassian.com/projects/spring/browse/"),
56
			new WebRepositoryInfo("ASM (GForge)", 
57
					"http://forge.objectweb.org/tracker/?atid=100023&group_id=23",
58
					"http://forge.objectweb.org/tracker/?func=add&group_id=23&atid=100023",
59
					"http://forge.objectweb.org/tracker/index.php?func=detail&group_id=23&atid=100023&aid="),
60
			new WebRepositoryInfo("edgewall.org (Trac)",
61
					// "http://trac.edgewall.org/query?status=new&status=assigned&status=reopened&order=id"
62
					"http://trac.edgewall.org/",
63
					"http://trac.edgewall.org/newticket",
64
					"http://trac.edgewall.org/ticket/"), };
37
	
65
	
38
	public WebRepositorySettingsPage(AbstractRepositoryConnector connector) {
66
	public WebRepositorySettingsPage(AbstractRepositoryConnector connector) {
39
		super(TITLE, DESCRIPTION, connector);
67
		super(TITLE, DESCRIPTION, connector);
40
	}
68
	}
41
69
70
	@Override
42
	protected void createAdditionalControls(Composite parent) {
71
	protected void createAdditionalControls(Composite parent) {
72
		for (WebRepositoryInfo info : REPOSITORY_TEMPLATES) {
73
			if(repositoryLabelCombo.indexOf(info.label)==-1) { 
74
				repositoryLabelCombo.add(info.label);
75
			}
76
		}
77
		
78
		repositoryLabelCombo.addSelectionListener(new SelectionListener() {
79
80
				public void widgetSelected(SelectionEvent e) {
81
					WebRepositoryInfo info = getInfo(repositoryLabelCombo.getText());
82
					if(info!=null) {
83
						serverUrlEditor.setStringValue(info.repositoryUrl);
84
						taskPrefixUrlEditor.setStringValue(info.taskPrefix);
85
						newTaskUrlEditor.setStringValue(info.newTaskUrl);
86
					}
87
				}
88
89
				public void widgetDefaultSelected(SelectionEvent e) {
90
					// ignore
91
				}
92
				
93
				private WebRepositoryInfo getInfo(String text) {
94
					for (WebRepositoryInfo info : REPOSITORY_TEMPLATES) {
95
						if(text.equals(info.label)) {
96
							return info;
97
						}
98
					}
99
					return null;
100
				}
101
			});
102
		
43
		taskPrefixUrlEditor = new StringFieldEditor("taskPrefixUrl", "Task prefix URL:", StringFieldEditor.UNLIMITED, parent);
103
		taskPrefixUrlEditor = new StringFieldEditor("taskPrefixUrl", "Task prefix URL:", StringFieldEditor.UNLIMITED, parent);
44
		taskPrefixUrlEditor.setPropertyChangeListener(this);
104
		taskPrefixUrlEditor.setPropertyChangeListener(this);
45
		
105
		
Lines 72-81 Link Here
72
132
73
	@Override
133
	@Override
74
	public TaskRepository createTaskRepository() {
134
	public TaskRepository createTaskRepository() {
75
		Map<String, String> properties = new HashMap<String, String>();
135
		TaskRepository repository = super.createTaskRepository();
76
		properties.put(WebRepositoryConnector.PROPERTY_TASK_PREFIX_URL, taskPrefixUrlEditor.getStringValue()); 
136
		repository.setProperty(WebRepositoryConnector.PROPERTY_TASK_PREFIX_URL, taskPrefixUrlEditor.getStringValue()); 
77
		properties.put(WebRepositoryConnector.PROPERTY_NEW_TASK_URL, newTaskUrlEditor.getStringValue());
137
		repository.setProperty(WebRepositoryConnector.PROPERTY_NEW_TASK_URL, newTaskUrlEditor.getStringValue()); 
78
		return new TaskRepository(getConnector().getRepositoryType(), getServerUrl(), properties);
138
		return repository;
139
	}
140
	
141
	
142
	private static class WebRepositoryInfo {
143
		public final String label;
144
		public final String repositoryUrl;
145
		public final String newTaskUrl;
146
		public final String taskPrefix;
147
		
148
		public WebRepositoryInfo(String label, String repositoryUrl, String newTaskUrl, String taskPrefix) {
149
			this.label = label;
150
			this.repositoryUrl = repositoryUrl;
151
			this.newTaskUrl = newTaskUrl;
152
			this.taskPrefix = taskPrefix;
153
		}
154
		
79
	}
155
	}
80
	
156
	
81
}
157
}

Return to bug 150327