Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2007-11-21 22:14:58 +0000
committerspingel2007-11-21 22:14:58 +0000
commit7284f998b44bdfb86b754a964d0d3953c8285eae (patch)
treef8437108dc6b391a80ab2e3d20919d32306301be
parentde8d415884aca6bec93b8d4ba1fc7c7b955e3e36 (diff)
downloadorg.eclipse.mylyn.tasks-7284f998b44bdfb86b754a964d0d3953c8285eae.tar.gz
org.eclipse.mylyn.tasks-7284f998b44bdfb86b754a964d0d3953c8285eae.tar.xz
org.eclipse.mylyn.tasks-7284f998b44bdfb86b754a964d0d3953c8285eae.zip
NEW - bug 210590: [api] add support for creating subtasks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=210590
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java10
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/plugin.xml24
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaImages.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/actions/NewBugzillaSubTaskAction.java107
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java1
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractTaskDataHandler.java16
-rw-r--r--org.eclipse.mylyn.tasks.ui/icons/etool16/sub-task-new.gif (renamed from org.eclipse.mylyn.bugzilla.ui/icons/etool16/sub-task-new.gif)bin381 -> 381 bytes
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiImages.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/NewSubTaskAction.java156
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java27
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java7
11 files changed, 218 insertions, 136 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java
index dde22abd2..61f30bed2 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java
@@ -338,7 +338,9 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
public boolean canGetMultiTaskData() {
return true;
}
- public void initializeSubTaskData(TaskRepository taskRepository, RepositoryTaskData taskData,
+
+ @Override
+ public boolean initializeSubTaskData(TaskRepository taskRepository, RepositoryTaskData taskData,
RepositoryTaskData parentTaskData, IProgressMonitor monitor) throws CoreException {
String project = parentTaskData.getProduct();
taskData.setAttributeValue(RepositoryTaskAttribute.PRODUCT, project);
@@ -347,6 +349,12 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
taskData.setAttributeValue(BugzillaReportElement.BLOCKED.getKeyString(), parentTaskData.getId());
taskData.setDescription("");
taskData.setSummary("");
+ return true;
+ }
+
+ @Override
+ public boolean canInitializeSubTaskData() {
+ return true;
}
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/plugin.xml b/org.eclipse.mylyn.bugzilla.ui/plugin.xml
index eb1cf04d8..d7620a368 100644
--- a/org.eclipse.mylyn.bugzilla.ui/plugin.xml
+++ b/org.eclipse.mylyn.bugzilla.ui/plugin.xml
@@ -36,28 +36,4 @@
</perspectiveExtension>
</extension>
- <extension point="org.eclipse.ui.popupMenus">
- <objectContribution
- id="org.eclipse.mylyn.bugzilla.ui.BugzillaTask"
- objectClass="org.eclipse.mylyn.internal.bugzilla.core.BugzillaTask">
- <action
- class="org.eclipse.mylyn.internal.bugzilla.ui.actions.NewBugzillaSubTaskAction"
- enablesFor="org.eclipse.mylyn.internal.bugzilla.core.BugzillaTask"
- icon="icons/etool16/sub-task-new.gif"
- id="org.eclipse.mylyn.bugzilla.ui.new.subtask"
- label="Subtask"
- menubarPath="org.eclipse.mylyn.tasks.ui.menu.new/repository"
- tooltip="New Bugzilla Subtask">
- </action>
- <menu
- id="org.eclipse.mylyn.tasks.ui.menu.new"
- label="New"
- path="new">
- <separator
- name="repository">
- </separator>
- </menu>
- </objectContribution>
- </extension>
-
</plugin>
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaImages.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaImages.java
index a38b3b747..9ba54c306 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaImages.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaImages.java
@@ -52,8 +52,6 @@ public class BugzillaImages {
public static final ImageDescriptor OVERLAY_MINOR = create(T_VIEW, "overlay-minor.gif");
- public static final ImageDescriptor NEW_SUB_TASK = create(T_TOOL, "sub-task-new.gif");
-
private static ImageDescriptor create(String prefix, String name) {
try {
return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/actions/NewBugzillaSubTaskAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/actions/NewBugzillaSubTaskAction.java
deleted file mode 100644
index 88a2aa36e..000000000
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/actions/NewBugzillaSubTaskAction.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.bugzilla.ui.actions;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTask;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTaskDataHandler;
-import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaImages;
-import org.eclipse.mylyn.monitor.core.StatusHandler;
-import org.eclipse.mylyn.tasks.core.AbstractAttributeFactory;
-import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
-import org.eclipse.mylyn.tasks.core.AbstractTask;
-import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
-import org.eclipse.mylyn.tasks.ui.editors.NewTaskEditorInput;
-import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
-import org.eclipse.ui.IViewActionDelegate;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Frank Becker
- */
-public class NewBugzillaSubTaskAction extends Action implements IViewActionDelegate, IExecutableExtension {
-
- private static final String LABEL = "Subtask";
-
- public static final String ID = "org.eclipse.mylyn.bugzilla.ui.new.subtask";
-
- private BugzillaTask selectedTask;
-
- public NewBugzillaSubTaskAction() {
- super(LABEL);
- setToolTipText(LABEL);
- setId(ID);
- setImageDescriptor(BugzillaImages.NEW_SUB_TASK);
- }
-
- public void init(IViewPart view) {
- // ignore
-
- }
-
- @SuppressWarnings("restriction")
- public void run(IAction action) {
- AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
- BugzillaCorePlugin.REPOSITORY_KIND);
-
- String repositoryUrl = selectedTask.getRepositoryUrl();
- TaskRepository taskRepository = TasksUiPlugin.getRepositoryManager().getRepository(repositoryUrl);
- RepositoryTaskData selectedTaskData = TasksUiPlugin.getTaskDataManager().getNewTaskData(repositoryUrl,
- selectedTask.getTaskId());
-
- BugzillaTaskDataHandler taskDataHandler = (BugzillaTaskDataHandler) connector.getTaskDataHandler();
- AbstractAttributeFactory attributeFactory = taskDataHandler.getAttributeFactory(taskRepository.getUrl(),
- taskRepository.getConnectorKind(), AbstractTask.DEFAULT_TASK_KIND);
- RepositoryTaskData taskData = new RepositoryTaskData(attributeFactory, BugzillaCorePlugin.REPOSITORY_KIND,
- taskRepository.getUrl(), TasksUiPlugin.getDefault().getNextNewRepositoryTaskId());
- taskData.setNew(true);
- try {
- taskDataHandler.initializeSubTaskData(taskRepository, taskData, selectedTaskData, new NullProgressMonitor());
- } catch (CoreException e) {
- StatusHandler.displayStatus("Unable to create Subtask", e.getStatus());
- }
-
- // open editor
- NewTaskEditorInput editorInput = new NewTaskEditorInput(taskRepository, taskData);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- TasksUiUtil.openEditor(editorInput, TaskEditor.ID_EDITOR, page);
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- selectedTask = null;
- if (selection instanceof StructuredSelection) {
- Object selectedObject = ((StructuredSelection) selection).getFirstElement();
- if (selectedObject instanceof BugzillaTask) {
- selectedTask = (BugzillaTask) selectedObject;
- }
- }
-
- action.setEnabled(selectedTask != null);
- }
-
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
- throws CoreException {
- // ignore
-
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java
index c45bca77f..4e126abde 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java
@@ -671,4 +671,5 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor {
}
return super.attributeChanged(attribute);
}
+
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractTaskDataHandler.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractTaskDataHandler.java
index 45a7f2901..e2914ecc9 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractTaskDataHandler.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractTaskDataHandler.java
@@ -67,6 +67,22 @@ public abstract class AbstractTaskDataHandler {
public abstract boolean initializeTaskData(TaskRepository repository, RepositoryTaskData data,
IProgressMonitor monitor) throws CoreException;
+ /**
+ * @since 2.2
+ * @return false if this operation is not supported by the connector, true if initialized
+ */
+ public boolean initializeSubTaskData(TaskRepository repository, RepositoryTaskData taskData,
+ RepositoryTaskData parentTaskData, IProgressMonitor monitor) throws CoreException {
+ return false;
+ }
+
+ /**
+ * @since 2.2
+ */
+ public boolean canInitializeSubTaskData() {
+ return false;
+ }
+
public abstract AbstractAttributeFactory getAttributeFactory(RepositoryTaskData taskData);
/**
diff --git a/org.eclipse.mylyn.bugzilla.ui/icons/etool16/sub-task-new.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/sub-task-new.gif
index ec27050fe..ec27050fe 100644
--- a/org.eclipse.mylyn.bugzilla.ui/icons/etool16/sub-task-new.gif
+++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/sub-task-new.gif
Binary files differ
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiImages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiImages.java
index 256105b2e..6159b572d 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiImages.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiImages.java
@@ -266,7 +266,9 @@ public class TasksUiImages {
public static final ImageDescriptor IMAGE_FIT = create(T_TOOL, "capture-fit.png");
public static final ImageDescriptor IMAGE_FILE = create(T_OBJ, "file-image.gif");
-
+
+ public static final ImageDescriptor NEW_SUB_TASK = create(T_TOOL, "sub-task-new.gif");
+
private static ImageDescriptor create(String prefix, String name) {
try {
return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/NewSubTaskAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/NewSubTaskAction.java
new file mode 100644
index 000000000..b67198335
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/NewSubTaskAction.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Mylyn project committers 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
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.actions;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
+import org.eclipse.mylyn.monitor.core.StatusHandler;
+import org.eclipse.mylyn.tasks.core.AbstractAttributeFactory;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
+import org.eclipse.mylyn.tasks.core.AbstractTask;
+import org.eclipse.mylyn.tasks.core.AbstractTaskDataHandler;
+import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
+import org.eclipse.mylyn.tasks.ui.editors.NewTaskEditorInput;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.progress.IProgressService;
+
+/**
+ * @author Steffen Pingel
+ *
+ * TODO support connectors that do not have a rich editor
+ */
+public class NewSubTaskAction extends Action implements IViewActionDelegate, IExecutableExtension {
+
+ private static final String TOOLTIP = "Create a new subtask";
+
+ private static final String LABEL = "Subtask";
+
+ public static final String ID = "org.eclipse.mylyn.tasks.ui.new.subtask";
+
+ private AbstractTask selectedTask;
+
+ public NewSubTaskAction() {
+ super(LABEL);
+ setToolTipText(TOOLTIP);
+ setId(ID);
+ setImageDescriptor(TasksUiImages.NEW_SUB_TASK);
+ }
+
+ @Override
+ public void run() {
+ if (selectedTask == null) {
+ return;
+ }
+
+ AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
+ selectedTask.getConnectorKind());
+ final AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
+ if (taskDataHandler == null || !taskDataHandler.canInitializeSubTaskData()) {
+ return;
+ }
+
+ String repositoryUrl = selectedTask.getRepositoryUrl();
+ final RepositoryTaskData selectedTaskData = TasksUiPlugin.getTaskDataManager().getNewTaskData(repositoryUrl,
+ selectedTask.getTaskId());
+ if (selectedTaskData == null) {
+ StatusHandler.displayStatus("Unable to create subtask", new Status(IStatus.WARNING,
+ TasksUiPlugin.ID_PLUGIN, "Could not retrieve task data for task: " + selectedTask.getUrl()));
+ return;
+ }
+
+ final TaskRepository taskRepository = TasksUiPlugin.getRepositoryManager().getRepository(repositoryUrl);
+ AbstractAttributeFactory attributeFactory = taskDataHandler.getAttributeFactory(taskRepository.getUrl(),
+ taskRepository.getConnectorKind(), AbstractTask.DEFAULT_TASK_KIND);
+ final RepositoryTaskData taskData = new RepositoryTaskData(attributeFactory, selectedTask.getConnectorKind(),
+ taskRepository.getUrl(), TasksUiPlugin.getDefault().getNextNewRepositoryTaskId());
+ taskData.setNew(true);
+
+ final boolean[] result = new boolean[1];
+ IProgressService service = PlatformUI.getWorkbench().getProgressService();
+ try {
+ service.run(false, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ result[0] = taskDataHandler.initializeSubTaskData(taskRepository, taskData, selectedTaskData,
+ new NullProgressMonitor());
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ });
+ } catch (InvocationTargetException e) {
+ StatusHandler.displayStatus("Unable to create subtask", ((CoreException) e.getCause()).getStatus());
+ return;
+ } catch (InterruptedException e) {
+ // canceled
+ return;
+ }
+
+ if (result[0]) {
+ // open editor
+ NewTaskEditorInput editorInput = new NewTaskEditorInput(taskRepository, taskData);
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ TasksUiUtil.openEditor(editorInput, TaskEditor.ID_EDITOR, page);
+ } else {
+ StatusHandler.displayStatus("Unable to create subtask", new Status(IStatus.INFO, TasksUiPlugin.ID_PLUGIN,
+ "The connector does not support creating subtasks for this task"));
+ }
+ }
+
+ public void run(IAction action) {
+ run();
+ }
+
+ public void init(IViewPart view) {
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ selectedTask = null;
+ if (selection instanceof StructuredSelection) {
+ Object selectedObject = ((StructuredSelection) selection).getFirstElement();
+ if (selectedObject instanceof AbstractTask) {
+ selectedTask = (AbstractTask) selectedObject;
+
+ AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
+ selectedTask.getConnectorKind());
+ final AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
+ if (taskDataHandler == null || !taskDataHandler.canInitializeSubTaskData()) {
+ selectedTask = null;
+ }
+ }
+ }
+
+ action.setEnabled(selectedTask != null);
+ }
+
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
+ throws CoreException {
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java
index b60abdca3..3db27c0b0 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java
@@ -75,6 +75,7 @@ import org.eclipse.mylyn.internal.tasks.ui.actions.GroupSubTasksAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.LinkWithEditorAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.MarkTaskCompleteAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.MarkTaskIncompleteAction;
+import org.eclipse.mylyn.internal.tasks.ui.actions.NewSubTaskAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.OpenTaskListElementAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.OpenTasksUiPreferencesAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.OpenWithBrowserAction;
@@ -177,8 +178,14 @@ public class TaskListView extends ViewPart implements IPropertyChangeListener {
private static final String MEMENTO_PRESENTATION = "presentation";
+ private static final String ID_MENU_NEW = "org.eclipse.mylyn.tasks.ui.menu.new";
+
private static final String ID_SEPARATOR_NEW = "new";
+ private static final String ID_SEPARATOR_NEW_LOCAL = "local";
+
+ private static final String ID_SEPARATOR_NEW_REPOSITORY = "repository";
+
private static final String ID_SEPARATOR_OPERATIONS = "operations";
private static final String ID_SEPARATOR_CONTEXT = "context";
@@ -1121,7 +1128,25 @@ public class TaskListView extends ViewPart implements IPropertyChangeListener {
task = (AbstractTask) element;
}
- manager.add(new Separator(ID_SEPARATOR_NEW));
+ if (task != null) {
+ NewSubTaskAction action = new NewSubTaskAction();
+ action.selectionChanged(action, new StructuredSelection(task));
+ if (action.isEnabled()) {
+ IMenuManager subMenu = manager.findMenuUsingPath(ID_MENU_NEW);
+ if (subMenu == null) {
+ subMenu = new MenuManager("New", ID_MENU_NEW);
+ manager.add(subMenu);
+ }
+
+ subMenu.add(new Separator(ID_SEPARATOR_NEW_REPOSITORY));
+ subMenu.add(action);
+ subMenu.add(new Separator(ID_SEPARATOR_NEW_LOCAL));
+ } else {
+ manager.add(new Separator(ID_SEPARATOR_NEW));
+ }
+ } else {
+ manager.add(new Separator(ID_SEPARATOR_NEW));
+ }
manager.add(new Separator());
if (element instanceof AbstractTask) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java
index cbe0ab474..e0fcd9ec8 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java
@@ -78,6 +78,7 @@ import org.eclipse.mylyn.internal.tasks.ui.actions.AttachAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.AttachScreenshotAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.CopyAttachmentToClipboardJob;
import org.eclipse.mylyn.internal.tasks.ui.actions.DownloadAttachmentJob;
+import org.eclipse.mylyn.internal.tasks.ui.actions.NewSubTaskAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.SynchronizeEditorAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.ToggleTaskActivationAction;
import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentTableLabelProvider;
@@ -646,6 +647,12 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage {
protected void fillToolBar(IToolBarManager toolBarManager) {
if (taskData != null && !taskData.isNew()) {
if (repositoryTask != null) {
+ NewSubTaskAction newSubTaskAction = new NewSubTaskAction();
+ newSubTaskAction.selectionChanged(newSubTaskAction, new StructuredSelection(getRepositoryTask()));
+ if (newSubTaskAction.isEnabled()) {
+ toolBarManager.add(newSubTaskAction);
+ }
+
synchronizeEditorAction = new SynchronizeEditorAction();
synchronizeEditorAction.selectionChanged(new StructuredSelection(this));
toolBarManager.add(synchronizeEditorAction);

Back to the top