Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2011-07-22 17:47:28 -0400
committerSteffen Pingel2011-07-22 17:47:28 -0400
commit11303ccd712dfd8fb7fa3f639fa8a8381170e553 (patch)
treeeec11fbb0e0d5b5e2a185bc1df331dd28c5aa4e9
parentd02ba239c8c77469ff137cbf4d939a834ff39c97 (diff)
downloadorg.eclipse.mylyn.tasks-11303ccd712dfd8fb7fa3f639fa8a8381170e553.tar.gz
org.eclipse.mylyn.tasks-11303ccd712dfd8fb7fa3f639fa8a8381170e553.tar.xz
org.eclipse.mylyn.tasks-11303ccd712dfd8fb7fa3f639fa8a8381170e553.zip
NEW - bug 336430: separate Context framework from Tasks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=336430
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java2
-rw-r--r--org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.mylyn.tasks.core/plugin.xml2
-rw-r--r--org.eclipse.mylyn.tasks.core/schema/activityMonitor.exsd97
-rw-r--r--org.eclipse.mylyn.tasks.core/schema/contextStore.exsd97
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/activity/DefaultTaskActivityMonitor.java51
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/context/DefaultTaskContextStore.java57
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/activity/AbstractTaskActivityMonitor.java50
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/context/AbstractTaskContextStore.java36
-rw-r--r--org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF38
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java3
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RefactorRepositoryUrlOperationTest.java62
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java42
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationHistoryTest.java6
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityTimingTest.java1321
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataImportTest.java47
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskExportImportTest.java4
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/ContextPerspectiveManagerTest.java106
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ActiveContextExternalizationParticipant.java186
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ActivityExternalizationParticipant.java133
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ChangeActivityHandleOperation.java72
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/RefactorRepositoryUrlOperation.java71
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskActivityMonitor.java154
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskHistoryHandler.java30
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java49
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskMigrator.java15
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/AttachmentUtil.java6
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java73
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiImages.java1
-rw-r--r--org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF7
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java2
32 files changed, 521 insertions, 2304 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java
index e39d557ed..2405cd891 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java
@@ -476,7 +476,7 @@ public class BugzillaAttachmentHandlerTest extends AbstractBugzillaTest {
ITask task = TasksUi.getRepositoryModel().createTask(repository, taskData.getTaskId());
TasksUiPlugin.getTaskList().addTask(task);
TasksUi.getTaskActivityManager().activateTask(task);
- File sourceContextFile = TasksUiPlugin.getContextStore().getFileForContext(repository, task);
+ File sourceContextFile = TasksUiPlugin.getContextStore().getFileForContext(task);
sourceContextFile.createNewFile();
sourceContextFile.deleteOnExit();
repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials("wrong", "wrong"), false);
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
index e6decda2f..05b28b446 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
@@ -829,7 +829,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
ITask task = generateLocalTaskAndDownload(data.getTaskId());
assertNotNull(task);
TasksUiPlugin.getTaskActivityManager().activateTask(task);
- File sourceContextFile = TasksUiPlugin.getContextStore().getFileForContext(repository, task);
+ File sourceContextFile = TasksUiPlugin.getContextStore().getFileForContext(task);
assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
sourceContextFile.createNewFile();
sourceContextFile.deleteOnExit();
diff --git a/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF
index 24f80728d..bfc2eee9c 100644
--- a/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF
@@ -12,11 +12,14 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.mylyn.commons.net;bundle-version="[3.0.0,4.0.0)"
Export-Package: org.eclipse.mylyn.internal.provisional.tasks.core;x-internal:=true,
org.eclipse.mylyn.internal.tasks.core;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
+ org.eclipse.mylyn.internal.tasks.core.activity;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
+ org.eclipse.mylyn.internal.tasks.core.context;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.activity,
org.eclipse.mylyn.tasks.core.context,
org.eclipse.mylyn.tasks.core.data,
org.eclipse.mylyn.tasks.core.sync
diff --git a/org.eclipse.mylyn.tasks.core/plugin.xml b/org.eclipse.mylyn.tasks.core/plugin.xml
index 2e643afcc..0aeab1a63 100644
--- a/org.eclipse.mylyn.tasks.core/plugin.xml
+++ b/org.eclipse.mylyn.tasks.core/plugin.xml
@@ -13,4 +13,6 @@
<plugin>
<extension-point id="templates" name="templates" schema="schema/templates.exsd"/>
<extension-point id="synchronizationParticipants" name="Synchronization Participants" schema="schema/synchronizationParticipants.exsd"/>
+ <extension-point id="activityMonitor" name="Task Activity Monitor" schema="schema/activityMonitor.exsd"/>
+ <extension-point id="contextStore" name="Task Context Store" schema="schema/contextStore.exsd"/>
</plugin>
diff --git a/org.eclipse.mylyn.tasks.core/schema/activityMonitor.exsd b/org.eclipse.mylyn.tasks.core/schema/activityMonitor.exsd
new file mode 100644
index 000000000..07cc78536
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/schema/activityMonitor.exsd
@@ -0,0 +1,97 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.mylyn.tasks.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.mylyn.tasks.core" id="activityMonitor" name="Task Activity Monitor"/>
+ </appInfo>
+ <documentation>
+ Provides activity monitoring, only one should be specified.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element internal="true" />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="activityMonitor"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="activityMonitor">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.mylyn.tasks.core.activity.AbstractTaskActivityMonitor:"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 3.7
+ </documentation>
+ </annotation>
+
+
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2011 Tasktop Technologies.
+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
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.mylyn.tasks.core/schema/contextStore.exsd b/org.eclipse.mylyn.tasks.core/schema/contextStore.exsd
new file mode 100644
index 000000000..cbc5c3ff2
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/schema/contextStore.exsd
@@ -0,0 +1,97 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.mylyn.tasks.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.mylyn.tasks.core" id="contextStore" name="Task Context Monitor"/>
+ </appInfo>
+ <documentation>
+ Provides a store for task contexts, only one should be specified.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element internal="true" />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="contextStore"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="contextStore">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.mylyn.tasks.core.context.AbstractTaskContextStore:"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 3.7
+ </documentation>
+ </annotation>
+
+
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2011 Tasktop Technologies.
+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
+ </documentation>
+ </annotation>
+
+</schema>
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
new file mode 100644
index 000000000..87a246361
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/activity/DefaultTaskActivityMonitor.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.activity;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.ITaskActivityManager;
+import org.eclipse.mylyn.tasks.core.activity.AbstractTaskActivityMonitor;
+
+/**
+ * @author Steffen Pingel
+ */
+public class DefaultTaskActivityMonitor extends AbstractTaskActivityMonitor {
+
+ @Override
+ public List<ITask> getActivationHistory() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public void loadActivityTime() {
+ // ignore
+ }
+
+ @Override
+ public void reloadActivityTime() {
+ // ignore
+ }
+
+ @Override
+ public void start(ITaskActivityManager taskActivityManager) {
+ // ignore
+ }
+
+ @Override
+ public void stop() {
+ // ignore
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/context/DefaultTaskContextStore.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/context/DefaultTaskContextStore.java
new file mode 100644
index 000000000..386ddfb4c
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/context/DefaultTaskContextStore.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.context;
+
+import java.io.File;
+
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.context.AbstractTaskContextStore;
+
+/**
+ * @author Steffen Pingel
+ */
+public class DefaultTaskContextStore extends AbstractTaskContextStore {
+
+ @Override
+ public boolean hasContext(ITask task) {
+ return false;
+ }
+
+ @Override
+ public void cloneContext(ITask sourceTask, ITask destinationTask) {
+ }
+
+ @Override
+ public File getFileForContext(ITask task) {
+ return null;
+ }
+
+ @Override
+ public void deleteContext(ITask oldTask) {
+ }
+
+ @Override
+ public void saveActiveContext() {
+ // ignore
+ }
+
+ @Override
+ public void refactorRepositoryUrl(String oldRepositoryUrl, String newRepositoryUrl) {
+ // ignore
+ }
+
+ @Override
+ public void setContextDirectory(File contextStoreDir) {
+ // 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
new file mode 100644
index 000000000..4d9bf4d41
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/activity/AbstractTaskActivityMonitor.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.core.activity;
+
+import java.util.List;
+
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.ITaskActivityManager;
+
+/**
+ * @author Steffen Pingel
+ * @since 3.7
+ */
+public abstract class AbstractTaskActivityMonitor {
+
+ /**
+ * @since 3.7
+ */
+ public abstract List<ITask> getActivationHistory();
+
+ /**
+ * @since 3.7
+ */
+ public abstract void loadActivityTime();
+
+ /**
+ * @since 3.7
+ */
+ public abstract void reloadActivityTime();
+
+ /**
+ * @since 3.7
+ */
+ public abstract void start(ITaskActivityManager taskActivityManager);
+
+ /**
+ * @since 3.7
+ */
+ public abstract void stop();
+
+}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/context/AbstractTaskContextStore.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/context/AbstractTaskContextStore.java
index 0187ba72c..542d87d8f 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/context/AbstractTaskContextStore.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/context/AbstractTaskContextStore.java
@@ -12,11 +12,8 @@
package org.eclipse.mylyn.tasks.core.context;
import java.io.File;
-import java.io.InputStream;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
/**
* A store for persisting task context.
@@ -27,35 +24,44 @@ import org.eclipse.mylyn.tasks.core.TaskRepository;
public abstract class AbstractTaskContextStore {
/**
+ * Copies the context from <code>sourceTask</code> to <code>destinationTask</code>. Creates a new context if a
+ * <code>sourceTask</code> does not have a context.
+ *
* @since 3.7
*/
- public abstract boolean hasContext(ITask task);
+ public abstract void cloneContext(ITask sourceTask, ITask destinationTask);
/**
- * @throws CoreException
- * thrown when the import fails
* @since 3.7
*/
- public abstract void importContext(ITask task, InputStream source) throws CoreException;
+ public abstract void deleteContext(ITask oldTask);
/**
- * Copies the context from <code>sourceTask</code> to <code>destinationTask</code>. Creates a new context if a
- * <code>sourceTask</code> does not have a context.
+ * Return the location of the context for <code>task</code>.
*
+ * @return null, if context for <code>task</code> does not exist
* @since 3.7
*/
- public abstract void cloneContext(ITask sourceTask, ITask destinationTask);
+ public abstract File getFileForContext(ITask task);
/**
- * Return the location of the context for <code>task</code>.
- *
- * @return null, if context for <code>task</code> does not exist
* @since 3.7
*/
- public abstract File getFileForContext(TaskRepository repository, ITask task);
+ public abstract boolean hasContext(ITask task);
- public abstract void deleteContext(ITask oldTask);
+ /**
+ * @since 3.7
+ */
+ public abstract void refactorRepositoryUrl(String oldRepositoryUrl, String newRepositoryUrl);
+ /**
+ * @since 3.7
+ */
public abstract void saveActiveContext();
+ /**
+ * @since 3.7
+ */
+ public abstract void setContextDirectory(File contextStoreDir);
+
}
diff --git a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
index 74fc76d2c..a4ae7218f 100644
--- a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
@@ -5,34 +5,30 @@ Bundle-SymbolicName: org.eclipse.mylyn.tasks.tests;singleton:=true
Bundle-Version: 3.7.0.qualifier
Bundle-Activator: org.eclipse.mylyn.tasks.tests.TasksTestsPlugin
Bundle-Vendor: Eclipse Mylyn
-Require-Bundle: org.eclipse.core.runtime,
+Require-Bundle: org.junit,
+ org.eclipse.core.expressions,
+ org.eclipse.core.resources,
+ org.eclipse.core.runtime,
org.eclipse.core.net,
- org.junit,
- org.eclipse.mylyn.context.core,
- org.eclipse.mylyn.context.tests,
- org.eclipse.mylyn.commons.tests,
+ org.eclipse.equinox.security,
org.eclipse.jdt.core,
- org.eclipse.core.resources,
+ org.eclipse.jface.text,
org.eclipse.ui,
- org.eclipse.mylyn.tasks.ui,
- org.eclipse.mylyn.context.ui,
- org.eclipse.mylyn.tasks.core,
- org.eclipse.mylyn.monitor.ui,
+ org.eclipse.ui.browser,
+ org.eclipse.ui.ide,
org.eclipse.ui.forms,
- org.eclipse.mylyn.resources.tests,
- org.eclipse.mylyn.monitor.core,
+ org.eclipse.mylyn.commons.core,
org.eclipse.mylyn.commons.net,
org.eclipse.mylyn.commons.ui,
- org.eclipse.jface.text,
- org.eclipse.ui.ide,
- org.eclipse.mylyn.tasks.bugs,
- org.eclipse.mylyn.commons.core,
org.eclipse.mylyn.commons.tests,
- org.eclipse.ui.browser,
- org.eclipse.core.expressions,
- org.eclipse.equinox.security,
- org.eclipse.mylyn.tests.util,
- org.eclipse.mylyn.tasks.search
+ org.eclipse.mylyn.monitor.core,
+ org.eclipse.mylyn.monitor.ui,
+ org.eclipse.mylyn.resources.tests,
+ org.eclipse.mylyn.tasks.core,
+ org.eclipse.mylyn.tasks.bugs,
+ org.eclipse.mylyn.tasks.ui,
+ org.eclipse.mylyn.tasks.search,
+ org.eclipse.mylyn.tests.util
Import-Package: com.sun.syndication.feed.synd;version="0.9.0";resolution:=optional
Export-Package: org.eclipse.mylyn.tasks.tests;x-internal:=true,
org.eclipse.mylyn.tasks.tests.connector;x-internal:=true,
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
index 896c9c720..a55247efb 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
@@ -20,7 +20,6 @@ import org.eclipse.mylyn.tasks.tests.core.TaskListUnmatchedContainerTest;
import org.eclipse.mylyn.tasks.tests.core.TaskRepositoryLocationTest;
import org.eclipse.mylyn.tasks.tests.data.TaskDataExternalizerTest;
import org.eclipse.mylyn.tasks.tests.data.Xml11InputStreamTest;
-import org.eclipse.mylyn.tasks.tests.ui.ContextPerspectiveManagerTest;
import org.eclipse.mylyn.tasks.tests.ui.RetrieveTitleFromUrlTest;
import org.eclipse.mylyn.tasks.tests.ui.TaskAttachmentPropertyTesterTest;
import org.eclipse.mylyn.tasks.tests.ui.TaskHyperlinkDetectorTest;
@@ -69,7 +68,6 @@ public class AllTasksTests {
suite.addTestSuite(TaskDataExportTest.class);
suite.addTestSuite(TaskDataImportTest.class);
suite.addTestSuite(ScheduledPresentationTest.class);
- suite.addTestSuite(TaskActivityTimingTest.class);
suite.addTestSuite(TaskAttachmentTest.class);
suite.addTestSuite(RepositorySettingsPageTest.class);
suite.addTestSuite(CommentQuoterTest.class);
@@ -97,7 +95,6 @@ public class AllTasksTests {
suite.addTestSuite(TaskEditorPartDescriptorTest.class);
suite.addTestSuite(TaskAttachmentPropertyTesterTest.class);
suite.addTestSuite(CommentGroupStrategyTest.class);
- suite.addTestSuite(ContextPerspectiveManagerTest.class);
suite.addTestSuite(ITasksCoreConstantsTest.class);
suite.addTestSuite(RetrieveTitleFromUrlTest.class);
suite.addTestSuite(EditorUtilTest.class);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RefactorRepositoryUrlOperationTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RefactorRepositoryUrlOperationTest.java
index 382685ee3..2053d39e4 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RefactorRepositoryUrlOperationTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RefactorRepositoryUrlOperationTest.java
@@ -11,22 +11,15 @@
package org.eclipse.mylyn.tasks.tests;
-import java.io.File;
-import java.util.Calendar;
-
import junit.framework.TestCase;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
-import org.eclipse.mylyn.internal.context.core.InteractionContext;
-import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.core.TaskList;
import org.eclipse.mylyn.internal.tasks.ui.RefactorRepositoryUrlOperation;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.monitor.core.InteractionEvent;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskRepository;
@@ -54,17 +47,6 @@ public class RefactorRepositoryUrlOperationTest extends TestCase {
TaskTestUtil.resetTaskList();
}
- public void testMigrateTaskContextFiles() throws Exception {
- File fileA = ContextCorePlugin.getContextStore().getFileForContext("http://a-1");
- fileA.createNewFile();
- fileA.deleteOnExit();
- assertTrue(fileA.exists());
- new RefactorRepositoryUrlOperation("http://a", "http://b").run(new NullProgressMonitor());
- File fileB = ContextCorePlugin.getContextStore().getFileForContext("http://b-1");
- assertTrue(fileB.exists());
- assertFalse(fileA.exists());
- }
-
public void testMigrateQueryUrlHandles() throws Exception {
RepositoryQuery query = new MockRepositoryQuery("mquery");
query.setRepositoryUrl("http://foo.bar");
@@ -132,50 +114,6 @@ public class RefactorRepositoryUrlOperationTest extends TestCase {
assertEquals("http://bb/task/123", task.getUrl());
}
- public void testRefactorMetaContextHandles() throws Exception {
- String firstUrl = "http://repository1.com/bugs";
- String secondUrl = "http://repository2.com/bugs";
- AbstractTask task1 = new MockTask(firstUrl, "1");
- AbstractTask task2 = new MockTask(firstUrl, "2");
- taskList.addTask(task1);
- taskList.addTask(task2);
- Calendar startDate = Calendar.getInstance();
- Calendar endDate = Calendar.getInstance();
- endDate.add(Calendar.MINUTE, 5);
-
- Calendar startDate2 = Calendar.getInstance();
- startDate2.add(Calendar.MINUTE, 15);
- Calendar endDate2 = Calendar.getInstance();
- endDate2.add(Calendar.MINUTE, 25);
-
- ContextCorePlugin.getContextManager().resetActivityMetaContext();
- InteractionContext metaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
- assertEquals(0, metaContext.getInteractionHistory().size());
-
- ContextCorePlugin.getContextManager().processActivityMetaContextEvent(
- new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(), "origin",
- null, InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startDate.getTime(),
- endDate.getTime()));
-
- ContextCorePlugin.getContextManager().processActivityMetaContextEvent(
- new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task2.getHandleIdentifier(), "origin",
- null, InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startDate2.getTime(),
- endDate2.getTime()));
-
- assertEquals(2, metaContext.getInteractionHistory().size());
- assertEquals(60 * 1000 * 5, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1));
- assertEquals(2 * 60 * 1000 * 5, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task2));
- new RefactorRepositoryUrlOperation(firstUrl, secondUrl).run(new NullProgressMonitor());
- metaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
- assertEquals(2, metaContext.getInteractionHistory().size());
- assertEquals(60 * 1000 * 5, TasksUiPlugin.getTaskActivityManager().getElapsedTime(new MockTask(secondUrl, "1")));
- assertEquals(2 * 60 * 1000 * 5,
- TasksUiPlugin.getTaskActivityManager().getElapsedTime(new MockTask(secondUrl, "2")));
- assertEquals(secondUrl + "-1", metaContext.getInteractionHistory().get(0).getStructureHandle());
- }
-
public void testMigrateTaskHandlesUnsubmittedTask() throws Exception {
ITask task = TasksUiUtil.createOutgoingNewTask(MockRepositoryConnector.CONNECTOR_KIND, "http://a");
String handleIdentifier = task.getHandleIdentifier();
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java
index 0ea5e2862..11abdc267 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java
@@ -15,14 +15,11 @@ import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import junit.framework.TestCase;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
-import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
-import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.DateRange;
import org.eclipse.mylyn.internal.tasks.core.DayDateRange;
@@ -33,7 +30,6 @@ import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListInterestFilter;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskScheduleContentProvider;
-import org.eclipse.mylyn.monitor.core.InteractionEvent;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
import org.eclipse.mylyn.tasks.core.TaskRepository;
@@ -47,8 +43,8 @@ public class ScheduledPresentationTest extends TestCase {
@Override
protected void setUp() throws Exception {
- ContextCorePlugin.getContextManager().getActivityMetaContext().reset();
- ContextCorePlugin.getContextManager().saveActivityMetaContext();
+// ContextCorePlugin.getContextManager().getActivityMetaContext().reset();
+// ContextCorePlugin.getContextManager().saveActivityMetaContext();
TaskTestUtil.resetTaskList();
TasksUiPlugin.getExternalizationManager().requestSave();
}
@@ -284,38 +280,4 @@ public class ScheduledPresentationTest extends TestCase {
// TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
// }
- public void testScheduledTaskContainer() {
-
- Calendar startDate = Calendar.getInstance();
- startDate.setTimeInMillis(1000);
- Calendar endDate = Calendar.getInstance();
- endDate.setTimeInMillis(2000);
-
- AbstractTask task1 = new LocalTask("task 1", "Task 1");
- AbstractTask task2 = new LocalTask("task 2", "Task 2");
- TasksUiPlugin.getTaskList().addTask(task1);
- TasksUiPlugin.getTaskList().addTask(task2);
-
- InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, startDate.getTime(), endDate.getTime());
-
- InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task2.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, startDate.getTime(), endDate.getTime());
-
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event1, false);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event2, false);
- Calendar start = TaskActivityUtil.getCalendar();
- start.setTimeInMillis(0);
- Calendar end = TaskActivityUtil.getCalendar();
- end.add(Calendar.MINUTE, 2);
- Set<AbstractTask> tasks = TasksUiPlugin.getTaskActivityManager().getActiveTasks(start, end);
- assertEquals(2, tasks.size());
- assertEquals(1000, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1));
- assertEquals(1000, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task2));
-
- }
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationHistoryTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationHistoryTest.java
index 2582c920b..c01a491e8 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationHistoryTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationHistoryTest.java
@@ -19,8 +19,6 @@ import java.util.Set;
import junit.framework.TestCase;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
-import org.eclipse.mylyn.internal.context.ui.ContextUiPlugin;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.AbstractTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.TaskActivationHistory;
@@ -69,7 +67,7 @@ public class TaskActivationHistoryTest extends TestCase {
taskActivityManager.deactivateActiveTask();
taskActivityManager.clear();
- ContextCorePlugin.getContextManager().resetActivityMetaContext();
+// ContextCorePlugin.getContextManager().resetActivityMetaContext();
TaskTestUtil.resetTaskList();
@@ -146,7 +144,7 @@ public class TaskActivationHistoryTest extends TestCase {
}
private IWorkingSet createWorkingSet(IAdaptable element) {
- IWorkingSetManager workingSetManager1 = ContextUiPlugin.getDefault().getWorkbench().getWorkingSetManager();
+ IWorkingSetManager workingSetManager1 = PlatformUI.getWorkbench().getWorkingSetManager();
IWorkingSet workingSet = workingSetManager1.createWorkingSet("Task Working Set", new IAdaptable[] { element });
workingSet.setId(TaskWorkingSetUpdater.ID_TASK_WORKING_SET);
assertTrue(Arrays.asList(workingSet.getElements()).contains(element));
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityTimingTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityTimingTest.java
deleted file mode 100644
index e35a45211..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityTimingTest.java
+++ /dev/null
@@ -1,1321 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.commons.tests.support.CommonTestUtil;
-import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
-import org.eclipse.mylyn.internal.context.core.InteractionContext;
-import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
-import org.eclipse.mylyn.internal.context.core.InteractionContextScaling;
-import org.eclipse.mylyn.internal.context.core.LegacyActivityAdaptor;
-import org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin;
-import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
-import org.eclipse.mylyn.internal.tasks.core.ITaskList;
-import org.eclipse.mylyn.internal.tasks.core.LocalTask;
-import org.eclipse.mylyn.internal.tasks.core.ScheduledTaskContainer;
-import org.eclipse.mylyn.internal.tasks.core.TaskActivityManager;
-import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
-import org.eclipse.mylyn.monitor.core.InteractionEvent;
-import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.ui.TasksUi;
-
-/**
- * @author Rob Elves
- */
-public class TaskActivityTimingTest extends TestCase {
-
- private TaskActivityManager activityManager;
-
- private ITaskList taskList;
-
- @Override
- protected void setUp() throws Exception {
- activityManager = (TaskActivityManager) TasksUi.getTaskActivityManager();
- taskList = TasksUiInternal.getTaskList();
- TaskTestUtil.resetTaskListAndRepositories();
- TaskTestUtil.saveAndReadTasklist();
- ContextCorePlugin.getContextManager().getActivityMetaContext().reset();
- ContextCorePlugin.getContextManager().saveActivityMetaContext();
- TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
- }
-
- @Override
- protected void tearDown() throws Exception {
- ContextCorePlugin.getContextManager().getActivityMetaContext().reset();
- TaskTestUtil.resetTaskList();
- }
-
- public void testLoadCorruptContext() throws Exception {
- String contextPath = TasksUiPlugin.getDefault().getDataDirectory() + '/' + "contexts" + '/';
- File contexts = new File(contextPath);
- if (!contexts.exists()) {
- contexts.mkdir();
- }
- File backup = new File(contexts, ".activity.xml.zip");
-
- File good = CommonTestUtil.getFile(this, "testdata/activityTests/.activity.xml.zip");
-
- CommonTestUtil.copy(good, backup);
-
- File corrupt = new File(contexts, "activity.xml.zip");
-
- File corruptSource = CommonTestUtil.getFile(this, "testdata/activityTests/.activity.xml.zip");
-
- CommonTestUtil.copy(corruptSource, corrupt);
-
- InteractionContextManager manager = ContextCorePlugin.getContextManager();
- manager.loadActivityMetaContext();
- assertFalse(manager.getActivityMetaContext().getInteractionHistory().isEmpty());
- }
-
- public void testConstantWriting() throws Exception {
-
- String contextPath = TasksUiPlugin.getDefault().getDataDirectory() + '/' + "contexts" + '/';
- File contexts = new File(contextPath);
- if (!contexts.exists()) {
- contexts.mkdir();
- }
- File backup = new File(contexts, ".activity.xml.zip");
-
- File good = CommonTestUtil.getFile(this, "testdata/activityTests/.activity.xml.zip");
-
- CommonTestUtil.copy(good, backup);
-
- InteractionContextManager manager = ContextCorePlugin.getContextManager();
- manager.loadActivityMetaContext();
- assertFalse(manager.getActivityMetaContext().getInteractionHistory().isEmpty());
-
- for (int i = 0; i < 50; i++) {
- manager.saveActivityMetaContext();
- }
-
- manager.loadActivityMetaContext();
- assertFalse(manager.getActivityMetaContext().getInteractionHistory().isEmpty());
-
- }
-
- public void testActivityWithNoTaskActive() {
- Calendar start = Calendar.getInstance();
- Calendar end = Calendar.getInstance();
- end.setTimeInMillis(start.getTimeInMillis());
- end.add(Calendar.HOUR_OF_DAY, 2);
-
- Calendar start2 = Calendar.getInstance();
- start2.add(Calendar.DAY_OF_MONTH, 1);
- Calendar end2 = Calendar.getInstance();
- end2.setTime(start2.getTime());
- end2.add(Calendar.HOUR_OF_DAY, 2);
-
- InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_WORKINGSET, "none", "originId", "navigatedRelation",
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, start.getTime(), end.getTime());
- InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_WORKINGSET, "none", "originId", "navigatedRelation",
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, start2.getTime(), end2.getTime());
-
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event1, false);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event2, false);
-
- long expectedTotalTime = end.getTime().getTime() - start.getTime().getTime();
- assertEquals(2 * expectedTotalTime, activityManager.getElapsedForWorkingSet("none", start, end2));
-
- }
-
- public void testActivityWithNoTaskActive2() {
- Calendar start = Calendar.getInstance();
- Calendar end = Calendar.getInstance();
- end.setTimeInMillis(start.getTimeInMillis());
- end.add(Calendar.HOUR_OF_DAY, 2);
-
- Calendar start2 = Calendar.getInstance();
- start2.add(Calendar.DAY_OF_MONTH, 1);
- Calendar end2 = Calendar.getInstance();
- end2.setTime(start2.getTime());
- end2.add(Calendar.HOUR_OF_DAY, 2);
-
- InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_WORKINGSET, "set 1", "originId", "navigatedRelation",
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, start.getTime(), end.getTime());
- InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_WORKINGSET, "set 2", "originId", "navigatedRelation",
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, start2.getTime(), end2.getTime());
-
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event1, false);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event2, false);
-
- long expectedTotalTime = end.getTime().getTime() - start.getTime().getTime();
- assertEquals(0, activityManager.getElapsedForWorkingSet("bogus", start, end2));
- assertEquals(0, activityManager.getElapsedForWorkingSet("none", start, end2));
- assertEquals(expectedTotalTime, activityManager.getElapsedForWorkingSet("set 1", start, end2));
- assertEquals(expectedTotalTime, activityManager.getElapsedForWorkingSet("set 2", start, end2));
- assertTrue(activityManager.getWorkingSets().contains("set 1"));
- assertTrue(activityManager.getWorkingSets().contains("set 2"));
- }
-
- public void testActivityCaptured() {
- AbstractTask task1 = new LocalTask("task 1", "Task 1");
- taskList.addTask(task1);
- assertEquals(0, activityManager.getElapsedTime(task1));
-
- Calendar start = Calendar.getInstance();
- Calendar end = Calendar.getInstance();
- end.setTimeInMillis(start.getTimeInMillis());
- end.add(Calendar.HOUR_OF_DAY, 2);
-
- Calendar start2 = Calendar.getInstance();
- start2.add(Calendar.DAY_OF_MONTH, 1);
- Calendar end2 = Calendar.getInstance();
- end2.setTime(start2.getTime());
- end2.add(Calendar.HOUR_OF_DAY, 2);
-
- InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION, "structureKind",
- task1.getHandleIdentifier(), "originId", "navigatedRelation",
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, start.getTime(), end.getTime());
- InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.ATTENTION, "structureKind",
- task1.getHandleIdentifier(), "originId", "navigatedRelation",
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, start2.getTime(), end2.getTime());
-
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event1, false);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event2, false);
-
- long expectedTotalTime = end.getTime().getTime() - start.getTime().getTime();
- assertEquals(2 * expectedTotalTime, activityManager.getElapsedTime(task1));
- Calendar startEarly = Calendar.getInstance();
- startEarly.setTimeInMillis(start.getTimeInMillis());
- startEarly.add(Calendar.MONTH, -1);
- Calendar endLate = Calendar.getInstance();
- endLate.setTimeInMillis(end.getTimeInMillis() + 60 * 5000);
- assertEquals(expectedTotalTime, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, startEarly, end));
- assertEquals(expectedTotalTime, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, start2, end2));
- assertEquals(2 * expectedTotalTime, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, start, end2));
- }
-
- public void testActivityDelete() {
-
- AbstractTask task1 = new LocalTask("1", "Task 1");
- taskList.addTask(task1);
- assertEquals(0, activityManager.getElapsedTime(task1));
-
- Calendar start = Calendar.getInstance();
- Calendar end = Calendar.getInstance();
- end.setTimeInMillis(start.getTimeInMillis());
- end.add(Calendar.HOUR_OF_DAY, 2);
-
- Calendar start2 = Calendar.getInstance();
- start2.add(Calendar.DAY_OF_MONTH, 1);
- Calendar end2 = Calendar.getInstance();
- end2.setTime(start2.getTime());
- end2.add(Calendar.HOUR_OF_DAY, 2);
-
- InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION, "structureKind",
- task1.getHandleIdentifier(), "originId", "navigatedRelation",
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, start.getTime(), end.getTime());
- InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.ATTENTION, "structureKind",
- task1.getHandleIdentifier(), "originId", "navigatedRelation",
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, start2.getTime(), end2.getTime());
-
- ContextCorePlugin.getContextManager().getActivityMetaContext().parseEvent(event1);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event1, false);
- ContextCorePlugin.getContextManager().getActivityMetaContext().parseEvent(event2);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event2, false);
-
- long expectedTotalTime = end.getTime().getTime() - start.getTime().getTime();
- assertEquals(2 * expectedTotalTime, activityManager.getElapsedTime(task1));
- Calendar startEarly = Calendar.getInstance();
- startEarly.setTimeInMillis(start.getTimeInMillis());
- startEarly.add(Calendar.MONTH, -1);
- Calendar endLate = Calendar.getInstance();
- endLate.setTimeInMillis(end.getTimeInMillis() + 60 * 5000);
- assertEquals(expectedTotalTime, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, startEarly, end));
- assertEquals(expectedTotalTime, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, start2, end2));
- assertEquals(2 * expectedTotalTime, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, start, end2));
-
- MonitorUiPlugin.getDefault()
- .getActivityContextManager()
- .removeActivityTime(task1.getHandleIdentifier(), start.getTimeInMillis(), end.getTimeInMillis());
- // Half gone since end date is exclusive (removes up to but not including hour)
- assertEquals(expectedTotalTime, activityManager.getElapsedTime(task1));
-
- ContextCorePlugin.getContextManager().saveActivityMetaContext();
- ContextCorePlugin.getContextManager().loadActivityMetaContext();
- TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
-
- assertEquals(expectedTotalTime, activityManager.getElapsedTime(task1));
-
- MonitorUiPlugin.getDefault()
- .getActivityContextManager()
- .removeActivityTime(task1.getHandleIdentifier(), start2.getTimeInMillis(), end2.getTimeInMillis());
-
- assertEquals(0, activityManager.getElapsedTime(task1));
- }
-
-// public void testActivityReset() {
-//
-// AbstractTask task1 = new LocalTask("1", "Task 1");
-// taskList.addTask(task1);
-// assertEquals(0, activityManager.getElapsedTime(task1));
-//
-// Calendar start = Calendar.getInstance();
-// Calendar end = Calendar.getInstance();
-// end.setTimeInMillis(start.getTimeInMillis());
-// end.add(Calendar.HOUR_OF_DAY, 2);
-//
-// Calendar start2 = Calendar.getInstance();
-// start2.add(Calendar.DAY_OF_MONTH, 1);
-// Calendar end2 = Calendar.getInstance();
-// end2.setTime(start2.getTime());
-// end2.add(Calendar.HOUR_OF_DAY, 2);
-//
-// InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION, "structureKind",
-// task1.getHandleIdentifier(), "originId", "navigatedRelation",
-// IInteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, start.getTime(), end.getTime());
-// InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.ATTENTION, "structureKind",
-// task1.getHandleIdentifier(), "originId", "navigatedRelation",
-// IInteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, start2.getTime(), end2.getTime());
-//
-// ContextCore.getContextManager().getActivityMetaContext().parseEvent(event1);
-// TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event1);
-// ContextCore.getContextManager().getActivityMetaContext().parseEvent(event2);
-// TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event2);
-//
-// long expectedTotalTime = end.getTime().getTime() - start.getTime().getTime();
-// assertEquals(2 * expectedTotalTime, activityManager.getElapsedTime(task1));
-// Calendar startEarly = Calendar.getInstance();
-// startEarly.setTimeInMillis(start.getTimeInMillis());
-// startEarly.add(Calendar.MONTH, -1);
-// Calendar endLate = Calendar.getInstance();
-// endLate.setTimeInMillis(end.getTimeInMillis() + 60 * 5000);
-// assertEquals(expectedTotalTime, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, startEarly, end));
-// assertEquals(expectedTotalTime, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, start2, end2));
-// assertEquals(2 * expectedTotalTime, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, start, end2));
-//
-// MonitorUiPlugin.getDefault().getActivityContextManager().clearActivityTime(task1.getHandleIdentifier(),
-// start.getTimeInMillis(), end.getTimeInMillis());
-// // Half gone since end date is exclusive (removes up to but not including hour)
-// assertEquals(expectedTotalTime, activityManager.getElapsedTime(task1));
-// assertTrue(activityManager.getActiveTasks(start, end).isEmpty());
-// assertFalse(activityManager.getActiveTasks(start2, end2).isEmpty());
-//
-// MonitorUiPlugin.getDefault().getActivityContextManager().clearActivityTime(task1.getHandleIdentifier(),
-// start.getTimeInMillis(), end2.getTimeInMillis() + (1000 * 60 * 60));
-//
-// // with end = hour beyond should result in zero
-// assertEquals(0, activityManager.getElapsedTime(task1));
-//
-// TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event1);
-// TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event2);
-// // one event blocked now by activity date filter so only half time collected
-// assertEquals(expectedTotalTime, activityManager.getElapsedTime(task1));
-// assertFalse(activityManager.getActiveTasks(start, end).isEmpty());
-// assertTrue(activityManager.getActiveTasks(start2, end2).isEmpty());
-//
-// ContextCore.getContextManager().saveActivityContext();
-// ContextCore.getContextManager().loadActivityMetaContext();
-// TasksUiPlugin.getTaskListManager().resetAndRollOver();
-//
-//// assertEquals(expectedTotalTime, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, startEarly, end));
-//// assertEquals(expectedTotalTime, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, start2, end2));
-//// assertEquals(2 * expectedTotalTime, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, start, end2));
-//
-// // reset still valid after restart
-// assertEquals(expectedTotalTime, activityManager.getElapsedTime(task1));
-// assertFalse(activityManager.getActiveTasks(start, end).isEmpty());
-// assertTrue(activityManager.getActiveTasks(start2, end2).isEmpty());
-//
-// }
-
- public void testNegativeActivity() {
-
- AbstractTask task1 = new LocalTask("task 1", "Task 1");
- taskList.addTask(task1);
- assertEquals(0, activityManager.getElapsedTime(task1));
-
- Calendar start = Calendar.getInstance();
- Calendar end = Calendar.getInstance();
- end.setTimeInMillis(start.getTimeInMillis());
- end.add(Calendar.HOUR_OF_DAY, 2);
-
- Calendar start2 = Calendar.getInstance();
- start2.add(Calendar.DAY_OF_MONTH, 1);
- Calendar end2 = Calendar.getInstance();
- end2.setTime(start2.getTime());
- end2.add(Calendar.HOUR_OF_DAY, 2);
-
- InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION, "structureKind",
- task1.getHandleIdentifier(), "originId", "navigatedRelation",
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, end.getTime(), start.getTime());
- InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.ATTENTION, "structureKind",
- task1.getHandleIdentifier(), "originId", "navigatedRelation",
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, end2.getTime(), start2.getTime());
-
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event1, false);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event2, false);
-
- assertEquals(0, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1));
- assertEquals(0, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, start, end));
- assertEquals(0, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, start2, end2));
- assertEquals(0, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1, start, end2));
-
- }
-
- public void testNullTaskHandle() {
- AbstractTask task1 = new LocalTask("task 1", "Task 1");
- taskList.addTask(task1);
- assertEquals(0, activityManager.getElapsedTime(task1));
-
- Calendar start = Calendar.getInstance();
- Calendar end = Calendar.getInstance();
- end.setTimeInMillis(start.getTimeInMillis());
- end.add(Calendar.HOUR_OF_DAY, 2);
-
- InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION, "structureKind", null,
- "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, start.getTime(),
- end.getTime());
- InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.ATTENTION, "structureKind", "",
- "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, start.getTime(),
- end.getTime());
-
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event1, false);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event2, false);
- assertEquals(0, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1));
- }
-
- public void testActivityNotLoggedTwice() {
- InteractionContext metaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
- metaContext.reset();
- assertEquals(0, metaContext.getInteractionHistory().size());
-
- ITask task1 = new LocalTask("local 1", "Task 1");
- ITask task2 = new LocalTask("local 2", "Task 2");
-
- Calendar startTime1 = Calendar.getInstance();
- TaskActivityUtil.snapStartOfHour(startTime1);
- Calendar endTime1 = Calendar.getInstance();
- endTime1.setTime(startTime1.getTime());
- endTime1.add(Calendar.SECOND, 20);
-
- Calendar startTime2 = Calendar.getInstance();
- startTime2.setTime(endTime1.getTime());
- startTime2.add(Calendar.SECOND, 20);
- Calendar endTime2 = Calendar.getInstance();
- endTime2.setTime(startTime2.getTime());
- endTime2.add(Calendar.MINUTE, 2);
-
- InteractionEvent activityEvent1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime1.getTime(), endTime1.getTime());
-
- InteractionEvent activityEvent2 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime2.getTime(), endTime2.getTime());
-
- InteractionEvent activityEvent3 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task2.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime1.getTime(), startTime1.getTime());
-
- // to activity events both within same hour will get collapsed
- metaContext.parseEvent(activityEvent1);
- metaContext.parseEvent(activityEvent2);
- // This is a bogus 3rd event with zero activity and shouldn't be recorded
- // this use to result in a second write of activity1 to the context
- metaContext.parseEvent(activityEvent3);
- metaContext = ContextCorePlugin.getContextManager().collapseActivityMetaContext(metaContext);
- assertEquals(1, metaContext.getInteractionHistory().size());
- }
-
- public void testDoubleBookKeeping() {
- AbstractTask task1 = new LocalTask("testDoubleBookKeeping", "testDoubleBookKeeping");
- TasksUiPlugin.getTaskList().addTask(task1);
- {
- Calendar startActiveTime = Calendar.getInstance();
- Calendar endActiveTime = Calendar.getInstance();
- endActiveTime.setTime(startActiveTime.getTime());
- endActiveTime.add(Calendar.SECOND, 20);
-
- Calendar startTime = Calendar.getInstance();
- startTime.setTime(startActiveTime.getTime());
- startTime.add(Calendar.SECOND, 5);
- Calendar endTime = Calendar.getInstance();
- endTime.setTime(endActiveTime.getTime());
- endTime.add(Calendar.SECOND, -5);
-
- InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
- task1.getHandleIdentifier(), InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH,
- "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f,
- startActiveTime.getTime(), startActiveTime.getTime());
- InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
- task1.getHandleIdentifier(), InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH,
- "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f,
- endActiveTime.getTime(), endActiveTime.getTime());
-
- InteractionEvent activityEvent1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime.getTime(), endTime.getTime());
-
- ContextCorePlugin.getContextManager().getActivityMetaContext().parseEvent(event1);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event1, false);
- ContextCorePlugin.getContextManager().getActivityMetaContext().parseEvent(activityEvent1);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(activityEvent1, false);
- ContextCorePlugin.getContextManager().getActivityMetaContext().parseEvent(event2);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event2, false);
-
- long elapsed = TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1);
- assertEquals(10000, elapsed);
-
- // 2nd activation - no activity
- ContextCorePlugin.getContextManager().getActivityMetaContext().parseEvent(event1);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event1, false);
- ContextCorePlugin.getContextManager().getActivityMetaContext().parseEvent(event2);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event2, false);
-
- elapsed = TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1);
- assertEquals(10000, elapsed);
- assertTrue(TasksUiPlugin.getTaskActivityManager().isActiveThisWeek(task1));
- }
-
- assertEquals(10000, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1));
- ///--- 2nd activity on same task
- {
- Calendar startActiveTime2 = Calendar.getInstance();
- Calendar endActiveTime2 = Calendar.getInstance();
- endActiveTime2.setTimeInMillis(startActiveTime2.getTimeInMillis());
- endActiveTime2.add(Calendar.SECOND, 20);
-
- Calendar startTime2 = Calendar.getInstance();
- startTime2.setTimeInMillis(startActiveTime2.getTimeInMillis() + 2000);
- Calendar endTime2 = Calendar.getInstance();
- endTime2.setTimeInMillis(endActiveTime2.getTimeInMillis() - 2000);
-
- InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
- task1.getHandleIdentifier(), InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH,
- "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f,
- startActiveTime2.getTime(), startActiveTime2.getTime());
- InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
- task1.getHandleIdentifier(), InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH,
- "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f,
- endActiveTime2.getTime(), endActiveTime2.getTime());
-
- InteractionEvent activityEvent1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime2.getTime(), endTime2.getTime());
-
- ContextCorePlugin.getContextManager().getActivityMetaContext().parseEvent(event1);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event1, false);
- ContextCorePlugin.getContextManager().getActivityMetaContext().parseEvent(activityEvent1);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(activityEvent1, false);
- ContextCorePlugin.getContextManager().getActivityMetaContext().parseEvent(event2);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event2, false);
- }
-
- assertEquals(26000, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1));
-
- ContextCorePlugin.getContextManager().saveActivityMetaContext();
- ContextCorePlugin.getContextManager().loadActivityMetaContext();
- TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
-
- assertEquals(26000, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1));
-
- }
-
- public void testAfterReloading() {
- AbstractTask task1 = new LocalTask("task 1", "Task 1");
- TasksUiPlugin.getTaskList().addTask(task1);
-
- Calendar startTime = Calendar.getInstance();
- Calendar endTime = Calendar.getInstance();
- endTime.setTimeInMillis(startTime.getTimeInMillis());
- endTime.add(Calendar.SECOND, 20);
-
- InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
- task1.getHandleIdentifier(), "originId", "navigatedRelation",
- InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, startTime.getTime(), startTime.getTime());
- InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
- task1.getHandleIdentifier(), "originId", "navigatedRelation",
- InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f, startTime.getTime(), startTime.getTime());
-
- InteractionEvent activityEvent1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime.getTime(), endTime.getTime());
-
- ContextCorePlugin.getContextManager().getActivityMetaContext().parseEvent(event1);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event1, false);
- ContextCorePlugin.getContextManager().getActivityMetaContext().parseEvent(activityEvent1);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(activityEvent1, false);
- ContextCorePlugin.getContextManager().getActivityMetaContext().parseEvent(event2);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event2, false);
- assertEquals(20000, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1));
-
- ContextCorePlugin.getContextManager().saveActivityMetaContext();
- ContextCorePlugin.getContextManager().loadActivityMetaContext();
- TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
-
- assertEquals(20000, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1));
-
- }
-
- public void testCollapsedTiming() {
- Calendar startTime1 = Calendar.getInstance();
- Calendar endTime1 = Calendar.getInstance();
- endTime1.setTimeInMillis(startTime1.getTimeInMillis());
- endTime1.add(Calendar.SECOND, 20);
-
- Calendar startTime2 = Calendar.getInstance();
- startTime2.setTimeInMillis(endTime1.getTimeInMillis());
- Calendar endTime2 = Calendar.getInstance();
- endTime2.setTimeInMillis(startTime2.getTimeInMillis() + 20 * 1000);
-
- Calendar startTime3 = Calendar.getInstance();
- startTime3.setTimeInMillis(endTime2.getTimeInMillis());
- Calendar endTime3 = Calendar.getInstance();
- endTime3.setTimeInMillis(startTime3.getTimeInMillis() + 20 * 1000);
-
- InteractionContext mockContext = new InteractionContext("doitest", new InteractionContextScaling());
- InteractionEvent activityEvent1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, "handle",
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime1.getTime(), endTime1.getTime());
-
- InteractionEvent activityEvent2 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, "handle",
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime2.getTime(), endTime2.getTime());
-
- InteractionEvent activityEvent3 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, "handle",
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime3.getTime(), endTime3.getTime());
-
- mockContext.parseEvent(activityEvent1);
- mockContext.parseEvent(activityEvent2);
- mockContext.parseEvent(activityEvent3);
- assertEquals(3, mockContext.getInteractionHistory().size());
- mockContext = ContextCorePlugin.getContextManager().collapseActivityMetaContext(mockContext);
- assertEquals(1, mockContext.getInteractionHistory().size());
-
- assertEquals(60 * 1000, mockContext.getInteractionHistory().get(0).getEndDate().getTime()
- - mockContext.getInteractionHistory().get(0).getDate().getTime());
- }
-
- /**
- * test that total collapsed time is same when events are separated in time
- */
- public void testCollapsedTiming2() {
- Calendar startTime1 = Calendar.getInstance();
- Calendar endTime1 = Calendar.getInstance();
- endTime1.setTimeInMillis(startTime1.getTimeInMillis());
- endTime1.add(Calendar.SECOND, 20);
-
- Calendar startTime2 = Calendar.getInstance();
- startTime2.setTimeInMillis(endTime1.getTimeInMillis());
- Calendar endTime2 = Calendar.getInstance();
- endTime2.setTimeInMillis(startTime2.getTimeInMillis() + 20 * 1000);
-
- Calendar startTime3 = Calendar.getInstance();
- startTime3.setTimeInMillis(endTime2.getTimeInMillis());
- Calendar endTime3 = Calendar.getInstance();
- endTime3.setTimeInMillis(startTime3.getTimeInMillis() + 50 * 1000);
-
- InteractionContext mockContext = new InteractionContext("doitest", new InteractionContextScaling());
- InteractionEvent activityEvent1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, "handle",
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime1.getTime(), endTime1.getTime());
-
- InteractionEvent activityEvent3 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, "handle",
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime3.getTime(), endTime3.getTime());
-
- mockContext.parseEvent(activityEvent1);
- mockContext.parseEvent(activityEvent3);
- assertEquals(2, mockContext.getInteractionHistory().size());
- mockContext = ContextCorePlugin.getContextManager().collapseActivityMetaContext(mockContext);
- assertEquals(1, mockContext.getInteractionHistory().size());
- assertEquals(70 * 1000, mockContext.getInteractionHistory().get(0).getEndDate().getTime()
- - mockContext.getInteractionHistory().get(0).getDate().getTime());
- }
-
- public void testCollapsedExternalization() throws Exception {
-
- Calendar startTime1 = Calendar.getInstance();
- Calendar endTime1 = Calendar.getInstance();
- endTime1.setTime(startTime1.getTime());
- endTime1.add(Calendar.SECOND, 20);
-
- Calendar startTime2 = Calendar.getInstance();
- startTime2.add(Calendar.DAY_OF_MONTH, 1);
- Calendar endTime2 = Calendar.getInstance();
- endTime2.setTime(startTime2.getTime());
- endTime2.add(Calendar.SECOND, 20);
-
- AbstractTask task1 = new LocalTask("task 1", "Task 1");
- TasksUiPlugin.getTaskList().addTask(task1);
- InteractionContext metaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
- metaContext.reset();
- assertEquals(0, metaContext.getInteractionHistory().size());
-
- TasksUiPlugin.getTaskActivityManager().activateTask(task1);
-
- InteractionEvent activityEvent1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime1.getTime(), endTime1.getTime());
-
- InteractionEvent activityEvent2 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime2.getTime(), endTime2.getTime());
-
- metaContext.parseEvent(activityEvent1);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(activityEvent1, false);
- metaContext.parseEvent(activityEvent2);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(activityEvent2, false);
- TasksUiPlugin.getTaskActivityManager().deactivateActiveTask();
- assertEquals(4, ContextCorePlugin.getContextManager().getActivityMetaContext().getInteractionHistory().size());
-
- TaskTestUtil.saveNow();
- ContextCorePlugin.getContextManager().saveActivityMetaContext();
- ContextCorePlugin.getContextManager().getActivityMetaContext().reset();
- assertEquals(0, ContextCorePlugin.getContextManager().getActivityMetaContext().getInteractionHistory().size());
- ContextCorePlugin.getContextManager().loadActivityMetaContext();
-
- assertEquals(4, ContextCorePlugin.getContextManager().getActivityMetaContext().getInteractionHistory().size());
-
- TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
- assertEquals((endTime1.getTimeInMillis() - startTime1.getTimeInMillis())
- + (endTime2.getTimeInMillis() - startTime2.getTimeInMillis()), TasksUiPlugin.getTaskActivityManager()
- .getElapsedTime(task1));
- }
-
- public void testCollapsedTwoTasks() {
- // test collapsing of attention events when two or more
- // task attention events occur sequentially
- Calendar startTime1 = Calendar.getInstance();
- Calendar endTime1 = Calendar.getInstance();
- endTime1.setTimeInMillis(startTime1.getTimeInMillis());
- endTime1.add(Calendar.SECOND, 20);
-
- Calendar startTime2 = Calendar.getInstance();
- startTime2.setTime(endTime1.getTime());
- startTime2.add(Calendar.SECOND, 2);
- Calendar endTime2 = Calendar.getInstance();
- endTime2.setTime(startTime2.getTime());
- endTime2.add(Calendar.SECOND, 20);
-
- InteractionContext mockContext = new InteractionContext("doitest", new InteractionContextScaling());
- InteractionEvent activityEvent1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, "handle1",
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime1.getTime(), endTime1.getTime());
-
- InteractionEvent activityEvent2 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, "handle2",
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime2.getTime(), endTime2.getTime());
-
- mockContext.parseEvent(activityEvent1);
- mockContext.parseEvent(activityEvent2);
-
- // Since these event times are within same hour, normally they would get collapsed
- // here we test that if the event belongs to two different tasks remain discrete
-
- assertEquals(2, mockContext.getInteractionHistory().size());
- mockContext = ContextCorePlugin.getContextManager().collapseActivityMetaContext(mockContext);
- assertEquals(2, mockContext.getInteractionHistory().size());
- }
-
- public void testCollapeedByTheHour() {
- Calendar startTime1 = Calendar.getInstance();
- startTime1.set(Calendar.MINUTE, 2);
- startTime1.set(Calendar.SECOND, 0);
- startTime1.set(Calendar.MILLISECOND, 0);
-
- Calendar endTime1 = Calendar.getInstance();
- endTime1.setTime(startTime1.getTime());
- endTime1.add(Calendar.MINUTE, 2);
-
- Calendar startTime2 = Calendar.getInstance();
- startTime2.add(Calendar.HOUR_OF_DAY, 1);
- startTime2.set(Calendar.MINUTE, 2);
- startTime2.set(Calendar.SECOND, 0);
- startTime2.set(Calendar.MILLISECOND, 0);
-
- Calendar endTime2 = Calendar.getInstance();
- endTime2.setTime(startTime2.getTime());
- endTime2.add(Calendar.MINUTE, 3);
-
- Calendar startTime3 = Calendar.getInstance();
- startTime3.add(Calendar.HOUR_OF_DAY, 1);
- startTime3.set(Calendar.MINUTE, 20);
- startTime3.set(Calendar.SECOND, 0);
- startTime3.set(Calendar.MILLISECOND, 0);
-
- Calendar endTime3 = Calendar.getInstance();
- endTime3.setTime(startTime3.getTime());
- endTime3.add(Calendar.MINUTE, 5);
-
- AbstractTask task1 = new LocalTask("task 1", "Task 1");
- TasksUiPlugin.getTaskList().addTask(task1);
-
- InteractionEvent activityEvent1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime1.getTime(), endTime1.getTime());
-
- InteractionEvent activityEvent2 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime2.getTime(), endTime2.getTime());
-
- InteractionEvent activityEvent3 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime3.getTime(), endTime3.getTime());
-
- List<InteractionEvent> events = new ArrayList<InteractionEvent>();
- events.add(activityEvent1);
- events.add(activityEvent2);
- events.add(activityEvent3);
- List<InteractionEvent> collapsedEvents = ContextCorePlugin.getContextManager().collapseEventsByHour(events);
-
- assertEquals(2, collapsedEvents.size());
- }
-
- public void testTaskListManagerInactivity() {
-
- AbstractTask task1 = new LocalTask("task 1", "Task 1");
- TasksUiPlugin.getTaskList().addTask(task1);
-
- ScheduledTaskContainer activityThisWeek = new ScheduledTaskContainer(TasksUiPlugin.getTaskActivityManager(),
- TaskActivityUtil.getCurrentWeek());
- assertNotNull(activityThisWeek);
- assertEquals(0, activityThisWeek.getChildren().size());
-
- InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
- task1.getHandleIdentifier(), "originId", "navigatedRelation",
- InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, activityThisWeek.getStart().getTime(),
- activityThisWeek.getStart().getTime());
- InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
- task1.getHandleIdentifier(), "originId", "navigatedRelation",
- InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f, activityThisWeek.getEnd().getTime(),
- activityThisWeek.getEnd().getTime());
-
- Calendar activityStart = Calendar.getInstance();
- Calendar activityEnd = Calendar.getInstance();
- activityEnd.setTimeInMillis(activityStart.getTimeInMillis());
- activityEnd.add(Calendar.HOUR_OF_DAY, 1);
-
- InteractionEvent activityEvent = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, activityStart.getTime(), activityEnd.getTime());
-
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event1, false);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(activityEvent, false);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event2, false);
-
- long expectedTotalTime = (activityEnd.getTime().getTime() - activityStart.getTime().getTime());
- assertEquals(expectedTotalTime, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1));
- }
-
- public void testElapsedSameAfterRead() throws Exception {
- // test that granularity of elapsed time map is retained after
- // being re-read from disk
-
- Calendar startTime1 = Calendar.getInstance();
- startTime1.set(Calendar.MINUTE, 2);
- startTime1.set(Calendar.SECOND, 0);
- startTime1.set(Calendar.MILLISECOND, 0);
-
- Calendar endTime1 = Calendar.getInstance();
- endTime1.setTime(startTime1.getTime());
- endTime1.add(Calendar.MINUTE, 2);
-
- Calendar startTime2 = Calendar.getInstance();
- startTime2.add(Calendar.HOUR_OF_DAY, 1);
- startTime2.set(Calendar.MINUTE, 2);
- startTime2.set(Calendar.SECOND, 0);
- startTime2.set(Calendar.MILLISECOND, 0);
-
- Calendar endTime2 = Calendar.getInstance();
- endTime2.setTime(startTime2.getTime());
- endTime2.add(Calendar.MINUTE, 3);
-
- Calendar startTime3 = Calendar.getInstance();
- startTime3.add(Calendar.HOUR_OF_DAY, 1);
- startTime3.set(Calendar.MINUTE, 20);
- startTime3.set(Calendar.SECOND, 0);
- startTime3.set(Calendar.MILLISECOND, 0);
-
- Calendar endTime3 = Calendar.getInstance();
- endTime3.setTime(startTime3.getTime());
- endTime3.add(Calendar.MINUTE, 5);
-
- AbstractTask task1 = new LocalTask("task 1", "Task 1");
- TasksUiPlugin.getTaskList().addTask(task1);
- TasksUiPlugin.getTaskActivityManager().activateTask(task1);
- InteractionContext metaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
- metaContext.reset();
- assertEquals(0, metaContext.getInteractionHistory().size());
-
- InteractionEvent activityEvent1 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime1.getTime(), endTime1.getTime());
-
- InteractionEvent activityEvent2 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime2.getTime(), endTime2.getTime());
-
- InteractionEvent activityEvent3 = new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(),
- InteractionContextManager.ACTIVITY_ORIGINID_WORKBENCH, null,
- InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startTime3.getTime(), endTime3.getTime());
-
- metaContext.parseEvent(activityEvent1);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(activityEvent1, false);
- metaContext.parseEvent(activityEvent2);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(activityEvent2, false);
- metaContext.parseEvent(activityEvent3);
- TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(activityEvent3, false);
-
- assertEquals(1000 * 60 * 10, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1));
- assertEquals(1000 * 60 * 2, activityManager.getElapsedTime(task1, startTime1, endTime1));
- assertEquals(1000 * 60 * 8, activityManager.getElapsedTime(task1, startTime2, endTime2));
-
- TasksUi.getTaskActivityManager().deactivateActiveTask();
- assertEquals(4, ContextCorePlugin.getContextManager().getActivityMetaContext().getInteractionHistory().size());
- TaskTestUtil.saveNow();
- ContextCorePlugin.getContextManager().saveActivityMetaContext();
- ContextCorePlugin.getContextManager().getActivityMetaContext().reset();
- assertEquals(0, ContextCorePlugin.getContextManager().getActivityMetaContext().getInteractionHistory().size());
- TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
- assertEquals(0, activityManager.getElapsedTime(task1));
- assertEquals(0, activityManager.getElapsedTime(task1, startTime1, endTime1));
- assertEquals(0, activityManager.getElapsedTime(task1, startTime2, endTime2));
-
- ContextCorePlugin.getContextManager().loadActivityMetaContext();
- assertEquals(3, ContextCorePlugin.getContextManager().getActivityMetaContext().getInteractionHistory().size());
- TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
-
- startTime1 = Calendar.getInstance();
- startTime1.set(Calendar.MINUTE, 0);
- startTime1.set(Calendar.SECOND, 0);
- startTime1.set(Calendar.MILLISECOND, 0);
-
- assertEquals(1000 * 60 * 10, activityManager.getElapsedTime(task1));
- assertEquals(1000 * 60 * 2, activityManager.getElapsedTime(task1, startTime1, endTime1));
- assertEquals(1000 * 60 * 8, activityManager.getElapsedTime(task1, startTime2, endTime2));
- }
-
- /**
- * @author Yuri Baburov (burchik@gmail.com)
- * @author Rob Elves adaption to test LegacyActivityAdaptor
- */
- public void testLegacyTimingMigration() {
- AbstractTask task1 = new LocalTask("task 1", "Task 1");
- TasksUiPlugin.getTaskList().addTask(task1);
-
-// ScheduledTaskContainer thisWeekActivity = new ScheduledTaskContainer(TasksUiPlugin.getTaskActivityManager(),
-// TaskActivityUtil.getCurrentWeek());
-//
-// assertNotNull(thisWeekActivity);
-// assertEquals(0, thisWeekActivity.getChildren().size());
-// thisWeekActivity.getStart().setTimeInMillis(1149490800000L);
-// // Start
-// // of
-// // the
-// // week
-// // Jun 5
-// // 2006
-// // - Jun
-// // 11
-// // 2006,
-// // NOVST
-// thisWeekActivity.getEnd().setTimeInMillis(1150095600000L); // End of
-// // the week
-
- Date time1 = new Date(1150007053171L); // Sun Jun 11 13:24:13 NOVST
- // 2006 - task 1 - activated
- Date time2 = new Date(1150007263468L); // Sun Jun 11 13:27:43 NOVST
- // 2006 - attention -
- // deactivated
- Date time3 = new Date(1150021535953L); // Sun Jun 11 17:25:35 NOVST
- // 2006 - attention - activated
- Date time4 = new Date(1150021658500L); // Sun Jun 11 17:27:38 NOVST
- // 2006 - attention -
- // deactivated
- Date time5 = new Date(1150031089250L); // Sun Jun 11 20:04:49 NOVST
- // 2006 - attention - activated
- Date time6 = new Date(1150031111578L); // Sun Jun 11 20:05:11 NOVST
- // 2006 - attention -
- // deactivated
- Date time7 = new Date(1150031111578L); // Sun Jun 11 20:05:11 NOVST
- // 2006 - task 1 - deactivated
-
- String task1handle = task1.getHandleIdentifier();
- InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind", task1handle,
- "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, time1, time1);
-
- InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind", "attention",
- "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, time1, time2);
- InteractionEvent event3 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind", "attention",
- "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, time3, time4);
- InteractionEvent event5 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind", "attention",
- "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, time5, time6);
- InteractionEvent event7 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind", task1handle,
- "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f, time7, time7);
-
- LegacyActivityAdaptor legacyAdaptor = new LegacyActivityAdaptor();
- TasksUiPlugin.getTaskActivityMonitor()
- .parseInteractionEvent(legacyAdaptor.parseInteractionEvent(event1), false);
- TasksUiPlugin.getTaskActivityMonitor()
- .parseInteractionEvent(legacyAdaptor.parseInteractionEvent(event2), false);
- TasksUiPlugin.getTaskActivityMonitor()
- .parseInteractionEvent(legacyAdaptor.parseInteractionEvent(event3), false);
- // TasksUiPlugin.getTaskListManager().parseInteractionEvent(event4);
- TasksUiPlugin.getTaskActivityMonitor()
- .parseInteractionEvent(legacyAdaptor.parseInteractionEvent(event5), false);
- // TaskActivityManager.getInstance().parseInteractionEvent(event6);
- TasksUiPlugin.getTaskActivityMonitor()
- .parseInteractionEvent(legacyAdaptor.parseInteractionEvent(event7), false);
- long expectedTotalTime = time6.getTime() - time5.getTime() + time4.getTime() - time3.getTime()
- + time2.getTime() - time1.getTime();
- assertEquals(expectedTotalTime, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1));
- }
-
-// DND: OLD ACTIVITY TESTS - Will be using to test activity report/view
-// public void testInterleavedActivation() {
-//
-// AbstractTask task1 = new LocalTask("task 1", "Task 1");
-// TasksUiPlugin.getTaskList().addTask(task1);
-//
-// ScheduledTaskContainer activityThisWeek = TasksUiPlugin.getTaskListManager().getActivityThisWeek();
-// assertNotNull(activityThisWeek);
-// assertEquals(0, activityThisWeek.getChildren().size());
-//
-// Calendar taskActivationStart = GregorianCalendar.getInstance();
-// taskActivationStart.add(Calendar.MILLISECOND, 15);
-// Calendar taskActivationStop = GregorianCalendar.getInstance();
-// taskActivationStop.add(Calendar.MILLISECOND, 25);
-//
-// Calendar inactivityStart1 = GregorianCalendar.getInstance();
-// inactivityStart1.add(Calendar.MILLISECOND, 5);
-// Calendar inactivityStop1 = GregorianCalendar.getInstance();
-// inactivityStop1.add(Calendar.MILLISECOND, 10);
-//
-// Calendar inactivityStart2 = GregorianCalendar.getInstance();
-// inactivityStart2.add(Calendar.MILLISECOND, 18);
-// Calendar inactivityStop2 = GregorianCalendar.getInstance();
-// inactivityStop2.add(Calendar.MILLISECOND, 25);
-//
-// InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
-// task1.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, taskActivationStart.getTime(),
-// taskActivationStart.getTime());
-// InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
-// task1.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f, taskActivationStop.getTime(),
-// taskActivationStop.getTime());
-//
-// InteractionEvent inactivityEvent1 = new InteractionEvent(InteractionEvent.Kind.COMMAND, "structureKind",
-// task1.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f, inactivityStart1.getTime(),
-// inactivityStop1.getTime());
-// InteractionEvent inactivityEvent2 = new InteractionEvent(InteractionEvent.Kind.COMMAND, "structureKind",
-// task1.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, inactivityStart2.getTime(),
-// inactivityStop2.getTime());
-//
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(inactivityEvent1);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event1);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event2);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(inactivityEvent2);
-// assertEquals(1, activityThisWeek.getChildren().size());
-//
-// // long expectedTotalTime = taskActivationStop.getTimeInMillis() -
-// // taskActivationStart.getTimeInMillis();
-// long expectedTotalTime = 0;
-// assertEquals(expectedTotalTime, activityThisWeek.getTotalElapsed());
-// assertEquals(expectedTotalTime, activityThisWeek.getElapsed(new ScheduledTaskDelegate(activityThisWeek, task1,
-// null, null)));
-// }
-//
-// public void testInterleavedActivation2() {
-//
-// AbstractTask task1 = new LocalTask("task 1", "Task 1");
-// TasksUiPlugin.getTaskList().addTask(task1);
-//
-// ScheduledTaskContainer activityThisWeek = TasksUiPlugin.getTaskListManager().getActivityThisWeek();
-// assertNotNull(activityThisWeek);
-// assertEquals(0, activityThisWeek.getChildren().size());
-//
-// Calendar taskActivationStart = GregorianCalendar.getInstance();
-// taskActivationStart.add(Calendar.MILLISECOND, 10);
-// Calendar taskActivationStop = GregorianCalendar.getInstance();
-// taskActivationStop.add(Calendar.MILLISECOND, 25);
-//
-// Calendar inactivityStart = GregorianCalendar.getInstance();
-// inactivityStart.add(Calendar.MILLISECOND, 15);
-// Calendar inactivityStop = GregorianCalendar.getInstance();
-// inactivityStop.add(Calendar.MILLISECOND, 20);
-//
-// InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
-// task1.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, taskActivationStart.getTime(),
-// taskActivationStart.getTime());
-// InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
-// task1.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f, taskActivationStop.getTime(),
-// taskActivationStop.getTime());
-//
-// InteractionEvent inactivityEvent1 = new InteractionEvent(InteractionEvent.Kind.COMMAND, "structureKind",
-// task1.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_ADDED, 2f, inactivityStart.getTime(),
-// inactivityStop.getTime());
-//
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event1);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(inactivityEvent1);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event1);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(inactivityEvent1);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event2);
-//
-// assertEquals(1, activityThisWeek.getChildren().size());
-//
-// long expectedTotalTime = 2 * (inactivityStart.getTimeInMillis() - taskActivationStart.getTimeInMillis());
-// assertEquals(expectedTotalTime, activityThisWeek.getTotalElapsed());
-// assertEquals(expectedTotalTime, activityThisWeek.getElapsed(new ScheduledTaskDelegate(activityThisWeek, task1,
-// null, null)));
-// }
-//
-//
-// /**
-// * Some 'attention' events when all tasks are inactive
-// *
-// * @author Yuri Baburov (burchik@gmail.com)
-// */
-// public void testTaskListManagerActivity2() {
-// AbstractTask task1 = new LocalTask("task 1", "Task 1");
-// TasksUiPlugin.getTaskList().addTask(task1);
-// ScheduledTaskContainer thisWeekActivity = TasksUiPlugin.getTaskListManager().getActivityThisWeek();
-// assertNotNull(thisWeekActivity);
-// assertEquals(0, thisWeekActivity.getChildren().size());
-// assertEquals(0, thisWeekActivity.getTotalElapsed());
-// thisWeekActivity.getStart().setTimeInMillis(1149490800000L); // Start
-// // of
-// // the
-// // week
-// // Jun 5
-// // 2006
-// // - Jun
-// // 11
-// // 2006,
-// // NOVST
-// thisWeekActivity.getEnd().setTimeInMillis(1150095600000L); // End of
-// // the week
-//
-// Date time1 = new Date(1149911820812L); // Sat Jun 10 10:57:00 NOVST
-// // 2006 - task 1 - activated
-// Date time2 = new Date(1149911820812L); // Sat Jun 10 10:57:00 NOVST
-// // 2006 - task 1 - deactivated
-// Date time3 = new Date(1149911840812L); // Sat Jun 10 10:57:20 NOVST
-// // 2006 - attention -
-// // deactivated
-// Date time4 = new Date(1149911941765L); // Sat Jun 10 10:59:01 NOVST
-// // 2006 - attention - activated
-// Date time5 = new Date(1149911948953L); // Sat Jun 10 10:59:08 NOVST
-// // 2006 - task 1 - activated
-// Date time6 = new Date(1149911988781L); // Sat Jun 10 10:59:48 NOVST
-// // 2006 - task 1 - deactivated
-//
-// String task1handle = task1.getHandleIdentifier();
-// InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind", task1handle,
-// "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, time1, time1);
-// InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind", task1handle,
-// "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f, time2, time2);
-// InteractionEvent event3 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind", "attention",
-// "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f, time3, time3);
-// InteractionEvent event4 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind", "attention",
-// "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, time4, time4);
-// InteractionEvent event5 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind", task1handle,
-// "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, time5, time5);
-// InteractionEvent event6 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind", task1handle,
-// "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f, time6, time6);
-//
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event1);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event2);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event3);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event4);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event5);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event6);
-// assertEquals(1, thisWeekActivity.getChildren().size());
-// long expectedTotalTime = 0;// time6.getTime() - time5.getTime() +
-// // time2.getTime() - time1.getTime();
-// assertEquals(expectedTotalTime, thisWeekActivity.getTotalElapsed());
-// assertEquals(expectedTotalTime, TasksUiPlugin.getTaskListManager().getElapsedTime(task1));
-// assertEquals(expectedTotalTime, thisWeekActivity.getElapsed(new ScheduledTaskDelegate(thisWeekActivity, task1,
-// null, null)));
-// }
-//
-// public void testTaskListManagerActivity() {
-//
-// AbstractTask task1 = new LocalTask("task 1", "Task 1");
-// AbstractTask task2 = new LocalTask("task 2", "Task 2");
-// TasksUiPlugin.getTaskList().addTask(task1);
-// TasksUiPlugin.getTaskList().addTask(task2);
-//
-// // test this week
-// ScheduledTaskContainer thisWeekActivity = TasksUiPlugin.getTaskListManager().getActivityThisWeek();
-// assertNotNull(thisWeekActivity);
-// assertEquals(0, thisWeekActivity.getChildren().size());
-// assertEquals(0, thisWeekActivity.getTotalElapsed());
-// Calendar thisWeekCalendarStart = GregorianCalendar.getInstance();
-// thisWeekCalendarStart.setTime(thisWeekActivity.getStart().getTime());
-// Calendar thisWeekCalendarStop = GregorianCalendar.getInstance();
-// thisWeekCalendarStop.setTime(thisWeekActivity.getStart().getTime());
-// thisWeekCalendarStop.add(Calendar.MILLISECOND, 2);
-// assertTrue(thisWeekActivity.includes(thisWeekCalendarStart));
-//
-// InteractionEvent event1 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
-// task1.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, thisWeekCalendarStart.getTime(),
-// thisWeekCalendarStart.getTime());
-// InteractionEvent event2 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
-// task1.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f, thisWeekCalendarStop.getTime(),
-// thisWeekCalendarStop.getTime());
-//
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event1);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event2);
-// assertEquals(1, thisWeekActivity.getChildren().size());
-// assertEquals(0, thisWeekActivity.getTotalElapsed());
-// // assertEquals(thisWeekCalendarStop.getTime().getTime() -
-// // thisWeekCalendarStart.getTime().getTime(),
-// // thisWeekActivity.getTotalElapsed());
-//
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event1);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event2);
-// assertEquals(1, thisWeekActivity.getChildren().size());
-// // assertEquals(2 * (thisWeekCalendarStop.getTime().getTime() -
-// // thisWeekCalendarStart.getTime().getTime()),
-// // thisWeekActivity.getTotalElapsed());
-// // assertEquals(2 * (thisWeekCalendarStop.getTime().getTime() -
-// // thisWeekCalendarStart.getTime().getTime()),
-// // thisWeekActivity.getElapsed(new
-// // DateRangeActivityDelegate(thisWeekActivity, task1, null, null)));
-//
-// // multiple tasks in category
-// event1 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind", task2.getHandleIdentifier(),
-// "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f,
-// thisWeekCalendarStart.getTime(), thisWeekCalendarStart.getTime());
-// event2 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind", task2.getHandleIdentifier(),
-// "originId", "navigatedRelation", InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f,
-// thisWeekCalendarStop.getTime(), thisWeekCalendarStop.getTime());
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event1);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event2);
-// assertEquals(2, thisWeekActivity.getChildren().size());
-//
-// // test Past
-// ScheduledTaskContainer pastActivity = TasksUiPlugin.getTaskListManager().getActivityPast();
-// assertNotNull(pastActivity);
-// assertEquals(0, pastActivity.getChildren().size());
-//
-// InteractionEvent event3 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
-// task2.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, pastActivity.getStart().getTime(),
-// pastActivity.getStart().getTime());
-// InteractionEvent event4 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
-// task2.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f, pastActivity.getEnd().getTime(),
-// pastActivity.getEnd().getTime());
-//
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event3);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event4);
-// assertEquals(1, pastActivity.getChildren().size());
-//
-// // test Future
-// ScheduledTaskContainer futureActivity = TasksUiPlugin.getTaskListManager().getActivityFuture();
-// assertNotNull(futureActivity);
-// assertEquals(0, futureActivity.getChildren().size());
-//
-// InteractionEvent event5 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
-// task2.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, futureActivity.getStart().getTime(),
-// futureActivity.getStart().getTime());
-// InteractionEvent event6 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
-// task2.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f, futureActivity.getEnd().getTime(),
-// futureActivity.getEnd().getTime());
-//
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event5);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event6);
-// // No longer adding activity to future bins (days of week, next week, or
-// // future)
-// assertEquals(0, futureActivity.getChildren().size());
-//
-// // test Next week activity
-// ScheduledTaskContainer activityNextWeek = TasksUiPlugin.getTaskListManager().getActivityNextWeek();
-// assertNotNull(activityNextWeek);
-// assertEquals(0, activityNextWeek.getChildren().size());
-//
-// InteractionEvent event7 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
-// task2.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, activityNextWeek.getStart().getTime(),
-// activityNextWeek.getStart().getTime());
-// InteractionEvent event8 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
-// task2.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f, activityNextWeek.getEnd().getTime(),
-// activityNextWeek.getEnd().getTime());
-//
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event7);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event8);
-// // No longer adding activity to future bins (days of week, next week, or
-// // future)
-// assertEquals(0, activityNextWeek.getChildren().size());
-//
-// // test Previous week activity
-// ScheduledTaskContainer activityPreviousWeek = TasksUiPlugin.getTaskListManager().getActivityPrevious();
-// assertNotNull(activityPreviousWeek);
-// assertEquals(0, activityPreviousWeek.getChildren().size());
-//
-// InteractionEvent event9 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
-// task2.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_ACTIVATED, 2f, activityPreviousWeek.getStart().getTime(),
-// activityPreviousWeek.getStart().getTime());
-// InteractionEvent event10 = new InteractionEvent(InteractionEvent.Kind.SELECTION, "structureKind",
-// task2.getHandleIdentifier(), "originId", "navigatedRelation",
-// InteractionContextManager.ACTIVITY_DELTA_DEACTIVATED, 2f, activityPreviousWeek.getEnd().getTime(),
-// activityPreviousWeek.getEnd().getTime());
-//
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event9);
-// TasksUiPlugin.getTaskListManager().parseInteractionEvent(event10);
-// assertEquals(1, activityPreviousWeek.getChildren().size());
-// }
-
-}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataImportTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataImportTest.java
index ab96d6b57..7eb4436a1 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataImportTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataImportTest.java
@@ -15,10 +15,9 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import junit.framework.TestCase;
+
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.mylyn.context.tests.AbstractContextTest;
-import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
-import org.eclipse.mylyn.internal.context.core.InteractionContext;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.LocalTask;
import org.eclipse.mylyn.internal.tasks.core.TaskList;
@@ -37,7 +36,7 @@ import org.eclipse.ui.internal.Workbench;
* @author Rob Elves
* @author Steffen Pingel
*/
-public class TaskDataImportTest extends AbstractContextTest {
+public class TaskDataImportTest extends TestCase {
private TaskDataImportWizard wizard = null;
@@ -67,14 +66,14 @@ public class TaskDataImportTest extends AbstractContextTest {
TaskTestUtil.resetTaskListAndRepositories();
taskList = TasksUiPlugin.getTaskList();
- ContextCorePlugin.getContextManager().getActivityMetaContext().reset();
+// ContextCorePlugin.getContextManager().getActivityMetaContext().reset();
}
@Override
protected void tearDown() throws Exception {
wizard.dispose();
wizardPage.dispose();
- ContextCorePlugin.getContextManager().resetActivityMetaContext();
+// ContextCorePlugin.getContextManager().resetActivityMetaContext();
TaskTestUtil.resetTaskListAndRepositories();
super.tearDown();
}
@@ -108,32 +107,32 @@ public class TaskDataImportTest extends AbstractContextTest {
* Tests the wizard when it has been asked to import all task data from a zip file
*/
public void testImportRepositoriesZip() {
- InteractionContext historyContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
+// InteractionContext historyContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
assertNotNull(taskList);
- assertNotNull(historyContext);
+// assertNotNull(historyContext);
assertTrue(taskList.getAllTasks().size() == 0);
- assertTrue(historyContext.getInteractionHistory().size() == 0);
+// assertTrue(historyContext.getInteractionHistory().size() == 0);
wizardPage.setSource(true, TaskTestUtil.getLocalFile(BACKUP_v1).getAbsolutePath());
wizard.performFinish();
Collection<AbstractTask> tasks = taskList.getAllTasks();
assertEquals(2, tasks.size());
- for (AbstractTask task : tasks) {
- assertTrue(ContextCorePlugin.getContextManager().hasContext(task.getHandleIdentifier()));
- }
- historyContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
- assertNotNull(historyContext);
- assertTrue(historyContext.getInteractionHistory().size() > 0);
+// for (AbstractTask task : tasks) {
+// assertTrue(ContextCorePlugin.getContextManager().hasContext(task.getHandleIdentifier()));
+// }
+// historyContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
+// assertNotNull(historyContext);
+// assertTrue(historyContext.getInteractionHistory().size() > 0);
assertTrue(TasksUiPlugin.getRepositoryManager().getAllRepositories().size() > 2);
}
public void testImportOverwritesAllTasks() {
- InteractionContext historyContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
+// InteractionContext historyContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
assertNotNull(taskList);
- assertNotNull(historyContext);
+// assertNotNull(historyContext);
assertTrue(taskList.getAllTasks().size() == 0);
- assertTrue(historyContext.getInteractionHistory().size() == 0);
+// assertTrue(historyContext.getInteractionHistory().size() == 0);
AbstractTask task1 = new LocalTask("999", "label");
taskList.addTask(task1);
@@ -146,12 +145,12 @@ public class TaskDataImportTest extends AbstractContextTest {
tasks = taskList.getAllTasks();
assertEquals(2, tasks.size());
assertTrue(!taskList.getAllTasks().contains(task1));
- for (AbstractTask task : tasks) {
- assertTrue(ContextCorePlugin.getContextManager().hasContext(task.getHandleIdentifier()));
- }
- historyContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
- assertNotNull(historyContext);
- assertTrue(historyContext.getInteractionHistory().size() > 0);
+// for (AbstractTask task : tasks) {
+// assertTrue(ContextCorePlugin.getContextManager().hasContext(task.getHandleIdentifier()));
+// }
+// historyContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
+// assertNotNull(historyContext);
+// assertTrue(historyContext.getInteractionHistory().size() > 0);
assertTrue(TasksUiPlugin.getRepositoryManager().getAllRepositories().size() > 2);
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskExportImportTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskExportImportTest.java
index 35c9b5a90..e7c3704fd 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskExportImportTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskExportImportTest.java
@@ -11,13 +11,13 @@
package org.eclipse.mylyn.tasks.tests;
-import org.eclipse.mylyn.context.tests.AbstractContextTest;
+import junit.framework.TestCase;
/**
* @author Jevgeni Holodkov
*/
//FIXME fix test
-public class TaskExportImportTest extends AbstractContextTest {
+public class TaskExportImportTest extends TestCase {
public void testRewriteTestCases() {
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/ContextPerspectiveManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/ContextPerspectiveManagerTest.java
deleted file mode 100644
index 27598ad0a..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/ContextPerspectiveManagerTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.ui;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.context.tests.support.ContextTestUtil;
-import org.eclipse.mylyn.internal.context.ui.ContextUiPlugin;
-import org.eclipse.mylyn.internal.context.ui.IContextUiPreferenceContstants;
-import org.eclipse.mylyn.internal.tasks.core.TaskTask;
-import org.eclipse.mylyn.tasks.tests.TaskTestUtil;
-import org.eclipse.mylyn.tasks.ui.TasksUi;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Steffen Pingel
- */
-public class ContextPerspectiveManagerTest extends TestCase {
-
- private static final String ID_RESOURCE_PERSPECTIVE = "org.eclipse.ui.resourcePerspective";
-
- private static final String ID_PLANNING_PERSPECTIVE = "org.eclipse.mylyn.tasks.ui.perspectives.planning";
-
- private boolean previousSetting;
-
- @Override
- protected void setUp() throws Exception {
- ContextTestUtil.triggerContextUiLazyStart();
-
- TaskTestUtil.resetTaskListAndRepositories();
- previousSetting = ContextUiPlugin.getDefault()
- .getPreferenceStore()
- .getBoolean(IContextUiPreferenceContstants.AUTO_MANAGE_PERSPECTIVES);
- ContextUiPlugin.getDefault()
- .getPreferenceStore()
- .setValue(IContextUiPreferenceContstants.AUTO_MANAGE_PERSPECTIVES, true);
- }
-
- @Override
- protected void tearDown() throws Exception {
- ContextUiPlugin.getDefault()
- .getPreferenceStore()
- .setValue(IContextUiPreferenceContstants.AUTO_MANAGE_PERSPECTIVES, previousSetting);
- TaskTestUtil.resetTaskListAndRepositories();
- }
-
- public void testRestorePerspective() throws Exception {
- PlatformUI.getWorkbench().showPerspective(ID_RESOURCE_PERSPECTIVE, getWorkbenchWindow());
- assertEquals(ID_RESOURCE_PERSPECTIVE, getActivePerspective());
- TaskTask task = TaskTestUtil.createMockTask("1");
-
- // check that perspective is not switched for new task
- TasksUi.getTaskActivityManager().activateTask(task);
- assertEquals(ID_RESOURCE_PERSPECTIVE, getActivePerspective());
-
- // check if previous perspective is restored on deactivation
- PlatformUI.getWorkbench().showPerspective(ID_PLANNING_PERSPECTIVE, getWorkbenchWindow());
- assertEquals(ID_PLANNING_PERSPECTIVE, getActivePerspective());
- TasksUi.getTaskActivityManager().deactivateActiveTask();
- assertEquals(ID_RESOURCE_PERSPECTIVE, getActivePerspective());
-
- // check if perspective is restored on activation
- TasksUi.getTaskActivityManager().activateTask(task);
- assertEquals(ID_PLANNING_PERSPECTIVE, getActivePerspective());
- }
-
- // FIXME 3.5 re-enable test
-// public void testRecreateTask() throws Exception {
-// PlatformUI.getWorkbench().showPerspective(ID_RESOURCE_PERSPECTIVE, MonitorUi.getLaunchingWorkbenchWindow());
-// TaskTask task = TaskTestUtil.createMockTask("1");
-//
-// // check that deleting task switches back to original perspective
-// TasksUi.getTaskActivityManager().activateTask(task);
-// PlatformUI.getWorkbench().showPerspective(ID_PLANNING_PERSPECTIVE, MonitorUi.getLaunchingWorkbenchWindow());
-// TasksUiPlugin.getTaskActivityManager().deactivateActiveTask();
-// TasksUiPlugin.getTaskList().deleteTask(task);
-// assertEquals(ID_RESOURCE_PERSPECTIVE, getActivePerspective());
-//
-// task = TaskTestUtil.createMockTask("1");
-//
-// // check that activating new task with the same id does not switch the perspective
-// TasksUi.getTaskActivityManager().activateTask(task);
-// assertEquals(ID_RESOURCE_PERSPECTIVE, getActivePerspective());
-// }
-
- private IWorkbenchWindow getWorkbenchWindow() {
- IWorkbenchWindow window = ContextUiPlugin.getPerspectiveManager().getWorkbenchWindow();
- assertNotNull(window);
- return window;
- }
-
- private String getActivePerspective() {
- return getWorkbenchWindow().getActivePage().getPerspective().getId();
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ActiveContextExternalizationParticipant.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ActiveContextExternalizationParticipant.java
deleted file mode 100644
index 745932886..000000000
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ActiveContextExternalizationParticipant.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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;
-
-import java.io.File;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.mylyn.context.core.AbstractContextListener;
-import org.eclipse.mylyn.context.core.ContextChangeEvent;
-import org.eclipse.mylyn.context.core.ContextCore;
-import org.eclipse.mylyn.context.core.IInteractionContext;
-import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
-import org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin;
-import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
-import org.eclipse.mylyn.internal.tasks.core.externalization.AbstractExternalizationParticipant;
-import org.eclipse.mylyn.internal.tasks.core.externalization.ExternalizationManager;
-import org.eclipse.mylyn.internal.tasks.core.externalization.IExternalizationContext;
-import org.eclipse.mylyn.monitor.ui.IUserAttentionListener;
-import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.ITaskActivityListener;
-import org.eclipse.mylyn.tasks.ui.TasksUi;
-
-/**
- * This externalization participant only handles saving the active context periodically. No snapshots are taken and task
- * activation and deactivation control the load and final write of the context in InteractionContextManager.
- *
- * @author Shawn Minto
- */
-@SuppressWarnings("restriction")
-public class ActiveContextExternalizationParticipant extends AbstractExternalizationParticipant implements
- ITaskActivityListener, IUserAttentionListener {
- private boolean isDirty = false;
-
- private final ExternalizationManager manager;
-
- private long lastUpdate;
-
- private IInteractionContext currentlyActiveContext;
-
- private final AbstractContextListener listener = new AbstractContextListener() {
- @Override
- public void contextChanged(ContextChangeEvent event) {
- switch (event.getEventKind()) {
- case ACTIVATED:
- currentlyActiveContext = event.getContext();
- break;
- case DEACTIVATED:
- currentlyActiveContext = null;
- setDirty(false);
- break;
- }
- }
- };
-
- public ActiveContextExternalizationParticipant(ExternalizationManager manager) {
- this.manager = manager;
- }
-
- public void registerListeners() {
- ContextCore.getContextManager().addListener(listener);
- TasksUi.getTaskActivityManager().addActivityListener(this);
- (MonitorUiPlugin.getDefault().getActivityContextManager()).addListener(this);
- currentlyActiveContext = ContextCore.getContextManager().getActiveContext();
- }
-
- // currently not called since no way to remove a participant
- public void dispose() {
- ContextCore.getContextManager().removeListener(listener);
- TasksUi.getTaskActivityManager().removeActivityListener(this);
- if (MonitorUiPlugin.getDefault().getActivityContextManager() != null) {
- (MonitorUiPlugin.getDefault().getActivityContextManager()).removeListener(this);
- }
- }
-
- @Override
- public void execute(IExternalizationContext context, IProgressMonitor monitor) throws CoreException {
- Assert.isNotNull(context);
- switch (context.getKind()) {
- case SAVE:
- if (shouldWriteContext()) {
- setDirty(false);
- ContextCorePlugin.getContextManager().saveContext(currentlyActiveContext);
- }
- break;
- case LOAD:
- // ignore loads since we will do this synchronously with task activation
- break;
- case SNAPSHOT:
- // ignore snapshots
- break;
- }
- }
-
- @Override
- public String getDescription() {
- return Messages.ActiveContextExternalizationParticipant_Active_Task_Context;
- }
-
- @Override
- public ISchedulingRule getSchedulingRule() {
- return ITasksCoreConstants.ACTIVE_CONTEXT_SCHEDULING_RULE;
- }
-
- @Override
- public boolean isDirty() {
- return isDirty(false);
- }
-
- @Override
- public boolean isDirty(boolean full) {
- synchronized (this) {
- return isDirty || (full && shouldWriteContext());
- }
- }
-
- public void setDirty(boolean dirty) {
- synchronized (this) {
- isDirty = dirty;
- }
- }
-
- @Override
- public String getFileName() {
- // ignore
- return null;
- }
-
- @Override
- public void load(File sourceFile, IProgressMonitor monitor) throws CoreException {
- // ignore see execute method
- }
-
- @Override
- public void save(File targetFile, IProgressMonitor monitor) throws CoreException {
- // ignore see execute method
- }
-
- public void elapsedTimeUpdated(ITask task, long newElapsedTime) {
- if (System.currentTimeMillis() - lastUpdate > 1000 * 60 * 3) {
- // TODO TYR TO CHECK IF IT IS DIRTY AND IT EXISTS
- setDirty(shouldWriteContext());
- if (isDirty()) {
- manager.requestSave();
- }
- lastUpdate = System.currentTimeMillis();
- }
- }
-
- private boolean shouldWriteContext() {
- if (ContextCorePlugin.getContextManager() != null && currentlyActiveContext != null
- && currentlyActiveContext.getAllElements().size() > 0) {
- // we could add a check here for whether there were changes to the context
- return true;
- }
- return false;
- }
-
- public void activityReset() {
- // ignore
- }
-
- public void userAttentionGained() {
- // ignore
- }
-
- public void userAttentionLost() {
- setDirty(shouldWriteContext());
- if (isDirty()) {
- manager.requestSave();
- }
- lastUpdate = System.currentTimeMillis();
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ActivityExternalizationParticipant.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ActivityExternalizationParticipant.java
deleted file mode 100644
index 19af29c93..000000000
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ActivityExternalizationParticipant.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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;
-
-import java.io.File;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
-import org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin;
-import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
-import org.eclipse.mylyn.internal.tasks.core.externalization.AbstractExternalizationParticipant;
-import org.eclipse.mylyn.internal.tasks.core.externalization.ExternalizationManager;
-import org.eclipse.mylyn.internal.tasks.core.externalization.IExternalizationContext;
-import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.ITaskActivityListener;
-
-/**
- * @author Rob Elves
- */
-@SuppressWarnings("restriction")
-public class ActivityExternalizationParticipant extends AbstractExternalizationParticipant implements
- ITaskActivityListener {
-
- private boolean isDirty = false;
-
- private final ExternalizationManager manager;
-
- private long lastUpdate;
-
- public ActivityExternalizationParticipant(ExternalizationManager manager) {
- this.manager = manager;
- MonitorUiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
- public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
- if (event.getProperty().equals(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED)) {
- requestSave();
- }
- }
- });
- }
-
- @Override
- public void execute(IExternalizationContext context, IProgressMonitor monitor) throws CoreException {
- Assert.isNotNull(context);
- switch (context.getKind()) {
- case SAVE:
- if (ContextCorePlugin.getDefault() != null && MonitorUiPlugin.getDefault().isActivityTrackingEnabled()
- && ContextCorePlugin.getContextManager() != null) {
- setDirty(false);
- ContextCorePlugin.getContextManager().saveActivityMetaContext();
- }
- break;
- case LOAD:
- ContextCorePlugin.getContextManager().loadActivityMetaContext();
- break;
- case SNAPSHOT:
- break;
- }
- }
-
- @Override
- public String getDescription() {
- return Messages.ActivityExternalizationParticipant_Activity_Context;
- }
-
- @Override
- public ISchedulingRule getSchedulingRule() {
- return ITasksCoreConstants.ACTIVITY_SCHEDULING_RULE;
- }
-
- @Override
- public boolean isDirty() {
- return isDirty(false);
- }
-
- @Override
- public boolean isDirty(boolean full) {
- synchronized (this) {
- return isDirty || full;
- }
- }
-
- public void setDirty(boolean dirty) {
- synchronized (this) {
- isDirty = dirty;
- }
- }
-
- @Override
- public String getFileName() {
- // ignore
- return null;
- }
-
- @Override
- public void load(File sourceFile, IProgressMonitor monitor) throws CoreException {
- // ignore see execute method
- }
-
- @Override
- public void save(File targetFile, IProgressMonitor monitor) throws CoreException {
- // ignore see execute method
- }
-
- public void activityReset() {
- // ignore see execute method
- }
-
- public void elapsedTimeUpdated(ITask task, long newElapsedTime) {
- if (System.currentTimeMillis() - lastUpdate > 1000 * 60) {
- requestSave();
- }
- }
-
- private void requestSave() {
- setDirty(true);
- manager.requestSave();
- lastUpdate = System.currentTimeMillis();
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ChangeActivityHandleOperation.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ChangeActivityHandleOperation.java
deleted file mode 100644
index 35a8785b1..000000000
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ChangeActivityHandleOperation.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 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;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
-import org.eclipse.mylyn.internal.context.core.InteractionContext;
-import org.eclipse.mylyn.monitor.core.InteractionEvent;
-
-/**
- * Changes handle from oldHandle to newHandle in Activity Meta Context
- *
- * @author Rob Elves
- */
-public class ChangeActivityHandleOperation extends TaskListModifyOperation {
-
- private final String oldHandle;
-
- private final String newHandle;
-
- public ChangeActivityHandleOperation(String oldHandle, String newHandle) {
- this.oldHandle = oldHandle;
- this.newHandle = newHandle;
- }
-
- @Override
- protected void operations(IProgressMonitor monitor) throws CoreException, InvocationTargetException,
- InterruptedException {
- if (oldHandle == null || newHandle == null || oldHandle.equals(newHandle)) {
- return;
- }
- try {
- monitor.beginTask(Messages.ChangeActivityHandleOperation_Activity_migration, IProgressMonitor.UNKNOWN);
- refactorMetaContextHandles(oldHandle, newHandle);
- TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
- } finally {
- monitor.done();
- }
- }
-
- @SuppressWarnings("restriction")
- private void refactorMetaContextHandles(String oldHandle, String newHandle) {
- ContextCorePlugin.getContextManager().saveActivityMetaContext();
- InteractionContext metaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
- ContextCorePlugin.getContextManager().resetActivityMetaContext();
- InteractionContext newMetaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
- for (InteractionEvent event : metaContext.getInteractionHistory()) {
- if (event.getStructureHandle() != null) {
- if (event.getStructureHandle().equals(oldHandle)) {
- event = new InteractionEvent(event.getKind(), event.getStructureKind(), newHandle,
- event.getOriginId(), event.getNavigation(), event.getDelta(),
- event.getInterestContribution(), event.getDate(), event.getEndDate());
- }
- }
- newMetaContext.parseEvent(event);
- }
- ContextCorePlugin.getContextManager().saveActivityMetaContext();
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/RefactorRepositoryUrlOperation.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/RefactorRepositoryUrlOperation.java
index 43c04e459..2ab9c8071 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/RefactorRepositoryUrlOperation.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/RefactorRepositoryUrlOperation.java
@@ -11,23 +11,13 @@
package org.eclipse.mylyn.internal.tasks.ui;
-import java.io.File;
import java.lang.reflect.InvocationTargetException;
-import java.net.URLDecoder;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
-import org.eclipse.mylyn.internal.context.core.InteractionContext;
-import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
-import org.eclipse.mylyn.internal.tasks.core.RepositoryTaskHandleUtil;
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManager;
-import org.eclipse.mylyn.monitor.core.InteractionEvent;
import org.eclipse.mylyn.tasks.core.ITask;
/**
@@ -56,48 +46,13 @@ public class RefactorRepositoryUrlOperation extends TaskListModifyOperation {
monitor.beginTask(Messages.RefactorRepositoryUrlOperation_Repository_URL_update, IProgressMonitor.UNKNOWN);
refactorOfflineHandles(oldUrl, newUrl);
getTaskList().refactorRepositoryUrl(oldUrl, newUrl);
- refactorMetaContextHandles(oldUrl, newUrl);
- refactorContextFileNames();
+ TasksUiPlugin.getContextStore().refactorRepositoryUrl(oldUrl, newUrl);
TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
} finally {
monitor.done();
}
}
- @SuppressWarnings("restriction")
- public void refactorContextFileNames() {
-
- File dataDir = new File(TasksUiPlugin.getDefault().getDataDirectory(), ITasksCoreConstants.CONTEXTS_DIRECTORY);
- if (dataDir.exists() && dataDir.isDirectory()) {
- File[] files = dataDir.listFiles();
- if (files != null) {
- for (File file : dataDir.listFiles()) {
- int dotIndex = file.getName().lastIndexOf(".xml"); //$NON-NLS-1$
- if (dotIndex != -1) {
- String storedHandle;
- try {
- storedHandle = URLDecoder.decode(file.getName().substring(0, dotIndex),
- InteractionContextManager.CONTEXT_FILENAME_ENCODING);
- int delimIndex = storedHandle.lastIndexOf(RepositoryTaskHandleUtil.HANDLE_DELIM);
- if (delimIndex != -1) {
- String storedUrl = storedHandle.substring(0, delimIndex);
- if (oldUrl.equals(storedUrl)) {
- String id = RepositoryTaskHandleUtil.getTaskId(storedHandle);
- String newHandle = RepositoryTaskHandleUtil.getHandle(newUrl, id);
- File newFile = ContextCorePlugin.getContextStore().getFileForContext(newHandle);
- file.renameTo(newFile);
- }
- }
- } catch (Exception e) {
- StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
- "Could not move context file: " + file.getName(), e)); //$NON-NLS-1$
- }
- }
- }
- }
- }
- }
-
private void refactorOfflineHandles(String oldRepositoryUrl, String newRepositoryUrl) throws CoreException {
TaskDataManager taskDataManager = TasksUiPlugin.getTaskDataManager();
for (ITask task : getTaskList().getAllTasks()) {
@@ -130,28 +85,4 @@ public class RefactorRepositoryUrlOperation extends TaskListModifyOperation {
// TasksUiPlugin.getTaskDataStorageManager().saveNow();
}
- @SuppressWarnings("restriction")
- private void refactorMetaContextHandles(String oldRepositoryUrl, String newRepositoryUrl) {
- InteractionContext metaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
- ContextCorePlugin.getContextManager().resetActivityMetaContext();
- InteractionContext newMetaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
- for (InteractionEvent event : metaContext.getInteractionHistory()) {
- if (event.getStructureHandle() != null) {
- String storedUrl = RepositoryTaskHandleUtil.getRepositoryUrl(event.getStructureHandle());
- if (storedUrl != null) {
- if (oldRepositoryUrl.equals(storedUrl)) {
- String taskId = RepositoryTaskHandleUtil.getTaskId(event.getStructureHandle());
- if (taskId != null) {
- String newHandle = RepositoryTaskHandleUtil.getHandle(newRepositoryUrl, taskId);
- event = new InteractionEvent(event.getKind(), event.getStructureKind(), newHandle,
- event.getOriginId(), event.getNavigation(), event.getDelta(),
- event.getInterestContribution(), event.getDate(), event.getEndDate());
- }
- }
- }
- }
- newMetaContext.parseEvent(event);
- }
- }
-
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskActivityMonitor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskActivityMonitor.java
deleted file mode 100644
index 7bb25f84a..000000000
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskActivityMonitor.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 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;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.context.core.AbstractContextListener;
-import org.eclipse.mylyn.context.core.ContextChangeEvent;
-import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
-import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
-import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
-import org.eclipse.mylyn.internal.tasks.core.TaskActivityManager;
-import org.eclipse.mylyn.internal.tasks.core.TaskList;
-import org.eclipse.mylyn.monitor.core.InteractionEvent;
-import org.eclipse.mylyn.tasks.core.ITask;
-
-/**
- * Monitors task activity and maintains task activation history
- *
- * @author Robert Elves
- * @author Steffen Pingel
- * @since 3.0
- */
-@SuppressWarnings("restriction")
-public class TaskActivityMonitor {
-
- private final InteractionContextManager contextManager;
-
- private final TaskActivityManager taskActivityManager;
-
- private final TaskList taskList;
-
- private final List<ITask> activationHistory;
-
- private final AbstractContextListener CONTEXT_LISTENER = new AbstractContextListener() {
-
- @Override
- public void contextChanged(ContextChangeEvent event) {
- switch (event.getEventKind()) {
- case INTEREST_CHANGED:
- List<InteractionEvent> events = contextManager.getActivityMetaContext().getInteractionHistory();
- if (events.size() > 0) {
- InteractionEvent interactionEvent = events.get(events.size() - 1);
- parseInteractionEvent(interactionEvent, false);
- }
- break;
- }
- }
- };
-
- private ActivityExternalizationParticipant externalizationParticipant;
-
- public TaskActivityMonitor(TaskActivityManager taskActivityManager, InteractionContextManager contextManager) {
- this.taskActivityManager = taskActivityManager;
- this.contextManager = contextManager;
- this.taskList = TasksUiPlugin.getTaskList();
- this.activationHistory = new ArrayList<ITask>();
- }
-
- public void start() {
- contextManager.addActivityMetaContextListener(CONTEXT_LISTENER);
- }
-
- /** public for testing */
- public boolean parseInteractionEvent(InteractionEvent event, boolean isReloading) {
- try {
- if (event.getKind().equals(InteractionEvent.Kind.COMMAND)) {
- if ((event.getDelta().equals(InteractionContextManager.ACTIVITY_DELTA_ACTIVATED))) {
- AbstractTask activatedTask = taskList.getTask(event.getStructureHandle());
- if (activatedTask != null) {
- activationHistory.add(activatedTask);
- return true;
- }
- }
- } else if (event.getKind().equals(InteractionEvent.Kind.ATTENTION)) {
- if ((event.getDelta().equals("added") || event.getDelta().equals("add"))) { //$NON-NLS-1$ //$NON-NLS-2$
- if (event.getDate().getTime() > 0 && event.getEndDate().getTime() > 0) {
- if (event.getStructureKind()
- .equals(InteractionContextManager.ACTIVITY_STRUCTUREKIND_WORKINGSET)) {
- taskActivityManager.addWorkingSetElapsedTime(event.getStructureHandle(), event.getDate(),
- event.getEndDate());
- if (!isReloading) {
- externalizationParticipant.setDirty(true);
- // save not requested for working set time updates so...
- externalizationParticipant.elapsedTimeUpdated(null, 0);
- }
- } else {
- AbstractTask activatedTask = taskList.getTask(event.getStructureHandle());
- if (activatedTask != null) {
- taskActivityManager.addElapsedTime(activatedTask, event.getDate(), event.getEndDate());
- }
- }
- }
- } else if (event.getDelta().equals("removed")) { //$NON-NLS-1$
- ITask task = taskList.getTask(event.getStructureHandle());
- if (task != null) {
- taskActivityManager.removeElapsedTime(task, event.getDate(), event.getEndDate());
- }
- }
- }
- } catch (Throwable t) {
- StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN,
- "Error parsing interaction event", t)); //$NON-NLS-1$
- }
- return false;
- }
-
- public void stop() {
- contextManager.removeActivityMetaContextListener(CONTEXT_LISTENER);
- }
-
- public void reloadActivityTime() {
- activationHistory.clear();
- taskActivityManager.clearActivity();
- List<InteractionEvent> events = contextManager.getActivityMetaContext().getInteractionHistory();
- for (InteractionEvent event : events) {
- parseInteractionEvent(event, true);
- }
- }
-
- /**
- * Returns the task corresponding to the interaction event history item at the specified position
- */
-// protected ITask getHistoryTaskAt(int pos) {
-// InteractionEvent event = contextManager.getActivityMetaContext().getInteractionHistory().get(pos);
-// if (event.getDelta().equals(InteractionContextManager.ACTIVITY_DELTA_ACTIVATED)) {
-// return TasksUiPlugin.getTaskList().getTask(event.getStructureHandle());
-// } else {
-// return null;
-// }
-// }
-
- public void setExternalizationParticipant(ActivityExternalizationParticipant participant) {
- this.externalizationParticipant = participant;
- }
-
- public List<ITask> getActivationHistory() {
- return new ArrayList<ITask>(activationHistory);
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskHistoryHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskHistoryHandler.java
index 27a81dc5c..dd184d8dc 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskHistoryHandler.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskHistoryHandler.java
@@ -15,12 +15,8 @@ package org.eclipse.mylyn.internal.tasks.ui;
import java.util.Map;
import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.TaskActivationHistory;
import org.eclipse.mylyn.internal.tasks.ui.actions.ActivateTaskDialogAction;
@@ -28,7 +24,6 @@ import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.menus.UIElement;
@@ -41,24 +36,7 @@ public class TaskHistoryHandler extends AbstractHandler implements IElementUpdat
public Object execute(final ExecutionEvent event) throws ExecutionException {
if (TasksUi.getTaskActivityManager().getActiveTask() != null) {
- if (ContextCore.getContextManager().isContextCapturePaused()) {
- IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
- if (window != null) {
- ICommandService commandService = (ICommandService) window.getService(ICommandService.class);
- if (commandService != null) {
- final Command command = commandService.getCommand("org.eclipse.mylyn.ui.context.capture.pause.command"); //$NON-NLS-1$
- if (command != null) {
- SafeRunner.run(new SafeRunnable() {
- public void run() throws Exception {
- command.executeWithChecks(event);
- }
- });
- }
- }
- }
- } else {
- TasksUi.getTaskActivityManager().deactivateActiveTask();
- }
+ TasksUi.getTaskActivityManager().deactivateActiveTask();
} else {
TaskActivationHistory taskHistory = TasksUiPlugin.getTaskActivityManager().getTaskActivationHistory();
if (taskHistory.hasPrevious()) {
@@ -83,11 +61,7 @@ public class TaskHistoryHandler extends AbstractHandler implements IElementUpdat
if (TasksUi.getTaskActivityManager().getActiveTask() == null) {
element.setIcon(TasksUiImages.CONTEXT_HISTORY_PREVIOUS);
} else {
- if (ContextCore.getContextManager().isContextCapturePaused()) {
- element.setIcon(TasksUiImages.CONTEXT_HISTORY_PREVIOUS_PAUSE);
- } else {
- element.setIcon(TasksUiImages.CONTEXT_HISTORY_PREVIOUS_ACTIVE);
- }
+ element.setIcon(TasksUiImages.CONTEXT_HISTORY_PREVIOUS_ACTIVE);
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java
index 75d8ade74..7c234ea2e 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java
@@ -95,11 +95,10 @@ import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
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.ITaskContainer;
import org.eclipse.mylyn.tasks.core.RepositoryTemplate;
-import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.activity.AbstractTaskActivityMonitor;
import org.eclipse.mylyn.tasks.core.context.AbstractTaskContextStore;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.AbstractTaskRepositoryLinkProvider;
@@ -256,20 +255,6 @@ public class TasksUiPlugin extends AbstractUIPlugin {
EDITOR, INTERNAL_BROWSER, EXTERNAL_BROWSER;
}
- private static ITaskActivationListener CONTEXT_TASK_ACTIVATION_LISTENER = new TaskActivationAdapter() {
-
- @Override
- public void taskActivated(final ITask task) {
- ContextCore.getContextManager().activateContext(task.getHandleIdentifier());
- }
-
- @Override
- public void taskDeactivated(final ITask task) {
- ContextCore.getContextManager().deactivateContext(task.getHandleIdentifier());
- }
-
- };
-
private static ITaskListNotificationProvider REMINDER_NOTIFICATION_PROVIDER = new ITaskListNotificationProvider() {
public Set<AbstractNotification> getNotifications() {
@@ -370,7 +355,7 @@ public class TasksUiPlugin extends AbstractUIPlugin {
}
};
- private TaskActivityMonitor taskActivityMonitor;
+ private AbstractTaskActivityMonitor taskActivityMonitor;
private ServiceReference proxyServiceReference;
@@ -378,8 +363,6 @@ public class TasksUiPlugin extends AbstractUIPlugin {
private static TaskListExternalizationParticipant taskListExternalizationParticipant;
- private ActiveContextExternalizationParticipant activeContextExternalizationParticipant;
-
private final Set<IRepositoryModelListener> listeners = new HashSet<IRepositoryModelListener>();
private File activationHistoryFile;
@@ -476,10 +459,6 @@ public class TasksUiPlugin extends AbstractUIPlugin {
} finally {
monitor.done();
}
- activeContextExternalizationParticipant = new ActiveContextExternalizationParticipant(
- externalizationManager);
- externalizationManager.addParticipant(activeContextExternalizationParticipant);
- activeContextExternalizationParticipant.registerListeners();
return new Status(IStatus.OK, TasksUiPlugin.ID_PLUGIN, IStatus.OK, "", null); //$NON-NLS-1$
}
}
@@ -617,10 +596,8 @@ public class TasksUiPlugin extends AbstractUIPlugin {
taskJobFactory = new TaskJobFactory(taskList, taskDataManager, repositoryManager, repositoryModel);
- taskActivityManager.addActivationListener(CONTEXT_TASK_ACTIVATION_LISTENER);
-
- taskActivityMonitor = new TaskActivityMonitor(taskActivityManager, ContextCorePlugin.getContextManager());
- taskActivityMonitor.start();
+ taskActivityMonitor = TasksUiExtensionReader.loadTaskActivityMonitor();
+ taskActivityMonitor.start(taskActivityManager);
saveParticipant = new ISaveParticipant() {
@@ -641,12 +618,6 @@ public class TasksUiPlugin extends AbstractUIPlugin {
};
ResourcesPlugin.getWorkspace().addSaveParticipant(this, saveParticipant);
- ActivityExternalizationParticipant ACTIVITY_EXTERNALIZTAION_PARTICIPANT = new ActivityExternalizationParticipant(
- externalizationManager);
- externalizationManager.addParticipant(ACTIVITY_EXTERNALIZTAION_PARTICIPANT);
- taskActivityManager.addActivityListener(ACTIVITY_EXTERNALIZTAION_PARTICIPANT);
- taskActivityMonitor.setExternalizationParticipant(ACTIVITY_EXTERNALIZTAION_PARTICIPANT);
-
// initialize externalization for task activation history
IPath stateLocation = Platform.getStateLocation(getBundle());
activationHistoryFile = stateLocation.append("TaskActivationHistory.xml").toFile(); //$NON-NLS-1$
@@ -894,15 +865,14 @@ public class TasksUiPlugin extends AbstractUIPlugin {
public void initializeDataSources() {
taskDataManager.setDataPath(getDataDirectory());
externalizationManager.setRootFolderPath(getDataDirectory());
- ContextCorePlugin.getContextStore().setContextDirectory(getContextStoreDir());
+ getContextStore().setContextDirectory(getContextStoreDir());
externalizationManager.load();
// TODO: Move management of template repositories to TaskRepositoryManager
loadTemplateRepositories();
taskActivityManager.clear();
- ContextCorePlugin.getContextManager().loadActivityMetaContext();
- taskActivityMonitor.reloadActivityTime();
+ taskActivityMonitor.loadActivityTime();
taskActivityManager.reloadPlanningData();
if (!activationHistoryFile.exists() && taskActivityManager.getTaskActivationHistory().getSize() == 0) {
@@ -1303,7 +1273,7 @@ public class TasksUiPlugin extends AbstractUIPlugin {
return externalizationManager;
}
- public static TaskActivityMonitor getTaskActivityMonitor() {
+ public static AbstractTaskActivityMonitor getTaskActivityMonitor() {
return INSTANCE.taskActivityMonitor;
}
@@ -1420,7 +1390,10 @@ public class TasksUiPlugin extends AbstractUIPlugin {
return identityModel;
}
- public static AbstractTaskContextStore getContextStore() {
+ public static synchronized AbstractTaskContextStore getContextStore() {
+ if (contextStore == null) {
+ contextStore = TasksUiExtensionReader.loadTaskContextStore();
+ }
return contextStore;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskMigrator.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskMigrator.java
index 85bd4b65e..79b9f50ea 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskMigrator.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskMigrator.java
@@ -11,19 +11,16 @@
package org.eclipse.mylyn.internal.tasks.ui.editors;
-import java.lang.reflect.InvocationTargetException;
import java.util.Date;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.DateRange;
-import org.eclipse.mylyn.internal.tasks.ui.ChangeActivityHandleOperation;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
@@ -192,18 +189,6 @@ public class TaskMigrator {
// migrate context
TasksUiPlugin.getContextStore().cloneContext(oldTask, newTask);
-
- // migrate task activity
- ChangeActivityHandleOperation operation = new ChangeActivityHandleOperation(oldTask.getHandleIdentifier(),
- newTask.getHandleIdentifier());
- try {
- operation.run(new NullProgressMonitor());
- } catch (InvocationTargetException e) {
- StatusHandler.log(new Status(IStatus.WARNING, TasksUiPlugin.ID_PLUGIN,
- "Failed to migrate activity to new task", e.getCause())); //$NON-NLS-1$
- } catch (InterruptedException e) {
- // ignore
- }
}
public static boolean isActive() {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/AttachmentUtil.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/AttachmentUtil.java
index faf88c226..10065c046 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/AttachmentUtil.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/AttachmentUtil.java
@@ -86,7 +86,7 @@ public class AttachmentUtil {
AbstractTaskAttachmentHandler attachmentHandler = connector.getTaskAttachmentHandler();
TasksUiPlugin.getContextStore().saveActiveContext();
- File file = TasksUiPlugin.getContextStore().getFileForContext(repository, task);
+ File file = TasksUiPlugin.getContextStore().getFileForContext(task);
if (attachmentHandler != null && file != null && file.exists()) {
FileTaskAttachmentSource attachment = new FileTaskAttachmentSource(file);
attachment.setDescription(CONTEXT_DESCRIPTION);
@@ -138,7 +138,7 @@ public class AttachmentUtil {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
TaskRepository repository = TasksUi.getRepositoryManager().getRepository(task.getConnectorKind(),
task.getRepositoryUrl());
- File targetFile = TasksUiPlugin.getContextStore().getFileForContext(repository, task);
+ File targetFile = TasksUiPlugin.getContextStore().getFileForContext(task);
try {
boolean exceptionThrown = true;
OutputStream out = new BufferedOutputStream(new FileOutputStream(targetFile));
@@ -183,7 +183,7 @@ public class AttachmentUtil {
public static boolean uploadContext(final TaskRepository repository, final ITask task, final String comment,
final IRunnableContext context) {
TasksUiPlugin.getContextStore().saveActiveContext();
- File sourceContextFile = TasksUiPlugin.getContextStore().getFileForContext(repository, task);
+ File sourceContextFile = TasksUiPlugin.getContextStore().getFileForContext(task);
if (!sourceContextFile.exists()) {
TasksUiInternal.displayStatus(Messages.AttachmentUtil_Mylyn_Information, new Status(IStatus.WARNING,
TasksUiPlugin.ID_PLUGIN, Messages.AttachmentUtil_The_context_is_empty));
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java
index 8f2a6744a..15b536962 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java
@@ -30,7 +30,10 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
+import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
+import org.eclipse.mylyn.internal.tasks.core.activity.DefaultTaskActivityMonitor;
+import org.eclipse.mylyn.internal.tasks.core.context.DefaultTaskContextStore;
import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizer;
import org.eclipse.mylyn.internal.tasks.ui.IDynamicSubMenuContributor;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
@@ -41,6 +44,8 @@ import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryMigrator;
import org.eclipse.mylyn.tasks.core.AbstractTaskListMigrator;
import org.eclipse.mylyn.tasks.core.RepositoryTemplate;
+import org.eclipse.mylyn.tasks.core.activity.AbstractTaskActivityMonitor;
+import org.eclipse.mylyn.tasks.core.context.AbstractTaskContextStore;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.AbstractTaskRepositoryLinkProvider;
import org.eclipse.mylyn.tasks.ui.TasksUi;
@@ -632,4 +637,72 @@ public class TasksUiExtensionReader {
}
}
+ public static AbstractTaskActivityMonitor loadTaskActivityMonitor() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint connectorsExtensionPoint = registry.getExtensionPoint(ITasksCoreConstants.ID_PLUGIN
+ + ".activityMonitor"); //$NON-NLS-1$
+ IExtension[] extensions = connectorsExtensionPoint.getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ for (IConfigurationElement element : elements) {
+ if ("activityMonitor".equals(element.getName())) { //$NON-NLS-1$
+ try {
+ Object object = element.createExecutableExtension("class"); //$NON-NLS-1$
+ if (object instanceof AbstractTaskActivityMonitor) {
+ return (AbstractTaskActivityMonitor) object;
+ } else {
+ StatusHandler.log(new Status(
+ IStatus.ERROR,
+ ITasksCoreConstants.ID_PLUGIN,
+ NLS.bind(
+ "Task activity monitor ''{0}'' does not extend expected class for extension contributed by {1}", //$NON-NLS-1$
+ object.getClass().getCanonicalName(), element.getContributor().getName())));
+ }
+ } catch (Throwable e) {
+ StatusHandler.log(new Status(
+ IStatus.ERROR,
+ ITasksCoreConstants.ID_PLUGIN,
+ NLS.bind(
+ "Task activity monitor failed to load for extension contributed by {0}", element.getContributor().getName()), e)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ return new DefaultTaskActivityMonitor();
+ }
+
+ public static AbstractTaskContextStore loadTaskContextStore() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint connectorsExtensionPoint = registry.getExtensionPoint(ITasksCoreConstants.ID_PLUGIN
+ + ".contextStore"); //$NON-NLS-1$
+ IExtension[] extensions = connectorsExtensionPoint.getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ for (IConfigurationElement element : elements) {
+ if ("contextStore".equals(element.getName())) { //$NON-NLS-1$
+ try {
+ Object object = element.createExecutableExtension("class"); //$NON-NLS-1$
+ if (object instanceof AbstractTaskContextStore) {
+ return (AbstractTaskContextStore) object;
+ } else {
+ StatusHandler.log(new Status(
+ IStatus.ERROR,
+ ITasksCoreConstants.ID_PLUGIN,
+ NLS.bind(
+ "Task context store ''{0}'' does not extend expected class for extension contributed by {1}", //$NON-NLS-1$
+ object.getClass().getCanonicalName(), element.getContributor().getName())));
+ }
+ } catch (Throwable e) {
+ StatusHandler.log(new Status(
+ IStatus.ERROR,
+ ITasksCoreConstants.ID_PLUGIN,
+ NLS.bind(
+ "Task context store failed to load for extension contributed by {0}", element.getContributor().getName()), e)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ return new DefaultTaskContextStore();
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiImages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiImages.java
index 558ca16b9..b2491ece8 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiImages.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiImages.java
@@ -142,6 +142,7 @@ public class TasksUiImages {
public static final ImageDescriptor CONTEXT_HISTORY_PREVIOUS = create(TOOL, "navigate-previous.gif"); //$NON-NLS-1$
+ @Deprecated
public static final ImageDescriptor CONTEXT_HISTORY_PREVIOUS_PAUSE = create(TOOL, "navigate-previous-pause.gif"); //$NON-NLS-1$
public static final ImageDescriptor CONTEXT_HISTORY_PREVIOUS_ACTIVE = create(TOOL, "navigate-previous-active.gif"); //$NON-NLS-1$
diff --git a/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
index 49f61e0c9..a7cb8b247 100644
--- a/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
@@ -3,8 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: Mylyn Trac Connector Tests
Bundle-SymbolicName: org.eclipse.mylyn.trac.tests;singleton:=true
Bundle-Version: 3.7.0.qualifier
-Require-Bundle: org.apache.xmlrpc;bundle-version="3.0.0",
- org.junit,
+Require-Bundle: org.junit,
org.eclipse.core.runtime,
org.eclipse.jface.text,
org.eclipse.search,
@@ -12,13 +11,13 @@ Require-Bundle: org.apache.xmlrpc;bundle-version="3.0.0",
org.eclipse.ui.workbench.texteditor,
org.eclipse.mylyn.commons.net,
org.eclipse.mylyn.commons.tests,
- org.eclipse.mylyn.context.core,
org.eclipse.mylyn.tasks.ui,
org.eclipse.mylyn.tasks.core,
org.eclipse.mylyn.tests.util,
org.eclipse.mylyn.trac.ui,
org.eclipse.mylyn.trac.core,
- org.apache.ws.commons.util;bundle-version="1.0.0"
+ org.apache.ws.commons.util;bundle-version="1.0.0",
+ org.apache.xmlrpc;bundle-version="3.0.0"
Export-Package: org.eclipse.mylyn.internal.trac.ui;x-internal:=true,
org.eclipse.mylyn.trac.tests;x-internal:=true,
org.eclipse.mylyn.trac.tests.client;x-internal:=true,
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java
index 72096486f..0a654b3b2 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java
@@ -154,7 +154,7 @@ public class TracRepositoryConnectorTest extends TestCase {
public void testContext() throws Exception {
String taskId = data.attachmentTicketId + "";
ITask task = TracTestUtil.createTask(repository, taskId);
- File sourceContextFile = TasksUiPlugin.getContextStore().getFileForContext(repository, task);
+ File sourceContextFile = TasksUiPlugin.getContextStore().getFileForContext(task);
sourceContextFile.createNewFile();
sourceContextFile.deleteOnExit();

Back to the top