Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2011-07-23 11:36:29 -0400
committerSteffen Pingel2011-07-23 11:36:29 -0400
commitec0f134722b3f25bfd4da33a3d0f2b1ab3c9493a (patch)
tree98545c8d8804e9088897367672e425f181b015a9
parent2e4364c74c04c703851844ed2d151b3878f6f3fe (diff)
downloadorg.eclipse.mylyn.tasks-ec0f134722b3f25bfd4da33a3d0f2b1ab3c9493a.tar.gz
org.eclipse.mylyn.tasks-ec0f134722b3f25bfd4da33a3d0f2b1ab3c9493a.tar.xz
org.eclipse.mylyn.tasks-ec0f134722b3f25bfd4da33a3d0f2b1ab3c9493a.zip
NEW - bug 352933: [api] extract task activity monitoring from
o.e.m.tasks.ui https://bugs.eclipse.org/bugs/show_bug.cgi?id=352933
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/activity/DefaultTaskActivityMonitor.java5
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/activity/AbstractTaskActivityMonitor.java5
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/PlanningPart.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java11
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java7
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java3
6 files changed, 27 insertions, 6 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/activity/DefaultTaskActivityMonitor.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/activity/DefaultTaskActivityMonitor.java
index 87a246361..603f6a4b5 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/activity/DefaultTaskActivityMonitor.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/activity/DefaultTaskActivityMonitor.java
@@ -29,6 +29,11 @@ public class DefaultTaskActivityMonitor extends AbstractTaskActivityMonitor {
}
@Override
+ public boolean isEnabled() {
+ return false;
+ }
+
+ @Override
public void loadActivityTime() {
// ignore
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/activity/AbstractTaskActivityMonitor.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/activity/AbstractTaskActivityMonitor.java
index 4d9bf4d41..e300c79ef 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/activity/AbstractTaskActivityMonitor.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/activity/AbstractTaskActivityMonitor.java
@@ -30,6 +30,11 @@ public abstract class AbstractTaskActivityMonitor {
/**
* @since 3.7
*/
+ public abstract boolean isEnabled();
+
+ /**
+ * @since 3.7
+ */
public abstract void loadActivityTime();
/**
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/PlanningPart.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/PlanningPart.java
index 21c45b06f..6594c1155 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/PlanningPart.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/PlanningPart.java
@@ -461,7 +461,7 @@ public class PlanningPart extends AbstractLocalEditorPart {
}
private void updateActiveTime() {
- boolean show = MonitorUiPlugin.getDefault().isActivityTrackingEnabled() && isActiveTimeEnabled();
+ boolean show = TasksUiInternal.isActivityTrackingEnabled() && isActiveTimeEnabled();
long elapsedTime = TasksUiInternal.getActiveTime(getTask());
boolean visible = activeTimeComposite != null && activeTimeComposite.isVisible();
if (show && (elapsedTime > 0 || getTask().isActive())) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java
index 5fac8ff7f..96ae6c607 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java
@@ -131,7 +131,13 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
createTaskNavigationGroup(container);
createTaskListGroup(container);
createTaskEditorGroup(container);
- createTaskActivityGroup(container);
+ Group taskActivityGroup = createTaskActivityGroup(container);
+ if (!TasksUiPlugin.getTaskActivityMonitor().isEnabled()) {
+ // hide controls but create them to avoid NPEs
+ taskActivityGroup.setVisible(false);
+ ((GridData) taskActivityGroup.getLayoutData()).exclude = true;
+ }
+
Composite advanced = createAdvancedSection(container);
createTaskDataControl(advanced);
@@ -521,7 +527,7 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED));
}
- private void createTaskActivityGroup(Composite container) {
+ private Group createTaskActivityGroup(Composite container) {
Group group = new Group(container, SWT.SHADOW_ETCHED_IN);
group.setText(Messages.TasksUiPreferencePage_Task_Timing);
group.setLayout(new GridLayout(3, false));
@@ -583,6 +589,7 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
timeoutLabel2 = new Label(group, SWT.NONE);
timeoutLabel2.setText(Messages.TasksUiPreferencePage_minutes_of_inactivity);
+ return group;
}
public void updateRefreshGroupEnablements() {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
index 3e1e9a401..dd64f9711 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
@@ -1281,7 +1281,7 @@ public class TasksUiInternal {
}
public static long getActiveTime(ITask task) {
- if (MonitorUiPlugin.getDefault().isActivityTrackingEnabled()) {
+ if (TasksUiInternal.isActivityTrackingEnabled()) {
return TasksUiPlugin.getTaskActivityManager().getElapsedTime(task);
}
return 0;
@@ -1439,4 +1439,9 @@ public class TasksUiInternal {
return account.kind(repository.getConnectorKind()).url(repository.getRepositoryUrl());
}
+ public static boolean isActivityTrackingEnabled() {
+ return TasksUiPlugin.getTaskActivityMonitor().isEnabled()
+ && MonitorUiPlugin.getDefault().isActivityTrackingEnabled();
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java
index 49aff359d..d83e34ede 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java
@@ -21,7 +21,6 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.mylyn.commons.core.DateUtil;
-import org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonFonts;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonUiUtil;
@@ -246,7 +245,7 @@ public class TaskListToolTip extends GradientToolTip {
private void appendEstimateAndActive(StringBuilder sb, int estimateTotal, long activeTotal) {
sb.append(NLS.bind(Messages.TaskListToolTip_Estimate, estimateTotal));
sb.append("\n"); //$NON-NLS-1$
- if (MonitorUiPlugin.getDefault().isActivityTrackingEnabled()) {
+ if (TasksUiInternal.isActivityTrackingEnabled()) {
sb.append(NLS.bind(Messages.TaskListToolTip_Active_X, DateUtil.getFormattedDurationShort(activeTotal)));
sb.append("\n"); //$NON-NLS-1$
}

Back to the top