### Eclipse Workspace Patch 1.0 #P org.eclipse.mylyn.bugzilla.ui Index: src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaImages.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaImages.java,v retrieving revision 1.14 diff -u -r1.14 BugzillaImages.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaImages.java 26 Jun 2007 01:16:18 -0000 1.14 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaImages.java 20 Nov 2007 19:18:30 -0000 @@ -51,6 +51,8 @@ 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 { Index: plugin.xml =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/plugin.xml,v retrieving revision 1.89 diff -u -r1.89 plugin.xml --- plugin.xml 23 Jun 2007 01:45:16 -0000 1.89 +++ plugin.xml 20 Nov 2007 19:18:30 -0000 @@ -35,5 +35,29 @@ + + + + + + + + + + + Index: src/org/eclipse/mylyn/internal/bugzilla/ui/actions/NewBugzillaSubTaskAction.java =================================================================== RCS file: src/org/eclipse/mylyn/internal/bugzilla/ui/actions/NewBugzillaSubTaskAction.java diff -N src/org/eclipse/mylyn/internal/bugzilla/ui/actions/NewBugzillaSubTaskAction.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/actions/NewBugzillaSubTaskAction.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,103 @@ +/******************************************************************************* + * 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; + +public class NewBugzillaSubTaskAction extends Action implements IViewActionDelegate, IExecutableExtension { + + private static final String LABEL = "New 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 + + } + +} #P org.eclipse.mylyn.bugzilla.core Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java,v retrieving revision 1.31 diff -u -r1.31 BugzillaTaskDataHandler.java --- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java 28 Aug 2007 21:07:38 -0000 1.31 +++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java 20 Nov 2007 19:18:31 -0000 @@ -338,5 +338,15 @@ 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(""); + } }