Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 169603 Details for
Bug 263528
display a repository service message to warn users of problems, updates, and other relevant information
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
v3
clipboard.txt (text/plain), 56.11 KB, created by
Steffen Pingel
on 2010-05-22 22:45:53 EDT
(
hide
)
Description:
v3
Filename:
MIME Type:
Creator:
Steffen Pingel
Created:
2010-05-22 22:45:53 EDT
Size:
56.11 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.core >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF,v >retrieving revision 1.365 >diff -u -r1.365 MANIFEST.MF >--- META-INF/MANIFEST.MF 11 Apr 2010 19:49:55 -0000 1.365 >+++ META-INF/MANIFEST.MF 23 May 2010 02:45:21 -0000 >@@ -14,6 +14,7 @@ > org.eclipse.mylyn.internal.tasks.core;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs", > org.eclipse.mylyn.internal.tasks.core.data;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs", > org.eclipse.mylyn.internal.tasks.core.externalization;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs", >+ org.eclipse.mylyn.internal.tasks.core.notifications;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs", > org.eclipse.mylyn.internal.tasks.core.sync;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs", > org.eclipse.mylyn.tasks.core, > org.eclipse.mylyn.tasks.core.data, >Index: src/org/eclipse/mylyn/internal/tasks/core/notifications/IServiceMessageListener.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/core/notifications/IServiceMessageListener.java >diff -N src/org/eclipse/mylyn/internal/tasks/core/notifications/IServiceMessageListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/core/notifications/IServiceMessageListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 Tasktop Technologies and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tasktop Technologies - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.core.notifications; >+ >+/** >+ * @author Robert Elves >+ */ >+public interface IServiceMessageListener { >+ >+ public void messagesUpdated(ServiceMessageEvent event); >+ >+} >Index: src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessage.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessage.java >diff -N src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,107 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 Tasktop Technologies and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tasktop Technologies - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.core.notifications; >+ >+/** >+ * @author Robert Elves >+ */ >+public class ServiceMessage { >+ >+ public enum Element { >+ ID, TITLE, DESCRIPTION, URL, IMAGE, VERSION >+ }; >+ >+ private String id; >+ >+ private String title; >+ >+ private String description; >+ >+ private String url; >+ >+ private String image; >+ >+ private String version; >+ >+ private String eTag; >+ >+ private String lastModified; >+ >+ public String getId() { >+ return id; >+ } >+ >+ public String getTitle() { >+ return title; >+ } >+ >+ public String getDescription() { >+ return description; >+ } >+ >+ public String getUrl() { >+ return url; >+ } >+ >+ public String getImage() { >+ return image; >+ } >+ >+ public void setETag(String eTag) { >+ this.eTag = eTag; >+ } >+ >+ public void setLastModified(String lastModified) { >+ this.lastModified = lastModified; >+ } >+ >+ public String getETag() { >+ return eTag; >+ } >+ >+ public String getLastModified() { >+ return lastModified; >+ } >+ >+ public String getVersion() { >+ return version; >+ } >+ >+ public void setId(String id) { >+ this.id = id; >+ } >+ >+ public void setTitle(String title) { >+ this.title = title; >+ } >+ >+ public void setDescription(String description) { >+ this.description = description; >+ } >+ >+ public void setUrl(String url) { >+ this.url = url; >+ } >+ >+ public void setImage(String image) { >+ this.image = image; >+ } >+ >+ public void setVersion(String version) { >+ this.version = version; >+ } >+ >+ public boolean isValid() { >+ return id != null && title != null && description != null && image != null; >+ } >+ >+} >Index: src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessageEvent.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessageEvent.java >diff -N src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessageEvent.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessageEvent.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 Tasktop Technologies and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tasktop Technologies - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.core.notifications; >+ >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.EventObject; >+import java.util.List; >+ >+/** >+ * @author Steffen Pingel >+ */ >+public class ServiceMessageEvent extends EventObject { >+ >+ private static final long serialVersionUID = 1L; >+ >+ private final List<ServiceMessage> messages; >+ >+ public ServiceMessageEvent(ServiceMessageManager manager, List<ServiceMessage> messages) { >+ super(manager); >+ this.messages = Collections.unmodifiableList(new ArrayList<ServiceMessage>(messages)); >+ } >+ >+ public List<ServiceMessage> getMessages() { >+ return messages; >+ } >+ >+} >Index: src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessageManager.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessageManager.java >diff -N src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessageManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessageManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,208 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2008 Tasktop Technologies. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Tasktop EULA >+ * which accompanies this distribution, and is available at >+ * http://tasktop.com/legal >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.core.notifications; >+ >+import java.io.InputStream; >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.List; >+import java.util.concurrent.CopyOnWriteArrayList; >+ >+import javax.xml.parsers.SAXParser; >+import javax.xml.parsers.SAXParserFactory; >+ >+import org.apache.commons.httpclient.Header; >+import org.apache.commons.httpclient.HostConfiguration; >+import org.apache.commons.httpclient.HttpClient; >+import org.apache.commons.httpclient.HttpStatus; >+import org.apache.commons.httpclient.methods.GetMethod; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.ISafeRunnable; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.SafeRunner; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.core.runtime.jobs.IJobChangeEvent; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.core.runtime.jobs.JobChangeAdapter; >+import org.eclipse.mylyn.commons.core.StatusHandler; >+import org.eclipse.mylyn.commons.net.WebLocation; >+import org.eclipse.mylyn.commons.net.WebUtil; >+import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants; >+ >+/** >+ * @author Robert Elves >+ * @author Steffen Pingel >+ */ >+public class ServiceMessageManager { >+ >+ protected static final long START_DELAY = 30 * 1000; >+ >+ protected static final long RECHECK_DELAY = 2 * 60 * 60 * 1000; >+ >+ private String serviceMessageUrl; >+ >+ private volatile List<ServiceMessage> messages = Collections.emptyList(); >+ >+ private Job messageCheckJob; >+ >+ private final List<IServiceMessageListener> listeners = new CopyOnWriteArrayList<IServiceMessageListener>(); >+ >+ private String lastModified; >+ >+ private String eTag; >+ >+ private boolean statusLogged; >+ >+ public ServiceMessageManager(String serviceMessageUrl, String lastModified, String eTag) { >+ this.serviceMessageUrl = serviceMessageUrl; >+ this.lastModified = lastModified; >+ this.eTag = eTag; >+ } >+ >+ public void start() { >+ if (messageCheckJob == null) { >+ messageCheckJob = new Job("Checking for new service message") { //$NON-NLS-1$ >+ @Override >+ protected IStatus run(IProgressMonitor monitor) { >+ updateServiceMessage(monitor); >+ return Status.OK_STATUS; >+ } >+ >+ }; >+ messageCheckJob.setSystem(true); >+ messageCheckJob.setPriority(Job.DECORATE); >+ messageCheckJob.addJobChangeListener(new JobChangeAdapter() { >+ @Override >+ public void done(IJobChangeEvent event) { >+ if (messageCheckJob != null) { >+ messageCheckJob.schedule(RECHECK_DELAY); >+ } >+ } >+ }); >+ } >+ messageCheckJob.schedule(START_DELAY); >+ } >+ >+ public void stop() { >+ if (messageCheckJob != null) { >+ messageCheckJob.cancel(); >+ messageCheckJob = null; >+ } >+ } >+ >+ public void setServiceMessageUrl(String url) { >+ this.serviceMessageUrl = url; >+ } >+ >+ public void addServiceMessageListener(IServiceMessageListener listener) { >+ listeners.add(listener); >+ } >+ >+ public void removeServiceMessageListener(IServiceMessageListener listener) { >+ listeners.remove(listener); >+ } >+ >+ private void notifyListeners(List<ServiceMessage> messages) { >+ this.messages = messages; >+ for (final ServiceMessage message : messages) { >+ message.setETag(eTag); >+ message.setLastModified(lastModified); >+ } >+ >+ final ServiceMessageEvent event = new ServiceMessageEvent(this, messages); >+ for (final IServiceMessageListener listener : listeners) { >+ SafeRunner.run(new ISafeRunnable() { >+ public void run() throws Exception { >+ listener.messagesUpdated(event); >+ } >+ >+ public void handleException(Throwable e) { >+ StatusHandler.log(new Status(IStatus.WARNING, ITasksCoreConstants.ID_PLUGIN, "Listener failed: " //$NON-NLS-1$ >+ + listener.getClass(), e)); >+ } >+ }); >+ } >+ } >+ >+ public List<ServiceMessage> getServiceMessages() { >+ return new ArrayList<ServiceMessage>(this.messages); >+ } >+ >+ /** >+ * Public for testing >+ */ >+ public int updateServiceMessage(IProgressMonitor monitor) { >+ int status = -1; >+ List<ServiceMessage> messages = null; >+ try { >+ HttpClient httpClient = new HttpClient(WebUtil.getConnectionManager()); >+ WebUtil.configureHttpClient(httpClient, null); >+ >+ WebLocation location = new WebLocation(serviceMessageUrl); >+ HostConfiguration hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, >+ new SubProgressMonitor(monitor, 1)); >+ >+ GetMethod method = new GetMethod(serviceMessageUrl); >+ method.setRequestHeader("If-Modified-Since", lastModified); //$NON-NLS-1$ >+ method.setRequestHeader("If-None-Match", eTag); //$NON-NLS-1$ >+ >+ try { >+ status = WebUtil.execute(httpClient, hostConfiguration, method, monitor); >+ if (status == HttpStatus.SC_OK) { >+ Header lastModifiedHeader = method.getResponseHeader("Last-Modified"); //$NON-NLS-1$ >+ if (lastModifiedHeader != null) { >+ lastModified = lastModifiedHeader.getValue(); >+ } >+ Header eTagHeader = method.getResponseHeader("ETag"); //$NON-NLS-1$ >+ if (eTagHeader != null) { >+ eTag = eTagHeader.getValue(); >+ } >+ >+ InputStream in = WebUtil.getResponseBodyAsStream(method, monitor); >+ try { >+ SAXParserFactory factory = SAXParserFactory.newInstance(); >+ factory.setValidating(false); >+ SAXParser parser = factory.newSAXParser(); >+ >+ ServiceMessageXmlHandler handler = new ServiceMessageXmlHandler(); >+ parser.parse(in, handler); >+ messages = handler.getMessages(); >+ } finally { >+ in.close(); >+ } >+ } else if (status == HttpStatus.SC_NOT_FOUND) { >+ // no messages >+ } else if (status == HttpStatus.SC_NOT_MODIFIED) { >+ // no new messages >+ } else { >+ if (!statusLogged) { >+ statusLogged = true; >+ StatusHandler.log(new Status(IStatus.WARNING, ITasksCoreConstants.ID_PLUGIN, >+ "Http error retrieving service message: " + HttpStatus.getStatusText(status))); //$NON-NLS-1$ >+ } >+ } >+ } finally { >+ WebUtil.releaseConnection(method, monitor); >+ } >+ } catch (Exception e) { >+ if (!statusLogged) { >+ statusLogged = true; >+ StatusHandler.log(new Status(IStatus.WARNING, ITasksCoreConstants.ID_PLUGIN, >+ "Http error retrieving service message.", e)); //$NON-NLS-1$ >+ } >+ } >+ >+ if (messages != null && messages.size() > 0) { >+ notifyListeners(messages); >+ } >+ return status; >+ } >+ >+} >Index: src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessageXmlHandler.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessageXmlHandler.java >diff -N src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessageXmlHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/core/notifications/ServiceMessageXmlHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,92 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 Tasktop Technologies and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tasktop Technologies - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.core.notifications; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.xml.sax.Attributes; >+import org.xml.sax.SAXException; >+import org.xml.sax.helpers.DefaultHandler; >+ >+/** >+ * @author Robert Elves >+ * @author Steffen Pingel >+ */ >+public class ServiceMessageXmlHandler extends DefaultHandler { >+ >+ private static final String TAG_MESSAGE = "ServiceMessage"; //$NON-NLS-1$ >+ >+ private StringBuilder characters; >+ >+ private final List<ServiceMessage> messages = new ArrayList<ServiceMessage>(); >+ >+ private ServiceMessage message; >+ >+ @Override >+ public void characters(char[] ch, int start, int length) throws SAXException { >+ characters.append(ch, start, length); >+ } >+ >+ @Override >+ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { >+ if (TAG_MESSAGE.equals(qName.trim())) { >+ message = new ServiceMessage(); >+ } >+ characters = new StringBuilder(); >+ } >+ >+ @Override >+ public void endElement(String uri, String localName, String qName) throws SAXException { >+ if (message == null) { >+ return; >+ } >+ if (TAG_MESSAGE.equals(qName.trim())) { >+ if (message.isValid()) { >+ messages.add(message); >+ } >+ } else { >+ String parsedText = characters.toString(); >+ ServiceMessage.Element element; >+ try { >+ element = ServiceMessage.Element.valueOf(qName.trim().toUpperCase()); >+ switch (element) { >+ case ID: >+ message.setId(parsedText); >+ break; >+ case DESCRIPTION: >+ message.setDescription(parsedText); >+ break; >+ case TITLE: >+ message.setTitle(parsedText); >+ break; >+ case URL: >+ message.setUrl(parsedText); >+ break; >+ case IMAGE: >+ message.setImage(parsedText); >+ break; >+ case VERSION: >+ message.setVersion(parsedText); >+ break; >+ } >+ } catch (IllegalArgumentException e) { >+ // ignore unrecognized elements >+ } >+ } >+ } >+ >+ public List<ServiceMessage> getMessages() { >+ return new ArrayList<ServiceMessage>(messages); >+ } >+ >+} >#P org.eclipse.mylyn.tasks.tests >Index: src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java,v >retrieving revision 1.87 >diff -u -r1.87 AllTasksTests.java >--- src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java 4 Mar 2010 18:41:15 -0000 1.87 >+++ src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java 23 May 2010 02:45:22 -0000 >@@ -30,6 +30,7 @@ > import org.eclipse.mylyn.tasks.tests.ui.editor.RepositoryCompletionProcessorTest; > import org.eclipse.mylyn.tasks.tests.ui.editor.TaskEditorPartDescriptorTest; > import org.eclipse.mylyn.tasks.tests.ui.editor.TaskUrlHyperlinkDetectorTest; >+import org.eclipse.mylyn.tasks.tests.util.ServiceMessageManagerTest; > > /** > * @author Mik Kersten >@@ -102,6 +103,7 @@ > suite.addTestSuite(PlanningPartTest.class); > suite.addTestSuite(RepositoryCompletionProcessorTest.class); > suite.addTestSuite(TaskAttributeDiffTest.class); >+ suite.addTestSuite(ServiceMessageManagerTest.class); > // XXX long running tests, put back? > //suite.addTestSuite(QueryExportImportTest.class); > //suite.addTestSuite(BackgroundSaveTest.class); >Index: src/org/eclipse/mylyn/tasks/tests/util/ServiceMessageManagerTest.java >=================================================================== >RCS file: src/org/eclipse/mylyn/tasks/tests/util/ServiceMessageManagerTest.java >diff -N src/org/eclipse/mylyn/tasks/tests/util/ServiceMessageManagerTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/tasks/tests/util/ServiceMessageManagerTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,81 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 Tasktop Technologies and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tasktop Technologies - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.tasks.tests.util; >+ >+import java.io.ByteArrayInputStream; >+import java.io.InputStream; >+ >+import javax.xml.parsers.SAXParser; >+import javax.xml.parsers.SAXParserFactory; >+ >+import junit.framework.TestCase; >+ >+import org.apache.commons.httpclient.HttpStatus; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.mylyn.internal.tasks.core.notifications.ServiceMessage; >+import org.eclipse.mylyn.internal.tasks.core.notifications.ServiceMessageManager; >+import org.eclipse.mylyn.internal.tasks.core.notifications.ServiceMessageXmlHandler; >+ >+/** >+ * @author Robert Elves >+ */ >+public class ServiceMessageManagerTest extends TestCase { >+ >+ private static final String MESSAGE_XML_URL = "http://eclipse.org/mylyn/messageTest.xml"; >+ >+ public void testRetrievingMessage() throws Exception { >+ ServiceMessageManager manager = new ServiceMessageManager(MESSAGE_XML_URL, "", ""); >+ int status = manager.updateServiceMessage(new NullProgressMonitor()); >+ assertEquals(HttpStatus.SC_OK, status); >+ ServiceMessage message = manager.getServiceMessages().get(0); >+ >+ assertEquals("1", message.getId()); >+ assertEquals("140 character description here....", message.getDescription()); >+ assertEquals("Mylyn 3.4 now available!", message.getTitle()); >+ assertEquals("http://eclipse.org/mylyn/downloads", message.getUrl()); >+ assertEquals("Mylyn 3.4 now available!", message.getTitle()); >+ assertEquals("dialog_messasge_info_image", message.getImage()); >+ } >+ >+ public void testETag() throws Exception { >+ >+ ServiceMessageManager manager = new ServiceMessageManager(MESSAGE_XML_URL, "", ""); >+ int status = manager.updateServiceMessage(new NullProgressMonitor()); >+ assertEquals(HttpStatus.SC_OK, status); >+ ServiceMessage message = manager.getServiceMessages().get(0); >+ >+ assertNotNull(message.getLastModified()); >+ assertNotNull(message.getETag()); >+ >+ status = manager.updateServiceMessage(new NullProgressMonitor()); >+ assertEquals(HttpStatus.SC_NOT_MODIFIED, status); >+ } >+ >+ public void testParsingMessageXml() throws Exception { >+ 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>"; >+ InputStream is = new ByteArrayInputStream(messageXml.getBytes("UTF-8")); >+ SAXParserFactory factory = SAXParserFactory.newInstance(); >+ factory.setValidating(false); >+ SAXParser parser = factory.newSAXParser(); >+ ServiceMessageXmlHandler handler = new ServiceMessageXmlHandler(); >+ parser.parse(is, handler); >+ ServiceMessage message = handler.getMessages().get(0); >+ >+ assertEquals("1", message.getId()); >+ assertEquals("140 character description here....", message.getDescription()); >+ assertEquals("Mylyn 3.4 now available!", message.getTitle()); >+ assertEquals("http://eclipse.org/mylyn/downloads", message.getUrl()); >+ assertEquals("Mylyn 3.4 now available!", message.getTitle()); >+ assertEquals("dialog_messasge_info_image", message.getImage()); >+ } >+ >+} >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java,v >retrieving revision 1.12 >diff -u -r1.12 ITasksUiPreferenceConstants.java >--- src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java 15 Jan 2010 02:02:58 -0000 1.12 >+++ src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java 23 May 2010 02:45:23 -0000 >@@ -52,6 +52,8 @@ > > public static final String NOTIFICATIONS_ENABLED = "org.eclipse.mylyn.tasks.ui.notifications.enabled"; //$NON-NLS-1$ > >+ public static final String SERVICE_MESSAGES_ENABLED = "org.eclipse.mylyn.tasks.ui.messages.enabled"; //$NON-NLS-1$ >+ > public static final String WEEK_START_DAY = "org.eclipse.mylyn.tasks.ui.planning.week.start.day"; //$NON-NLS-1$ > > public static final String PLANNING_ENDHOUR = "org.eclipse.mylyn.tasks.ui.planning.end.hour"; //$NON-NLS-1$ >@@ -87,4 +89,12 @@ > public static final String PREF_DATA_DIR = "org.eclipse.mylyn.data.dir"; //$NON-NLS-1$ > > public static final String DEFAULT_ATTACHMENTS_DIRECTORY = "org.eclipse.mylyn.tasks.ui.attachments.defaultDirectory"; //$NON-NLS-1$ >+ >+ public static final String SERVICE_MESSAGE_URL = "org.eclipse.mylyn.tasks.ui.servicemessage.url"; //$NON-NLS-1$; >+ >+ public static final String LAST_SERVICE_MESSAGE_ID = "org.eclipse.mylyn.tasks.ui.servicemessage.id"; //$NON-NLS-1$ >+ >+ public static final String LAST_SERVICE_MESSAGE_ETAG = "org.eclipse.mylyn.tasks.ui.servicemessage.etag"; //$NON-NLS-1$ >+ >+ public static final String LAST_SERVICE_MESSAGE_LAST_MODIFIED = "org.eclipse.mylyn.tasks.ui.servicemessage.lastmodified"; //$NON-NLS-1$ > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java,v >retrieving revision 1.131 >diff -u -r1.131 TasksUiPlugin.java >--- src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java 5 Feb 2010 01:12:35 -0000 1.131 >+++ src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java 23 May 2010 02:45:23 -0000 >@@ -77,6 +77,7 @@ > import org.eclipse.mylyn.internal.tasks.core.externalization.IExternalizationParticipant; > import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizationParticipant; > import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizer; >+import org.eclipse.mylyn.internal.tasks.core.notifications.ServiceMessageManager; > import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListNotificationReminder; > import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListNotifier; > import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiExtensionReader; >@@ -149,6 +150,8 @@ > > private RepositoryTemplateManager repositoryTemplateManager; > >+ private ServiceMessageManager serviceMessageManager; >+ > private final Set<AbstractTaskEditorPageFactory> taskEditorPageFactories = new HashSet<AbstractTaskEditorPageFactory>(); > > private final TreeSet<AbstractTaskRepositoryLinkProvider> repositoryLinkProviders = new TreeSet<AbstractTaskRepositoryLinkProvider>( >@@ -343,6 +346,15 @@ > || event.getProperty().equals(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS)) { > updateSynchronizationScheduler(false); > } >+ >+ // TODO: ROB >+ if (event.getProperty().equals(ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED)) { >+ if (getPreferenceStore().getBoolean(ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED)) { >+ serviceMessageManager.start(); >+ } else { >+ serviceMessageManager.stop(); >+ } >+ } > } > }; > >@@ -605,6 +617,17 @@ > // make this available early for clients that are not initialized through tasks ui but need access > taskListNotificationManager = new TaskListNotificationManager(); > >+ String lastMod = getPreferenceStore().getString( >+ ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_LAST_MODIFIED); >+ String etag = getPreferenceStore().getString(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ETAG); >+ >+ serviceMessageManager = new ServiceMessageManager(getPreferenceStore().getString( >+ ITasksUiPreferenceConstants.SERVICE_MESSAGE_URL), lastMod, etag); >+ >+ if (getPreferenceStore().getBoolean(ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED)) { >+ serviceMessageManager.start(); >+ } >+ > // trigger lazy initialization > new TasksUiInitializationJob().schedule(); > } catch (Exception e) { >@@ -727,6 +750,7 @@ > // ContextCorePlugin.getDefault().getPluginPreferences().removePropertyChangeListener( > // PREFERENCE_LISTENER); > // } >+ serviceMessageManager.stop(); > taskEditorBloatManager.dispose(PlatformUI.getWorkbench()); > INSTANCE = null; > } >@@ -868,6 +892,7 @@ > store.setDefault(ITasksUiPreferenceConstants.PREF_DATA_DIR, getDefaultDataDirectory()); > store.setDefault(ITasksUiPreferenceConstants.GROUP_SUBTASKS, true); > store.setDefault(ITasksUiPreferenceConstants.NOTIFICATIONS_ENABLED, true); >+ store.setDefault(ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED, true); > store.setDefault(ITasksUiPreferenceConstants.FILTER_PRIORITY, PriorityLevel.P5.toString()); > store.setDefault(ITasksUiPreferenceConstants.EDITOR_TASKS_RICH, true); > store.setDefault(ITasksUiPreferenceConstants.EDITOR_CURRENT_LINE_HIGHLIGHT, false); >@@ -894,6 +919,8 @@ > > store.setDefault(ITasksUiPreferenceConstants.AUTO_EXPAND_TASK_LIST, true); > store.setDefault(ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED, true); >+ >+ store.setDefault(ITasksUiPreferenceConstants.SERVICE_MESSAGE_URL, "http://eclipse.org/mylyn/message.xml"); //$NON-NLS-1$ > } > > public static TaskActivityManager getTaskActivityManager() { >@@ -1306,4 +1333,8 @@ > } > } > >+ public ServiceMessageManager getServiceMessageManager() { >+ return serviceMessageManager; >+ } >+ > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListServiceMessageControl.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListServiceMessageControl.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListServiceMessageControl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListServiceMessageControl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,281 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 Tasktop Technologies and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tasktop Technologies - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.notifications; >+ >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages; >+import org.eclipse.mylyn.internal.provisional.commons.ui.CommonThemes; >+import org.eclipse.mylyn.internal.provisional.commons.ui.GradientCanvas; >+import org.eclipse.mylyn.internal.tasks.core.notifications.IServiceMessageListener; >+import org.eclipse.mylyn.internal.tasks.core.notifications.ServiceMessage; >+import org.eclipse.mylyn.internal.tasks.core.notifications.ServiceMessageEvent; >+import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants; >+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; >+import org.eclipse.mylyn.tasks.ui.TasksUiUtil; >+import org.eclipse.osgi.service.resolver.VersionRange; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.DisposeEvent; >+import org.eclipse.swt.events.DisposeListener; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.FontData; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.forms.FormColors; >+import org.eclipse.ui.forms.IFormColors; >+import org.eclipse.ui.forms.events.HyperlinkAdapter; >+import org.eclipse.ui.forms.events.HyperlinkEvent; >+import org.eclipse.ui.forms.events.IHyperlinkListener; >+import org.eclipse.ui.forms.widgets.Hyperlink; >+import org.eclipse.ui.forms.widgets.ImageHyperlink; >+import org.eclipse.ui.forms.widgets.TableWrapData; >+import org.eclipse.ui.forms.widgets.TableWrapLayout; >+import org.osgi.framework.Version; >+ >+/** >+ * @author Robert Elves >+ * @author Steffen Pingel >+ */ >+public class TaskListServiceMessageControl implements IServiceMessageListener { >+ >+ private ImageHyperlink imageHyperlink; >+ >+ private Hyperlink titleHyperlink; >+ >+ private Label descriptionLabel; >+ >+ private GridData headData; >+ >+ private final Composite parent; >+ >+ private GradientCanvas head; >+ >+ private ImageHyperlink closeLink; >+ >+ private ServiceMessage currentMessage; >+ >+ private boolean constructed; >+ >+ private String messageUrl; >+ >+ public TaskListServiceMessageControl(Composite parent) { >+ this.parent = parent; >+ createControl(parent); >+ } >+ >+ private void setTitleImage(Image image) { >+ imageHyperlink.setImage(image); >+ } >+ >+ private void setTitle(String title) { >+ titleHyperlink.setText(title); >+ } >+ >+ private void setDescription(String description) { >+ descriptionLabel.setText(description); >+ } >+ >+ private void addHyperlinkListener(IHyperlinkListener listener) { >+ titleHyperlink.addHyperlinkListener(listener); >+ imageHyperlink.addHyperlinkListener(listener); >+ } >+ >+ protected void setMessageUrl(String url) { >+ messageUrl = url; >+ } >+ >+ public Control createControl(Composite parent) { >+ FormColors colors = TasksUiPlugin.getDefault().getFormColors(parent.getDisplay()); >+ head = new GradientCanvas(parent, SWT.NONE); >+ GridLayout headLayout = new GridLayout(); >+ headLayout.marginHeight = 0; >+ headLayout.marginWidth = 0; >+ headLayout.horizontalSpacing = 0; >+ headLayout.verticalSpacing = 0; >+ headLayout.numColumns = 1; >+ head.setLayout(headLayout); >+ headData = new GridData(SWT.FILL, SWT.TOP, true, false); >+ head.setLayoutData(headData); >+ setHidden(true); >+ >+ Color top = colors.getColor(IFormColors.H_GRADIENT_END); >+ Color bot = colors.getColor(IFormColors.H_GRADIENT_START); >+ head.setBackgroundGradient(new Color[] { bot, top }, new int[] { 100 }, true); >+ head.setSeparatorVisible(true); >+ head.setSeparatorAlignment(SWT.TOP); >+ >+ head.putColor(IFormColors.H_BOTTOM_KEYLINE1, colors.getColor(IFormColors.H_BOTTOM_KEYLINE1)); >+ head.putColor(IFormColors.H_BOTTOM_KEYLINE2, colors.getColor(IFormColors.H_BOTTOM_KEYLINE2)); >+ head.putColor(IFormColors.H_HOVER_LIGHT, colors.getColor(IFormColors.H_HOVER_LIGHT)); >+ head.putColor(IFormColors.H_HOVER_FULL, colors.getColor(IFormColors.H_HOVER_FULL)); >+ head.putColor(IFormColors.TB_TOGGLE, colors.getColor(IFormColors.TB_TOGGLE)); >+ head.putColor(IFormColors.TB_TOGGLE_HOVER, colors.getColor(IFormColors.TB_TOGGLE_HOVER)); >+ >+ Composite informationComp = new Composite(head, SWT.NONE); >+ informationComp.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));//new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL)); >+ TableWrapLayout layout = new TableWrapLayout(); >+ layout.numColumns = 3; >+ informationComp.setLayout(layout); >+ >+ imageHyperlink = new ImageHyperlink(informationComp, SWT.NONE); >+ >+ titleHyperlink = new Hyperlink(informationComp, SWT.WRAP); >+ setHeaderFontSizeAndStyle(titleHyperlink); >+ >+ addHyperlinkListener(new HyperlinkAdapter() { >+ @Override >+ public void linkActivated(HyperlinkEvent e) { >+ if (messageUrl != null) { >+ TasksUiUtil.openUrl(messageUrl); >+ } >+ >+ } >+ }); >+ >+ closeLink = new ImageHyperlink(informationComp, SWT.NONE); >+ closeLink.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_CLOSE)); >+ TableWrapData data = new TableWrapData(); >+ data.align = TableWrapData.RIGHT; >+ closeLink.setLayoutData(data); >+ //GridDataFactory.fillDefaults().align(SWT.END, SWT.BEGINNING).applyTo(closeLink); >+ closeLink.addHyperlinkListener(new HyperlinkAdapter() { >+ @Override >+ public void linkActivated(HyperlinkEvent e) { >+ closeMessage(); >+ } >+ >+ @Override >+ public void linkEntered(HyperlinkEvent e) { >+ closeLink.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_CLOSE_HOVER)); >+ } >+ >+ @Override >+ public void linkExited(HyperlinkEvent e) { >+ closeLink.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_CLOSE)); >+ } >+ }); >+ >+ // spacer >+ new Label(informationComp, SWT.NONE).setText(" "); //$NON-NLS-1$ >+ >+ descriptionLabel = new Label(informationComp, SWT.WRAP); >+ //GridDataFactory.swtDefaults().span(2, 1).applyTo(descriptionLabel); >+ data = new TableWrapData(); >+ data.colspan = 2; >+ descriptionLabel.setLayoutData(data); >+ constructed = true; >+ return head; >+ } >+ >+ private void closeMessage() { >+ if (currentMessage != null) { >+ setHidden(true); >+ TasksUiPlugin.getDefault() >+ .getPreferenceStore() >+ .setValue(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ID, currentMessage.getId()); >+ } >+ } >+ >+ public void setHidden(boolean hidden) { >+ headData.exclude = hidden; >+ if (constructed) { >+ parent.layout(true); >+ } >+ } >+ >+ // From EditorUtil >+ private static Font setHeaderFontSizeAndStyle(Control text) { >+ float sizeFactor = 1.2f; >+ Font initialFont = text.getFont(); >+ FontData[] fontData = initialFont.getFontData(); >+ for (FontData element : fontData) { >+ element.setHeight((int) (element.getHeight() * sizeFactor)); >+ element.setStyle(element.getStyle() | SWT.BOLD); >+ } >+ final Font textFont = new Font(text.getDisplay(), fontData); >+ text.setFont(textFont); >+ text.addDisposeListener(new DisposeListener() { >+ public void widgetDisposed(DisposeEvent e) { >+ textFont.dispose(); >+ } >+ }); >+ Color color = PlatformUI.getWorkbench() >+ .getThemeManager() >+ .getCurrentTheme() >+ .getColorRegistry() >+ .get(CommonThemes.COLOR_COMPLETED); >+ text.setForeground(color); >+ return textFont; >+ } >+ >+ public void messagesUpdated(final ServiceMessageEvent event) { >+ IPreferenceStore preferenceStore = TasksUiPlugin.getDefault().getPreferenceStore(); >+ String lastMessageId = preferenceStore.getString(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ID); >+ for (final ServiceMessage message : event.getMessages()) { >+ if (!message.isValid() || message.getId().equals("-1")) { //$NON-NLS-1$ >+ continue; >+ } >+ >+ if (!lastMessageId.equals(message.getId()) && isForCurrentVersion(message)) { >+ Display.getDefault().asyncExec(new Runnable() { >+ public void run() { >+ if (!head.isDisposed()) { >+ setMessage(message); >+ } >+ } >+ }); >+ } >+ } >+ } >+ >+ private boolean isForCurrentVersion(ServiceMessage message) { >+ if (message.getVersion() == null) { >+ return true; >+ } >+ >+ try { >+ VersionRange version = new VersionRange(message.getVersion()); >+ String versionString = (String) TasksUiPlugin.getDefault().getBundle().getHeaders().get("Bundle-Version"); //$NON-NLS-1$ >+ return version.isIncluded(new Version(versionString)); >+ } catch (IllegalArgumentException e) { >+ // invalid version range >+ return false; >+ } >+ } >+ >+ protected void setMessage(ServiceMessage message) { >+ if (message != null) { >+ IPreferenceStore preferenceStore = TasksUiPlugin.getDefault().getPreferenceStore(); >+ preferenceStore.setValue(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ETAG, message.getETag()); >+ preferenceStore.setValue(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_LAST_MODIFIED, >+ message.getLastModified()); >+ this.currentMessage = message; >+ >+ setTitle(message.getTitle()); >+ setDescription(message.getDescription()); >+ setTitleImage(Dialog.getImage(message.getImage())); >+ setMessageUrl(message.getUrl()); >+ setHidden(false); >+ } else { >+ this.currentMessage = null; >+ setHidden(true); >+ } >+ } >+ >+} >Index: src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java,v >retrieving revision 1.6 >diff -u -r1.6 Messages.java >--- src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java 3 Apr 2010 06:10:03 -0000 1.6 >+++ src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java 23 May 2010 02:45:23 -0000 >@@ -63,6 +63,8 @@ > > public static String TasksUiPreferencePage_See_X_for_configuring_Task_List_colors; > >+ public static String TasksUiPreferencePage_show_service_messages; >+ > public static String TasksUiPreferencePage_Show_tooltip_on_hover_Label; > > public static String TasksUiPreferencePage_Specify_the_folder_for_tasks; >Index: src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java,v >retrieving revision 1.41 >diff -u -r1.41 TasksUiPreferencePage.java >--- src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java 26 Feb 2010 04:07:20 -0000 1.41 >+++ src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java 23 May 2010 02:45:23 -0000 >@@ -109,6 +109,8 @@ > > private Button taskListTooltipEnabledButton; > >+ private Button taskListServiceMessageEnabledButton; >+ > public TasksUiPreferencePage() { > super(); > setPreferenceStore(TasksUiPlugin.getDefault().getPreferenceStore()); >@@ -208,16 +210,22 @@ > getPreferenceStore().setValue(ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED, > taskListTooltipEnabledButton.getSelection()); > >+ getPreferenceStore().setValue(ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED, >+ taskListServiceMessageEnabledButton.getSelection()); >+ > getPreferenceStore().setValue(ITasksUiPreferenceConstants.WEEK_START_DAY, getWeekStartValue()); > //getPreferenceStore().setValue(TasksUiPreferenceConstants.PLANNING_STARTHOUR, hourDayStart.getSelection()); > // getPreferenceStore().setValue(TasksUiPreferenceConstants.PLANNING_ENDHOUR, hourDayEnd.getSelection()); >- MonitorUiPlugin.getDefault().getPreferenceStore().setValue(ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED, >- timeoutEnabledButton.getSelection()); >- MonitorUiPlugin.getDefault().getPreferenceStore().setValue(ActivityContextManager.ACTIVITY_TIMEOUT, >- timeoutMinutes.getSelection() * (60 * 1000)); >- >- MonitorUiPlugin.getDefault().getPreferenceStore().setValue(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED, >- activityTrackingEnabledButton.getSelection()); >+ MonitorUiPlugin.getDefault() >+ .getPreferenceStore() >+ .setValue(ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED, timeoutEnabledButton.getSelection()); >+ MonitorUiPlugin.getDefault() >+ .getPreferenceStore() >+ .setValue(ActivityContextManager.ACTIVITY_TIMEOUT, timeoutMinutes.getSelection() * (60 * 1000)); >+ >+ MonitorUiPlugin.getDefault() >+ .getPreferenceStore() >+ .setValue(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED, activityTrackingEnabledButton.getSelection()); > > String taskDirectory = taskDirectoryText.getText(); > taskDirectory = taskDirectory.replaceAll(BACKSLASH_MULTI, FORWARDSLASH); >@@ -276,6 +284,9 @@ > taskListTooltipEnabledButton.setSelection(getPreferenceStore().getBoolean( > ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED)); > >+ taskListServiceMessageEnabledButton.setSelection(getPreferenceStore().getBoolean( >+ ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED)); >+ > weekStartCombo.select(getPreferenceStore().getInt(ITasksUiPreferenceConstants.WEEK_START_DAY) - 1); > //hourDayStart.setSelection(getPreferenceStore().getInt(TasksUiPreferenceConstants.PLANNING_STARTHOUR)); > // hourDayEnd.setSelection(getPreferenceStore().getInt(TasksUiPreferenceConstants.PLANNING_ENDHOUR)); >@@ -283,11 +294,13 @@ > int minutes = MonitorUiPlugin.getDefault().getPreferenceStore().getInt(ActivityContextManager.ACTIVITY_TIMEOUT) > / MS_MINUTES; > timeoutMinutes.setSelection(minutes); >- timeoutEnabledButton.setSelection(MonitorUiPlugin.getDefault().getPreferenceStore().getBoolean( >- ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED)); >- >- activityTrackingEnabledButton.setSelection(MonitorUiPlugin.getDefault().getPreferenceStore().getBoolean( >- MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED)); >+ timeoutEnabledButton.setSelection(MonitorUiPlugin.getDefault() >+ .getPreferenceStore() >+ .getBoolean(ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED)); >+ >+ activityTrackingEnabledButton.setSelection(MonitorUiPlugin.getDefault() >+ .getPreferenceStore() >+ .getBoolean(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED)); > > return true; > } >@@ -310,6 +323,9 @@ > taskListTooltipEnabledButton.setSelection(getPreferenceStore().getDefaultBoolean( > ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED)); > >+ taskListServiceMessageEnabledButton.setSelection(getPreferenceStore().getDefaultBoolean( >+ ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED)); >+ > // synchQueries.setSelection(getPreferenceStore().getDefaultBoolean( > // TaskListPreferenceConstants.REPOSITORY_SYNCH_ON_STARTUP)); > enableBackgroundSynch.setSelection(getPreferenceStore().getDefaultBoolean( >@@ -322,15 +338,18 @@ > weekStartCombo.select(getPreferenceStore().getDefaultInt(ITasksUiPreferenceConstants.WEEK_START_DAY) - 1); > // hourDayStart.setSelection(getPreferenceStore().getDefaultInt(TasksUiPreferenceConstants.PLANNING_STARTHOUR)); > // hourDayEnd.setSelection(getPreferenceStore().getDefaultInt(TasksUiPreferenceConstants.PLANNING_ENDHOUR)); >- int activityTimeoutMinutes = MonitorUiPlugin.getDefault().getPreferenceStore().getDefaultInt( >- ActivityContextManager.ACTIVITY_TIMEOUT) >+ int activityTimeoutMinutes = MonitorUiPlugin.getDefault() >+ .getPreferenceStore() >+ .getDefaultInt(ActivityContextManager.ACTIVITY_TIMEOUT) > / MS_MINUTES; > timeoutMinutes.setSelection(activityTimeoutMinutes); >- timeoutEnabledButton.setSelection(MonitorUiPlugin.getDefault().getPreferenceStore().getDefaultBoolean( >- ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED)); >- >- activityTrackingEnabledButton.setSelection(MonitorUiPlugin.getDefault().getPreferenceStore().getDefaultBoolean( >- MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED)); >+ timeoutEnabledButton.setSelection(MonitorUiPlugin.getDefault() >+ .getPreferenceStore() >+ .getDefaultBoolean(ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED)); >+ >+ activityTrackingEnabledButton.setSelection(MonitorUiPlugin.getDefault() >+ .getPreferenceStore() >+ .getDefaultBoolean(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED)); > > updateRefreshGroupEnablements(); > } >@@ -480,6 +499,11 @@ > taskListTooltipEnabledButton.setText(Messages.TasksUiPreferencePage_Show_tooltip_on_hover_Label); > taskListTooltipEnabledButton.setSelection(getPreferenceStore().getBoolean( > ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED)); >+ >+ taskListServiceMessageEnabledButton = new Button(group, SWT.CHECK); >+ taskListServiceMessageEnabledButton.setText(Messages.TasksUiPreferencePage_show_service_messages); >+ taskListServiceMessageEnabledButton.setSelection(getPreferenceStore().getBoolean( >+ ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED)); > } > > private void createTaskActivityGroup(Composite container) { >@@ -488,11 +512,13 @@ > group.setLayout(new GridLayout(3, false)); > group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); > >- boolean activityTrackingEnabled = MonitorUiPlugin.getDefault().getPreferenceStore().getBoolean( >- MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED); >- >- boolean timeoutEnabled = MonitorUiPlugin.getDefault().getPreferenceStore().getBoolean( >- ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED); >+ boolean activityTrackingEnabled = MonitorUiPlugin.getDefault() >+ .getPreferenceStore() >+ .getBoolean(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED); >+ >+ boolean timeoutEnabled = MonitorUiPlugin.getDefault() >+ .getPreferenceStore() >+ .getBoolean(ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED); > > activityTrackingEnabledButton = new Button(group, SWT.CHECK); > activityTrackingEnabledButton.setText(Messages.TasksUiPreferencePage_Enable_Time_Tracking); >@@ -525,8 +551,9 @@ > timeoutMinutes.setIncrement(5); > timeoutMinutes.setMaximum(60); > timeoutMinutes.setMinimum(1); >- long minutes = MonitorUiPlugin.getDefault().getPreferenceStore().getLong( >- ActivityContextManager.ACTIVITY_TIMEOUT) >+ long minutes = MonitorUiPlugin.getDefault() >+ .getPreferenceStore() >+ .getLong(ActivityContextManager.ACTIVITY_TIMEOUT) > / MS_MINUTES; > timeoutMinutes.setSelection((int) minutes); > timeoutMinutes.addSelectionListener(new SelectionAdapter() { >Index: src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties,v >retrieving revision 1.10 >diff -u -r1.10 messages.properties >--- src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties 3 Apr 2010 06:10:03 -0000 1.10 >+++ src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties 23 May 2010 02:45:23 -0000 >@@ -27,6 +27,7 @@ > TasksUiPreferencePage_Rich_Editor__Recommended_=Rich Editor (Recommended) > TasksUiPreferencePage_Scheduling=Scheduling > TasksUiPreferencePage_See_X_for_configuring_Task_List_colors=See <a>''{0}''</a> for configuring Task List colors. >+TasksUiPreferencePage_show_service_messages=Show service messages > TasksUiPreferencePage_Show_tooltip_on_hover_Label=Show task overview popups on hover > TasksUiPreferencePage_Specify_the_folder_for_tasks=Specify the folder for tasks > TasksUiPreferencePage_Stop_time_accumulation_after=Stop time accumulation after >Index: src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java,v >retrieving revision 1.338 >diff -u -r1.338 TaskListView.java >--- src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java 26 Apr 2010 17:37:32 -0000 1.338 >+++ src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java 23 May 2010 02:45:23 -0000 >@@ -64,6 +64,8 @@ > import org.eclipse.mylyn.internal.tasks.core.ITaskListChangeListener; > import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants; > import org.eclipse.mylyn.internal.tasks.core.TaskContainerDelta; >+import org.eclipse.mylyn.internal.tasks.core.notifications.ServiceMessageEvent; >+import org.eclipse.mylyn.internal.tasks.core.notifications.ServiceMessageManager; > import org.eclipse.mylyn.internal.tasks.ui.AbstractTaskListFilter; > import org.eclipse.mylyn.internal.tasks.ui.CategorizedPresentation; > import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants; >@@ -86,21 +88,22 @@ > import org.eclipse.mylyn.internal.tasks.ui.actions.TaskListSortAction; > import org.eclipse.mylyn.internal.tasks.ui.actions.TaskListViewActionGroup; > import org.eclipse.mylyn.internal.tasks.ui.editors.TaskListChangeAdapter; >+import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListServiceMessageControl; > import org.eclipse.mylyn.internal.tasks.ui.util.PlatformUtil; > import org.eclipse.mylyn.internal.tasks.ui.util.SortCriterion; >+import org.eclipse.mylyn.internal.tasks.ui.util.SortCriterion.SortKey; > import org.eclipse.mylyn.internal.tasks.ui.util.TaskDragSourceListener; > import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; > import org.eclipse.mylyn.internal.tasks.ui.util.TreeWalker; >-import org.eclipse.mylyn.internal.tasks.ui.util.SortCriterion.SortKey; > import org.eclipse.mylyn.internal.tasks.ui.util.TreeWalker.TreeVisitor; > import org.eclipse.mylyn.tasks.core.IRepositoryElement; > import org.eclipse.mylyn.tasks.core.ITask; >+import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel; > import org.eclipse.mylyn.tasks.core.ITaskActivationListener; > import org.eclipse.mylyn.tasks.core.ITaskActivityListener; > import org.eclipse.mylyn.tasks.core.ITaskContainer; > import org.eclipse.mylyn.tasks.core.TaskActivationAdapter; > import org.eclipse.mylyn.tasks.core.TaskActivityAdapter; >-import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel; > import org.eclipse.mylyn.tasks.ui.ITasksUiConstants; > import org.eclipse.mylyn.tasks.ui.TaskElementLabelProvider; > import org.eclipse.mylyn.tasks.ui.TasksUi; >@@ -131,6 +134,7 @@ > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Menu; > import org.eclipse.swt.widgets.Text; >@@ -390,6 +394,8 @@ > > private CustomTaskListDecorationDrawer customDrawer; > >+ private TaskListServiceMessageControl serviceMessageControl; >+ > private final IPageListener PAGE_LISTENER = new IPageListener() { > public void pageActivated(IWorkbenchPage page) { > filteredTree.indicateActiveTaskWorkingSet(); >@@ -554,6 +560,7 @@ > @Override > public void dispose() { > super.dispose(); >+ TasksUiPlugin.getDefault().getServiceMessageManager().removeServiceMessageListener(serviceMessageControl); > TasksUiPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(tasksUiPreferenceListener); > TasksUiInternal.getTaskList().removeChangeListener(TASKLIST_CHANGE_LISTENER); > TasksUiPlugin.getTaskActivityManager().removeActivityListener(TASK_ACTIVITY_LISTENER); >@@ -730,6 +737,15 @@ > > @Override > public void createPartControl(Composite parent) { >+ Composite body = new Composite(parent, SWT.NONE); >+ GridLayout layout = new GridLayout(1, false); >+ layout.marginHeight = 0; >+ layout.marginWidth = 0; >+ layout.horizontalSpacing = 0; >+ layout.verticalSpacing = 0; >+ layout.numColumns = 1; >+ body.setLayout(layout); >+ > IWorkbenchSiteProgressService progress = (IWorkbenchSiteProgressService) getSite().getAdapter( > IWorkbenchSiteProgressService.class); > if (progress != null) { >@@ -743,7 +759,7 @@ > themeManager = getSite().getWorkbenchWindow().getWorkbench().getThemeManager(); > themeManager.addPropertyChangeListener(THEME_CHANGE_LISTENER); > >- filteredTree = new TaskListFilteredTree(parent, SWT.MULTI | SWT.VERTICAL | /* SWT.H_SCROLL | */SWT.V_SCROLL >+ filteredTree = new TaskListFilteredTree(body, SWT.MULTI | SWT.VERTICAL | /* SWT.H_SCROLL | */SWT.V_SCROLL > | SWT.NO_SCROLL | SWT.FULL_SELECTION, new SubstringPatternFilter(), getViewSite().getWorkbenchWindow()); > > // need to do initialize tooltip early for native tooltip disablement to take effect >@@ -923,6 +939,11 @@ > > TasksUiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(tasksUiPreferenceListener); > >+ serviceMessageControl = new TaskListServiceMessageControl(body); >+ ServiceMessageManager manager = TasksUiPlugin.getDefault().getServiceMessageManager(); >+ serviceMessageControl.messagesUpdated(new ServiceMessageEvent(manager, manager.getServiceMessages())); >+ TasksUiPlugin.getDefault().getServiceMessageManager().addServiceMessageListener(serviceMessageControl); >+ > // Need to do this because the page, which holds the active working set is not around on creation, see bug 203179 > PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPageListener(PAGE_LISTENER); > } >@@ -1179,8 +1200,9 @@ > > getViewer().addDoubleClickListener(new IDoubleClickListener() { > public void doubleClick(DoubleClickEvent event) { >- if (TasksUiPlugin.getDefault().getPreferenceStore().getBoolean( >- ITasksUiPreferenceConstants.ACTIVATE_WHEN_OPENED)) { >+ if (TasksUiPlugin.getDefault() >+ .getPreferenceStore() >+ .getBoolean(ITasksUiPreferenceConstants.ACTIVATE_WHEN_OPENED)) { > AbstractTask selectedTask = getSelectedTask(); > if (selectedTask != null && !selectedTask.isActive()) { > TasksUiInternal.activateTaskThroughCommand(selectedTask); >@@ -1263,6 +1285,7 @@ > } > > public void goIntoCategory() { >+ serviceMessageControl.setHidden(true); > ISelection selection = getViewer().getSelection(); > if (selection instanceof StructuredSelection) { > StructuredSelection structuredSelection = (StructuredSelection) selection; >@@ -1280,6 +1303,7 @@ > } > > public void goUpToRoot() { >+ serviceMessageControl.setHidden(false); > drilledIntoCategory = null; > drillDownAdapter.goBack(); > IActionBars bars = getViewSite().getActionBars(); >@@ -1401,8 +1425,9 @@ > > public static String getCurrentPriorityLevel() { > if (TasksUiPlugin.getDefault().getPreferenceStore().contains(ITasksUiPreferenceConstants.FILTER_PRIORITY)) { >- return TasksUiPlugin.getDefault().getPreferenceStore().getString( >- ITasksUiPreferenceConstants.FILTER_PRIORITY); >+ return TasksUiPlugin.getDefault() >+ .getPreferenceStore() >+ .getString(ITasksUiPreferenceConstants.FILTER_PRIORITY); > } else { > return PriorityLevel.P5.toString(); > } >@@ -1435,8 +1460,9 @@ > } > > private boolean isAutoExpandMode() { >- return TasksUiPlugin.getDefault().getPreferenceStore().getBoolean( >- ITasksUiPreferenceConstants.AUTO_EXPAND_TASK_LIST); >+ return TasksUiPlugin.getDefault() >+ .getPreferenceStore() >+ .getBoolean(ITasksUiPreferenceConstants.AUTO_EXPAND_TASK_LIST); > } > > public void setFocusedMode(boolean focusedMode) { >@@ -1567,8 +1593,9 @@ > // bug#160897 > // http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg29614.html > if (taskListToolTip != null) { >- boolean enabled = TasksUiPlugin.getDefault().getPreferenceStore().getBoolean( >- ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED); >+ boolean enabled = TasksUiPlugin.getDefault() >+ .getPreferenceStore() >+ .getBoolean(ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED); > taskListToolTip.setEnabled(enabled); > if (getViewer().getTree() != null && !getViewer().getTree().isDisposed()) { > getViewer().getTree().setToolTipText((enabled) ? "" : null); //$NON-NLS-1$
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 263528
:
167544
|
167547
|
167548
|
167550
|
169594
|
169595
|
169603
|
169740
|
169741
|
169747
|
169882
|
169902
|
170600
|
170980
|
171059
|
171060