summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2011-09-28 19:34:24 (EDT)
committer Steffen Pingel2011-09-29 15:18:30 (EDT)
commit5392bbe6c0f3c613a69b84d95182c753c780ca61 (patch)
treece1e702f3c262e5506411af10828e79bcbca97ef
parent278ebf55185a90a1558ebe1d0cdca38f5ac9a3c0 (diff)
downloadorg.eclipse.mylyn.tasks-5392bbe6c0f3c613a69b84d95182c753c780ca61.zip
org.eclipse.mylyn.tasks-5392bbe6c0f3c613a69b84d95182c753c780ca61.tar.gz
org.eclipse.mylyn.tasks-5392bbe6c0f3c613a69b84d95182c753c780ca61.tar.bz2
NEW - bug 336430: separate Tasks framework from Context
https://bugs.eclipse.org/bugs/show_bug.cgi?id=336430 Change-Id: Id47587b48f071ccbd2f3229eda0984db5524dcb2
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/context/DefaultTaskContextStore.java10
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/context/AbstractTaskContextStore.java13
-rw-r--r--org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF10
-rw-r--r--org.eclipse.mylyn.tasks.ui/icons/elcl16/context-clear.gifbin0 -> 316 bytes
-rw-r--r--org.eclipse.mylyn.tasks.ui/icons/elcl16/context-transfer.gifbin0 -> 325 bytes
-rw-r--r--org.eclipse.mylyn.tasks.ui/plugin.properties16
-rw-r--r--org.eclipse.mylyn.tasks.ui/plugin.xml326
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/FocusTaskListAction.java191
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/AbstractTaskAttachmentCommandHandler.java46
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/AttachContextHandler.java42
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ClearContextHandler.java47
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextAttachWizard.java55
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextAttachWizardPage.java81
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextRetrieveWizard.java58
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextRetrieveWizardPage.java158
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/CopyContextHandler.java104
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/Messages.java86
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ProgressContainer.java215
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/RetrieveContextAttachmentHandler.java29
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/RetrieveContextHandler.java39
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/RetrieveLatestContextDialog.java178
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/TaskAttachmentComparator.java35
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/messages.properties45
24 files changed, 1721 insertions, 65 deletions
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
index 882362e..394b42b 100644
--- 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
@@ -15,6 +15,7 @@ import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
@@ -34,8 +35,8 @@ public class DefaultTaskContextStore extends AbstractTaskContextStore {
private File contextDirectory;
@Override
- public void cloneContext(ITask sourceTask, ITask destinationTask) {
- // ignore
+ public IAdaptable cloneContext(ITask sourceTask, ITask destinationTask) {
+ return null;
}
@Override
@@ -90,4 +91,9 @@ public class DefaultTaskContextStore extends AbstractTaskContextStore {
this.contextDirectory = directory;
}
+ @Override
+ public void mergeContext(ITask sourceTask, ITask targetTask) {
+ // ignore
+ }
+
}
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 542d87d..91b85bc 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
@@ -13,10 +13,11 @@ package org.eclipse.mylyn.tasks.core.context;
import java.io.File;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.mylyn.tasks.core.ITask;
/**
- * A store for persisting task context.
+ * A store for persisting task contexts.
*
* @author Steffen Pingel
* @since 3.7
@@ -27,14 +28,15 @@ 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.
*
+ * @return result of the clone operation
* @since 3.7
*/
- public abstract void cloneContext(ITask sourceTask, ITask destinationTask);
+ public abstract IAdaptable cloneContext(ITask sourceTask, ITask destinationTask);
/**
* @since 3.7
*/
- public abstract void deleteContext(ITask oldTask);
+ public abstract void deleteContext(ITask task);
/**
* Return the location of the context for <code>task</code>.
@@ -64,4 +66,9 @@ public abstract class AbstractTaskContextStore {
*/
public abstract void setContextDirectory(File contextStoreDir);
+ /**
+ * @since 3.7
+ */
+ public abstract void mergeContext(ITask sourceTask, ITask targetTask);
+
}
diff --git a/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF
index 6644800..d9b9c4b 100644
--- a/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF
@@ -19,14 +19,15 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.views,
org.eclipse.ui.workbench.texteditor,
org.eclipse.mylyn.commons.core;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.mylyn.monitor.ui;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.mylyn.tasks.core;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.mylyn.discovery.ui;bundle-version="3.6.0";resolution:=optional;x-installation:=greedy,
+ org.eclipse.mylyn.commons.repositories;bundle-version="0.1.0",
org.eclipse.mylyn.commons.identity;bundle-version="0.8.0",
org.eclipse.mylyn.commons.net;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.mylyn.commons.repositories;bundle-version="0.1.0",
org.eclipse.mylyn.commons.ui;bundle-version="[3.0.0,4.0.0)",
org.eclipse.mylyn.monitor.core;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.mylyn.commons.repositories;bundle-version="0.1.0",
- org.eclipse.mylyn.discovery.ui;bundle-version="3.6.0";resolution:=optional;x-installation:=greedy
+ org.eclipse.mylyn.monitor.ui;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.mylyn.tasks.core;bundle-version="[3.0.0,4.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor
Export-Package: org.eclipse.mylyn.internal.provisional.tasks.ui.wizards;x-internal:=true,
@@ -34,6 +35,7 @@ Export-Package: org.eclipse.mylyn.internal.provisional.tasks.ui.wizards;x-intern
org.eclipse.mylyn.internal.tasks.ui.actions;x-internal:=true,
org.eclipse.mylyn.internal.tasks.ui.commands;x-internal:=true,
org.eclipse.mylyn.internal.tasks.ui.compare;x-internal:=true,
+ org.eclipse.mylyn.internal.tasks.ui.context;x-internal:=true,
org.eclipse.mylyn.internal.tasks.ui.dialogs;x-internal:=true,
org.eclipse.mylyn.internal.tasks.ui.editors;x-internal:=true,
org.eclipse.mylyn.internal.tasks.ui.editors.outline;x-internal:=true,
diff --git a/org.eclipse.mylyn.tasks.ui/icons/elcl16/context-clear.gif b/org.eclipse.mylyn.tasks.ui/icons/elcl16/context-clear.gif
new file mode 100644
index 0000000..cbb71be
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/icons/elcl16/context-clear.gif
Binary files differ
diff --git a/org.eclipse.mylyn.tasks.ui/icons/elcl16/context-transfer.gif b/org.eclipse.mylyn.tasks.ui/icons/elcl16/context-transfer.gif
new file mode 100644
index 0000000..0a97a2d
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/icons/elcl16/context-transfer.gif
Binary files differ
diff --git a/org.eclipse.mylyn.tasks.ui/plugin.properties b/org.eclipse.mylyn.tasks.ui/plugin.properties
index dcb28e6..542fba4 100644
--- a/org.eclipse.mylyn.tasks.ui/plugin.properties
+++ b/org.eclipse.mylyn.tasks.ui/plugin.properties
@@ -204,3 +204,19 @@ context.editors.task.name = In Tasks Editor
command.attachment.open.label = Open
command.attachment.open.name = Open Attachment
+
+FocusTaskListAction.label = Focus on Workweek
+FocusTaskListAction.tooltip = Focus on Workweek
+
+commands.task.attachContext.name = Attach Context
+commands.task.retrieveContext.name = Retrieve Context
+commands.task.copyContext.name = Copy Context
+commands.task.clearContext.name = Clear Context
+commands.attachment.retrieveContext.name = Retrieve Context Attachment
+
+menu.task.context.label = Context
+commands.task.attachContext.label = Attach...
+commands.task.retrieveContext.label = Retrieve...
+commands.task.copyContext.label = Copy to...
+commands.task.clearContext.label = Clear
+commands.attachment.retrieveContext.label = Retrieve Context
diff --git a/org.eclipse.mylyn.tasks.ui/plugin.xml b/org.eclipse.mylyn.tasks.ui/plugin.xml
index c9316d8..3e7bcb1 100644
--- a/org.eclipse.mylyn.tasks.ui/plugin.xml
+++ b/org.eclipse.mylyn.tasks.ui/plugin.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?><!--
+<?eclipse version="3.0"?>
+<!--
Copyright (c) 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
@@ -9,7 +10,6 @@
Contributors:
Tasktop Technologies - initial API and implementation
-->
-
<plugin>
<extension-point id="actions" name="Tasklist Actions" schema="schema/actions.exsd"/>
<extension-point id="repositories" name="Task Repositories" schema="schema/repositories.exsd"/>
@@ -248,61 +248,55 @@
<viewContribution
id="org.eclipse.mylyn.tasks.ui.actions.view"
targetID="org.eclipse.mylyn.tasks.ui.views.tasks">
-
- <action
- class="org.eclipse.mylyn.internal.tasks.ui.actions.SynchronizeAllAction"
- enablesFor="*"
- icon="icons/etool16/repository-synchronize.gif"
- id="org.eclipse.mylyn.tasks.ui.synchronize.changed"
- label="%SynchronizeAllAction.label"
- menubarPath="tasks"
- toolbarPath="new"
- tooltip="%SynchronizeAllAction.tooltip">
- </action>
- <action
- class="org.eclipse.mylyn.internal.tasks.ui.actions.RestoreTaskListAction"
- icon="icons/etool16/import.gif"
- id="org.eclipse.mylyn.tasks.ui.tasks.restore"
- label="%RestoreTaskListAction.label"
+ <action
+ class="org.eclipse.mylyn.internal.tasks.ui.actions.SynchronizeAllAction"
+ enablesFor="*"
+ icon="icons/etool16/repository-synchronize.gif"
+ id="org.eclipse.mylyn.tasks.ui.synchronize.changed"
+ label="%SynchronizeAllAction.label"
menubarPath="tasks"
- style="push">
- </action>
-
- <action
- class="org.eclipse.mylyn.internal.tasks.ui.actions.ShowTaskRepositoriesViewAction"
- enablesFor="*"
- icon="icons/eview16/repositories.gif"
- id="org.eclipse.mylyn.tasks.ui.open.repositories.view"
- label="%ShowTaskRepositoriesViewAction.label"
- menubarPath="tasks"
- tooltip="%ShowTaskRepositoriesViewAction.tooltip">
- </action>
- <action
- class="org.eclipse.mylyn.internal.tasks.ui.actions.ShowTasksUiLegendAction"
- icon="icons/etool16/icons-legend.gif"
- id="org.eclipse.mylyn.doc.legend.show.action"
- label="%ShowTasksUiLegendAction.label"
- menubarPath="additions"
- style="push"
- tooltip="%ShowTasksUiLegendAction.tooltip">
- </action>
- <!--<action
- class="org.eclipse.mylyn.internal.tasks.ui.actions.NewLocalTaskAction"
- icon="icons/etool16/task-new.gif"
- id="org.eclipse.mylyn.tasks.ui.actions.new.task"
- label="Task"
- style="push"
- toolbarPath="new"
- tooltip="New Task">
- </action> -->
- <!--
- <action
- class="org.eclipse.mylyn.internal.tasklist.ui.actions.CopyDetailsAction"
- id="org.eclipse.mylyn.tasklist.copy.details"
- label="Copy Details"
- style="push"/>
- -->
- </viewContribution>
+ toolbarPath="new"
+ tooltip="%SynchronizeAllAction.tooltip">
+ </action>
+ <action
+ class="org.eclipse.mylyn.internal.tasks.ui.actions.RestoreTaskListAction"
+ icon="icons/etool16/import.gif"
+ id="org.eclipse.mylyn.tasks.ui.tasks.restore"
+ label="%RestoreTaskListAction.label"
+ menubarPath="tasks"
+ style="push">
+ </action>
+
+ <action
+ class="org.eclipse.mylyn.internal.tasks.ui.actions.ShowTaskRepositoriesViewAction"
+ enablesFor="*"
+ icon="icons/eview16/repositories.gif"
+ id="org.eclipse.mylyn.tasks.ui.open.repositories.view"
+ label="%ShowTaskRepositoriesViewAction.label"
+ menubarPath="tasks"
+ tooltip="%ShowTaskRepositoriesViewAction.tooltip">
+ </action>
+ <action
+ class="org.eclipse.mylyn.internal.tasks.ui.actions.ShowTasksUiLegendAction"
+ icon="icons/etool16/icons-legend.gif"
+ id="org.eclipse.mylyn.doc.legend.show.action"
+ label="%ShowTasksUiLegendAction.label"
+ menubarPath="additions"
+ style="push"
+ tooltip="%ShowTasksUiLegendAction.tooltip">
+ </action>
+
+ <action
+ class="org.eclipse.mylyn.internal.tasks.ui.actions.FocusTaskListAction"
+ enablesFor="*"
+ icon="icons/eview16/focus.gif"
+ id="org.eclipse.mylyn.context.ui.actions.tasklist.focus"
+ label="%FocusTaskListAction.label"
+ menubarPath="additions"
+ style="toggle"
+ toolbarPath="context"
+ tooltip="%FocusTaskListAction.tooltip"/>
+ </viewContribution>
</extension>
<extension point="org.eclipse.ui.popupMenus">
@@ -2128,4 +2122,224 @@
</enabledWhen>
</handler>
</extension>
+
+ <!-- Context related commands and UI contributions -->
+
+ <extension point="org.eclipse.ui.commands">
+ <category
+ name="%commands.category.name"
+ description="%commands.category.description"
+ id="org.eclipse.mylyn.context.ui.commands">
+ </category>
+ <command
+ categoryId="org.eclipse.mylyn.context.ui.commands"
+ id="org.eclipse.mylyn.context.ui.commands.task.attachContext"
+ name="%commands.task.attachContext.name">
+ </command>
+ <command
+ categoryId="org.eclipse.mylyn.context.ui.commands"
+ id="org.eclipse.mylyn.context.ui.commands.task.retrieveContext"
+ name="%commands.task.retrieveContext.name">
+ </command>
+ <command
+ categoryId="org.eclipse.mylyn.context.ui.commands"
+ id="org.eclipse.mylyn.context.ui.commands.task.copyContext"
+ name="%commands.task.copyContext.name">
+ </command>
+ <command
+ categoryId="org.eclipse.mylyn.context.ui.commands"
+ id="org.eclipse.mylyn.context.ui.commands.task.clearContext"
+ name="%commands.task.clearContext.name">
+ </command>
+ <command
+ categoryId="org.eclipse.mylyn.context.ui.commands"
+ id="org.eclipse.mylyn.context.ui.commands.attachment.retrieveContext"
+ name="%commands.attachment.retrieveContext.name">
+ </command>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.ui.popup.any?after=operations">
+ <menu
+ id="org.eclipse.mylyn.context.ui.menu.task.context"
+ label="%menu.task.context.label">
+ <visibleWhen
+ checkEnabled="false">
+ <or>
+ <and>
+ <count
+ value="1">
+ </count>
+ <iterate>
+ <adapt
+ type="org.eclipse.mylyn.tasks.core.ITask">
+ </adapt>
+ </iterate>
+ </and>
+ </or>
+ </visibleWhen>
+ <separator
+ name="group.repository"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.mylyn.context.ui.commands.task.attachContext"
+ icon="icons/etool16/context-attach.gif"
+ label="%commands.task.attachContext.label"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.mylyn.context.ui.commands.task.retrieveContext"
+ icon="icons/etool16/context-retrieve.gif"
+ label="%commands.task.retrieveContext.label"
+ style="push">
+ </command>
+ <separator
+ name="group.local"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.mylyn.context.ui.commands.task.copyContext"
+ icon="icons/elcl16/context-transfer.gif"
+ label="%commands.task.copyContext.label"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.mylyn.context.ui.commands.task.clearContext"
+ icon="icons/elcl16/context-clear.gif"
+ label="%commands.task.clearContext.label"
+ style="push">
+ </command>
+ <separator
+ name="additions">
+ </separator>
+ </menu>
+ </menuContribution>
+ <menuContribution
+ locationURI="popup:org.eclipse.ui.popup.any?after=additions">
+ <command
+ commandId="org.eclipse.mylyn.context.ui.commands.attachment.retrieveContext"
+ icon="icons/etool16/context-retrieve.gif"
+ label="%commands.attachment.retrieveContext.label"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <or>
+ <iterate
+ ifEmpty="false">
+ <adapt
+ type="org.eclipse.mylyn.tasks.core.ITaskAttachment">
+ <test
+ property="org.eclipse.mylyn.task.attachment.isContext"
+ value="true">
+ </test>
+ </adapt>
+ </iterate>
+ </or>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.mylyn.internal.tasks.ui.context.AttachContextHandler"
+ commandId="org.eclipse.mylyn.context.ui.commands.task.attachContext">
+ <enabledWhen>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <and>
+ <adapt
+ type="org.eclipse.mylyn.tasks.core.ITask">
+ <test
+ property="org.eclipse.mylyn.task.canPostAttachment"
+ value="true">
+ </test>
+ </adapt>
+ </and>
+ </iterate>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.mylyn.internal.tasks.ui.context.RetrieveContextHandler"
+ commandId="org.eclipse.mylyn.context.ui.commands.task.retrieveContext">
+ <enabledWhen>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <and>
+ <adapt
+ type="org.eclipse.mylyn.tasks.core.ITask">
+ <test
+ property="org.eclipse.mylyn.task.canGetAttachment"
+ value="true">
+ </test>
+ <test
+ property="org.eclipse.mylyn.task.hasRepositoryContext"
+ value="true">
+ </test>
+ </adapt>
+ </and>
+ </iterate>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.mylyn.internal.tasks.ui.context.CopyContextHandler"
+ commandId="org.eclipse.mylyn.context.ui.commands.task.copyContext">
+ <enabledWhen>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <and>
+ <adapt
+ type="org.eclipse.mylyn.tasks.core.ITask">
+ <test
+ property="org.eclipse.mylyn.task.hasLocalContext"
+ value="true">
+ </test>
+ </adapt>
+ </and>
+ </iterate>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.mylyn.internal.tasks.ui.context.ClearContextHandler"
+ commandId="org.eclipse.mylyn.context.ui.commands.task.clearContext">
+ <enabledWhen>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <and>
+ <adapt
+ type="org.eclipse.mylyn.tasks.core.ITask">
+ <test
+ property="org.eclipse.mylyn.task.hasLocalContext"
+ value="true">
+ </test>
+ </adapt>
+ </and>
+ </iterate>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.mylyn.internal.tasks.ui.context.RetrieveContextAttachmentHandler"
+ commandId="org.eclipse.mylyn.context.ui.commands.attachment.retrieveContext">
+ <enabledWhen>
+ <and>
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.mylyn.tasks.core.ITaskAttachment">
+ </instanceof>
+ </iterate>
+ </and>
+ </enabledWhen>
+ </handler>
+ </extension>
+
</plugin>
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java
index fe080f0..4ec877e 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java
@@ -78,6 +78,8 @@ public interface ITasksUiPreferenceConstants {
public static final String AUTO_EXPAND_TASK_LIST = "org.eclipse.mylyn.tasks.ui.auto.expand"; //$NON-NLS-1$
+ public static final String TASK_LIST_FOCUSED = "org.eclipse.mylyn.tasks.ui.task.list.focused"; //$NON-NLS-1$
+
/**
* Local subtasks are now enabled by default.
*
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/FocusTaskListAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/FocusTaskListAction.java
new file mode 100644
index 0000000..b00fdee
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/FocusTaskListAction.java
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * 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.actions;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.mylyn.internal.provisional.commons.ui.IFilteredTreeListener;
+import org.eclipse.mylyn.internal.tasks.ui.AbstractTaskListFilter;
+import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskListInterestFilter;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskListInterestSorter;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskScheduleContentProvider;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IActionDelegate2;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+
+/**
+ * @author Mik Kersten
+ * @author Steffen Pingel
+ */
+public class FocusTaskListAction implements IFilteredTreeListener, IViewActionDelegate, IActionDelegate2 {
+
+ private Set<AbstractTaskListFilter> previousFilters = new HashSet<AbstractTaskListFilter>();
+
+ private ViewerSorter previousSorter;
+
+ private final TaskListInterestFilter taskListInterestFilter = new TaskListInterestFilter();
+
+ private final TaskListInterestSorter taskListInterestSorter = new TaskListInterestSorter();
+
+ private TaskListView taskListView;
+
+ private IAction action;
+
+ public FocusTaskListAction() {
+ }
+
+ public void filterTextChanged(final String text) {
+ if (taskListView.isFocusedMode() && (text == null || "".equals(text.trim()))) { //$NON-NLS-1$
+ taskListView.getViewer().expandAll();
+ }
+ }
+
+ public void init(IAction action) {
+ this.action = action;
+ initAction();
+ }
+
+ public void init(IViewPart view) {
+ if (view instanceof TaskListView) {
+ taskListView = (TaskListView) view;
+ taskListView.getFilteredTree().getRefreshPolicy().addListener(this);
+ taskListView.getFilteredTree().addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ taskListView.getFilteredTree().getRefreshPolicy().removeListener(FocusTaskListAction.this);
+ }
+ });
+ if (TasksUiPlugin.getDefault()
+ .getPreferenceStore()
+ .getBoolean(ITasksUiPreferenceConstants.TASK_LIST_FOCUSED)) {
+ installInterestFilter();
+ }
+ initAction();
+ showProgressBar(taskListView.isFocusedMode());
+ }
+ }
+
+ private void initAction() {
+ if (action != null && taskListView != null) {
+ action.setChecked(taskListView.isFocusedMode());
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ // ignore
+ }
+
+ private void showProgressBar(boolean visible) {
+ taskListView.getFilteredTree().setShowProgress(visible);
+ }
+
+ protected void installInterestFilter() {
+ TasksUiInternal.preservingSelection(taskListView.getViewer(), new Runnable() {
+ public void run() {
+ try {
+ taskListView.getFilteredTree().setRedraw(false);
+ taskListView.setFocusedMode(true);
+ previousSorter = taskListView.getViewer().getSorter();
+ previousFilters = new HashSet<AbstractTaskListFilter>(taskListView.getFilters());
+ taskListView.clearFilters();
+ if (!taskListView.getFilters().contains(taskListInterestFilter)) {
+ taskListView.addFilter(taskListInterestFilter);
+ }
+ // Setting sorter causes root refresh
+ taskListView.getViewer().setSorter(taskListInterestSorter);
+ taskListView.getViewer().expandAll();
+// taskListView.selectedAndFocusTask(TasksUiPlugin.getTaskList().getActiveTask());
+
+ showProgressBar(true);
+ } finally {
+ taskListView.getFilteredTree().setRedraw(true);
+ }
+ }
+ });
+ }
+
+ protected void uninstallInterestFilter() {
+ TasksUiInternal.preservingSelection(taskListView.getViewer(), new Runnable() {
+ public void run() {
+ try {
+ taskListView.getViewer().getControl().setRedraw(false);
+ taskListView.setFocusedMode(false);
+ for (AbstractTaskListFilter filter : previousFilters) {
+ taskListView.addFilter(filter);
+ }
+ taskListView.removeFilter(taskListInterestFilter);
+ Text textControl = taskListView.getFilteredTree().getFilterControl();
+ if (textControl != null && textControl.getText().length() > 0) {
+ taskListView.getViewer().expandAll();
+ } else {
+ taskListView.getViewer().collapseAll();
+ // expand first element (Today) in scheduled mode
+ if (taskListView.getViewer().getContentProvider() instanceof TaskScheduleContentProvider
+ && taskListView.getViewer().getTree().getItemCount() > 0) {
+ TreeItem item = taskListView.getViewer().getTree().getItem(0);
+ if (item.getData() != null) {
+ taskListView.getViewer().expandToLevel(item.getData(), 1);
+ }
+ }
+ }
+ taskListView.getViewer().setSorter(previousSorter);
+ showProgressBar(false);
+ } finally {
+ taskListView.getViewer().getControl().setRedraw(true);
+ }
+ }
+ });
+ }
+
+ public void run() {
+ if (taskListView == null) {
+ return;
+ }
+
+ if (!taskListView.isFocusedMode()) {
+ TasksUiPlugin.getDefault()
+ .getPreferenceStore()
+ .setValue(ITasksUiPreferenceConstants.TASK_LIST_FOCUSED, true);
+ installInterestFilter();
+ } else {
+ TasksUiPlugin.getDefault()
+ .getPreferenceStore()
+ .setValue(ITasksUiPreferenceConstants.TASK_LIST_FOCUSED, false);
+ uninstallInterestFilter();
+ }
+ }
+
+ public void run(IAction action) {
+ run();
+ }
+
+ public void runWithEvent(IAction action, Event event) {
+ run();
+ }
+
+ public void dispose() {
+ // ignore
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/AbstractTaskAttachmentCommandHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/AbstractTaskAttachmentCommandHandler.java
new file mode 100644
index 0000000..149fe18
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/AbstractTaskAttachmentCommandHandler.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.context;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.mylyn.tasks.core.ITaskAttachment;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * @author Steffen Pingel
+ */
+public abstract class AbstractTaskAttachmentCommandHandler extends AbstractHandler {
+
+ public AbstractTaskAttachmentCommandHandler() {
+ }
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof IStructuredSelection) {
+ Object[] items = ((IStructuredSelection) selection).toArray();
+ for (Object item : items) {
+ if (item instanceof ITaskAttachment) {
+ execute(event, (ITaskAttachment) item);
+ }
+ }
+ }
+ return null;
+ }
+
+ protected void execute(ExecutionEvent event, ITaskAttachment attachment) {
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/AttachContextHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/AttachContextHandler.java
new file mode 100644
index 0000000..dbfa5a9
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/AttachContextHandler.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.context;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil;
+import org.eclipse.mylyn.internal.tasks.ui.commands.AbstractTaskHandler;
+import org.eclipse.mylyn.tasks.core.ITask;
+
+/**
+ * @author Steffen Pingel
+ */
+public class AttachContextHandler extends AbstractTaskHandler {
+
+ @Override
+ protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
+ run(task);
+ }
+
+ public static void run(ITask task) {
+ ContextAttachWizard wizard = new ContextAttachWizard(task);
+ WizardDialog dialog = new WizardDialog(WorkbenchUtil.getShell(), wizard);
+ dialog.create();
+ dialog.setBlockOnOpen(true);
+ if (dialog.open() == Window.CANCEL) {
+ return;
+ }
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ClearContextHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ClearContextHandler.java
new file mode 100644
index 0000000..46373bb
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ClearContextHandler.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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.context;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.commands.AbstractTaskHandler;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Steffen Pingel
+ */
+public class ClearContextHandler extends AbstractTaskHandler {
+
+ @Override
+ protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
+ run(task);
+ }
+
+ public static void run(ITask task) {
+ boolean deleteConfirmed = MessageDialog.openQuestion(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getShell(), Messages.ClearContextHandler_Confirm_clear_context,
+ Messages.ClearContextHandler_CLEAR_THE_CONTEXT_THE_FOR_SELECTED_TASK);
+ if (!deleteConfirmed) {
+ return;
+ }
+
+ TasksUiPlugin.getDefault();
+ TasksUiPlugin.getContextStore().deleteContext(task);
+ TasksUiInternal.getTaskList().notifyElementChanged(task);
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextAttachWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextAttachWizard.java
new file mode 100644
index 0000000..e64fdc8
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextAttachWizard.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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.context;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.mylyn.tasks.ui.TasksUiImages;
+
+/**
+ * @author Rob Elves
+ * @author Steffen Pingel
+ */
+@SuppressWarnings({ "restriction" })
+public class ContextAttachWizard extends Wizard {
+
+ private final TaskRepository repository;
+
+ private final ITask task;
+
+ private ContextAttachWizardPage wizardPage;
+
+ public ContextAttachWizard(ITask task) {
+ this.repository = TasksUi.getRepositoryManager()
+ .getRepository(task.getConnectorKind(), task.getRepositoryUrl());
+ this.task = task;
+ setWindowTitle(Messages.ContextAttachWizard_Attach_Context);
+ setDefaultPageImageDescriptor(TasksUiImages.BANNER_REPOSITORY_CONTEXT);
+ setNeedsProgressMonitor(true);
+ }
+
+ @Override
+ public void addPages() {
+ wizardPage = new ContextAttachWizardPage(repository, task);
+ addPage(wizardPage);
+ super.addPages();
+ }
+
+ @Override
+ public final boolean performFinish() {
+ return AttachmentUtil.uploadContext(repository, task, wizardPage.getComment(), getContainer());
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextAttachWizardPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextAttachWizardPage.java
new file mode 100644
index 0000000..bba0cd6
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextAttachWizardPage.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * 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.context;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Rob Elves
+ */
+public class ContextAttachWizardPage extends WizardPage {
+
+ private final TaskRepository repository;
+
+ private final ITask task;
+
+ private Text commentText;
+
+ protected ContextAttachWizardPage(TaskRepository repository, ITask task) {
+ super(Messages.ContextAttachWizardPage_Enter_comment);
+ this.repository = repository;
+ this.task = task;
+ setTitle(Messages.ContextAttachWizardPage_Enter_comment);
+ setDescription(Messages.ContextAttachWizardPage_Attaches_local_context_to_repository_task);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+
+ Text summary = new Text(composite, SWT.NONE);
+ summary.setText(NLS.bind(Messages.ContextAttachWizardPage_Task, task.getSummary()));
+ summary.setEditable(false);
+ Text repositoryText = new Text(composite, SWT.NONE);
+ repositoryText.setText(Messages.ContextAttachWizardPage_Repository_ + repository.getRepositoryUrl());
+ repositoryText.setEditable(false);
+
+ new Label(composite, SWT.NONE).setText(Messages.ContextAttachWizardPage_Comment_);
+ commentText = new Text(composite, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP);
+ commentText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ commentText.addKeyListener(new KeyListener() {
+ public void keyPressed(KeyEvent e) {
+ getWizard().getContainer().updateButtons();
+ }
+
+ public void keyReleased(KeyEvent e) {
+ getWizard().getContainer().updateButtons();
+ }
+ });
+
+ setControl(composite);
+ commentText.setFocus();
+ Dialog.applyDialogFont(composite);
+ }
+
+ public String getComment() {
+ return commentText.getText();
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextRetrieveWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextRetrieveWizard.java
new file mode 100644
index 0000000..6549b64
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextRetrieveWizard.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.context;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.ITaskAttachment;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.mylyn.tasks.ui.TasksUiImages;
+
+/**
+ * @author Rob Elves
+ * @author Mik Kersten
+ * @author Steffen Pingel
+ */
+@SuppressWarnings({ "restriction" })
+public class ContextRetrieveWizard extends Wizard {
+
+ private final TaskRepository repository;
+
+ private final ITask task;
+
+ private ContextRetrieveWizardPage wizardPage;
+
+ public ContextRetrieveWizard(ITask task) {
+ this.task = task;
+ this.repository = TasksUi.getRepositoryManager()
+ .getRepository(task.getConnectorKind(), task.getRepositoryUrl());
+ setWindowTitle(Messages.ContextRetrieveWizard_Retrieve_Context);
+ setDefaultPageImageDescriptor(TasksUiImages.BANNER_REPOSITORY_CONTEXT);
+ setNeedsProgressMonitor(true);
+ }
+
+ @Override
+ public void addPages() {
+ wizardPage = new ContextRetrieveWizardPage(repository, task);
+ addPage(wizardPage);
+ super.addPages();
+ }
+
+ @Override
+ public final boolean performFinish() {
+ ITaskAttachment attachment = wizardPage.getSelectedContext();
+ return AttachmentUtil.downloadContext(task, attachment, getContainer());
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextRetrieveWizardPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextRetrieveWizardPage.java
new file mode 100644
index 0000000..d343c2f
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ContextRetrieveWizardPage.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * 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.context;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
+import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.ITaskAttachment;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TaskElementLabelProvider;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+import com.ibm.icu.text.DateFormat;
+
+/**
+ * @author Rob Elves
+ * @author Mik Kersten
+ */
+@SuppressWarnings({ "restriction" })
+public class ContextRetrieveWizardPage extends WizardPage {
+
+ private final TaskRepository repository;
+
+ private final ITask task;
+
+ private final TaskElementLabelProvider labelProvider = new TaskElementLabelProvider(false);
+
+ private ITaskAttachment selectedContextAttachment;
+
+ protected ContextRetrieveWizardPage(TaskRepository repository, ITask task) {
+ super(Messages.ContextRetrieveWizardPage_Select_context);
+ this.repository = repository;
+ this.task = task;
+ setDescription(Messages.ContextRetrieveWizardPage_SELECT_A_CONTEXT_TO_RETTRIEVE_FROM_TABLE_BELOW);
+ setTitle(Messages.ContextRetrieveWizardPage_Select_context);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1, false));
+
+ Text summary = new Text(composite, SWT.NONE);
+ summary.setText(NLS.bind(Messages.ContextRetrieveWizardPage_Task, labelProvider.getText(task)));
+ summary.setEditable(false);
+ // new Label(composite, SWT.NONE).setText("Repository: " +
+ // repository.getUrl());
+ // new Label(composite, SWT.NONE).setText("Select context below:");
+
+ final Table contextTable = new Table(composite, SWT.FULL_SELECTION | SWT.BORDER);
+ contextTable.setHeaderVisible(true);
+ contextTable.setLinesVisible(true);
+
+ contextTable.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ if (contextTable.getSelectionIndex() > -1) {
+ selectedContextAttachment = (ITaskAttachment) contextTable.getItem(contextTable.getSelectionIndex())
+ .getData();
+ getWizard().getContainer().updateButtons();
+ }
+ }
+ });
+ contextTable.addMouseListener(new MouseListener() {
+
+ public void mouseDoubleClick(MouseEvent e) {
+ selectedContextAttachment = (ITaskAttachment) contextTable.getItem(contextTable.getSelectionIndex())
+ .getData();
+ getWizard().getContainer().updateButtons();
+ getWizard().performFinish();
+ // TODO: is there a better way of closing?
+ getWizard().getContainer().getShell().close();
+ }
+
+ public void mouseDown(MouseEvent e) {
+ }
+
+ public void mouseUp(MouseEvent e) {
+ }
+
+ });
+
+ List<ITaskAttachment> contextAttachments = AttachmentUtil.getContextAttachments(repository, task);
+
+ Collections.sort(contextAttachments, new TaskAttachmentComparator());
+
+ TableColumn[] columns = new TableColumn[3];
+ columns[0] = new TableColumn(contextTable, SWT.LEFT);
+ columns[0].setText(Messages.ContextRetrieveWizardPage_Date);
+ columns[1] = new TableColumn(contextTable, SWT.LEFT);
+ columns[1].setText(Messages.ContextRetrieveWizardPage_Author);
+ columns[2] = new TableColumn(contextTable, SWT.CENTER);
+ columns[2].setText(Messages.ContextRetrieveWizardPage_Description);
+
+ for (ITaskAttachment attachment : contextAttachments) {
+ TableItem item = new TableItem(contextTable, SWT.NONE);
+ item.setText(0, DateFormat.getInstance().format(attachment.getCreationDate()));
+ IRepositoryPerson author = attachment.getAuthor();
+ if (author != null) {
+ item.setText(1, author.toString());
+ }
+ item.setText(2, attachment.getDescription());
+ item.setData(attachment);
+ }
+
+ for (TableColumn column : columns) {
+ column.pack();
+ }
+
+ contextTable.setLayoutData(new GridData(GridData.FILL_BOTH));
+ setControl(composite);
+ if (contextAttachments.size() > 0) {
+ contextTable.setSelection(0);
+ selectedContextAttachment = contextAttachments.get(0);
+ getWizard().getContainer().updateButtons();
+ }
+ contextTable.setFocus();
+ Dialog.applyDialogFont(composite);
+ }
+
+ public ITaskAttachment getSelectedContext() {
+ return selectedContextAttachment;
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ if (selectedContextAttachment == null) {
+ return false;
+ }
+ return super.isPageComplete();
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/CopyContextHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/CopyContextHandler.java
new file mode 100644
index 0000000..8300d22
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/CopyContextHandler.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * 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.context;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.actions.TaskSelectionDialog;
+import org.eclipse.mylyn.internal.tasks.ui.commands.AbstractTaskHandler;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Steffen Pingel
+ */
+public class CopyContextHandler extends AbstractTaskHandler {
+
+ private static final String TITLE_DIALOG = Messages.CopyContextHandler_Copy_Context;
+
+ @Override
+ protected void execute(ExecutionEvent event, ITask sourceTask) throws ExecutionException {
+ run(sourceTask);
+ }
+
+ public static void run(ITask sourceTask) {
+ if (sourceTask == null) {
+ MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ TITLE_DIALOG, Messages.CopyContextHandler_No_source_task_selected);
+ return;
+ }
+
+ TaskSelectionDialog dialog = new TaskSelectionDialog(WorkbenchUtil.getShell());
+ dialog.setNeedsCreateTask(false);
+ dialog.setTitle(Messages.CopyContextHandler_Select_Target_Task);
+ dialog.setMessage(Messages.CopyContextHandler_Select_the_target_task__);
+
+ if (dialog.open() != Window.OK) {
+ return;
+ }
+
+ Object result = dialog.getFirstResult();
+
+ if (result instanceof ITask) {
+ ITask targetTask = (ITask) result;
+ TasksUi.getTaskActivityManager().deactivateActiveTask();
+ if (targetTask.equals(sourceTask)) {
+ MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ TITLE_DIALOG, Messages.CopyContextHandler_TARGET_TASK_CON_NOT_BE_THE_SAME_AS_SOURCE_TASK);
+ } else {
+ final int REPLACE = 0;
+ final int MERGE = 1;
+ final int CANCEL = 2;
+ int action = REPLACE;
+ if (TasksUiPlugin.getContextStore().hasContext(targetTask)) {
+ MessageDialog dialog2 = new MessageDialog(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getShell(), TITLE_DIALOG, null,
+ Messages.CopyContextHandler_SELECTED_TASK_ALREADY_HAS_CONTEXT, MessageDialog.QUESTION,
+ new String[] { Messages.CopyContextHandler_Replace, Messages.CopyContextHandler_Merge,
+ IDialogConstants.CANCEL_LABEL }, 1);
+ action = dialog2.open();
+ }
+
+ switch (action) {
+ case REPLACE:
+ IAdaptable context = TasksUiPlugin.getContextStore().cloneContext(sourceTask, targetTask);
+ if (context == null) {
+ MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ TITLE_DIALOG, Messages.CopyContextHandler_SOURCE_TASK_DOES_HAVE_A_CONTEXT);
+ return;
+ }
+ break;
+ case MERGE:
+ TasksUiPlugin.getContextStore().mergeContext(sourceTask, targetTask);
+ break;
+ case CANCEL:
+ return;
+ }
+
+ TasksUiInternal.activateTaskThroughCommand(targetTask);
+ }
+ } else {
+ MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ TITLE_DIALOG, Messages.CopyContextHandler_No_target_task_selected);
+ }
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/Messages.java
new file mode 100644
index 0000000..67938b2
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/Messages.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * 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.context;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.tasks.ui.context.messages"; //$NON-NLS-1$
+
+ static {
+ // load message values from bundle file
+ reloadMessages();
+ }
+
+ public static void reloadMessages() {
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ public static String ContextAttachWizard_Attach_Context;
+
+ public static String ContextAttachWizardPage_Enter_comment;
+
+ public static String ContextAttachWizardPage_Attaches_local_context_to_repository_task;
+
+ public static String ContextAttachWizardPage_Comment_;
+
+ public static String ContextAttachWizardPage_Repository_;
+
+ public static String ContextAttachWizardPage_Task;
+
+ public static String ContextRetrieveWizard_Retrieve_Context;
+
+ public static String ContextRetrieveWizardPage_Author;
+
+ public static String ContextRetrieveWizardPage_Date;
+
+ public static String ContextRetrieveWizardPage_Description;
+
+ public static String ContextRetrieveWizardPage_Select_context;
+
+ public static String ContextRetrieveWizardPage_SELECT_A_CONTEXT_TO_RETTRIEVE_FROM_TABLE_BELOW;
+
+ public static String ContextRetrieveWizardPage_Task;
+
+ public static String RetrieveLatestContextDialog_Dialog_Title;
+
+ public static String RetrieveLatestContextDialog_No_local_context_exists;
+
+ public static String RetrieveLatestContextDialog_Show_All_Contexts_Label;
+
+ public static String RetrieveLatestContextDialog_Unknown;
+
+ public static String ClearContextHandler_CLEAR_THE_CONTEXT_THE_FOR_SELECTED_TASK;
+
+ public static String ClearContextHandler_Confirm_clear_context;
+
+ public static String CopyContextHandler_Merge;
+
+ public static String CopyContextHandler_Copy_Context;
+
+ public static String CopyContextHandler_No_source_task_selected;
+
+ public static String CopyContextHandler_No_target_task_selected;
+
+ public static String CopyContextHandler_Replace;
+
+ public static String CopyContextHandler_Select_Target_Task;
+
+ public static String CopyContextHandler_Select_the_target_task__;
+
+ public static String CopyContextHandler_SELECTED_TASK_ALREADY_HAS_CONTEXT;
+
+ public static String CopyContextHandler_SOURCE_TASK_DOES_HAVE_A_CONTEXT;
+
+ public static String CopyContextHandler_TARGET_TASK_CON_NOT_BE_THE_SAME_AS_SOURCE_TASK;
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ProgressContainer.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ProgressContainer.java
new file mode 100644
index 0000000..62acd52
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/ProgressContainer.java
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Chris Gross (schtoo@schtoo.com) - patch for bug 16179
+ * Tasktop Technologies - extracted code for Mylyn
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.context;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.operation.ModalContext;
+import org.eclipse.jface.wizard.ProgressMonitorPart;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * A helper class for running operations in dialogs. Based on {@link WizardDialog}.
+ *
+ * @author Steffen Pingel
+ */
+class ProgressContainer implements IRunnableContext {
+
+ private static final String FOCUS_CONTROL = "focusControl"; //$NON-NLS-1$
+
+ // The number of long running operation executed from the dialog.
+ private long activeRunningOperations = 0;
+
+ private Cursor arrowCursor;
+
+ private Button cancelButton;
+
+ private boolean lockedUI = false;
+
+ // The progress monitor
+ private final ProgressMonitorPart progressMonitorPart;
+
+ private final Shell shell;
+
+ private Cursor waitCursor;
+
+ public ProgressContainer(Shell shell, ProgressMonitorPart progressMonitorPart) {
+ Assert.isNotNull(shell);
+ Assert.isNotNull(progressMonitorPart);
+ this.shell = shell;
+ this.progressMonitorPart = progressMonitorPart;
+ }
+
+ /**
+ * About to start a long running operation triggered through the wizard. Shows the progress monitor and disables the
+ * wizard's buttons and controls.
+ *
+ * @param enableCancelButton
+ * <code>true</code> if the Cancel button should be enabled, and <code>false</code> if it should be
+ * disabled
+ * @return the saved UI state
+ */
+ private Object aboutToStart(boolean enableCancelButton) {
+ Map<Object, Object> savedState = null;
+ if (getShell() != null) {
+ // Save focus control
+ Control focusControl = getShell().getDisplay().getFocusControl();
+ if (focusControl != null && focusControl.getShell() != getShell()) {
+ focusControl = null;
+ }
+ //cancelButton.removeSelectionListener(cancelListener);
+ // Set the busy cursor to all shells.
+ Display d = getShell().getDisplay();
+ waitCursor = new Cursor(d, SWT.CURSOR_WAIT);
+ setDisplayCursor(waitCursor);
+ // Set the arrow cursor to the cancel component.
+ arrowCursor = new Cursor(d, SWT.CURSOR_ARROW);
+ cancelButton.setCursor(arrowCursor);
+ // Deactivate shell
+ savedState = new HashMap<Object, Object>(10);
+ saveUiState(savedState);
+ if (focusControl != null) {
+ savedState.put(FOCUS_CONTROL, focusControl);
+ }
+ // Attach the progress monitor part to the cancel button
+ progressMonitorPart.attachToCancelComponent(cancelButton);
+ progressMonitorPart.setVisible(true);
+ }
+ return savedState;
+ }
+
+ public Button getCancelButton() {
+ return cancelButton;
+ }
+
+ private IProgressMonitor getProgressMonitor() {
+ return progressMonitorPart;
+ }
+
+ public Shell getShell() {
+ return shell;
+ }
+
+ public boolean isActive() {
+ return activeRunningOperations > 0;
+ }
+
+ public boolean isLockedUI() {
+ return lockedUI;
+ }
+
+ protected void restoreUiState(Map<Object, Object> state) {
+ // ignore
+
+ }
+
+ /**
+ * This implementation of IRunnableContext#run(boolean, boolean, IRunnableWithProgress) blocks until the runnable
+ * has been run, regardless of the value of <code>fork</code>. It is recommended that <code>fork</code> is set to
+ * true in most cases. If <code>fork</code> is set to <code>false</code>, the runnable will run in the UI thread and
+ * it is the runnable's responsibility to call <code>Display.readAndDispatch()</code> to ensure UI responsiveness.
+ * UI state is saved prior to executing the long-running operation and is restored after the long-running operation
+ * completes executing. Any attempt to change the UI state of the wizard in the long-running operation will be
+ * nullified when original UI state is restored.
+ */
+ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException,
+ InterruptedException {
+ // The operation can only be canceled if it is executed in a separate
+ // thread.
+ // Otherwise the UI is blocked anyway.
+ Object state = null;
+ if (activeRunningOperations == 0) {
+ state = aboutToStart(fork && cancelable);
+ }
+ activeRunningOperations++;
+ try {
+ if (!fork) {
+ lockedUI = true;
+ }
+ ModalContext.run(runnable, fork, getProgressMonitor(), getShell().getDisplay());
+ lockedUI = false;
+ } finally {
+ activeRunningOperations--;
+ // Stop if this is the last one
+ if (state != null) {
+ stopped(state);
+ }
+ }
+ }
+
+ protected void saveUiState(Map<Object, Object> savedState) {
+ // ignore
+
+ }
+
+ public void setCancelButton(Button cancelButton) {
+ this.cancelButton = cancelButton;
+ }
+
+ /**
+ * Sets the given cursor for all shells currently active for this window's display.
+ *
+ * @param c
+ * the cursor
+ */
+ private void setDisplayCursor(Cursor c) {
+ Shell[] shells = getShell().getDisplay().getShells();
+ for (Shell shell2 : shells) {
+ shell2.setCursor(c);
+ }
+ }
+
+ /**
+ * A long running operation triggered through the wizard was stopped either by user input or by normal end. Hides
+ * the progress monitor and restores the enable state wizard's buttons and controls.
+ *
+ * @param savedState
+ * the saved UI state as returned by <code>aboutToStart</code>
+ * @see #aboutToStart
+ */
+ @SuppressWarnings("unchecked")
+ private void stopped(Object savedState) {
+ if (getShell() != null && !getShell().isDisposed()) {
+ progressMonitorPart.setVisible(false);
+ progressMonitorPart.removeFromCancelComponent(cancelButton);
+
+ Map<Object, Object> state = (Map<Object, Object>) savedState;
+ restoreUiState(state);
+// cancelButton.addSelectionListener(cancelListener);
+ setDisplayCursor(null);
+ cancelButton.setCursor(null);
+ waitCursor.dispose();
+ waitCursor = null;
+ arrowCursor.dispose();
+ arrowCursor = null;
+ Control focusControl = (Control) state.get(FOCUS_CONTROL);
+ if (focusControl != null && !focusControl.isDisposed()) {
+ focusControl.setFocus();
+ }
+ }
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/RetrieveContextAttachmentHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/RetrieveContextAttachmentHandler.java
new file mode 100644
index 0000000..6b44cac
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/RetrieveContextAttachmentHandler.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.context;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
+import org.eclipse.mylyn.tasks.core.ITaskAttachment;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Steffen Pingel
+ */
+public class RetrieveContextAttachmentHandler extends AbstractTaskAttachmentCommandHandler {
+
+ @Override
+ protected void execute(ExecutionEvent event, ITaskAttachment attachment) {
+ AttachmentUtil.downloadContext(attachment.getTask(), attachment, PlatformUI.getWorkbench().getProgressService());
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/RetrieveContextHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/RetrieveContextHandler.java
new file mode 100644
index 0000000..42d5fb7
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/RetrieveContextHandler.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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.context;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil;
+import org.eclipse.mylyn.internal.tasks.ui.commands.AbstractTaskHandler;
+import org.eclipse.mylyn.tasks.core.ITask;
+
+/**
+ * @author Steffen Pingel
+ */
+public class RetrieveContextHandler extends AbstractTaskHandler {
+
+ @Override
+ protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
+ run(task);
+ }
+
+ public static void run(ITask task) {
+ ContextRetrieveWizard wizard = new ContextRetrieveWizard(task);
+ WizardDialog dialog = new WizardDialog(WorkbenchUtil.getShell(), wizard);
+ dialog.create();
+ dialog.setBlockOnOpen(true);
+ dialog.open();
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/RetrieveLatestContextDialog.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/RetrieveLatestContextDialog.java
new file mode 100644
index 0000000..a261474
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/RetrieveLatestContextDialog.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 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.context;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.wizard.ProgressMonitorPart;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil;
+import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.ITaskAttachment;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Shell;
+
+import com.ibm.icu.text.DateFormat;
+
+/**
+ * @author Steffen Pingel
+ */
+public class RetrieveLatestContextDialog extends MessageDialog {
+
+ public static boolean openQuestion(Shell shell, ITask task) {
+ TaskRepository repository = TasksUi.getRepositoryManager().getRepository(task.getConnectorKind(),
+ task.getRepositoryUrl());
+ List<ITaskAttachment> contextAttachments = AttachmentUtil.getContextAttachments(repository, task);
+ Collections.sort(contextAttachments, new TaskAttachmentComparator());
+ if (contextAttachments.size() > 0) {
+ ITaskAttachment attachment = contextAttachments.get(0);
+ String author = null;
+ if (attachment.getAuthor() != null) {
+ author = (attachment.getAuthor().getName()) != null
+ ? attachment.getAuthor().getName()
+ : attachment.getAuthor().getPersonId();
+ }
+ if (author == null) {
+ author = Messages.RetrieveLatestContextDialog_Unknown;
+ }
+ Date date = attachment.getCreationDate();
+ String dateString = null;
+ if (date != null) {
+ dateString = DateFormat.getDateInstance(DateFormat.LONG).format(date);
+ }
+ if (dateString == null) {
+ dateString = Messages.RetrieveLatestContextDialog_Unknown;
+ }
+ String message = NLS.bind(Messages.RetrieveLatestContextDialog_No_local_context_exists, author, dateString);
+ int kind = QUESTION;
+ int style = SWT.NONE;
+
+ RetrieveLatestContextDialog dialog = new RetrieveLatestContextDialog(shell,
+ Messages.RetrieveLatestContextDialog_Dialog_Title, null, message, kind, new String[] {
+ IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0, task, attachment);
+ style &= TasksUiInternal.SWT_SHEET;
+ dialog.setShellStyle(dialog.getShellStyle() | style);
+ return dialog.open() == 0;
+ }
+ return false;
+ }
+
+ private final ITaskAttachment attachment;
+
+ private Link link;
+
+ private ProgressContainer progressContainer;
+
+ private ProgressMonitorPart progressMonitorPart;
+
+ private final ITask task;
+
+ public RetrieveLatestContextDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage,
+ String dialogMessage, int dialogImageType, String[] dialogButtonLabels, int defaultIndex, ITask task,
+ ITaskAttachment attachment) {
+ super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels,
+ defaultIndex);
+ this.task = task;
+ this.attachment = attachment;
+ }
+
+ @Override
+ protected void buttonPressed(int buttonId) {
+ if (progressContainer.isActive()) {
+ return;
+ }
+ if (buttonId == 0) {
+ if (!AttachmentUtil.downloadContext(task, attachment, progressContainer)) {
+ // failed
+ return;
+ }
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ @Override
+ protected Control createButtonBar(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).create());
+ GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(composite);
+ Control control = createLink(composite);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(control);
+ super.createButtonBar(composite);
+ return composite;
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Control control = super.createContents(parent);
+ progressContainer.setCancelButton(getButton(1));
+ getButton(0).setFocus();
+ return control;
+ }
+
+ @Override
+ protected Control createCustomArea(Composite parent) {
+ progressMonitorPart = new ProgressMonitorPart(parent, null);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(progressMonitorPart);
+ progressContainer = new ProgressContainer(getShell(), progressMonitorPart) {
+ @Override
+ protected void restoreUiState(Map<Object, Object> state) {
+ link.setEnabled(true);
+ getButton(0).setEnabled(true);
+ getButton(1).setEnabled(true);
+ };
+
+ @Override
+ protected void saveUiState(Map<Object, Object> savedState) {
+ link.setEnabled(false);
+ getButton(0).setEnabled(false);
+ };
+ };
+ return progressMonitorPart;
+ }
+
+ protected Control createLink(Composite parent) {
+ link = new Link(parent, SWT.NONE);
+ link.setText(Messages.RetrieveLatestContextDialog_Show_All_Contexts_Label);
+ link.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ close();
+
+ ContextRetrieveWizard wizard = new ContextRetrieveWizard(task);
+ WizardDialog dialog = new WizardDialog(WorkbenchUtil.getShell(), wizard);
+ dialog.create();
+ dialog.setBlockOnOpen(true);
+ setReturnCode(dialog.open());
+ }
+ });
+ return link;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/TaskAttachmentComparator.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/TaskAttachmentComparator.java
new file mode 100644
index 0000000..f63dbc9
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/TaskAttachmentComparator.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 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.context;
+
+import java.util.Comparator;
+import java.util.Date;
+
+import org.eclipse.mylyn.tasks.core.ITaskAttachment;
+
+class TaskAttachmentComparator implements Comparator<ITaskAttachment> {
+ public int compare(ITaskAttachment attachment1, ITaskAttachment attachment2) {
+ Date created1 = null;
+ Date created2 = null;
+ created1 = attachment1.getCreationDate();
+ created2 = attachment2.getCreationDate();
+ if (created1 != null && created2 != null) {
+ return (-1) * created1.compareTo(created2);
+ } else if (created1 == null && created2 != null) {
+ return 1;
+ } else if (created1 != null && created2 == null) {
+ return -1;
+ } else {
+ return 0;
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/messages.properties
new file mode 100644
index 0000000..11b550e
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/context/messages.properties
@@ -0,0 +1,45 @@
+###############################################################################
+# Copyright (c) 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
+###############################################################################
+ContextAttachWizard_Attach_Context=Attach Context
+
+ContextAttachWizardPage_Enter_comment=Enter comment
+ContextAttachWizardPage_Attaches_local_context_to_repository_task=Attaches local context to repository task
+ContextAttachWizardPage_Comment_=Comment:
+ContextAttachWizardPage_Repository_=Repository:
+
+ContextAttachWizardPage_Task=Task: {0}
+
+ContextRetrieveWizard_Retrieve_Context=Retrieve Context
+
+ContextRetrieveWizardPage_Author=Author
+ContextRetrieveWizardPage_Date=Date
+ContextRetrieveWizardPage_Description=Description
+ContextRetrieveWizardPage_Select_context=Select context
+ContextRetrieveWizardPage_SELECT_A_CONTEXT_TO_RETTRIEVE_FROM_TABLE_BELOW=Select a context to retrieve from table below.
+ContextRetrieveWizardPage_Task=Task: {0}
+RetrieveLatestContextDialog_Dialog_Title=Activate Task
+RetrieveLatestContextDialog_No_local_context_exists=No local context exists. Retrieve context created by {0} on {1} from repository?
+RetrieveLatestContextDialog_Show_All_Contexts_Label=<a>Show All Contexts</a>
+RetrieveLatestContextDialog_Unknown=<Unknown>
+
+ClearContextHandler_CLEAR_THE_CONTEXT_THE_FOR_SELECTED_TASK=Clear the context for the selected task? This cannot be undone.
+ClearContextHandler_Confirm_clear_context=Confirm clear context
+
+CopyContextHandler_Merge=Merge
+CopyContextHandler_Copy_Context=Copy Context
+CopyContextHandler_No_source_task_selected=No source task selected.
+CopyContextHandler_No_target_task_selected=No target task selected.
+CopyContextHandler_Replace=Replace
+CopyContextHandler_Select_Target_Task=Select Target Task
+CopyContextHandler_Select_the_target_task__=&Select the target task (? = any character, * = any String):
+CopyContextHandler_SELECTED_TASK_ALREADY_HAS_CONTEXT=The selected task already has a context. Would you like to replace the context or merge the new context into it?
+CopyContextHandler_SOURCE_TASK_DOES_HAVE_A_CONTEXT=Source task does not have a context.
+CopyContextHandler_TARGET_TASK_CON_NOT_BE_THE_SAME_AS_SOURCE_TASK=Target task can not be the same as source task.