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

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorExtensions.java (-2 / +20 lines)
Lines 86-92 Link Here
86
		init();
86
		init();
87
		String id = taskRepository.getProperty(REPOSITORY_PROPERTY_EDITOR_EXTENSION);
87
		String id = taskRepository.getProperty(REPOSITORY_PROPERTY_EDITOR_EXTENSION);
88
		if (id == null) {
88
		if (id == null) {
89
			// TODO 3.1 disabled until bug 244653 is resolved
89
			// TODO 3.1 disabled until bug 253115 is resolved
90
			//id = getDefaultTaskEditorExtensionId(taskRepository);
90
			//id = getDefaultTaskEditorExtensionId(taskRepository);
91
		}
91
		}
92
		return id;
92
		return id;
Lines 96-104 Link Here
96
		repository.setProperty(REPOSITORY_PROPERTY_EDITOR_EXTENSION, editorExtensionId);
96
		repository.setProperty(REPOSITORY_PROPERTY_EDITOR_EXTENSION, editorExtensionId);
97
	}
97
	}
98
98
99
	/**
100
	 * Get the default task editor extension id for the given task repository
101
	 * 
102
	 * @param taskRepository
103
	 * @return the default task editor extension id or null if there is no default
104
	 */
99
	public static String getDefaultTaskEditorExtensionId(TaskRepository taskRepository) {
105
	public static String getDefaultTaskEditorExtensionId(TaskRepository taskRepository) {
106
		return getDefaultTaskEditorExtensionId(taskRepository.getConnectorKind());
107
	}
108
109
	/**
110
	 * Get the default task editor extension id for the given kind of connector
111
	 * 
112
	 * @param connectorKind
113
	 *            the kind of connector
114
	 * 
115
	 * @return the default task editor extension id or null if there is no default
116
	 */
117
	public static String getDefaultTaskEditorExtensionId(String connectorKind) {
100
		init();
118
		init();
101
		return associationByConnectorKind.get(taskRepository.getConnectorKind());
119
		return associationByConnectorKind.get(connectorKind);
102
	}
120
	}
103
121
104
	/**
122
	/**
(-)src/org/eclipse/mylyn/internal/tasks/ui/wizards/EditRepositoryWizard.java (-3 / +6 lines)
Lines 18-23 Link Here
18
import org.eclipse.jface.viewers.IStructuredSelection;
18
import org.eclipse.jface.viewers.IStructuredSelection;
19
import org.eclipse.jface.wizard.Wizard;
19
import org.eclipse.jface.wizard.Wizard;
20
import org.eclipse.mylyn.commons.core.StatusHandler;
20
import org.eclipse.mylyn.commons.core.StatusHandler;
21
import org.eclipse.mylyn.internal.tasks.core.LocalRepositoryConnector;
21
import org.eclipse.mylyn.internal.tasks.ui.RefactorRepositoryUrlOperation;
22
import org.eclipse.mylyn.internal.tasks.ui.RefactorRepositoryUrlOperation;
22
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
23
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
23
import org.eclipse.mylyn.tasks.core.TaskRepository;
24
import org.eclipse.mylyn.tasks.core.TaskRepository;
Lines 72-78 Link Here
72
73
73
			repository.flushAuthenticationCredentials();
74
			repository.flushAuthenticationCredentials();
74
75
75
			repository.setRepositoryUrl(newUrl);
76
			if (!repository.getConnectorKind().equals(LocalRepositoryConnector.CONNECTOR_KIND)) {
77
				repository.setRepositoryUrl(newUrl);
78
			}
76
			settingsPage.applyTo(repository);
79
			settingsPage.applyTo(repository);
77
			if (oldUrl != null && newUrl != null && !oldUrl.equals(newUrl)) {
80
			if (oldUrl != null && newUrl != null && !oldUrl.equals(newUrl)) {
78
				TasksUiPlugin.getRepositoryManager().notifyRepositoryUrlChanged(repository, oldUrl);
81
				TasksUiPlugin.getRepositoryManager().notifyRepositoryUrlChanged(repository, oldUrl);
Lines 90-97 Link Here
90
	@Override
93
	@Override
91
	public void addPages() {
94
	public void addPages() {
92
		AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(repository.getConnectorKind());
95
		AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(repository.getConnectorKind());
93
		// TODO 3.1 pass repository
96
94
		settingsPage = connectorUi.getSettingsPage(null);
97
		settingsPage = connectorUi.getSettingsPage(repository);
95
		if (settingsPage instanceof AbstractRepositorySettingsPage) {
98
		if (settingsPage instanceof AbstractRepositorySettingsPage) {
96
			((AbstractRepositorySettingsPage) settingsPage).setRepository(repository);
99
			((AbstractRepositorySettingsPage) settingsPage).setRepository(repository);
97
			((AbstractRepositorySettingsPage) settingsPage).setVersion(repository.getVersion());
100
			((AbstractRepositorySettingsPage) settingsPage).setVersion(repository.getVersion());
(-)src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java (-23 / +194 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
* Copyright (c) 2004, 2008 Tasktop Technologies and others.
2
 * Copyright (c) 2004, 2008 Tasktop Technologies and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 28-34 Link Here
28
import org.eclipse.jface.operation.IRunnableWithProgress;
28
import org.eclipse.jface.operation.IRunnableWithProgress;
29
import org.eclipse.jface.preference.PreferenceDialog;
29
import org.eclipse.jface.preference.PreferenceDialog;
30
import org.eclipse.jface.preference.StringFieldEditor;
30
import org.eclipse.jface.preference.StringFieldEditor;
31
import org.eclipse.jface.wizard.WizardPage;
32
import org.eclipse.mylyn.commons.core.StatusHandler;
31
import org.eclipse.mylyn.commons.core.StatusHandler;
33
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
32
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
34
import org.eclipse.mylyn.commons.net.AuthenticationType;
33
import org.eclipse.mylyn.commons.net.AuthenticationType;
Lines 67-73 Link Here
67
import org.eclipse.ui.forms.events.HyperlinkEvent;
66
import org.eclipse.ui.forms.events.HyperlinkEvent;
68
import org.eclipse.ui.forms.events.IHyperlinkListener;
67
import org.eclipse.ui.forms.events.IHyperlinkListener;
69
import org.eclipse.ui.forms.widgets.ExpandableComposite;
68
import org.eclipse.ui.forms.widgets.ExpandableComposite;
70
import org.eclipse.ui.forms.widgets.FormToolkit;
71
import org.eclipse.ui.forms.widgets.Hyperlink;
69
import org.eclipse.ui.forms.widgets.Hyperlink;
72
70
73
/**
71
/**
Lines 78-85 Link Here
78
 * @author Rob Elves
76
 * @author Rob Elves
79
 * @author Steffen Pingel
77
 * @author Steffen Pingel
80
 * @author Frank Becker
78
 * @author Frank Becker
79
 * @author David Green
80
 * @since 2.0
81
 */
81
 */
82
public abstract class AbstractRepositorySettingsPage extends WizardPage implements ITaskRepositoryPage {
82
public abstract class AbstractRepositorySettingsPage extends AbstractTaskRepositoryPage implements ITaskRepositoryPage {
83
83
84
	protected static final String PREFS_PAGE_ID_NET_PROXY = "org.eclipse.ui.net.NetPreferences";
84
	protected static final String PREFS_PAGE_ID_NET_PROXY = "org.eclipse.ui.net.NetPreferences";
85
85
Lines 123-128 Link Here
123
123
124
	protected StringFieldEditor proxyPasswordEditor;
124
	protected StringFieldEditor proxyPasswordEditor;
125
125
126
	// FIXME shadows declaration in super
126
	protected TaskRepository repository;
127
	protected TaskRepository repository;
127
128
128
	private Button validateServerButton;
129
	private Button validateServerButton;
Lines 205-222 Link Here
205
206
206
	private Button disconnectedButton;
207
	private Button disconnectedButton;
207
208
208
	// TODO 3.1 make accessible to subclasses 
209
	private FormToolkit toolkit;
210
211
	/**
209
	/**
212
	 * @since 3.0
210
	 * @since 3.0
213
	 */
211
	 */
214
	public AbstractRepositorySettingsPage(String title, String description, TaskRepository taskRepository) {
212
	public AbstractRepositorySettingsPage(String title, String description, TaskRepository taskRepository) {
215
		super(title);
213
		super(title, description, taskRepository);
216
		this.repository = taskRepository;
217
		this.connector = TasksUi.getRepositoryManager().getRepositoryConnector(getConnectorKind());
214
		this.connector = TasksUi.getRepositoryManager().getRepositoryConnector(getConnectorKind());
218
		setTitle(title);
219
		setDescription(description);
220
		setNeedsAnonymousLogin(false);
215
		setNeedsAnonymousLogin(false);
221
		setNeedsEncoding(true);
216
		setNeedsEncoding(true);
222
		setNeedsTimeZone(true);
217
		setNeedsTimeZone(true);
Lines 228-247 Link Here
228
	/**
223
	/**
229
	 * @since 3.0
224
	 * @since 3.0
230
	 */
225
	 */
226
	@Override
231
	public abstract String getConnectorKind();
227
	public abstract String getConnectorKind();
232
228
233
	@Override
229
	@Override
234
	public void dispose() {
230
	public void dispose() {
235
		super.dispose();
231
		super.dispose();
236
		if (toolkit != null) {
237
			toolkit.dispose();
238
			toolkit = null;
239
		}
240
	}
232
	}
241
233
242
	public void createControl(Composite parent) {
234
	/**
243
		toolkit = new FormToolkit(TasksUiPlugin.getDefault().getFormColors(parent.getDisplay()));
235
	 * @since 2.0
236
	 */
237
	@Override
238
	protected void createContents(Composite parent) {
239
		createSettingControls(parent);
240
	}
244
241
242
	/**
243
	 * @since 2.0
244
	 */
245
	@Override
246
	protected void createSettingControls(Composite parent) {
245
		if (repository != null) {
247
		if (repository != null) {
246
			originalUrl = repository.getRepositoryUrl();
248
			originalUrl = repository.getRepositoryUrl();
247
			AuthenticationCredentials oldCredentials = repository.getCredentials(AuthenticationType.REPOSITORY);
249
			AuthenticationCredentials oldCredentials = repository.getCredentials(AuthenticationType.REPOSITORY);
Lines 628-633 Link Here
628
630
629
		addStatusSection();
631
		addStatusSection();
630
632
633
		addContributionSection();
634
631
		Composite managementComposite = new Composite(compositeContainer, SWT.NULL);
635
		Composite managementComposite = new Composite(compositeContainer, SWT.NULL);
632
		GridLayout managementLayout = new GridLayout(4, false);
636
		GridLayout managementLayout = new GridLayout(4, false);
633
		managementLayout.marginHeight = 0;
637
		managementLayout.marginHeight = 0;
Lines 701-707 Link Here
701
705
702
		updateHyperlinks();
706
		updateHyperlinks();
703
707
704
		setControl(compositeContainer);
705
	}
708
	}
706
709
707
	private void addProxySection() {
710
	private void addProxySection() {
Lines 855-860 Link Here
855
		proxyExpComposite.setExpanded(!systemProxyButton.getSelection());
858
		proxyExpComposite.setExpanded(!systemProxyButton.getSelection());
856
	}
859
	}
857
860
861
	private void addContributionSection() {
862
		Composite composite = toolkit.createComposite(compositeContainer);
863
		GridDataFactory.fillDefaults().grab(true, false).span(2, SWT.DEFAULT).applyTo(composite);
864
865
		GridLayout layout = new GridLayout(1, false);
866
		layout.marginWidth = 0;
867
		layout.marginTop = -5;
868
		composite.setLayout(layout);
869
870
		composite.setBackground(compositeContainer.getBackground());
871
872
		createContributionControls(composite);
873
	}
874
858
	private void addStatusSection() {
875
	private void addStatusSection() {
859
		ExpandableComposite statusComposite = toolkit.createExpandableComposite(compositeContainer,
876
		ExpandableComposite statusComposite = toolkit.createExpandableComposite(compositeContainer,
860
				ExpandableComposite.COMPACT | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
877
				ExpandableComposite.COMPACT | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
Lines 912-917 Link Here
912
		}
929
		}
913
	}
930
	}
914
931
932
	/**
933
	 * @since 2.0
934
	 */
915
	public void setAnonymous(boolean selected) {
935
	public void setAnonymous(boolean selected) {
916
		if (!needsAnonymousLogin) {
936
		if (!needsAnonymousLogin) {
917
			return;
937
			return;
Lines 937-942 Link Here
937
		}
957
		}
938
	}
958
	}
939
959
960
	/**
961
	 * @since 2.0
962
	 */
940
	public void setHttpAuth(boolean selected) {
963
	public void setHttpAuth(boolean selected) {
941
		if (!needsHttpAuth) {
964
		if (!needsHttpAuth) {
942
			return;
965
			return;
Lines 963-968 Link Here
963
		return httpAuthButton.getSelection();
986
		return httpAuthButton.getSelection();
964
	}
987
	}
965
988
989
	/**
990
	 * @since 2.0
991
	 */
966
	public void setUseDefaultProxy(boolean selected) {
992
	public void setUseDefaultProxy(boolean selected) {
967
		if (!needsProxy) {
993
		if (!needsProxy) {
968
			return;
994
			return;
Lines 985-992 Link Here
985
		setProxyAuth(proxyAuthButton.getSelection());
1011
		setProxyAuth(proxyAuthButton.getSelection());
986
	}
1012
	}
987
1013
1014
	/**
1015
	 * @since 2.0
1016
	 */
988
	public void setProxyAuth(boolean selected) {
1017
	public void setProxyAuth(boolean selected) {
989
990
		proxyAuthButton.setSelection(selected);
1018
		proxyAuthButton.setSelection(selected);
991
		proxyAuthButton.setEnabled(!systemProxyButton.getSelection());
1019
		proxyAuthButton.setEnabled(!systemProxyButton.getSelection());
992
		if (!selected) {
1020
		if (!selected) {
Lines 1039-1046 Link Here
1039
	protected void repositoryTemplateSelected(RepositoryTemplate template) {
1067
	protected void repositoryTemplateSelected(RepositoryTemplate template) {
1040
	}
1068
	}
1041
1069
1070
	/**
1071
	 * @since 2.0
1072
	 */
1042
	protected abstract void createAdditionalControls(Composite parent);
1073
	protected abstract void createAdditionalControls(Composite parent);
1043
1074
1075
	/**
1076
	 * @since 2.0
1077
	 */
1044
	protected abstract boolean isValidUrl(String name);
1078
	protected abstract boolean isValidUrl(String name);
1045
1079
1046
	private void updateHyperlinks() {
1080
	private void updateHyperlinks() {
Lines 1064-1069 Link Here
1064
		}
1098
		}
1065
	}
1099
	}
1066
1100
1101
	/**
1102
	 * @since 2.0
1103
	 */
1067
	public String getRepositoryLabel() {
1104
	public String getRepositoryLabel() {
1068
		return repositoryLabelEditor.getStringValue();
1105
		return repositoryLabelEditor.getStringValue();
1069
	}
1106
	}
Lines 1075-1088 Link Here
1075
		return TaskRepositoryManager.stripSlashes(serverUrlCombo.getText());
1112
		return TaskRepositoryManager.stripSlashes(serverUrlCombo.getText());
1076
	}
1113
	}
1077
1114
1115
	/**
1116
	 * @since 2.0
1117
	 */
1078
	public String getUserName() {
1118
	public String getUserName() {
1079
		return repositoryUserNameEditor.getStringValue();
1119
		return repositoryUserNameEditor.getStringValue();
1080
	}
1120
	}
1081
1121
1122
	/**
1123
	 * @since 2.0
1124
	 */
1082
	public String getPassword() {
1125
	public String getPassword() {
1083
		return repositoryPasswordEditor.getStringValue();
1126
		return repositoryPasswordEditor.getStringValue();
1084
	}
1127
	}
1085
1128
1129
	/**
1130
	 * @since 2.0
1131
	 */
1086
	public String getHttpAuthUserId() {
1132
	public String getHttpAuthUserId() {
1087
		if (needsHttpAuth()) {
1133
		if (needsHttpAuth()) {
1088
			return httpAuthUserNameEditor.getStringValue();
1134
			return httpAuthUserNameEditor.getStringValue();
Lines 1091-1096 Link Here
1091
		}
1137
		}
1092
	}
1138
	}
1093
1139
1140
	/**
1141
	 * @since 2.0
1142
	 */
1094
	public String getHttpAuthPassword() {
1143
	public String getHttpAuthPassword() {
1095
		if (needsHttpAuth()) {
1144
		if (needsHttpAuth()) {
1096
			return httpAuthPasswordEditor.getStringValue();
1145
			return httpAuthPasswordEditor.getStringValue();
Lines 1099-1104 Link Here
1099
		}
1148
		}
1100
	}
1149
	}
1101
1150
1151
	/**
1152
	 * @since 2.0
1153
	 */
1102
	public String getProxyHostname() {
1154
	public String getProxyHostname() {
1103
		if (needsProxy()) {
1155
		if (needsProxy()) {
1104
			return proxyHostnameEditor.getStringValue();
1156
			return proxyHostnameEditor.getStringValue();
Lines 1107-1112 Link Here
1107
		}
1159
		}
1108
	}
1160
	}
1109
1161
1162
	/**
1163
	 * @since 2.0
1164
	 */
1110
	public String getProxyPort() {
1165
	public String getProxyPort() {
1111
		if (needsProxy()) {
1166
		if (needsProxy()) {
1112
			return proxyPortEditor.getStringValue();
1167
			return proxyPortEditor.getStringValue();
Lines 1115-1120 Link Here
1115
		}
1170
		}
1116
	}
1171
	}
1117
1172
1173
	/**
1174
	 * @since 2.0
1175
	 */
1118
	public Boolean getUseDefaultProxy() {
1176
	public Boolean getUseDefaultProxy() {
1119
		if (needsProxy()) {
1177
		if (needsProxy()) {
1120
			return systemProxyButton.getSelection();
1178
			return systemProxyButton.getSelection();
Lines 1123-1128 Link Here
1123
		}
1181
		}
1124
	}
1182
	}
1125
1183
1184
	/**
1185
	 * @since 2.0
1186
	 */
1126
	public String getProxyUserName() {
1187
	public String getProxyUserName() {
1127
		if (needsProxy()) {
1188
		if (needsProxy()) {
1128
			return proxyUserNameEditor.getStringValue();
1189
			return proxyUserNameEditor.getStringValue();
Lines 1131-1136 Link Here
1131
		}
1192
		}
1132
	}
1193
	}
1133
1194
1195
	/**
1196
	 * @since 2.0
1197
	 */
1134
	public String getProxyPassword() {
1198
	public String getProxyPassword() {
1135
		if (needsProxy()) {
1199
		if (needsProxy()) {
1136
			return proxyPasswordEditor.getStringValue();
1200
			return proxyPasswordEditor.getStringValue();
Lines 1139-1148 Link Here
1139
		}
1203
		}
1140
	}
1204
	}
1141
1205
1206
	/**
1207
	 * @since 2.0
1208
	 */
1142
	public void init(IWorkbench workbench) {
1209
	public void init(IWorkbench workbench) {
1143
		// ignore
1210
		// ignore
1144
	}
1211
	}
1145
1212
1213
	/**
1214
	 * @since 2.0
1215
	 */
1146
	public boolean isAnonymousAccess() {
1216
	public boolean isAnonymousAccess() {
1147
		if (anonymousButton != null) {
1217
		if (anonymousButton != null) {
1148
			return anonymousButton.getSelection();
1218
			return anonymousButton.getSelection();
Lines 1206-1211 Link Here
1206
				|| repositoryPasswordEditor.getStringValue().trim().equals("");
1276
				|| repositoryPasswordEditor.getStringValue().trim().equals("");
1207
	}
1277
	}
1208
1278
1279
	/**
1280
	 * @since 2.0
1281
	 */
1209
	protected String isUniqueUrl(String urlString) {
1282
	protected String isUniqueUrl(String urlString) {
1210
		if (!urlString.equals(originalUrl)) {
1283
		if (!urlString.equals(originalUrl)) {
1211
			if (repositoryUrls == null) {
1284
			if (repositoryUrls == null) {
Lines 1223-1233 Link Here
1223
		return null;
1296
		return null;
1224
	}
1297
	}
1225
1298
1299
	/**
1300
	 * @since 2.0
1301
	 */
1226
	@Deprecated
1302
	@Deprecated
1227
	public void setRepository(TaskRepository repository) {
1303
	public void setRepository(TaskRepository repository) {
1228
		this.repository = repository;
1304
		this.repository = repository;
1229
	}
1305
	}
1230
1306
1307
	/**
1308
	 * @since 2.0
1309
	 */
1231
	public void setVersion(String previousVersion) {
1310
	public void setVersion(String previousVersion) {
1232
		if (previousVersion == null) {
1311
		if (previousVersion == null) {
1233
			serverVersion = TaskRepository.NO_VERSION_SPECIFIED;
1312
			serverVersion = TaskRepository.NO_VERSION_SPECIFIED;
Lines 1236-1249 Link Here
1236
		}
1315
		}
1237
	}
1316
	}
1238
1317
1318
	/**
1319
	 * @since 2.0
1320
	 */
1239
	public String getVersion() {
1321
	public String getVersion() {
1240
		return serverVersion;
1322
		return serverVersion;
1241
	}
1323
	}
1242
1324
1325
	/**
1326
	 * @since 2.0
1327
	 */
1243
	public TaskRepository getRepository() {
1328
	public TaskRepository getRepository() {
1244
		return repository;
1329
		return repository;
1245
	}
1330
	}
1246
1331
1332
	/**
1333
	 * @since 2.0
1334
	 */
1247
	public String getCharacterEncoding() {
1335
	public String getCharacterEncoding() {
1248
		if (defaultEncoding == null) {
1336
		if (defaultEncoding == null) {
1249
			return null;
1337
			return null;
Lines 1260-1265 Link Here
1260
		}
1348
		}
1261
	}
1349
	}
1262
1350
1351
	/**
1352
	 * @since 2.0
1353
	 */
1263
	public TaskRepository createTaskRepository() {
1354
	public TaskRepository createTaskRepository() {
1264
		TaskRepository repository = new TaskRepository(connector.getConnectorKind(), getRepositoryUrl());
1355
		TaskRepository repository = new TaskRepository(connector.getConnectorKind(), getRepositoryUrl());
1265
		applyTo(repository);
1356
		applyTo(repository);
Lines 1269-1274 Link Here
1269
	/**
1360
	/**
1270
	 * @since 2.2
1361
	 * @since 2.2
1271
	 */
1362
	 */
1363
	@Override
1272
	public void applyTo(TaskRepository repository) {
1364
	public void applyTo(TaskRepository repository) {
1273
		repository.setVersion(getVersion());
1365
		repository.setVersion(getVersion());
1274
		if (needsEncoding()) {
1366
		if (needsEncoding()) {
Lines 1307-1362 Link Here
1307
		}
1399
		}
1308
1400
1309
		repository.setOffline(disconnectedButton.getSelection());
1401
		repository.setOffline(disconnectedButton.getSelection());
1402
1403
		super.applyTo(repository);
1310
	}
1404
	}
1311
1405
1406
	/**
1407
	 * @since 2.0
1408
	 */
1312
	public AbstractRepositoryConnector getConnector() {
1409
	public AbstractRepositoryConnector getConnector() {
1313
		return connector;
1410
		return connector;
1314
	}
1411
	}
1315
1412
1413
	/**
1414
	 * @since 2.0
1415
	 */
1316
	public boolean needsEncoding() {
1416
	public boolean needsEncoding() {
1317
		return needsEncoding;
1417
		return needsEncoding;
1318
	}
1418
	}
1319
1419
1420
	/**
1421
	 * @since 2.0
1422
	 */
1320
	public boolean needsTimeZone() {
1423
	public boolean needsTimeZone() {
1321
		return needsTimeZone;
1424
		return needsTimeZone;
1322
	}
1425
	}
1323
1426
1427
	/**
1428
	 * @since 2.0
1429
	 */
1324
	public boolean needsAnonymousLogin() {
1430
	public boolean needsAnonymousLogin() {
1325
		return needsAnonymousLogin;
1431
		return needsAnonymousLogin;
1326
	}
1432
	}
1327
1433
1434
	/**
1435
	 * @since 2.0
1436
	 */
1328
	public boolean needsAdvanced() {
1437
	public boolean needsAdvanced() {
1329
		return needsAdvanced;
1438
		return needsAdvanced;
1330
	}
1439
	}
1331
1440
1441
	/**
1442
	 * @since 2.0
1443
	 */
1332
	public void setNeedsEncoding(boolean needsEncoding) {
1444
	public void setNeedsEncoding(boolean needsEncoding) {
1333
		this.needsEncoding = needsEncoding;
1445
		this.needsEncoding = needsEncoding;
1334
	}
1446
	}
1335
1447
1448
	/**
1449
	 * @since 2.0
1450
	 */
1336
	public void setNeedsTimeZone(boolean needsTimeZone) {
1451
	public void setNeedsTimeZone(boolean needsTimeZone) {
1337
		this.needsTimeZone = needsTimeZone;
1452
		this.needsTimeZone = needsTimeZone;
1338
	}
1453
	}
1339
1454
1455
	/**
1456
	 * @since 2.0
1457
	 */
1340
	public void setNeedsAdvanced(boolean needsAdvanced) {
1458
	public void setNeedsAdvanced(boolean needsAdvanced) {
1341
		this.needsAdvanced = needsAdvanced;
1459
		this.needsAdvanced = needsAdvanced;
1342
	}
1460
	}
1343
1461
1462
	/**
1463
	 * @since 2.0
1464
	 */
1344
	public boolean needsHttpAuth() {
1465
	public boolean needsHttpAuth() {
1345
		return this.needsHttpAuth;
1466
		return this.needsHttpAuth;
1346
	}
1467
	}
1347
1468
1469
	/**
1470
	 * @since 2.0
1471
	 */
1348
	public void setNeedsHttpAuth(boolean needsHttpAuth) {
1472
	public void setNeedsHttpAuth(boolean needsHttpAuth) {
1349
		this.needsHttpAuth = needsHttpAuth;
1473
		this.needsHttpAuth = needsHttpAuth;
1350
	}
1474
	}
1351
1475
1476
	/**
1477
	 * @since 2.0
1478
	 */
1352
	public void setNeedsProxy(boolean needsProxy) {
1479
	public void setNeedsProxy(boolean needsProxy) {
1353
		this.needsProxy = needsProxy;
1480
		this.needsProxy = needsProxy;
1354
	}
1481
	}
1355
1482
1483
	/**
1484
	 * @since 2.0
1485
	 */
1356
	public boolean needsProxy() {
1486
	public boolean needsProxy() {
1357
		return this.needsProxy;
1487
		return this.needsProxy;
1358
	}
1488
	}
1359
1489
1490
	/**
1491
	 * @since 2.0
1492
	 */
1360
	public void setNeedsAnonymousLogin(boolean needsAnonymousLogin) {
1493
	public void setNeedsAnonymousLogin(boolean needsAnonymousLogin) {
1361
		this.needsAnonymousLogin = needsAnonymousLogin;
1494
		this.needsAnonymousLogin = needsAnonymousLogin;
1362
	}
1495
	}
Lines 1365-1385 Link Here
1365
		this.needsValidation = needsValidation;
1498
		this.needsValidation = needsValidation;
1366
	}
1499
	}
1367
1500
1501
	/**
1502
	 * @since 2.0
1503
	 */
1368
	public boolean needsValidation() {
1504
	public boolean needsValidation() {
1369
		return needsValidation;
1505
		return needsValidation;
1370
	}
1506
	}
1371
1507
1372
	/** for testing */
1508
	/**
1509
	 * Public for testing.
1510
	 * 
1511
	 * @since 2.0
1512
	 */
1373
	public void setUrl(String url) {
1513
	public void setUrl(String url) {
1374
		serverUrlCombo.setText(url);
1514
		serverUrlCombo.setText(url);
1375
	}
1515
	}
1376
1516
1377
	/** for testing */
1517
	/**
1518
	 * Public for testing.
1519
	 * 
1520
	 * @since 2.0
1521
	 */
1378
	public void setUserId(String id) {
1522
	public void setUserId(String id) {
1379
		repositoryUserNameEditor.setStringValue(id);
1523
		repositoryUserNameEditor.setStringValue(id);
1380
	}
1524
	}
1381
1525
1382
	/** for testing */
1526
	/**
1527
	 * Public for testing.
1528
	 * 
1529
	 * @since 2.0
1530
	 */
1383
	public void setPassword(String pass) {
1531
	public void setPassword(String pass) {
1384
		repositoryPasswordEditor.setStringValue(pass);
1532
		repositoryPasswordEditor.setStringValue(pass);
1385
	}
1533
	}
Lines 1413-1418 Link Here
1413
		}
1561
		}
1414
	}
1562
	}
1415
1563
1564
	/**
1565
	 * Validate settings provided by the {@link #getValidator(TaskRepository) validator}, typically the server settings.
1566
	 * 
1567
	 * @since 2.0
1568
	 */
1416
	protected void validateSettings() {
1569
	protected void validateSettings() {
1417
		final Validator validator = getValidator(createTaskRepository());
1570
		final Validator validator = getValidator(createTaskRepository());
1418
		if (validator == null) {
1571
		if (validator == null) {
Lines 1453-1458 Link Here
1453
		getWizard().getContainer().updateButtons();
1606
		getWizard().getContainer().updateButtons();
1454
	}
1607
	}
1455
1608
1609
	/**
1610
	 * @since 3.1
1611
	 */
1612
	@Override
1613
	protected IStatus validate() {
1614
		return null;
1615
	}
1616
1617
	/**
1618
	 * @since 2.0
1619
	 */
1456
	protected void applyValidatorResult(Validator validator) {
1620
	protected void applyValidatorResult(Validator validator) {
1457
		IStatus status = validator.getStatus();
1621
		IStatus status = validator.getStatus();
1458
		String message = status.getMessage();
1622
		String message = status.getMessage();
Lines 1483-1491 Link Here
1483
		setErrorMessage(null);
1647
		setErrorMessage(null);
1484
	}
1648
	}
1485
1649
1650
	/**
1651
	 * @since 2.0
1652
	 */
1486
	protected abstract Validator getValidator(TaskRepository repository);
1653
	protected abstract Validator getValidator(TaskRepository repository);
1487
1654
1488
	// public for testing
1655
	/**
1656
	 * Public for testing.
1657
	 * 
1658
	 * @since 2.0
1659
	 */
1489
	public abstract class Validator {
1660
	public abstract class Validator {
1490
1661
1491
		private IStatus status;
1662
		private IStatus status;
(-)plugin.xml (+1 lines)
Lines 8-13 Link Here
8
    <extension-point id="duplicateDetectors" name="duplicateDetectors" schema="schema/duplicateDetectors.exsd"/>
8
    <extension-point id="duplicateDetectors" name="duplicateDetectors" schema="schema/duplicateDetectors.exsd"/>
9
    <extension-point id="presentations" name="presentations" schema="schema/presentations.exsd"/>
9
    <extension-point id="presentations" name="presentations" schema="schema/presentations.exsd"/>
10
    <extension-point id="taskEditorExtensions" name="Task Editor Extension" schema="schema/taskEditorExtensions.exsd"/>
10
    <extension-point id="taskEditorExtensions" name="Task Editor Extension" schema="schema/taskEditorExtensions.exsd"/>
11
    <extension-point id="taskRepositoryPageContribution" name="Task Repository Page Contribution" schema="schema/taskRepositoryPageContribution.exsd"/>
11
12
12
    <extension
13
    <extension
13
          point="org.eclipse.mylyn.context.core.bridges">
14
          point="org.eclipse.mylyn.context.core.bridges">
(-).refactorings/2008/11/45/refactorings.index (+1 lines)
Added Link Here
1
1225666565025	Rename type 'AbstractExtensibleRepositorySettingsPage'
(-)src/org/eclipse/mylyn/tasks/ui/wizards/AbstractTaskRepositoryPage.java (+349 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 Mylyn project committers and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.eclipse.mylyn.tasks.ui.wizards;
10
11
import java.util.ArrayList;
12
import java.util.Collections;
13
import java.util.Comparator;
14
import java.util.List;
15
16
import org.eclipse.core.runtime.IConfigurationElement;
17
import org.eclipse.core.runtime.IExtension;
18
import org.eclipse.core.runtime.IExtensionPoint;
19
import org.eclipse.core.runtime.IExtensionRegistry;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.MultiStatus;
23
import org.eclipse.core.runtime.Platform;
24
import org.eclipse.core.runtime.Status;
25
import org.eclipse.jface.dialogs.IMessageProvider;
26
import org.eclipse.jface.layout.GridDataFactory;
27
import org.eclipse.jface.wizard.WizardPage;
28
import org.eclipse.mylyn.commons.core.StatusHandler;
29
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
30
import org.eclipse.mylyn.tasks.core.TaskRepository;
31
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.layout.GridLayout;
33
import org.eclipse.swt.widgets.Composite;
34
import org.eclipse.ui.forms.events.ExpansionAdapter;
35
import org.eclipse.ui.forms.events.ExpansionEvent;
36
import org.eclipse.ui.forms.widgets.ExpandableComposite;
37
import org.eclipse.ui.forms.widgets.FormToolkit;
38
39
/**
40
 * An abstract base class for repository settings page that supports the <code>taskRepositoryPageContribution</code>
41
 * extension point.
42
 * 
43
 * {@link ITaskRepositoryPage} implementations are encouraged to extend {@link AbstractRepositorySettingsPage} if
44
 * possible as it provides a standard UI for managing server settings.
45
 * 
46
 * @see AbstractRepositorySettingsPage
47
 * @author David Green
48
 * @since 3.1
49
 */
50
public abstract class AbstractTaskRepositoryPage extends WizardPage implements ITaskRepositoryPage {
51
52
	private static final String KIND = "connectorKind";
53
54
	private static final String TASK_REPOSITORY_PAGE_CONTRIBUTION = "taskRepositoryPageContribution";
55
56
	private static final String TASK_REPOSITORY_PAGE_CONTRIBUTION_EXTENSION = "org.eclipse.mylyn.tasks.ui.taskRepositoryPageContribution";
57
58
	private static final Comparator<AbstractTaskRepositoryPageContribution> CONTRIBUTION_COMPARATOR = new ContributionComparator();
59
60
	private final TaskRepository repository;
61
62
	private final List<AbstractTaskRepositoryPageContribution> contributions;
63
64
	FormToolkit toolkit;
65
66
	private Composite compositeContainer;
67
68
	private final AbstractTaskRepositoryPageContribution.Listener contributionListener = new AbstractTaskRepositoryPageContribution.Listener() {
69
		public void validationRequired(AbstractTaskRepositoryPageContribution contribution) {
70
			validatePageSettings();
71
		}
72
	};
73
74
	/**
75
	 * @since 3.1
76
	 */
77
	public AbstractTaskRepositoryPage(String title, String description, TaskRepository repository) {
78
		super(title);
79
		if (repository != null && !repository.getConnectorKind().equals(getConnectorKind())) {
80
			throw new IllegalArgumentException("connectorKind of repository does not match connectorKind of page");
81
		}
82
		this.repository = repository;
83
		this.contributions = new ArrayList<AbstractTaskRepositoryPageContribution>();
84
		setTitle(title);
85
		setDescription(description);
86
	}
87
88
	/**
89
	 * Get the kind of connector supported by this page.
90
	 * 
91
	 * @return the kind of connector, never null
92
	 * @since 3.1
93
	 */
94
	public abstract String getConnectorKind();
95
96
	@Override
97
	public void dispose() {
98
		if (toolkit != null) {
99
			toolkit.dispose();
100
			toolkit = null;
101
		}
102
		super.dispose();
103
	}
104
105
	public void createControl(Composite parent) {
106
		toolkit = new FormToolkit(TasksUiPlugin.getDefault().getFormColors(parent.getDisplay()));
107
108
		compositeContainer = new Composite(parent, SWT.NULL);
109
		GridLayout layout = new GridLayout(1, true);
110
		compositeContainer.setLayout(layout);
111
112
		createContents(compositeContainer);
113
114
		setControl(compositeContainer);
115
	}
116
117
	/**
118
	 * Creates the contents of the page. Subclasses may override this method to change where the contributions are
119
	 * added.
120
	 * 
121
	 * @since 3.1
122
	 */
123
	protected void createContents(Composite parent) {
124
		createSettingControls(parent);
125
		createContributionControls(parent);
126
	}
127
128
	/**
129
	 * Creates the controls of this page.
130
	 * 
131
	 * @since 3.1
132
	 */
133
	protected abstract void createSettingControls(Composite parent);
134
135
	@Override
136
	public boolean isPageComplete() {
137
		return super.isPageComplete() && conributionsIsPageComplete();
138
	}
139
140
	@Override
141
	public boolean canFlipToNextPage() {
142
		return super.canFlipToNextPage() && contributionsCanFlipToNextPage();
143
	}
144
145
	private boolean contributionsCanFlipToNextPage() {
146
		for (AbstractTaskRepositoryPageContribution contribution : contributions) {
147
			if (!contribution.canFlipToNextPage()) {
148
				return false;
149
			}
150
		}
151
		return true;
152
	}
153
154
	private boolean conributionsIsPageComplete() {
155
		for (AbstractTaskRepositoryPageContribution contribution : contributions) {
156
			if (!contribution.isPageComplete()) {
157
				return false;
158
			}
159
		}
160
		return true;
161
	}
162
163
	/**
164
	 * Subclasses should only call this method if they override {@link #createContents(Composite)}.
165
	 * 
166
	 * @param parentControl
167
	 *            the container into which the contributions will create their UI
168
	 * @since 3.1
169
	 */
170
	protected void createContributionControls(Composite parentControl) {
171
		contributions.clear();
172
		contributions.addAll(findApplicableContributors());
173
174
		if (!contributions.isEmpty()) {
175
			for (AbstractTaskRepositoryPageContribution contribution : contributions) {
176
				contribution.init(getConnectorKind(), repository);
177
				contribution.addListener(contributionListener);
178
			}
179
180
			Collections.sort(contributions, CONTRIBUTION_COMPARATOR);
181
182
			for (AbstractTaskRepositoryPageContribution contribution : contributions) {
183
				ExpandableComposite section = toolkit.createExpandableComposite(parentControl,
184
						ExpandableComposite.COMPACT | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
185
				section.clientVerticalSpacing = 0;
186
				section.setBackground(parentControl.getBackground());
187
				section.setFont(parentControl.getFont());
188
				section.addExpansionListener(new ExpansionAdapter() {
189
					@Override
190
					public void expansionStateChanged(ExpansionEvent e) {
191
						getControl().getShell().pack();
192
					}
193
				});
194
				section.setText(contribution.getTitle());
195
				section.setToolTipText(contribution.getDescription());
196
197
				GridDataFactory.fillDefaults().grab(true, false).applyTo(section);
198
199
				Composite sectionContentsContainer = toolkit.createComposite(section);
200
				sectionContentsContainer.setBackground(parentControl.getBackground());
201
				contribution.createControl(sectionContentsContainer);
202
203
				section.setClient(sectionContentsContainer);
204
			}
205
		}
206
	}
207
208
	/**
209
	 * Validate the settings of this page, not including contributions. This method should not be called directly by
210
	 * page implementations. Always run on a UI thread.
211
	 * 
212
	 * @return the status, or null if there are no messages.
213
	 * @see #validatePageSettings()
214
	 * @since 3.1
215
	 */
216
	protected abstract IStatus validate();
217
218
	/**
219
	 * Overriding methods should call <code>super.applyTo(repository)</code>
220
	 * 
221
	 * @since 3.1
222
	 */
223
	public void applyTo(TaskRepository repository) {
224
		applyContributionSettingsTo(repository);
225
	}
226
227
	private void applyContributionSettingsTo(TaskRepository repository) {
228
		for (AbstractTaskRepositoryPageContribution contribution : contributions) {
229
			contribution.applyTo(repository);
230
		}
231
	}
232
233
	/**
234
	 * Returns a status if there is a message to display, otherwise null.
235
	 */
236
	private IStatus computeValidation() {
237
		MultiStatus cumulativeResult = new MultiStatus(TasksUiPlugin.ID_PLUGIN, IStatus.OK, "Validation failed", null);
238
239
		// validate the page
240
		IStatus result = validate();
241
		if (result != null) {
242
			cumulativeResult.add(result);
243
		}
244
245
		// validate contributions
246
		for (AbstractTaskRepositoryPageContribution contribution : contributions) {
247
			result = contribution.validate();
248
			if (result != null) {
249
				cumulativeResult.add(result);
250
			}
251
		}
252
253
		return cumulativeResult;
254
	}
255
256
	/**
257
	 * Validate all settings in the page including contributions. This method should be called whenever a setting is
258
	 * changed on the page.
259
	 * 
260
	 * The results of validation are applied and the buttons of the page are updated.
261
	 * 
262
	 * @see #validate(IProgressMonitor)
263
	 * @see #applyValidationResult(IStatus[])
264
	 */
265
	private void validatePageSettings() {
266
		IStatus validationStatus = computeValidation();
267
		applyValidationResult(validationStatus);
268
		getWizard().getContainer().updateButtons();
269
	}
270
271
	/**
272
	 * Apply the results of validation to the page. The implementation finds the most {@link IStatus#getSeverity()
273
	 * severe} status and {@link #setMessage(String, int) applies the message} to the page.
274
	 * 
275
	 * @param status
276
	 *            the status of the validation, or null
277
	 */
278
	private void applyValidationResult(IStatus status) {
279
		if (status == null || status.isOK()) {
280
			setMessage(null, IMessageProvider.INFORMATION);
281
			setErrorMessage(null);
282
		} else {
283
			// find the most severe status
284
			int messageType;
285
			switch (status.getSeverity()) {
286
			case IStatus.OK:
287
			case IStatus.INFO:
288
				messageType = IMessageProvider.INFORMATION;
289
				break;
290
			case IStatus.WARNING:
291
				messageType = IMessageProvider.WARNING;
292
				break;
293
			case IStatus.ERROR:
294
			default:
295
				messageType = IMessageProvider.ERROR;
296
				break;
297
			}
298
			setErrorMessage(null);
299
			setMessage(status.getMessage(), messageType);
300
		}
301
	}
302
303
	private List<AbstractTaskRepositoryPageContribution> findApplicableContributors() {
304
		List<AbstractTaskRepositoryPageContribution> contributors = new ArrayList<AbstractTaskRepositoryPageContribution>();
305
306
		IExtensionRegistry registry = Platform.getExtensionRegistry();
307
308
		IExtensionPoint editorExtensionPoint = registry.getExtensionPoint(TASK_REPOSITORY_PAGE_CONTRIBUTION_EXTENSION);
309
		IExtension[] editorExtensions = editorExtensionPoint.getExtensions();
310
		for (IExtension extension : editorExtensions) {
311
			IConfigurationElement[] elements = extension.getConfigurationElements();
312
			for (IConfigurationElement element : elements) {
313
				if (element.getName().equals(TASK_REPOSITORY_PAGE_CONTRIBUTION)) {
314
					String kind = element.getAttribute(KIND);
315
					if (kind == null || kind.length() == 0 || kind.equals(getConnectorKind())) {
316
						try {
317
							Object contributor = element.createExecutableExtension("class");
318
							contributors.add((AbstractTaskRepositoryPageContribution) contributor);
319
						} catch (Exception e) {
320
							// FIXME add id to error message
321
							StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not load "
322
									+ TASK_REPOSITORY_PAGE_CONTRIBUTION, e));
323
						}
324
					}
325
				}
326
			}
327
		}
328
329
		return contributors;
330
	}
331
332
	private static class ContributionComparator implements Comparator<AbstractTaskRepositoryPageContribution> {
333
334
		public int compare(AbstractTaskRepositoryPageContribution o1, AbstractTaskRepositoryPageContribution o2) {
335
			if (o1 == o2) {
336
				return 0;
337
			}
338
			String s1 = o1.getTitle();
339
			String s2 = o2.getTitle();
340
			int i = s1.compareTo(s2);
341
			if (i == 0) {
342
				// FIXME why compare the hash code instead of returning 0?
343
				i = new Integer(System.identityHashCode(o1)).compareTo(System.identityHashCode(o2));
344
			}
345
			return i;
346
		}
347
348
	}
349
}
(-).refactorings/2008/11/45/refactorings.history (+4 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<session version="1.0">
3
<refactoring comment="Rename type &apos;org.eclipse.mylyn.tasks.ui.wizards.AbstractExtensibleRepositorySettingsPage&apos; to &apos;AbstractTaskRepositoryPage&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Original element: &apos;org.eclipse.mylyn.tasks.ui.wizards.AbstractExtensibleRepositorySettingsPage&apos;&#x0A;- Renamed element: &apos;org.eclipse.mylyn.tasks.ui.wizards.AbstractTaskRepositoryPage&apos;&#x0A;- Update references to refactored element&#x0A;- Update textual occurrences in comments and strings" description="Rename type &apos;AbstractExtensibleRepositorySettingsPage&apos;" flags="589830" id="org.eclipse.jdt.ui.rename.type" input="/src&lt;org.eclipse.mylyn.tasks.ui.wizards{AbstractExtensibleRepositorySettingsPage.java[AbstractExtensibleRepositorySettingsPage" matchStrategy="1" name="AbstractTaskRepositoryPage" qualified="false" references="true" similarDeclarations="false" stamp="1225666565025" textual="false" version="1.0"/>
4
</session>
(-)schema/taskRepositoryPageContribution.exsd (+112 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.mylyn.tasks.ui" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appinfo>
6
         <meta.schema plugin="org.eclipse.mylyn.tasks.ui" id="taskRepositoryPageContribution" name="Task Repository Page Contribution"/>
7
      </appinfo>
8
      <documentation>
9
         This extension point enables plug-ins to contribute user interface to the task repository settings dialog.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <annotation>
15
         <appinfo>
16
            <meta.element />
17
         </appinfo>
18
      </annotation>
19
      <complexType>
20
         <sequence>
21
            <element ref="taskRepositoryPageContribution" minOccurs="1" maxOccurs="unbounded"/>
22
         </sequence>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appinfo>
43
                  <meta.attribute translatable="true"/>
44
               </appinfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49
50
   <element name="taskRepositoryPageContribution">
51
      <complexType>
52
         <attribute name="class" type="string" use="required">
53
            <annotation>
54
               <documentation>
55
                  
56
               </documentation>
57
               <appinfo>
58
                  <meta.attribute kind="java" basedOn="org.eclipse.mylyn.tasks.ui.wizards.AbstractTaskRepositoryPageContribution:"/>
59
               </appinfo>
60
            </annotation>
61
         </attribute>
62
         <attribute name="connectorKind" type="string">
63
            <annotation>
64
               <documentation>
65
                  the kind of repository connector for which this contributor should be used, or &quot;&quot; (the empty string) if it applies to all connectors
66
               </documentation>
67
            </annotation>
68
         </attribute>
69
      </complexType>
70
   </element>
71
72
   <annotation>
73
      <appinfo>
74
         <meta.section type="since"/>
75
      </appinfo>
76
      <documentation>
77
         3.1
78
      </documentation>
79
   </annotation>
80
81
   <annotation>
82
      <appinfo>
83
         <meta.section type="examples"/>
84
      </appinfo>
85
      <documentation>
86
             &lt;extension
87
          point=&quot;org.eclipse.mylyn.tasks.ui.taskRepositoryPageContribution&quot;&gt;
88
       &lt;taskRepositoryPageContribution class=&quot;org.eclipse.mylyn.internal.tasks.ui.wizards.TaskEditorExtensionSettingsContribution&quot;/&gt;
89
    &lt;/extension&gt;
90
      </documentation>
91
   </annotation>
92
93
   <annotation>
94
      <appinfo>
95
         <meta.section type="apiinfo"/>
96
      </appinfo>
97
      <documentation>
98
         [Enter API information here.]
99
      </documentation>
100
   </annotation>
101
102
   <annotation>
103
      <appinfo>
104
         <meta.section type="implementation"/>
105
      </appinfo>
106
      <documentation>
107
         [Enter information about supplied implementation of this extension point.]
108
      </documentation>
109
   </annotation>
110
111
112
</schema>
(-)src/org/eclipse/mylyn/tasks/ui/wizards/AbstractTaskRepositoryPageContribution.java (+195 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.eclipse.mylyn.tasks.ui.wizards;
10
11
import java.util.List;
12
import java.util.concurrent.CopyOnWriteArrayList;
13
14
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.jface.dialogs.IDialogPage;
17
import org.eclipse.jface.wizard.IWizardPage;
18
import org.eclipse.mylyn.tasks.core.TaskRepository;
19
import org.eclipse.swt.widgets.Composite;
20
21
/**
22
 * A contribution to a {@link ITaskRepositoryPage}, which enables plug-ins to contribute UI to the task repository
23
 * settings.
24
 * 
25
 * subclasses must have a default public constructor.
26
 * 
27
 * @author David Green
28
 * @since 3.1
29
 */
30
public abstract class AbstractTaskRepositoryPageContribution {
31
32
	/**
33
	 * A listener interface that should be implemented by classes wishing to be notified of changes that occur within
34
	 * the contribution.
35
	 * 
36
	 * @since 3.1
37
	 */
38
	public interface Listener {
39
40
		/**
41
		 * Called when the state of the contribution changes such that validation should be performed
42
		 * 
43
		 * @param contribution
44
		 *            the contribution that changed
45
		 * 
46
		 * @see ITaskRepositoryPageContribution#validate(IProgressMonitor)
47
		 */
48
		public void validationRequired(AbstractTaskRepositoryPageContribution contribution);
49
50
	}
51
52
	private final List<Listener> listeners = new CopyOnWriteArrayList<Listener>();
53
54
	private final String title;
55
56
	private final String description;
57
58
	private TaskRepository repository;
59
60
	private String connectorKind;
61
62
	/**
63
	 * 
64
	 * @param title
65
	 *            the title of the contribution, as displayed to the user, usually used as a section heading
66
	 * @param description
67
	 *            the description of the contribution, as displayed to the user, typically as a tool-tip
68
	 * @since 3.1
69
	 */
70
	protected AbstractTaskRepositoryPageContribution(String title, String description) {
71
		this.title = title;
72
		this.description = description;
73
	}
74
75
	/**
76
	 * Initialize the contribution
77
	 * 
78
	 * @param connectorKind
79
	 *            the kind of connector for which this is a contribution
80
	 * @param repository
81
	 *            the repository for which this contribution was created, or null if the repository is not yet available
82
	 * @since 3.1
83
	 */
84
	public void init(String connectorKind, TaskRepository repository) {
85
		this.connectorKind = connectorKind;
86
		this.repository = repository;
87
	}
88
89
	/**
90
	 * Add a listener to this contribution. The contribution must notify the listener at the appropriate times, for
91
	 * example when a setting has changed in the UI.
92
	 * 
93
	 * @see #removeListener(Listener)
94
	 * @since 3.1
95
	 */
96
	public void addListener(Listener listener) {
97
		listeners.add(listener);
98
	}
99
100
	/**
101
	 * Remove a listener from this contribution.
102
	 * 
103
	 * @see #addListener(Listener)
104
	 * @since 3.1
105
	 */
106
	public void removeListener(Listener listener) {
107
		listeners.remove(listener);
108
	}
109
110
	/**
111
	 * @see IDialogPage#createControl(Composite)
112
	 * @since 3.1
113
	 */
114
	public abstract void createControl(Composite parent);
115
116
	/**
117
	 * @see IDialogPage#getTitle()
118
	 * @since 3.1
119
	 */
120
	public String getTitle() {
121
		return title;
122
	}
123
124
	/**
125
	 * @see IDialogPage#getDescription()
126
	 * @since 3.1
127
	 */
128
	public String getDescription() {
129
		return description;
130
	}
131
132
	/**
133
	 * @see IWizardPage#isPageComplete()
134
	 * @since 3.1
135
	 */
136
	public abstract boolean isPageComplete();
137
138
	/**
139
	 * @see IWizardPage#canFlipToNextPage()
140
	 * @since 3.1
141
	 */
142
	public abstract boolean canFlipToNextPage();
143
144
	/**
145
	 * Validate the settings of the contribution. Contributions should expect this method to be called often and should
146
	 * thus return quickly. Always called on the UI thread.
147
	 * 
148
	 * @return the status (errors) on the contribution, or null if there are none. A MultiStatus should be used to
149
	 *         return multiple error messages or warnings.
150
	 * @since 3.1
151
	 */
152
	public abstract IStatus validate();
153
154
	/**
155
	 * Apply the settings in the contribution to the given repository.
156
	 * 
157
	 * @param repository
158
	 *            the repository to which settings should be applied
159
	 * 
160
	 * @see ITaskRepositoryPage#applyTo(TaskRepository)
161
	 * @since 3.1
162
	 */
163
	public abstract void applyTo(TaskRepository repository);
164
165
	/**
166
	 * Requests a validation.
167
	 * 
168
	 * @see #validate()
169
	 * @since 3.1
170
	 */
171
	protected void fireValidationRequired() {
172
		for (Listener l : listeners) {
173
			l.validationRequired(this);
174
		}
175
	}
176
177
	/**
178
	 * Returns the repository for which this contribution was created, or null if it was created for a new repository.
179
	 * 
180
	 * @since 3.1
181
	 */
182
	protected TaskRepository getRepository() {
183
		return repository;
184
	}
185
186
	/**
187
	 * Returns the kind of connector for which this contribution was created.
188
	 * 
189
	 * @since 3.1
190
	 */
191
	protected String getConnectorKind() {
192
		return connectorKind;
193
	}
194
195
}

Return to bug 244653