Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2007-11-21 08:52:01 +0000
committerrelves2007-11-21 08:52:01 +0000
commit9346f4efd6af94f6c79935c28b0ffbbabca39574 (patch)
tree73dd13342a2375be3685fb9f7d0dda857d167c59
parentc527fab343af64327a55de0dff7476bdb98efe1d (diff)
downloadorg.eclipse.mylyn.tasks-9346f4efd6af94f6c79935c28b0ffbbabca39574.tar.gz
org.eclipse.mylyn.tasks-9346f4efd6af94f6c79935c28b0ffbbabca39574.tar.xz
org.eclipse.mylyn.tasks-9346f4efd6af94f6c79935c28b0ffbbabca39574.zip
NEW - bug 207524: [patch] add create subtask action for Bugzilla editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=207524
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java10
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/icons/etool16/sub-task-new.gifbin0 -> 381 bytes
-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
6 files changed, 144 insertions, 1 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 e26f48a49..dde22abd2 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,5 +338,15 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
public boolean canGetMultiTaskData() {
return true;
}
+ public void initializeSubTaskData(TaskRepository taskRepository, RepositoryTaskData taskData,
+ RepositoryTaskData parentTaskData, IProgressMonitor monitor) throws CoreException {
+ String project = parentTaskData.getProduct();
+ taskData.setAttributeValue(RepositoryTaskAttribute.PRODUCT, project);
+ BugzillaRepositoryConnector.setupNewBugAttributes(taskRepository, taskData);
+ cloneTaskData(parentTaskData, taskData);
+ taskData.setAttributeValue(BugzillaReportElement.BLOCKED.getKeyString(), parentTaskData.getId());
+ taskData.setDescription("");
+ taskData.setSummary("");
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java
index c8942349d..99930f560 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java
@@ -130,7 +130,7 @@ public class BugzillaConfigurationTest extends TestCase {
assertEquals(7, config.getStatusValues().size());
assertEquals(9, config.getResolutions().size());
assertEquals(6, config.getPlatforms().size());
- assertEquals(29, config.getOSs().size());
+ assertEquals(30, config.getOSs().size());
assertEquals(5, config.getPriorities().size());
assertEquals(7, config.getSeverities().size());
assertTrue(config.getProducts().size() > 50);
diff --git a/org.eclipse.mylyn.bugzilla.ui/icons/etool16/sub-task-new.gif b/org.eclipse.mylyn.bugzilla.ui/icons/etool16/sub-task-new.gif
new file mode 100644
index 000000000..ec27050fe
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/icons/etool16/sub-task-new.gif
Binary files differ
diff --git a/org.eclipse.mylyn.bugzilla.ui/plugin.xml b/org.eclipse.mylyn.bugzilla.ui/plugin.xml
index b7fe62a0d..eb1cf04d8 100644
--- a/org.eclipse.mylyn.bugzilla.ui/plugin.xml
+++ b/org.eclipse.mylyn.bugzilla.ui/plugin.xml
@@ -35,5 +35,29 @@
<newWizardShortcut id="org.eclipse.mylyn.bugzilla.bugWizard"/>
</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 7f2ec6e0b..a38b3b747 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
@@ -51,6 +51,8 @@ public class BugzillaImages {
public static final ImageDescriptor OVERLAY_ENHANCEMENT = create(T_VIEW, "overlay-enhancement.gif");
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 {
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
new file mode 100644
index 000000000..88a2aa36e
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/actions/NewBugzillaSubTaskAction.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * 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
+
+ }
+
+}

Back to the top