View | Details | Raw Unified | Return to bug 263528 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (+1 lines)
Lines 14-19 Link Here
14
 org.eclipse.mylyn.internal.tasks.core;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
14
 org.eclipse.mylyn.internal.tasks.core;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
15
 org.eclipse.mylyn.internal.tasks.core.data;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
15
 org.eclipse.mylyn.internal.tasks.core.data;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
16
 org.eclipse.mylyn.internal.tasks.core.externalization;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
16
 org.eclipse.mylyn.internal.tasks.core.externalization;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
17
 org.eclipse.mylyn.internal.tasks.core.servicemessage,
17
 org.eclipse.mylyn.internal.tasks.core.sync;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
18
 org.eclipse.mylyn.internal.tasks.core.sync;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
18
 org.eclipse.mylyn.tasks.core,
19
 org.eclipse.mylyn.tasks.core,
19
 org.eclipse.mylyn.tasks.core.data,
20
 org.eclipse.mylyn.tasks.core.data,
(-)src/org/eclipse/mylyn/internal/tasks/core/servicemessage/ServiceMessageXmlHandler.java (+73 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Tasktop Technologies 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
 * Contributors:
9
 *     Tasktop Technologies - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.tasks.core.servicemessage;
13
14
import org.xml.sax.Attributes;
15
import org.xml.sax.SAXException;
16
import org.xml.sax.helpers.DefaultHandler;
17
18
public class ServiceMessageXmlHandler extends DefaultHandler {
19
20
	private StringBuilder characters;
21
22
	private final ServiceMessage message = new ServiceMessage();
23
24
	@Override
25
	public void characters(char[] ch, int start, int length) throws SAXException {
26
		characters.append(ch, start, length);
27
	}
28
29
	@Override
30
	public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
31
		characters = new StringBuilder();
32
	}
33
34
	@Override
35
	public void endElement(String uri, String localName, String qName) throws SAXException {
36
37
		String parsedText = characters.toString();
38
		ServiceMessage.Element element;
39
		try {
40
			element = ServiceMessage.Element.valueOf(qName.trim());
41
			switch (element) {
42
			case id:
43
				message.setId(parsedText);
44
				break;
45
			case description:
46
				message.setDescription(parsedText);
47
				break;
48
			case title:
49
				message.setTitle(parsedText);
50
				break;
51
			case url:
52
				message.setUrl(parsedText);
53
				break;
54
			case image:
55
				message.setImage(parsedText);
56
				break;
57
			case mylynVersion:
58
				message.setMylynVersion(parsedText);
59
				break;
60
			}
61
		} catch (RuntimeException e) {
62
			if (e instanceof IllegalArgumentException) {
63
				// ignore unrecognized elements
64
				return;
65
			}
66
			throw e;
67
		}
68
	}
69
70
	public ServiceMessage getMessage() {
71
		return message;
72
	}
73
}
(-)src/org/eclipse/mylyn/internal/tasks/core/servicemessage/ServiceMessageManager.java (+208 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 Tasktop Technologies.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Tasktop EULA
5
 * which accompanies this distribution, and is available at
6
 * http://tasktop.com/legal
7
 *******************************************************************************/
8
9
package org.eclipse.mylyn.internal.tasks.core.servicemessage;
10
11
import java.io.InputStream;
12
import java.util.HashSet;
13
import java.util.Set;
14
15
import javax.xml.parsers.SAXParser;
16
import javax.xml.parsers.SAXParserFactory;
17
18
import org.apache.commons.httpclient.Header;
19
import org.apache.commons.httpclient.HostConfiguration;
20
import org.apache.commons.httpclient.HttpClient;
21
import org.apache.commons.httpclient.HttpStatus;
22
import org.apache.commons.httpclient.methods.GetMethod;
23
import org.eclipse.core.runtime.IProgressMonitor;
24
import org.eclipse.core.runtime.IStatus;
25
import org.eclipse.core.runtime.Status;
26
import org.eclipse.core.runtime.SubProgressMonitor;
27
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
28
import org.eclipse.core.runtime.jobs.Job;
29
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
30
import org.eclipse.mylyn.commons.core.StatusHandler;
31
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
32
import org.eclipse.mylyn.commons.net.WebLocation;
33
import org.eclipse.mylyn.commons.net.WebUtil;
34
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
35
36
// Todo: use Last-Modified and ETag headers
37
public class ServiceMessageManager {
38
39
	protected static final long START_DELAY = 30 * 1000;
40
41
	protected static final long RECHECK_DELAY = 2 * 60 * 60 * 1000;
42
43
	private static final String USER_AGENT = "MylynServiceMessageManager"; //$NON-NLS-1$
44
45
	private String serviceMessageUrl;
46
47
	private ServiceMessage currentMessage = null;
48
49
	private Job messageCheckJob;
50
51
	private final Set<IServiceMessageListener> listeners = new HashSet<IServiceMessageListener>();
52
53
	private final HttpClient httpClient = new HttpClient(WebUtil.getConnectionManager());
54
55
	private String lastModified;
56
57
	private String eTag;
58
59
	private int status;
60
61
	public ServiceMessageManager(String serviceMessageUrl, String lastModified, String eTag) {
62
63
		this.serviceMessageUrl = serviceMessageUrl;
64
65
		this.lastModified = lastModified;
66
67
		this.eTag = eTag;
68
69
		WebUtil.configureHttpClient(httpClient, USER_AGENT);
70
71
	}
72
73
	public void start() {
74
		if (messageCheckJob == null) {
75
			messageCheckJob = new Job("Checking for new service message") { //$NON-NLS-1$
76
				@Override
77
				protected IStatus run(IProgressMonitor monitor) {
78
79
					updateServiceMessage(monitor);
80
81
					return Status.OK_STATUS;
82
				}
83
84
			};
85
			messageCheckJob.setSystem(true);
86
			messageCheckJob.setPriority(Job.DECORATE);
87
			messageCheckJob.addJobChangeListener(new JobChangeAdapter() {
88
				@Override
89
				public void done(IJobChangeEvent event) {
90
					if (messageCheckJob != null) {
91
						messageCheckJob.schedule(RECHECK_DELAY);
92
					}
93
				}
94
			});
95
		}
96
		messageCheckJob.schedule(START_DELAY);
97
	}
98
99
	public void stop() {
100
		notifyListeners(null);
101
		if (messageCheckJob != null) {
102
			messageCheckJob.cancel();
103
			messageCheckJob = null;
104
		}
105
	}
106
107
	public void setServiceMessageUrl(String url) {
108
		this.serviceMessageUrl = url;
109
	}
110
111
	public void addServiceMessageListener(IServiceMessageListener listener) {
112
		listeners.add(listener);
113
	}
114
115
	public void removeServiceMessageListener(IServiceMessageListener listener) {
116
		listeners.remove(listener);
117
	}
118
119
	private void notifyListeners(ServiceMessage message) {
120
		for (IServiceMessageListener listener : listeners) {
121
			listener.setServiceMessage(message);
122
		}
123
	}
124
125
	public ServiceMessage getServiceMessage() {
126
		return currentMessage;
127
	}
128
129
	/**
130
	 * Public for testing
131
	 */
132
	public void updateServiceMessage(IProgressMonitor monitor) {
133
		GetMethod getMethod = null;
134
		try {
135
136
			HostConfiguration hostConfiguration = null;
137
			AbstractWebLocation location = null;
138
139
			location = new WebLocation(serviceMessageUrl);
140
			hostConfiguration = WebUtil.createHostConfiguration(httpClient, location,
141
					new SubProgressMonitor(monitor, 1));
142
143
			getMethod = new GetMethod(serviceMessageUrl);
144
145
			getMethod.setRequestHeader("If-Modified-Since", lastModified); //$NON-NLS-1$
146
			getMethod.setRequestHeader("If-None-Match", eTag); //$NON-NLS-1$
147
148
			httpClient.getHttpConnectionManager().getParams().setSoTimeout(WebUtil.getConnectionTimeout());
149
150
			status = WebUtil.execute(httpClient, hostConfiguration, getMethod, monitor);
151
152
			if (status == HttpStatus.SC_OK) {
153
				Header lastModifiedHeader = getMethod.getResponseHeader("Last-Modified"); //$NON-NLS-1$
154
				if (lastModifiedHeader != null) {
155
					lastModified = lastModifiedHeader.getValue();
156
				}
157
				Header eTagHeader = getMethod.getResponseHeader("ETag"); //$NON-NLS-1$
158
				if (eTagHeader != null) {
159
					eTag = eTagHeader.getValue();
160
				}
161
162
				InputStream in = WebUtil.getResponseBodyAsStream(getMethod, monitor);
163
				ServiceMessage message;
164
				if (getMethod.getResponseHeader("Content-Length").getValue().equals("0")) { //$NON-NLS-1$ //$NON-NLS-2$
165
					message = new ServiceMessage();
166
					message.setId("-1"); //$NON-NLS-1$
167
				} else {
168
					ServiceMessageXmlHandler handler = new ServiceMessageXmlHandler();
169
					try {
170
						SAXParserFactory factory = SAXParserFactory.newInstance();
171
						factory.setValidating(false);
172
						SAXParser parser = factory.newSAXParser();
173
						parser.parse(in, handler);
174
					} finally {
175
						in.close();
176
					}
177
178
					message = handler.getMessage();
179
				}
180
				if (message.getId() != null) {
181
					currentMessage = message;
182
					currentMessage.setETag(eTag);
183
					currentMessage.setLastModified(lastModified);
184
					notifyListeners(message);
185
				}
186
			} else if (status == HttpStatus.SC_NOT_MODIFIED) {
187
			} else {
188
				StatusHandler.log(new Status(IStatus.WARNING, ITasksCoreConstants.ID_PLUGIN,
189
						"Http error retrieving service message: " + HttpStatus.getStatusText(status))); //$NON-NLS-1$
190
			}
191
		} catch (Exception e) {
192
			StatusHandler.log(new Status(IStatus.WARNING, ITasksCoreConstants.ID_PLUGIN,
193
					"Http error retrieving service message.", e)); //$NON-NLS-1$
194
		} finally {
195
			try {
196
				if (getMethod != null) {
197
					getMethod.releaseConnection();
198
				}
199
			} catch (Throwable t) {
200
				// ignore
201
			}
202
		}
203
	}
204
205
	public int getStatus() {
206
		return status;
207
	}
208
}
(-)src/org/eclipse/mylyn/internal/tasks/core/servicemessage/IServiceMessageListener.java (+18 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Tasktop Technologies 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
 * Contributors:
9
 *     Tasktop Technologies - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.tasks.core.servicemessage;
13
14
public interface IServiceMessageListener {
15
16
	public void setServiceMessage(ServiceMessage message);
17
18
}
(-)src/org/eclipse/mylyn/internal/tasks/core/servicemessage/ServiceMessage.java (+100 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Tasktop Technologies 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
 * Contributors:
9
 *     Tasktop Technologies - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.tasks.core.servicemessage;
13
14
public class ServiceMessage {
15
16
	public enum Element {
17
		id, title, description, url, image, mylynVersion
18
	};
19
20
	private String id;
21
22
	private String title;
23
24
	private String description;
25
26
	private String url;
27
28
	private String image;
29
30
	private String mylynVersion;
31
32
	private String eTag;
33
34
	private String lastModified;
35
36
	public String getId() {
37
		return id;
38
	}
39
40
	public String getTitle() {
41
		return title;
42
	}
43
44
	public String getDescription() {
45
		return description;
46
	}
47
48
	public String getUrl() {
49
		return url;
50
	}
51
52
	public String getImage() {
53
		return image;
54
	}
55
56
	public void setETag(String eTag) {
57
		this.eTag = eTag;
58
	}
59
60
	public void setLastModified(String lastModified) {
61
		this.lastModified = lastModified;
62
	}
63
64
	public String getETag() {
65
		return eTag;
66
	}
67
68
	public String getLastModified() {
69
		return lastModified;
70
	}
71
72
	public String getMylynVersion() {
73
		return mylynVersion;
74
	}
75
76
	public void setId(String id) {
77
		this.id = id;
78
	}
79
80
	public void setTitle(String title) {
81
		this.title = title;
82
	}
83
84
	public void setDescription(String description) {
85
		this.description = description;
86
	}
87
88
	public void setUrl(String url) {
89
		this.url = url;
90
	}
91
92
	public void setImage(String image) {
93
		this.image = image;
94
	}
95
96
	public void setMylynVersion(String mylynVersion) {
97
		this.mylynVersion = mylynVersion;
98
	}
99
100
}
(-)src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java (+2 lines)
Lines 30-35 Link Here
30
import org.eclipse.mylyn.tasks.tests.ui.editor.RepositoryCompletionProcessorTest;
30
import org.eclipse.mylyn.tasks.tests.ui.editor.RepositoryCompletionProcessorTest;
31
import org.eclipse.mylyn.tasks.tests.ui.editor.TaskEditorPartDescriptorTest;
31
import org.eclipse.mylyn.tasks.tests.ui.editor.TaskEditorPartDescriptorTest;
32
import org.eclipse.mylyn.tasks.tests.ui.editor.TaskUrlHyperlinkDetectorTest;
32
import org.eclipse.mylyn.tasks.tests.ui.editor.TaskUrlHyperlinkDetectorTest;
33
import org.eclipse.mylyn.tasks.tests.util.ServiceMessageManagerTest;
33
34
34
/**
35
/**
35
 * @author Mik Kersten
36
 * @author Mik Kersten
Lines 102-107 Link Here
102
		suite.addTestSuite(PlanningPartTest.class);
103
		suite.addTestSuite(PlanningPartTest.class);
103
		suite.addTestSuite(RepositoryCompletionProcessorTest.class);
104
		suite.addTestSuite(RepositoryCompletionProcessorTest.class);
104
		suite.addTestSuite(TaskAttributeDiffTest.class);
105
		suite.addTestSuite(TaskAttributeDiffTest.class);
106
		suite.addTestSuite(ServiceMessageManagerTest.class);
105
		// XXX long running tests, put back?
107
		// XXX long running tests, put back?
106
		//suite.addTestSuite(QueryExportImportTest.class);
108
		//suite.addTestSuite(QueryExportImportTest.class);
107
		//suite.addTestSuite(BackgroundSaveTest.class);
109
		//suite.addTestSuite(BackgroundSaveTest.class);
(-)src/org/eclipse/mylyn/tasks/tests/util/ServiceMessageManagerTest.java (+101 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Tasktop Technologies 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
 * Contributors:
9
 *     Tasktop Technologies - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.tasks.tests.util;
13
14
import java.io.ByteArrayInputStream;
15
import java.io.InputStream;
16
17
import javax.xml.parsers.SAXParser;
18
import javax.xml.parsers.SAXParserFactory;
19
20
import junit.framework.TestCase;
21
22
import org.apache.commons.httpclient.HttpStatus;
23
import org.eclipse.core.runtime.NullProgressMonitor;
24
import org.eclipse.mylyn.internal.tasks.core.servicemessage.ServiceMessage;
25
import org.eclipse.mylyn.internal.tasks.core.servicemessage.ServiceMessageManager;
26
import org.eclipse.mylyn.internal.tasks.core.servicemessage.ServiceMessageXmlHandler;
27
import org.eclipse.mylyn.internal.tasks.ui.notifications.MylynVersion;
28
29
/**
30
 * @author Robert Elves
31
 */
32
public class ServiceMessageManagerTest extends TestCase {
33
34
	private static final String MESSAGE_XML_URL = "http://eclipse.org/mylyn/messageTest.xml";
35
36
	public void testRetrievingMessage() throws Exception {
37
		ServiceMessageManager manager = new ServiceMessageManager(MESSAGE_XML_URL, "", "");
38
		manager.updateServiceMessage(new NullProgressMonitor());
39
		assertEquals(HttpStatus.SC_OK, manager.getStatus());
40
		ServiceMessage message = manager.getServiceMessage();
41
42
		assertEquals("1", message.getId());
43
		assertEquals("140 character description here....", message.getDescription());
44
		assertEquals("Mylyn 3.4 now available!", message.getTitle());
45
		assertEquals("http://eclipse.org/mylyn/downloads", message.getUrl());
46
		assertEquals("Mylyn 3.4 now available!", message.getTitle());
47
		assertEquals("dialog_messasge_info_image", message.getImage());
48
	}
49
50
	public void testETag() throws Exception {
51
52
		ServiceMessageManager manager = new ServiceMessageManager(MESSAGE_XML_URL, "", "");
53
		manager.updateServiceMessage(new NullProgressMonitor());
54
		assertEquals(HttpStatus.SC_OK, manager.getStatus());
55
		ServiceMessage message = manager.getServiceMessage();
56
57
		assertNotNull(message.getLastModified());
58
		assertNotNull(message.getETag());
59
60
		assertEquals(HttpStatus.SC_OK, manager.getStatus());
61
62
		manager.updateServiceMessage(new NullProgressMonitor());
63
		assertEquals(HttpStatus.SC_NOT_MODIFIED, manager.getStatus());
64
	}
65
66
	public void testParsingMessageXml() throws Exception {
67
		String messageXml = "<ServiceMessage> <id>1</id><description>140 character description here....</description><title>Mylyn 3.4 now available!</title><url>http://eclipse.org/mylyn/downloads</url><image>dialog_messasge_info_image</image></ServiceMessage>";
68
		InputStream is = new ByteArrayInputStream(messageXml.getBytes("UTF-8"));
69
		SAXParserFactory factory = SAXParserFactory.newInstance();
70
		factory.setValidating(false);
71
		SAXParser parser = factory.newSAXParser();
72
		ServiceMessageXmlHandler handler = new ServiceMessageXmlHandler();
73
		parser.parse(is, handler);
74
		ServiceMessage message = handler.getMessage();
75
76
		assertEquals("1", message.getId());
77
		assertEquals("140 character description here....", message.getDescription());
78
		assertEquals("Mylyn 3.4 now available!", message.getTitle());
79
		assertEquals("http://eclipse.org/mylyn/downloads", message.getUrl());
80
		assertEquals("Mylyn 3.4 now available!", message.getTitle());
81
		assertEquals("dialog_messasge_info_image", message.getImage());
82
	}
83
84
	public void testMylynVersion() {
85
		MylynVersion v1 = new MylynVersion("3.4.0.I20100521-1600-e3x");
86
		MylynVersion v2 = new MylynVersion("3.4.0.v20100521-1600-e3x");
87
		assertTrue(v1.compareTo(v2) < 0);
88
89
		MylynVersion v3 = new MylynVersion("3.4.0");
90
		MylynVersion v4 = new MylynVersion("3.4.0.I20100521-1600-e3x");
91
		assertTrue(v3.compareTo(v4) < 0);
92
93
		v1 = new MylynVersion("3.5.0");
94
		v2 = new MylynVersion("3.4.0.I20100521-1600-e3x");
95
		assertTrue(v1.compareTo(v2) > 0);
96
97
		v1 = new MylynVersion("3.5.0");
98
		v2 = new MylynVersion("3.5.0");
99
		assertTrue(v1.compareTo(v2) == 0);
100
	}
101
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java (+2 lines)
Lines 63-68 Link Here
63
63
64
	public static String TasksUiPreferencePage_See_X_for_configuring_Task_List_colors;
64
	public static String TasksUiPreferencePage_See_X_for_configuring_Task_List_colors;
65
65
66
	public static String TasksUiPreferencePage_show_service_messages;
67
66
	public static String TasksUiPreferencePage_Show_tooltip_on_hover_Label;
68
	public static String TasksUiPreferencePage_Show_tooltip_on_hover_Label;
67
69
68
	public static String TasksUiPreferencePage_Specify_the_folder_for_tasks;
70
	public static String TasksUiPreferencePage_Specify_the_folder_for_tasks;
(-)src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java (-8 / +23 lines)
Lines 23-29 Link Here
23
import org.eclipse.mylyn.commons.core.StatusHandler;
23
import org.eclipse.mylyn.commons.core.StatusHandler;
24
import org.eclipse.mylyn.internal.monitor.ui.ActivityContextManager;
24
import org.eclipse.mylyn.internal.monitor.ui.ActivityContextManager;
25
import org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin;
25
import org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin;
26
import org.eclipse.mylyn.internal.provisional.commons.core.CommonMessages;
27
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonColors;
26
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonColors;
28
import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
27
import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
29
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
28
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
Lines 109-114 Link Here
109
108
110
	private Button taskListTooltipEnabledButton;
109
	private Button taskListTooltipEnabledButton;
111
110
111
	private Button taskListServiceMessageEnabledButton;
112
112
	public TasksUiPreferencePage() {
113
	public TasksUiPreferencePage() {
113
		super();
114
		super();
114
		setPreferenceStore(TasksUiPlugin.getDefault().getPreferenceStore());
115
		setPreferenceStore(TasksUiPlugin.getDefault().getPreferenceStore());
Lines 208-213 Link Here
208
		getPreferenceStore().setValue(ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED,
209
		getPreferenceStore().setValue(ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED,
209
				taskListTooltipEnabledButton.getSelection());
210
				taskListTooltipEnabledButton.getSelection());
210
211
212
		getPreferenceStore().setValue(ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED,
213
				taskListServiceMessageEnabledButton.getSelection());
214
211
		getPreferenceStore().setValue(ITasksUiPreferenceConstants.WEEK_START_DAY, getWeekStartValue());
215
		getPreferenceStore().setValue(ITasksUiPreferenceConstants.WEEK_START_DAY, getWeekStartValue());
212
		//getPreferenceStore().setValue(TasksUiPreferenceConstants.PLANNING_STARTHOUR, hourDayStart.getSelection());
216
		//getPreferenceStore().setValue(TasksUiPreferenceConstants.PLANNING_STARTHOUR, hourDayStart.getSelection());
213
//		getPreferenceStore().setValue(TasksUiPreferenceConstants.PLANNING_ENDHOUR, hourDayEnd.getSelection());
217
//		getPreferenceStore().setValue(TasksUiPreferenceConstants.PLANNING_ENDHOUR, hourDayEnd.getSelection());
Lines 276-281 Link Here
276
		taskListTooltipEnabledButton.setSelection(getPreferenceStore().getBoolean(
280
		taskListTooltipEnabledButton.setSelection(getPreferenceStore().getBoolean(
277
				ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED));
281
				ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED));
278
282
283
		taskListServiceMessageEnabledButton.setSelection(getPreferenceStore().getBoolean(
284
				ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED));
285
279
		weekStartCombo.select(getPreferenceStore().getInt(ITasksUiPreferenceConstants.WEEK_START_DAY) - 1);
286
		weekStartCombo.select(getPreferenceStore().getInt(ITasksUiPreferenceConstants.WEEK_START_DAY) - 1);
280
		//hourDayStart.setSelection(getPreferenceStore().getInt(TasksUiPreferenceConstants.PLANNING_STARTHOUR));
287
		//hourDayStart.setSelection(getPreferenceStore().getInt(TasksUiPreferenceConstants.PLANNING_STARTHOUR));
281
//		hourDayEnd.setSelection(getPreferenceStore().getInt(TasksUiPreferenceConstants.PLANNING_ENDHOUR));
288
//		hourDayEnd.setSelection(getPreferenceStore().getInt(TasksUiPreferenceConstants.PLANNING_ENDHOUR));
Lines 310-315 Link Here
310
		taskListTooltipEnabledButton.setSelection(getPreferenceStore().getDefaultBoolean(
317
		taskListTooltipEnabledButton.setSelection(getPreferenceStore().getDefaultBoolean(
311
				ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED));
318
				ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED));
312
319
320
		taskListServiceMessageEnabledButton.setSelection(getPreferenceStore().getDefaultBoolean(
321
				ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED));
322
313
		// synchQueries.setSelection(getPreferenceStore().getDefaultBoolean(
323
		// synchQueries.setSelection(getPreferenceStore().getDefaultBoolean(
314
		// TaskListPreferenceConstants.REPOSITORY_SYNCH_ON_STARTUP));
324
		// TaskListPreferenceConstants.REPOSITORY_SYNCH_ON_STARTUP));
315
		enableBackgroundSynch.setSelection(getPreferenceStore().getDefaultBoolean(
325
		enableBackgroundSynch.setSelection(getPreferenceStore().getDefaultBoolean(
Lines 459-471 Link Here
459
//		weekStartCombo.add(LABEL_SUNDAY);
469
//		weekStartCombo.add(LABEL_SUNDAY);
460
//		weekStartCombo.add(LABEL_MONDAY);
470
//		weekStartCombo.add(LABEL_MONDAY);
461
//		weekStartCombo.add(LABEL_SATURDAY);
471
//		weekStartCombo.add(LABEL_SATURDAY);
462
		weekStartCombo.add(CommonMessages.Sunday);
472
		weekStartCombo.add(""); //$NON-NLS-1$
463
		weekStartCombo.add(CommonMessages.Monday);
473
		weekStartCombo.add(""); //$NON-NLS-1$
464
		weekStartCombo.add(CommonMessages.Tuesday);
474
		weekStartCombo.add(""); //$NON-NLS-1$
465
		weekStartCombo.add(CommonMessages.Wednesday);
475
		weekStartCombo.add(""); //$NON-NLS-1$
466
		weekStartCombo.add(CommonMessages.Thursday);
476
		weekStartCombo.add(""); //$NON-NLS-1$
467
		weekStartCombo.add(CommonMessages.Friday);
477
		weekStartCombo.add(""); //$NON-NLS-1$
468
		weekStartCombo.add(CommonMessages.Saturday);
478
		weekStartCombo.add(""); //$NON-NLS-1$
469
		weekStartCombo.select(getPreferenceStore().getInt(ITasksUiPreferenceConstants.WEEK_START_DAY) - 1);
479
		weekStartCombo.select(getPreferenceStore().getInt(ITasksUiPreferenceConstants.WEEK_START_DAY) - 1);
470
480
471
	}
481
	}
Lines 480-485 Link Here
480
		taskListTooltipEnabledButton.setText(Messages.TasksUiPreferencePage_Show_tooltip_on_hover_Label);
490
		taskListTooltipEnabledButton.setText(Messages.TasksUiPreferencePage_Show_tooltip_on_hover_Label);
481
		taskListTooltipEnabledButton.setSelection(getPreferenceStore().getBoolean(
491
		taskListTooltipEnabledButton.setSelection(getPreferenceStore().getBoolean(
482
				ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED));
492
				ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED));
493
494
		taskListServiceMessageEnabledButton = new Button(group, SWT.CHECK);
495
		taskListServiceMessageEnabledButton.setText(Messages.TasksUiPreferencePage_show_service_messages);
496
		taskListServiceMessageEnabledButton.setSelection(getPreferenceStore().getBoolean(
497
				ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED));
483
	}
498
	}
484
499
485
	private void createTaskActivityGroup(Composite container) {
500
	private void createTaskActivityGroup(Composite container) {
(-)src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties (+1 lines)
Lines 27-32 Link Here
27
TasksUiPreferencePage_Rich_Editor__Recommended_=Rich Editor (Recommended)
27
TasksUiPreferencePage_Rich_Editor__Recommended_=Rich Editor (Recommended)
28
TasksUiPreferencePage_Scheduling=Scheduling
28
TasksUiPreferencePage_Scheduling=Scheduling
29
TasksUiPreferencePage_See_X_for_configuring_Task_List_colors=See <a>''{0}''</a> for configuring Task List colors.
29
TasksUiPreferencePage_See_X_for_configuring_Task_List_colors=See <a>''{0}''</a> for configuring Task List colors.
30
TasksUiPreferencePage_show_service_messages=Show service messages
30
TasksUiPreferencePage_Show_tooltip_on_hover_Label=Show task overview popups on hover
31
TasksUiPreferencePage_Show_tooltip_on_hover_Label=Show task overview popups on hover
31
TasksUiPreferencePage_Specify_the_folder_for_tasks=Specify the folder for tasks
32
TasksUiPreferencePage_Specify_the_folder_for_tasks=Specify the folder for tasks
32
TasksUiPreferencePage_Stop_time_accumulation_after=Stop time accumulation after
33
TasksUiPreferencePage_Stop_time_accumulation_after=Stop time accumulation after
(-)src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java (+10 lines)
Lines 52-57 Link Here
52
52
53
	public static final String NOTIFICATIONS_ENABLED = "org.eclipse.mylyn.tasks.ui.notifications.enabled"; //$NON-NLS-1$
53
	public static final String NOTIFICATIONS_ENABLED = "org.eclipse.mylyn.tasks.ui.notifications.enabled"; //$NON-NLS-1$
54
54
55
	public static final String SERVICE_MESSAGES_ENABLED = "org.eclipse.mylyn.tasks.ui.messages.enabled"; //$NON-NLS-1$
56
55
	public static final String WEEK_START_DAY = "org.eclipse.mylyn.tasks.ui.planning.week.start.day"; //$NON-NLS-1$
57
	public static final String WEEK_START_DAY = "org.eclipse.mylyn.tasks.ui.planning.week.start.day"; //$NON-NLS-1$
56
58
57
	public static final String PLANNING_ENDHOUR = "org.eclipse.mylyn.tasks.ui.planning.end.hour"; //$NON-NLS-1$
59
	public static final String PLANNING_ENDHOUR = "org.eclipse.mylyn.tasks.ui.planning.end.hour"; //$NON-NLS-1$
Lines 87-90 Link Here
87
	public static final String PREF_DATA_DIR = "org.eclipse.mylyn.data.dir"; //$NON-NLS-1$
89
	public static final String PREF_DATA_DIR = "org.eclipse.mylyn.data.dir"; //$NON-NLS-1$
88
90
89
	public static final String DEFAULT_ATTACHMENTS_DIRECTORY = "org.eclipse.mylyn.tasks.ui.attachments.defaultDirectory"; //$NON-NLS-1$
91
	public static final String DEFAULT_ATTACHMENTS_DIRECTORY = "org.eclipse.mylyn.tasks.ui.attachments.defaultDirectory"; //$NON-NLS-1$
92
93
	public static final String SERVICE_MESSAGE_URL = "org.eclipse.mylyn.tasks.ui.servicemessage.url"; //$NON-NLS-1$;
94
95
	public static final String LAST_SERVICE_MESSAGE_ID = "org.eclipse.mylyn.tasks.ui.servicemessage.id"; //$NON-NLS-1$
96
97
	public static final String LAST_SERVICE_MESSAGE_ETAG = "org.eclipse.mylyn.tasks.ui.servicemessage.etag"; //$NON-NLS-1$
98
99
	public static final String LAST_SERVICE_MESSAGE_LAST_MODIFIED = "org.eclipse.mylyn.tasks.ui.servicemessage.lastmodified"; //$NON-NLS-1$
90
}
100
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java (+31 lines)
Lines 77-82 Link Here
77
import org.eclipse.mylyn.internal.tasks.core.externalization.IExternalizationParticipant;
77
import org.eclipse.mylyn.internal.tasks.core.externalization.IExternalizationParticipant;
78
import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizationParticipant;
78
import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizationParticipant;
79
import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizer;
79
import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizer;
80
import org.eclipse.mylyn.internal.tasks.core.servicemessage.ServiceMessageManager;
80
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListNotificationReminder;
81
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListNotificationReminder;
81
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListNotifier;
82
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListNotifier;
82
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiExtensionReader;
83
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiExtensionReader;
Lines 149-154 Link Here
149
150
150
	private RepositoryTemplateManager repositoryTemplateManager;
151
	private RepositoryTemplateManager repositoryTemplateManager;
151
152
153
	private ServiceMessageManager serviceMessageManager;
154
152
	private final Set<AbstractTaskEditorPageFactory> taskEditorPageFactories = new HashSet<AbstractTaskEditorPageFactory>();
155
	private final Set<AbstractTaskEditorPageFactory> taskEditorPageFactories = new HashSet<AbstractTaskEditorPageFactory>();
153
156
154
	private final TreeSet<AbstractTaskRepositoryLinkProvider> repositoryLinkProviders = new TreeSet<AbstractTaskRepositoryLinkProvider>(
157
	private final TreeSet<AbstractTaskRepositoryLinkProvider> repositoryLinkProviders = new TreeSet<AbstractTaskRepositoryLinkProvider>(
Lines 343-348 Link Here
343
					|| event.getProperty().equals(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS)) {
346
					|| event.getProperty().equals(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS)) {
344
				updateSynchronizationScheduler(false);
347
				updateSynchronizationScheduler(false);
345
			}
348
			}
349
350
			// TODO: ROB
351
			if (event.getProperty().equals(ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED)) {
352
				if (getPreferenceStore().getBoolean(ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED)) {
353
					serviceMessageManager.start();
354
				} else {
355
					serviceMessageManager.stop();
356
				}
357
			}
346
		}
358
		}
347
	};
359
	};
348
360
Lines 605-610 Link Here
605
			// make this available early for clients that are not initialized through tasks ui but need access 
617
			// make this available early for clients that are not initialized through tasks ui but need access 
606
			taskListNotificationManager = new TaskListNotificationManager();
618
			taskListNotificationManager = new TaskListNotificationManager();
607
619
620
			String lastMod = getPreferenceStore().getString(
621
					ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_LAST_MODIFIED);
622
			String etag = getPreferenceStore().getString(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ETAG);
623
624
			serviceMessageManager = new ServiceMessageManager(getPreferenceStore().getString(
625
					ITasksUiPreferenceConstants.SERVICE_MESSAGE_URL), lastMod, etag);
626
627
			if (getPreferenceStore().getBoolean(ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED)) {
628
				serviceMessageManager.start();
629
			}
630
608
			// trigger lazy initialization
631
			// trigger lazy initialization
609
			new TasksUiInitializationJob().schedule();
632
			new TasksUiInitializationJob().schedule();
610
		} catch (Exception e) {
633
		} catch (Exception e) {
Lines 727-732 Link Here
727
//					ContextCorePlugin.getDefault().getPluginPreferences().removePropertyChangeListener(
750
//					ContextCorePlugin.getDefault().getPluginPreferences().removePropertyChangeListener(
728
//							PREFERENCE_LISTENER);
751
//							PREFERENCE_LISTENER);
729
//				}
752
//				}
753
				serviceMessageManager.stop();
730
				taskEditorBloatManager.dispose(PlatformUI.getWorkbench());
754
				taskEditorBloatManager.dispose(PlatformUI.getWorkbench());
731
				INSTANCE = null;
755
				INSTANCE = null;
732
			}
756
			}
Lines 868-873 Link Here
868
		store.setDefault(ITasksUiPreferenceConstants.PREF_DATA_DIR, getDefaultDataDirectory());
892
		store.setDefault(ITasksUiPreferenceConstants.PREF_DATA_DIR, getDefaultDataDirectory());
869
		store.setDefault(ITasksUiPreferenceConstants.GROUP_SUBTASKS, true);
893
		store.setDefault(ITasksUiPreferenceConstants.GROUP_SUBTASKS, true);
870
		store.setDefault(ITasksUiPreferenceConstants.NOTIFICATIONS_ENABLED, true);
894
		store.setDefault(ITasksUiPreferenceConstants.NOTIFICATIONS_ENABLED, true);
895
		store.setDefault(ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED, true);
871
		store.setDefault(ITasksUiPreferenceConstants.FILTER_PRIORITY, PriorityLevel.P5.toString());
896
		store.setDefault(ITasksUiPreferenceConstants.FILTER_PRIORITY, PriorityLevel.P5.toString());
872
		store.setDefault(ITasksUiPreferenceConstants.EDITOR_TASKS_RICH, true);
897
		store.setDefault(ITasksUiPreferenceConstants.EDITOR_TASKS_RICH, true);
873
		store.setDefault(ITasksUiPreferenceConstants.EDITOR_CURRENT_LINE_HIGHLIGHT, false);
898
		store.setDefault(ITasksUiPreferenceConstants.EDITOR_CURRENT_LINE_HIGHLIGHT, false);
Lines 894-899 Link Here
894
919
895
		store.setDefault(ITasksUiPreferenceConstants.AUTO_EXPAND_TASK_LIST, true);
920
		store.setDefault(ITasksUiPreferenceConstants.AUTO_EXPAND_TASK_LIST, true);
896
		store.setDefault(ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED, true);
921
		store.setDefault(ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED, true);
922
923
		store.setDefault(ITasksUiPreferenceConstants.SERVICE_MESSAGE_URL, "http://eclipse.org/mylyn/message.xml"); //$NON-NLS-1$
897
	}
924
	}
898
925
899
	public static TaskActivityManager getTaskActivityManager() {
926
	public static TaskActivityManager getTaskActivityManager() {
Lines 1306-1309 Link Here
1306
		}
1333
		}
1307
	}
1334
	}
1308
1335
1336
	public ServiceMessageManager getServiceMessageManager() {
1337
		return serviceMessageManager;
1338
	}
1339
1309
}
1340
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java (-1 / +22 lines)
Lines 86-91 Link Here
86
import org.eclipse.mylyn.internal.tasks.ui.actions.TaskListSortAction;
86
import org.eclipse.mylyn.internal.tasks.ui.actions.TaskListSortAction;
87
import org.eclipse.mylyn.internal.tasks.ui.actions.TaskListViewActionGroup;
87
import org.eclipse.mylyn.internal.tasks.ui.actions.TaskListViewActionGroup;
88
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskListChangeAdapter;
88
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskListChangeAdapter;
89
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListServiceMessageControl;
89
import org.eclipse.mylyn.internal.tasks.ui.util.PlatformUtil;
90
import org.eclipse.mylyn.internal.tasks.ui.util.PlatformUtil;
90
import org.eclipse.mylyn.internal.tasks.ui.util.SortCriterion;
91
import org.eclipse.mylyn.internal.tasks.ui.util.SortCriterion;
91
import org.eclipse.mylyn.internal.tasks.ui.util.TaskDragSourceListener;
92
import org.eclipse.mylyn.internal.tasks.ui.util.TaskDragSourceListener;
Lines 131-136 Link Here
131
import org.eclipse.swt.graphics.Image;
132
import org.eclipse.swt.graphics.Image;
132
import org.eclipse.swt.graphics.Point;
133
import org.eclipse.swt.graphics.Point;
133
import org.eclipse.swt.graphics.Rectangle;
134
import org.eclipse.swt.graphics.Rectangle;
135
import org.eclipse.swt.layout.GridLayout;
134
import org.eclipse.swt.widgets.Composite;
136
import org.eclipse.swt.widgets.Composite;
135
import org.eclipse.swt.widgets.Menu;
137
import org.eclipse.swt.widgets.Menu;
136
import org.eclipse.swt.widgets.Text;
138
import org.eclipse.swt.widgets.Text;
Lines 390-395 Link Here
390
392
391
	private CustomTaskListDecorationDrawer customDrawer;
393
	private CustomTaskListDecorationDrawer customDrawer;
392
394
395
	private TaskListServiceMessageControl serviceMessageControl;
396
393
	private final IPageListener PAGE_LISTENER = new IPageListener() {
397
	private final IPageListener PAGE_LISTENER = new IPageListener() {
394
		public void pageActivated(IWorkbenchPage page) {
398
		public void pageActivated(IWorkbenchPage page) {
395
			filteredTree.indicateActiveTaskWorkingSet();
399
			filteredTree.indicateActiveTaskWorkingSet();
Lines 730-735 Link Here
730
734
731
	@Override
735
	@Override
732
	public void createPartControl(Composite parent) {
736
	public void createPartControl(Composite parent) {
737
738
		Composite body = new Composite(parent, SWT.NONE);
739
		GridLayout layout = new GridLayout(1, false);
740
		layout.marginHeight = 0;
741
		layout.marginWidth = 0;
742
		layout.horizontalSpacing = 0;
743
		layout.verticalSpacing = 0;
744
		layout.numColumns = 1;
745
		body.setLayout(layout);
746
733
		IWorkbenchSiteProgressService progress = (IWorkbenchSiteProgressService) getSite().getAdapter(
747
		IWorkbenchSiteProgressService progress = (IWorkbenchSiteProgressService) getSite().getAdapter(
734
				IWorkbenchSiteProgressService.class);
748
				IWorkbenchSiteProgressService.class);
735
		if (progress != null) {
749
		if (progress != null) {
Lines 743-749 Link Here
743
		themeManager = getSite().getWorkbenchWindow().getWorkbench().getThemeManager();
757
		themeManager = getSite().getWorkbenchWindow().getWorkbench().getThemeManager();
744
		themeManager.addPropertyChangeListener(THEME_CHANGE_LISTENER);
758
		themeManager.addPropertyChangeListener(THEME_CHANGE_LISTENER);
745
759
746
		filteredTree = new TaskListFilteredTree(parent, SWT.MULTI | SWT.VERTICAL | /* SWT.H_SCROLL | */SWT.V_SCROLL
760
		filteredTree = new TaskListFilteredTree(body, SWT.MULTI | SWT.VERTICAL | /* SWT.H_SCROLL | */SWT.V_SCROLL
747
				| SWT.NO_SCROLL | SWT.FULL_SELECTION, new SubstringPatternFilter(), getViewSite().getWorkbenchWindow());
761
				| SWT.NO_SCROLL | SWT.FULL_SELECTION, new SubstringPatternFilter(), getViewSite().getWorkbenchWindow());
748
762
749
		// need to do initialize tooltip early for native tooltip disablement to take effect
763
		// need to do initialize tooltip early for native tooltip disablement to take effect
Lines 922-927 Link Here
922
		TasksUiInternal.getTaskList().addChangeListener(TASKLIST_CHANGE_LISTENER);
936
		TasksUiInternal.getTaskList().addChangeListener(TASKLIST_CHANGE_LISTENER);
923
937
924
		TasksUiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(tasksUiPreferenceListener);
938
		TasksUiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(tasksUiPreferenceListener);
939
		serviceMessageControl = new TaskListServiceMessageControl(body);
940
		serviceMessageControl.setServiceMessage(TasksUiPlugin.getDefault()
941
				.getServiceMessageManager()
942
				.getServiceMessage());
943
		TasksUiPlugin.getDefault().getServiceMessageManager().addServiceMessageListener(serviceMessageControl);
925
944
926
		// Need to do this because the page, which holds the active working set is not around on creation, see bug 203179
945
		// Need to do this because the page, which holds the active working set is not around on creation, see bug 203179
927
		PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPageListener(PAGE_LISTENER);
946
		PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPageListener(PAGE_LISTENER);
Lines 1263-1268 Link Here
1263
	}
1282
	}
1264
1283
1265
	public void goIntoCategory() {
1284
	public void goIntoCategory() {
1285
		serviceMessageControl.setHidden(true);
1266
		ISelection selection = getViewer().getSelection();
1286
		ISelection selection = getViewer().getSelection();
1267
		if (selection instanceof StructuredSelection) {
1287
		if (selection instanceof StructuredSelection) {
1268
			StructuredSelection structuredSelection = (StructuredSelection) selection;
1288
			StructuredSelection structuredSelection = (StructuredSelection) selection;
Lines 1280-1285 Link Here
1280
	}
1300
	}
1281
1301
1282
	public void goUpToRoot() {
1302
	public void goUpToRoot() {
1303
		serviceMessageControl.setHidden(false);
1283
		drilledIntoCategory = null;
1304
		drilledIntoCategory = null;
1284
		drillDownAdapter.goBack();
1305
		drillDownAdapter.goBack();
1285
		IActionBars bars = getViewSite().getActionBars();
1306
		IActionBars bars = getViewSite().getActionBars();
(-)src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListServiceMessageControl.java (+247 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Tasktop Technologies 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
 * Contributors:
9
 *     Tasktop Technologies - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.tasks.ui.notifications;
13
14
import org.eclipse.jface.dialogs.Dialog;
15
import org.eclipse.jface.layout.GridDataFactory;
16
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
17
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonThemes;
18
import org.eclipse.mylyn.internal.provisional.commons.ui.GradientCanvas;
19
import org.eclipse.mylyn.internal.tasks.core.servicemessage.IServiceMessageListener;
20
import org.eclipse.mylyn.internal.tasks.core.servicemessage.ServiceMessage;
21
import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
22
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
23
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.events.DisposeEvent;
26
import org.eclipse.swt.events.DisposeListener;
27
import org.eclipse.swt.graphics.Color;
28
import org.eclipse.swt.graphics.Font;
29
import org.eclipse.swt.graphics.FontData;
30
import org.eclipse.swt.graphics.Image;
31
import org.eclipse.swt.layout.GridData;
32
import org.eclipse.swt.layout.GridLayout;
33
import org.eclipse.swt.widgets.Composite;
34
import org.eclipse.swt.widgets.Control;
35
import org.eclipse.swt.widgets.Display;
36
import org.eclipse.swt.widgets.Label;
37
import org.eclipse.ui.PlatformUI;
38
import org.eclipse.ui.forms.FormColors;
39
import org.eclipse.ui.forms.IFormColors;
40
import org.eclipse.ui.forms.events.HyperlinkAdapter;
41
import org.eclipse.ui.forms.events.HyperlinkEvent;
42
import org.eclipse.ui.forms.events.IHyperlinkListener;
43
import org.eclipse.ui.forms.widgets.Hyperlink;
44
import org.eclipse.ui.forms.widgets.ImageHyperlink;
45
46
/**
47
 * @author Robert Elves
48
 */
49
public class TaskListServiceMessageControl implements IServiceMessageListener {
50
51
	private ImageHyperlink imageHyperlink;
52
53
	private Hyperlink titleHyperlink;
54
55
	private Label descriptionLabel;
56
57
	private GridData headData;
58
59
	private final Composite parent;
60
61
	private GradientCanvas head;
62
63
	private ImageHyperlink closeLink;
64
65
	private ServiceMessage currentMessage;
66
67
	private boolean constructed;
68
69
	private String messageUrl;
70
71
	public TaskListServiceMessageControl(Composite parent) {
72
		this.parent = parent;
73
		createControl(parent);
74
	}
75
76
	private void setTitleImage(Image image) {
77
		imageHyperlink.setImage(image);
78
	}
79
80
	private void setTitle(String title) {
81
		titleHyperlink.setText(title);
82
	}
83
84
	private void setDescription(String description) {
85
		descriptionLabel.setText(description);
86
	}
87
88
	private void addHyperlinkListener(IHyperlinkListener listener) {
89
		titleHyperlink.addHyperlinkListener(listener);
90
		imageHyperlink.addHyperlinkListener(listener);
91
	}
92
93
	protected void setMessageUrl(String url) {
94
		messageUrl = url;
95
	}
96
97
	public Control createControl(Composite parent) {
98
		FormColors colors = new FormColors(parent.getDisplay());
99
		head = new GradientCanvas(parent, SWT.NONE);
100
		GridLayout headLayout = new GridLayout();
101
		headLayout.marginHeight = 0;
102
		headLayout.marginWidth = 0;
103
		headLayout.horizontalSpacing = 0;
104
		headLayout.verticalSpacing = 0;
105
		headLayout.numColumns = 1;
106
		head.setLayout(headLayout);
107
		headData = new GridData(SWT.FILL, SWT.TOP, true, false);
108
		head.setLayoutData(headData);
109
		setHidden(true);
110
111
		Color top = colors.getColor(IFormColors.H_GRADIENT_END);
112
		Color bot = colors.getColor(IFormColors.H_GRADIENT_START);
113
		head.setBackgroundGradient(new Color[] { bot, top }, new int[] { 100 }, true);
114
		head.setSeparatorVisible(true);
115
		head.setSeparatorAlignment(SWT.TOP);
116
117
		head.putColor(IFormColors.H_BOTTOM_KEYLINE1, colors.getColor(IFormColors.H_BOTTOM_KEYLINE1));
118
		head.putColor(IFormColors.H_BOTTOM_KEYLINE2, colors.getColor(IFormColors.H_BOTTOM_KEYLINE2));
119
		head.putColor(IFormColors.H_HOVER_LIGHT, colors.getColor(IFormColors.H_HOVER_LIGHT));
120
		head.putColor(IFormColors.H_HOVER_FULL, colors.getColor(IFormColors.H_HOVER_FULL));
121
		head.putColor(IFormColors.TB_TOGGLE, colors.getColor(IFormColors.TB_TOGGLE));
122
		head.putColor(IFormColors.TB_TOGGLE_HOVER, colors.getColor(IFormColors.TB_TOGGLE_HOVER));
123
124
		Composite informationComp = new Composite(head, SWT.NONE);
125
		informationComp.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));//new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL));
126
		informationComp.setLayout(new GridLayout(3, false));
127
128
		imageHyperlink = new ImageHyperlink(informationComp, SWT.NONE);
129
130
		titleHyperlink = new Hyperlink(informationComp, SWT.WRAP);
131
		setHeaderFontSizeAndStyle(titleHyperlink);
132
133
		addHyperlinkListener(new HyperlinkAdapter() {
134
			@Override
135
			public void linkActivated(HyperlinkEvent e) {
136
				if (messageUrl != null) {
137
					TasksUiUtil.openUrl(messageUrl);
138
				}
139
140
			}
141
		});
142
143
		closeLink = new ImageHyperlink(informationComp, SWT.NONE);
144
		closeLink.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_CLOSE));
145
		GridDataFactory.fillDefaults().align(SWT.END, SWT.BEGINNING).applyTo(closeLink);
146
		closeLink.addHyperlinkListener(new HyperlinkAdapter() {
147
			@Override
148
			public void linkActivated(HyperlinkEvent e) {
149
				closeMessage();
150
151
			}
152
153
		});
154
155
		new Label(informationComp, SWT.NONE);
156
157
		descriptionLabel = new Label(informationComp, SWT.WRAP);
158
		GridDataFactory.swtDefaults().span(2, 1).applyTo(descriptionLabel);
159
		constructed = true;
160
		return head;
161
	}
162
163
	private void closeMessage() {
164
		if (currentMessage != null) {
165
			setHidden(true);
166
			TasksUiPlugin.getDefault().getPreferenceStore().setValue(
167
					ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ID, currentMessage.getId());
168
		}
169
	}
170
171
	public void setHidden(boolean hidden) {
172
		headData.exclude = hidden;
173
		if (constructed) {
174
			parent.layout(true);
175
		}
176
	}
177
178
	// From EditorUtil
179
	private static Font setHeaderFontSizeAndStyle(Control text) {
180
		float sizeFactor = 1.2f;
181
		Font initialFont = text.getFont();
182
		FontData[] fontData = initialFont.getFontData();
183
		for (FontData element : fontData) {
184
			element.setHeight((int) (element.getHeight() * sizeFactor));
185
			element.setStyle(element.getStyle() | SWT.BOLD);
186
		}
187
		final Font textFont = new Font(text.getDisplay(), fontData);
188
		text.setFont(textFont);
189
		text.addDisposeListener(new DisposeListener() {
190
			public void widgetDisposed(DisposeEvent e) {
191
				textFont.dispose();
192
			}
193
		});
194
		Color color = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().get(
195
				CommonThemes.COLOR_COMPLETED);
196
		text.setForeground(color);
197
		return textFont;
198
	}
199
200
	public void setServiceMessage(final ServiceMessage message) {
201
		if (message != null) {
202
			String lastMessageId = TasksUiPlugin.getDefault().getPreferenceStore().getString(
203
					ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ID);
204
			TasksUiPlugin.getDefault().getPreferenceStore().setValue(
205
					ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ETAG, message.getETag());
206
			TasksUiPlugin.getDefault().getPreferenceStore().setValue(
207
					ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_LAST_MODIFIED, message.getLastModified());
208
209
			boolean displayForCurrentMylynVersion = true;
210
211
			if (message.getMylynVersion() != null && !message.getMylynVersion().equals("")) { //$NON-NLS-1$
212
213
				MylynVersion version = new MylynVersion(message.getMylynVersion());
214
				String versionString = (String) TasksUiPlugin.getDefault().getBundle().getHeaders().get(
215
						"Bundle-Version"); //$NON-NLS-1$
216
				MylynVersion versionInstalled = new MylynVersion(versionString);
217
218
				displayForCurrentMylynVersion = (versionInstalled.compareTo(version) <= 0);
219
			}
220
221
			if (displayForCurrentMylynVersion && !lastMessageId.equals(message.getId())
222
					&& !message.getId().equals("-1")) { //$NON-NLS-1$
223
				currentMessage = message;
224
				Display.getDefault().asyncExec(new Runnable() {
225
226
					public void run() {
227
						if (!head.isDisposed()) {
228
							if (message != null) {
229
								setTitle(message.getTitle());
230
								setDescription(message.getDescription());
231
								setTitleImage(Dialog.getImage(message.getImage()));
232
								setHidden(false);
233
								setMessageUrl(message.getUrl());
234
							} else {
235
								setHidden(true);
236
							}
237
						}
238
239
					}
240
				});
241
			}
242
		} else {
243
			setHidden(true);
244
		}
245
	}
246
247
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/notifications/MylynVersion.java (+91 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 Eugene Kuleshov 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
 * Contributors:
9
 *     Eugene Kuleshov - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.tasks.ui.notifications;
13
14
/**
15
 * Mylyn version holder (derived from JiraVersion)
16
 * 
17
 * @author Eugene Kuleshov
18
 * @author Thomas Ehrnhoefer
19
 */
20
public class MylynVersion implements Comparable<MylynVersion> {
21
22
	private final int major;
23
24
	private final int minor;
25
26
	private final int micro;
27
28
	private final String qualifier;
29
30
	public MylynVersion(String version) {
31
		String[] segments = version == null ? new String[0] : version.split("\\."); //$NON-NLS-1$
32
		major = segments.length > 0 ? parse(segments[0]) : 0;
33
		minor = segments.length > 1 ? parse(segments[1]) : 0;
34
		micro = segments.length > 2 ? parse(segments[2]) : 0;
35
		if (segments.length <= 3) {
36
			qualifier = ""; //$NON-NLS-1$
37
		} else {
38
			qualifier = segments.length == 0 ? "" : segments[3]; //$NON-NLS-1$
39
		}
40
	}
41
42
	private int parse(String segment) {
43
		try {
44
			return segment.length() == 0 ? 0 : Integer.parseInt(segment);
45
		} catch (NumberFormatException e) {
46
			return 0;
47
		}
48
	}
49
50
	public boolean isSmallerOrEquals(MylynVersion v) {
51
		return compareTo(v) <= 0;
52
	}
53
54
	public int compareTo(MylynVersion v) {
55
		if (major < v.major) {
56
			return -1;
57
		} else if (major > v.major) {
58
			return 1;
59
		}
60
61
		if (minor < v.minor) {
62
			return -1;
63
		} else if (minor > v.minor) {
64
			return 1;
65
		}
66
67
		if (micro < v.micro) {
68
			return -1;
69
		} else if (micro > v.micro) {
70
			return 1;
71
		}
72
73
		// qualifier is not needed to compare with min version
74
		return qualifier.compareTo(v.qualifier);
75
	}
76
77
	@Override
78
	public String toString() {
79
		StringBuilder sb = new StringBuilder();
80
		sb.append(Integer.toString(major));
81
		sb.append(".").append(Integer.toString(minor)); //$NON-NLS-1$
82
		if (micro > 0) {
83
			sb.append(".").append(Integer.toString(micro)); //$NON-NLS-1$
84
		}
85
		if (qualifier.length() > 0) {
86
			sb.append(".").append(qualifier); //$NON-NLS-1$
87
		}
88
		return sb.toString();
89
	}
90
91
}

Return to bug 263528