Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2010-06-03 22:38:56 +0000
committerspingel2010-06-03 22:38:56 +0000
commit873a2e9ac93e65487f4cbc998a6e5a62252ff260 (patch)
tree7359e0d3c478ecb088936c7d950b3b40f02a8d1f
parentd90351e014fde1d896fde19d5cf30dba1fe85bd6 (diff)
downloadorg.eclipse.mylyn.tasks-873a2e9ac93e65487f4cbc998a6e5a62252ff260.tar.gz
org.eclipse.mylyn.tasks-873a2e9ac93e65487f4cbc998a6e5a62252ff260.tar.xz
org.eclipse.mylyn.tasks-873a2e9ac93e65487f4cbc998a6e5a62252ff260.zip
RESOLVED - bug 315533: task list notifier retains memory when notifications are disabled
https://bugs.eclipse.org/bugs/show_bug.cgi?id=315533
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListNotificationManager.java13
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListNotification.java20
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListNotifier.java27
3 files changed, 54 insertions, 6 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListNotificationManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListNotificationManager.java
index 31a1ac0b1..ce2dc56b1 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListNotificationManager.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListNotificationManager.java
@@ -29,6 +29,7 @@ import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.window.Window;
import org.eclipse.mylyn.internal.provisional.commons.ui.AbstractNotification;
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListNotificationPopup;
+import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListNotifier;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
@@ -150,10 +151,22 @@ public class TaskListNotificationManager implements IPropertyChangeListener {
}
openJob.setSystem(runSystem);
openJob.schedule(initialStartupTime);
+
+ for (ITaskListNotificationProvider provider : notificationProviders) {
+ if (provider instanceof TaskListNotifier) {
+ ((TaskListNotifier) provider).setEnabled(true);
+ }
+ }
}
}
public void stopNotification() {
+ for (ITaskListNotificationProvider provider : notificationProviders) {
+ if (provider instanceof TaskListNotifier) {
+ ((TaskListNotifier) provider).setEnabled(false);
+ }
+ }
+
openJob.cancel();
// closeJob.cancel();
// if (popup != null) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListNotification.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListNotification.java
index a7fe9e251..6f1426888 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListNotification.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListNotification.java
@@ -15,6 +15,7 @@ import java.util.Date;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.mylyn.internal.provisional.commons.ui.AbstractNotification;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
@@ -31,15 +32,14 @@ import org.eclipse.ui.PlatformUI;
*/
public class TaskListNotification extends AbstractNotification {
+ private static DecoratingLabelProvider labelProvider;
+
protected final ITask task;
protected Date date;
private String description;
- private final DecoratingLabelProvider labelProvider = new DecoratingLabelProvider(
- new TaskElementLabelProvider(true), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator());
-
private final Object token;
public TaskListNotification(ITask task) {
@@ -52,6 +52,16 @@ public class TaskListNotification extends AbstractNotification {
this.token = token;
}
+ private LabelProvider getLabelProvider() {
+ // lazily instantiate on UI thread
+ if (labelProvider == null) {
+ labelProvider = new DecoratingLabelProvider(new TaskElementLabelProvider(true), PlatformUI.getWorkbench()
+ .getDecoratorManager()
+ .getLabelDecorator());
+ }
+ return labelProvider;
+ }
+
@Override
public String getDescription() {
return description;
@@ -59,7 +69,7 @@ public class TaskListNotification extends AbstractNotification {
@Override
public String getLabel() {
- return labelProvider.getText(task);
+ return getLabelProvider().getText(task);
}
public void setDescription(String description) {
@@ -77,7 +87,7 @@ public class TaskListNotification extends AbstractNotification {
@Override
public Image getNotificationImage() {
- return labelProvider.getImage(task);
+ return getLabelProvider().getImage(task);
}
protected ITask getTask() {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListNotifier.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListNotifier.java
index 51d1e3dae..b9fe6e2d2 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListNotifier.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListNotifier.java
@@ -45,6 +45,8 @@ public class TaskListNotifier implements ITaskDataManagerListener, ITaskListNoti
private final RepositoryModel repositoryModel;
+ public boolean enabled;
+
public TaskListNotifier(RepositoryModel repositoryModel, TaskDataManager taskDataManager) {
this.repositoryModel = repositoryModel;
this.taskDataManager = taskDataManager;
@@ -84,6 +86,12 @@ public class TaskListNotifier implements ITaskDataManagerListener, ITaskListNoti
}
public void taskDataUpdated(TaskDataManagerEvent event) {
+ synchronized (notificationQueue) {
+ if (!enabled) {
+ // skip expensive processing
+ return;
+ }
+ }
if (event.getToken() != null && event.getTaskDataChanged()) {
AbstractRepositoryConnectorUi connectorUi = TasksUi.getRepositoryConnectorUi(event.getTaskData()
.getConnectorKind());
@@ -91,7 +99,9 @@ public class TaskListNotifier implements ITaskDataManagerListener, ITaskListNoti
TaskListNotification notification = getNotification(event.getTask(), event.getToken());
if (notification != null) {
synchronized (notificationQueue) {
- notificationQueue.add(notification);
+ if (enabled) {
+ notificationQueue.add(notification);
+ }
}
}
}
@@ -113,4 +123,19 @@ public class TaskListNotifier implements ITaskDataManagerListener, ITaskListNoti
// ignore
}
+ public void setEnabled(boolean enabled) {
+ synchronized (notificationQueue) {
+ if (!enabled) {
+ notificationQueue.clear();
+ }
+ this.enabled = enabled;
+ }
+ }
+
+ public boolean isEnabled() {
+ synchronized (notificationQueue) {
+ return enabled;
+ }
+ }
+
}

Back to the top