diff options
author | spingel | 2009-05-16 07:47:18 +0000 |
---|---|---|
committer | spingel | 2009-05-16 07:47:18 +0000 |
commit | 86dcd0b2007cbc7a3a25ac7d8bae6c1ec3edb09b (patch) | |
tree | 5911ca168a7cb7bbf10473c0f985665403ee317c /org.eclipse.mylyn.tasks.bugs | |
parent | 08474d7eb40d11c396c8c03a9cecf8183cb2499a (diff) | |
download | org.eclipse.mylyn.tasks-86dcd0b2007cbc7a3a25ac7d8bae6c1ec3edb09b.tar.gz org.eclipse.mylyn.tasks-86dcd0b2007cbc7a3a25ac7d8bae6c1ec3edb09b.tar.xz org.eclipse.mylyn.tasks-86dcd0b2007cbc7a3a25ac7d8bae6c1ec3edb09b.zip |
NEW - bug 150278: [api] associate plugins with task repositories and products
https://bugs.eclipse.org/bugs/show_bug.cgi?id=150278
Diffstat (limited to 'org.eclipse.mylyn.tasks.bugs')
26 files changed, 1607 insertions, 253 deletions
diff --git a/org.eclipse.mylyn.tasks.bugs/plugin.xml b/org.eclipse.mylyn.tasks.bugs/plugin.xml index 2ffd9b035..6b6c58044 100644 --- a/org.eclipse.mylyn.tasks.bugs/plugin.xml +++ b/org.eclipse.mylyn.tasks.bugs/plugin.xml @@ -2,6 +2,7 @@ <?eclipse version="3.0"?> <plugin> <extension-point id="pluginRepositoryMappings" name="Plug-in to Repository Mappings" schema="schema/pluginRepositoryMappings.exsd"/> + <extension-point id="support" name="Integrated Support" schema="schema/support.exsd"/> <extension-point id="taskContributors" name="Task Contributors" schema="schema/taskContributors.exsd"/> <extension point="org.eclipse.ui.popupMenus"> diff --git a/org.eclipse.mylyn.tasks.bugs/schema/pluginRepositoryMappings.exsd b/org.eclipse.mylyn.tasks.bugs/schema/pluginRepositoryMappings.exsd index 7b434686c..d9f0259d6 100644 --- a/org.eclipse.mylyn.tasks.bugs/schema/pluginRepositoryMappings.exsd +++ b/org.eclipse.mylyn.tasks.bugs/schema/pluginRepositoryMappings.exsd @@ -2,9 +2,9 @@ <!-- Schema file written by PDE --> <schema targetNamespace="org.eclipse.mylyn.tasks.bugs" xmlns="http://www.w3.org/2001/XMLSchema"> <annotation> - <appinfo> + <appInfo> <meta.schema plugin="org.eclipse.mylyn.tasks.bugs" id="pluginRepositoryMappings" name="Plug-in to Repository Mappings"/> - </appinfo> + </appInfo> <documentation> [Enter description of this extension point.] </documentation> @@ -12,9 +12,9 @@ <element name="extension"> <annotation> - <appinfo> - <meta.element internal="true" /> - </appinfo> + <appInfo> + <meta.element deprecated="true" internal="true" /> + </appInfo> </annotation> <complexType> <sequence> @@ -39,9 +39,9 @@ <documentation> </documentation> - <appinfo> + <appInfo> <meta.attribute translatable="true"/> - </appinfo> + </appInfo> </annotation> </attribute> </complexType> @@ -142,36 +142,36 @@ </element> <annotation> - <appinfo> + <appInfo> <meta.section type="since"/> - </appinfo> + </appInfo> <documentation> [Enter the first release in which this extension point appears.] </documentation> </annotation> <annotation> - <appinfo> + <appInfo> <meta.section type="examples"/> - </appinfo> + </appInfo> <documentation> [Enter extension point usage example here.] </documentation> </annotation> <annotation> - <appinfo> + <appInfo> <meta.section type="apiInfo"/> - </appinfo> + </appInfo> <documentation> [Enter API information here.] </documentation> </annotation> <annotation> - <appinfo> + <appInfo> <meta.section type="implementation"/> - </appinfo> + </appInfo> <documentation> [Enter information about supplied implementation of this extension point.] </documentation> diff --git a/org.eclipse.mylyn.tasks.bugs/schema/support.exsd b/org.eclipse.mylyn.tasks.bugs/schema/support.exsd new file mode 100644 index 000000000..4cc9baa30 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/schema/support.exsd @@ -0,0 +1,294 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.mylyn.tasks.bugs" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="org.eclipse.mylyn.tasks.bugs" id="support" name="Integrated Support Extensions"/> + </appInfo> + <documentation> + Allows client to provide information for integrated bug reporting. + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element internal="true" /> + </appInfo> + </annotation> + <complexType> + <sequence> + <element ref="category" minOccurs="0" maxOccurs="unbounded"/> + <element ref="mapping" minOccurs="0" maxOccurs="unbounded"/> + <element ref="product" minOccurs="0" maxOccurs="1"/> + <element ref="provider" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="mapping"> + <complexType> + <sequence> + <element ref="repository" minOccurs="0" maxOccurs="1"/> + <element ref="property" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="namespace" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="productId" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="repository"> + <complexType> + <attribute name="url" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="kind" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="product"> + <complexType> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="providerId" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="description" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="pluginId" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="property"> + <complexType> + <attribute name="value" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="category"> + <complexType> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="description" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="provider"> + <complexType> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="categoryId" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="description" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="url" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="icon" type="string"> + <annotation> + <documentation> + A 32x32 icon branding icon. + </documentation> + <appInfo> + <meta.attribute kind="resource"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + 3.2 + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + <extension point="org.eclipse.mylyn.tasks.bugs.support"> +<category + id="org.eclipse.mylyn.tasks.bugs.openSource" + name="Open-Source" + description="Community supported Open-Source projects"/> +<organization + id="org.eclipse" + name="Eclipse.org" + description="Eclipse Open-Source projects" + icon="icons/32/eclipse.png"/> +<product + id="org.eclipse.mylyn" + name="Mylyn" + description="Task Management and Task-Focused Interface" + pluginId="org.eclipse.mylyn" (for branding icon, installed version) /> +<productRepositoryMapping + namespace="org.eclipse.mylyn" + productId="org.eclipse.mylyn" + <repository + kind="bugzilla" + url="https://bugs.eclipse.org/bugs"> + </repository> + <property + name="product" + value="Mylyn"> + </property> +/> +<productRepositoryMapping + namespace="org.eclipse.mylyn.tasks" + productId="org.eclipse.mylyn" + <property + name="component" + value="Tasks"> + </property> +</product> +</extension> + </documentation> + </annotation> + + + + <annotation> + <appInfo> + <meta.section type="copyright"/> + </appInfo> + <documentation> + Copyright (c) 2009 Tasktop Technologies and others. + </documentation> + </annotation> + +</schema> diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/AbstractTaskContributor.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/AbstractTaskContributor.java index f3af852ec..16c1673af 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/AbstractTaskContributor.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/AbstractTaskContributor.java @@ -15,6 +15,7 @@ import java.util.Map; import org.eclipse.core.runtime.IStatus; import org.eclipse.mylyn.tasks.core.data.TaskData; +import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput; /** * @author Steffen Pingel @@ -22,13 +23,47 @@ import org.eclipse.mylyn.tasks.core.data.TaskData; */ public abstract class AbstractTaskContributor { + /** + * @since 3.2 + */ + public void preProcess(ISupportRequest request) { + } + + /** + * @deprecated use {@link #contribute(ISTatus, ITaskContribution)} instead + */ + @Deprecated public abstract Map<String, String> getAttributes(IStatus status); + /** + * Returns the id of an editor that should be used to open the {@link TaskEditorInput} with the task. + * + * @param status + * the status + * @return id of editor + */ + @Deprecated public String getEditorId(IStatus status) { return null; } + /** + * @since 3.2 + */ + public void process(ITaskContribution contribution) { + } + + /** + * @deprecated use {@link #postProcess(ISupportResponse)} instead + */ + @Deprecated public void postProcess(IStatus status, TaskData taskData) { } + /** + * @since 3.2 + */ + public void postProcess(ISupportResponse response) { + } + } diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/IProduct.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/IProduct.java new file mode 100644 index 000000000..f4076acad --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/IProduct.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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.provisional.tasks.bugs; + +/** + * @author Steffen Pingel + * @since 3.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface IProduct { + + public abstract String getName(); + + public abstract String getDescription(); + + public abstract String getId(); + + public abstract IProvider getProvider(); + +} diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/IProvider.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/IProvider.java new file mode 100644 index 000000000..4a7bf8640 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/IProvider.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.provisional.tasks.bugs; + +/** + * @author Steffen Pingel + * @since 3.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface IProvider { + + public abstract String getName(); + + public abstract String getDescription(); + + public abstract String getId(); + +} diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/ISupportRequest.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/ISupportRequest.java new file mode 100644 index 000000000..3ca6990cf --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/ISupportRequest.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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.provisional.tasks.bugs; + +import org.eclipse.core.runtime.IStatus; + +/** + * @author Steffen Pingel + * @since 3.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ISupportRequest { + + public ITaskContribution getOrCreateContribution(IProduct product); + + public ITaskContribution getDefaultContribution(); + + public IStatus getStatus(); + +} diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/ISupportResponse.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/ISupportResponse.java new file mode 100644 index 000000000..618d0e83a --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/ISupportResponse.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.provisional.tasks.bugs; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.mylyn.tasks.core.data.TaskData; + +/** + * @author Steffen Pingel + * @since 3.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ISupportResponse { + + public TaskData getTaskData(); + + public IStatus getStatus(); + +} diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/ITaskContribution.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/ITaskContribution.java new file mode 100644 index 000000000..5002135b4 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/ITaskContribution.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.provisional.tasks.bugs; + +import org.eclipse.core.runtime.IStatus; + +/** + * @author Steffen Pingel + * @since 3.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ITaskContribution { + + /** + * Appends <code>text</code> to the description of the task. + */ + public abstract void appendToDescription(String text); + + public abstract String getAttribute(String name); + + public abstract IProduct getProduct(); + + public abstract IStatus getStatus(); + + public abstract void setAttribute(String name, String value); + +} diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/AttributeTaskMapper.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/AttributeTaskMapper.java index b7fe78f9f..4bbd6baf4 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/AttributeTaskMapper.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/AttributeTaskMapper.java @@ -11,47 +11,46 @@ package org.eclipse.mylyn.internal.tasks.bugs; -import java.util.Date; -import java.util.List; +import java.util.HashMap; import java.util.Map; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProduct; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.ISupportResponse; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.ITaskContribution; import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; import org.eclipse.mylyn.tasks.core.ITaskMapping; -import org.eclipse.mylyn.tasks.core.TaskMapping; import org.eclipse.mylyn.tasks.core.TaskRepository; -import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel; import org.eclipse.mylyn.tasks.core.data.TaskData; import org.eclipse.mylyn.tasks.ui.TasksUi; /** * @author Steffen Pingel */ -public class AttributeTaskMapper { +public class AttributeTaskMapper implements ITaskContribution, ISupportResponse { private final Map<String, String> attributes; - public AttributeTaskMapper(Map<String, String> attributes) { - Assert.isNotNull(attributes); - this.attributes = attributes; - } + private final IProduct product; - public boolean isMappingComplete() { - return getTaskRepository() != null && attributes.get(IRepositoryConstants.PRODUCT) != null; + private final IStatus status; + + private TaskData taskData; + + public AttributeTaskMapper(IStatus status, IProduct product) { + Assert.isNotNull(status); + Assert.isNotNull(product); + this.status = status; + this.product = product; + this.attributes = new HashMap<String, String>(); } - public TaskRepository getTaskRepository() { - TaskRepository taskRepository = null; - String repositoryUrl = attributes.get(IRepositoryConstants.REPOSITORY_URL); - if (repositoryUrl != null) { - String connectorKind = attributes.get(IRepositoryConstants.CONNECTOR_KIND); - if (connectorKind != null) { - taskRepository = TasksUi.getRepositoryManager().getRepository(connectorKind, repositoryUrl); - } - } - return taskRepository; + public void appendToDescription(String text) { + String description = getAttribute(IRepositoryConstants.DESCRIPTION); + setAttribute(IRepositoryConstants.DESCRIPTION, (description != null) ? description + text : text); } public TaskData createTaskData(IProgressMonitor monitor) throws CoreException { @@ -59,134 +58,52 @@ public class AttributeTaskMapper { return TasksUiInternal.createTaskData(getTaskRepository(), taskMapping, taskMapping, monitor); } - public ITaskMapping getTaskMapping() { - return new KeyValueMapping(attributes); + public String getAttribute(String name) { + return attributes.get(name); } - private static class KeyValueMapping extends TaskMapping { - - private final Map<String, String> attributes; - - public KeyValueMapping(Map<String, String> attributes) { - Assert.isNotNull(attributes); - this.attributes = attributes; - } - - @Override - public void merge(ITaskMapping source) { - } - - @Override - public Date getCompletionDate() { - // ignore - return null; - } - - @Override - public String getComponent() { - return attributes.get(IRepositoryConstants.COMPONENT); - } - - @Override - public Date getCreationDate() { - // ignore - return null; - } - - @Override - public String getDescription() { - return attributes.get(IRepositoryConstants.DESCRIPTION); - } - - @Override - public Date getDueDate() { - // ignore - return null; - } - - @Override - public Date getModificationDate() { - // ignore - return null; - } - - @Override - public String getOwner() { - // ignore - return null; - } - - @Override - public PriorityLevel getPriorityLevel() { - // ignore - return null; - } - - @Override - public String getProduct() { - return attributes.get(IRepositoryConstants.PRODUCT); - } - - @Override - public String getSummary() { - // ignore - return null; - } - - @Override - public TaskData getTaskData() { - // ignore - return null; - } - - @Override - public String getTaskKey() { - // ignore - return null; - } + public Map<String, String> getAttributes() { + return attributes; + } - @Override - public String getTaskKind() { - // ignore - return null; - } + public IProduct getProduct() { + return product; + } - @Override - public String getTaskUrl() { - // ignore - return null; - } + public IStatus getStatus() { + return status; + } - @Override - public List<String> getCc() { - // ignore - return null; - } + public TaskData getTaskData() { + return taskData; + } - @Override - public List<String> getKeywords() { - // ignore - return null; - } + public ITaskMapping getTaskMapping() { + return new KeyValueMapping(attributes); + } - @Override - public String getReporter() { - // ignore - return null; + public TaskRepository getTaskRepository() { + TaskRepository taskRepository = null; + String repositoryUrl = attributes.get(IRepositoryConstants.REPOSITORY_URL); + if (repositoryUrl != null) { + String connectorKind = attributes.get(IRepositoryConstants.CONNECTOR_KIND); + if (connectorKind != null) { + taskRepository = TasksUi.getRepositoryManager().getRepository(connectorKind, repositoryUrl); + } } + return taskRepository; + } - @Override - public String getResolution() { - // ignore - return null; - } + public boolean isMappingComplete() { + return getTaskRepository() != null; + } - @Override - public String getTaskStatus() { - // ignore - return null; - } + public void setAttribute(String name, String value) { + attributes.put(name, value); + } + void setTaskData(TaskData taskData) { + this.taskData = taskData; } } diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/DefaultTaskContributor.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/DefaultTaskContributor.java index 610b18a90..d046a6234 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/DefaultTaskContributor.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/DefaultTaskContributor.java @@ -22,17 +22,23 @@ import org.eclipse.core.runtime.IProduct; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.mylyn.internal.provisional.tasks.bugs.AbstractTaskContributor; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.ITaskContribution; import org.eclipse.mylyn.internal.tasks.bugs.wizards.ErrorLogStatus; import org.eclipse.mylyn.internal.tasks.bugs.wizards.FeatureStatus; -import org.eclipse.mylyn.tasks.ui.editors.TaskEditor; import org.eclipse.osgi.util.NLS; import org.osgi.framework.Bundle; /** * @author Steffen Pingel */ +@SuppressWarnings("deprecation") public class DefaultTaskContributor extends AbstractTaskContributor { + @Override + public void process(ITaskContribution contribution) { + contribution.appendToDescription(getDescription(contribution.getStatus())); + } + public void appendErrorDetails(StringBuilder sb, IStatus status, Date date) { sb.append("\n\n"); sb.append(Messages.DefaultTaskContributor_Error_Details); @@ -118,11 +124,6 @@ public class DefaultTaskContributor extends AbstractTaskContributor { } } - @Override - public String getEditorId(IStatus status) { - return TaskEditor.ID_EDITOR; - } - private String getSeverityText(int severity) { switch (severity) { case IStatus.ERROR: diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/IRepositoryConstants.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/IRepositoryConstants.java index 9f050d207..415cb759d 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/IRepositoryConstants.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/IRepositoryConstants.java @@ -27,14 +27,19 @@ public class IRepositoryConstants { public static final String PRODUCT = "product"; //$NON-NLS-1$ + @Deprecated public static final String PRODUCT_CATEGORY = "productCategory"; //$NON-NLS-1$ + @Deprecated public static final String PRODUCT_DESCRIPTION = "productDescription"; //$NON-NLS-1$ + @Deprecated public static final String PRODUCT_NAME = "productName"; //$NON-NLS-1$ + @Deprecated public static final String PRODUCT_TITLE = "productTitle"; //$NON-NLS-1$ + @Deprecated public static final String REPOSITORY_KIND = "repositoryKind"; //$NON-NLS-1$ public static final String REPOSITORY_URL = "repositoryUrl"; //$NON-NLS-1$ diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/KeyValueMapping.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/KeyValueMapping.java new file mode 100644 index 000000000..0c7bf7f97 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/KeyValueMapping.java @@ -0,0 +1,148 @@ +/******************************************************************************* + * 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.bugs; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.mylyn.tasks.core.ITaskMapping; +import org.eclipse.mylyn.tasks.core.TaskMapping; +import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel; +import org.eclipse.mylyn.tasks.core.data.TaskData; + +public class KeyValueMapping extends TaskMapping { + + private final Map<String, String> attributes; + + public KeyValueMapping(Map<String, String> attributes) { + Assert.isNotNull(attributes); + this.attributes = attributes; + } + + @Override + public List<String> getCc() { + // ignore + return null; + } + + @Override + public Date getCompletionDate() { + // ignore + return null; + } + + @Override + public String getComponent() { + return attributes.get(IRepositoryConstants.COMPONENT); + } + + @Override + public Date getCreationDate() { + // ignore + return null; + } + + @Override + public String getDescription() { + return attributes.get(IRepositoryConstants.DESCRIPTION); + } + + @Override + public Date getDueDate() { + // ignore + return null; + } + + @Override + public List<String> getKeywords() { + // ignore + return null; + } + + @Override + public Date getModificationDate() { + // ignore + return null; + } + + @Override + public String getOwner() { + // ignore + return null; + } + + @Override + public PriorityLevel getPriorityLevel() { + // ignore + return null; + } + + @Override + public String getProduct() { + return attributes.get(IRepositoryConstants.PRODUCT); + } + + @Override + public String getReporter() { + // ignore + return null; + } + + @Override + public String getResolution() { + // ignore + return null; + } + + @Override + public String getSummary() { + // ignore + return null; + } + + @Override + public TaskData getTaskData() { + // ignore + return null; + } + + @Override + public String getTaskKey() { + // ignore + return null; + } + + @Override + public String getTaskKind() { + // ignore + return null; + } + + @Override + public String getTaskStatus() { + // ignore + return null; + } + + @Override + public String getTaskUrl() { + // ignore + return null; + } + + @Override + public void merge(ITaskMapping source) { + } + +}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/PluginRepositoryMappingManager.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/PluginRepositoryMappingManager.java index baa94adce..441b44726 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/PluginRepositoryMappingManager.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/PluginRepositoryMappingManager.java @@ -30,9 +30,6 @@ import org.eclipse.mylyn.commons.core.StatusHandler; */ public class PluginRepositoryMappingManager { - private static final String[] MAPPING_CHILD_ELEMENTS = new String[] { IRepositoryConstants.PRODUCT, - IRepositoryConstants.COMPONENT }; - private static final String EXTENSION_ID_PLUGIN_REPOSITORY_MAPPING = "org.eclipse.mylyn.tasks.bugs.pluginRepositoryMappings"; //$NON-NLS-1$ private static final String ELEMENT_MAPPING = "mapping"; //$NON-NLS-1$ @@ -41,6 +38,8 @@ public class PluginRepositoryMappingManager { private static final String ELEMENT_REPOSITORY = "repository"; //$NON-NLS-1$ + private static final String ELEMENT_PROPERTY = "property"; //$NON-NLS-1$ + private static final String ATTRIBUTE_PLUGIN_ID_PREFIX = "pluginIdPrefix"; //$NON-NLS-1$ private static final String ATTRIBUTE_REPOSITORY_URL = "url"; //$NON-NLS-1$ @@ -53,6 +52,8 @@ public class PluginRepositoryMappingManager { private static final String ATTRIBUTE_BRANDING_CATEGORY = "category"; //$NON-NLS-1$ + private static final String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$ + private static final String ATTRIBUTE_VALUE = "value"; //$NON-NLS-1$ private TreeMap<String, PluginRepositoryMapping> mappingByPrefix; @@ -72,11 +73,10 @@ public class PluginRepositoryMappingManager { attributes.put(IRepositoryConstants.CONNECTOR_KIND, connectorKind); } // attributes - for (String elementName : MAPPING_CHILD_ELEMENTS) { - for (IConfigurationElement attributeElement : element.getChildren(elementName)) { - String value = attributeElement.getAttribute(ATTRIBUTE_VALUE); - attributes.put(elementName, value); - } + for (IConfigurationElement attributeElement : element.getChildren(ELEMENT_PROPERTY)) { + String name = attributeElement.getAttribute(ATTRIBUTE_NAME); + String value = attributeElement.getAttribute(ATTRIBUTE_VALUE); + attributes.put(name, value); } // branding for (IConfigurationElement attributeElement : element.getChildren(ELEMENT_BRANDING)) { diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/ProductRepositoryMapping.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/ProductRepositoryMapping.java new file mode 100644 index 000000000..0a040ee76 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/ProductRepositoryMapping.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * 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.bugs; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * @author Steffen Pingel + */ +public class ProductRepositoryMapping { + + private final Map<String, String> attributes; + + private final String namespace; + +// private IProduct product; + + public ProductRepositoryMapping(String namespace) { + this.namespace = namespace; + this.attributes = new HashMap<String, String>(); + } + + public void addAttributes(Map<String, String> attributes) { + this.attributes.putAll(attributes); + } + + public Map<String, String> getAttributes() { + return Collections.unmodifiableMap(attributes); + } + + public String getNamespace() { + return namespace; + } + +// public IProduct getProduct() { +// return product; +// } +// +// public void setProduct(IProduct product) { +// this.product = product; +// } + +} diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportCategory.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportCategory.java new file mode 100644 index 000000000..fda28de82 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportCategory.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.bugs; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProvider; + +public class SupportCategory { + + private String description; + + private final String id; + + private String name; + + private List<IProvider> providers; + + public SupportCategory(String id) { + Assert.isNotNull(id); + this.id = id; + } + + public String getDescription() { + return description; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setName(String name) { + this.name = name; + } + + public void add(IProvider provider) { + if (providers == null) { + providers = new ArrayList<IProvider>(); + } + providers.add(provider); + } + +} diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportProduct.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportProduct.java new file mode 100644 index 000000000..d36141038 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportProduct.java @@ -0,0 +1,131 @@ +/******************************************************************************* + * 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.bugs; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.TreeMap; + +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProduct; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProvider; + +/** + * @author Steffen Pingel + */ +public class SupportProduct implements IProduct { + + private String description; + + private String name; + + private String id; + + private IProvider provider; + + private String pluginId; + + TreeMap<String, ProductRepositoryMapping> mappingByNamespace; + + public SupportProduct() { + mappingByNamespace = new TreeMap<String, ProductRepositoryMapping>(); + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public IProvider getProvider() { + return provider; + } + + public void setProvider(IProvider provider) { + this.provider = provider; + } + + public String getPluginId() { + return pluginId; + } + + public void setPluginId(String pluginId) { + this.pluginId = pluginId; + } + + public void addRepositoryMapping(ProductRepositoryMapping mapping) { + ProductRepositoryMapping existingMapping = mappingByNamespace.get(mapping.getNamespace()); + if (existingMapping != null) { + existingMapping.getAttributes().putAll(mapping.getAttributes()); + } else { + mappingByNamespace.put(mapping.getNamespace(), mapping); + } + } + + public ProductRepositoryMapping getMapping(String prefix) { + return mappingByNamespace.get(prefix); + } + + public boolean hasMappings() { + return !mappingByNamespace.isEmpty(); + } + + public Map<String, String> getAllAttributes(String prefix) { + Map<String, String> attributes = null; + for (int i = 0; i <= prefix.length(); i++) { + ProductRepositoryMapping mapping = getMapping(prefix.substring(0, i)); + if (mapping != null) { + if (attributes == null) { + attributes = new HashMap<String, String>(); + } + attributes.putAll(mapping.getAttributes()); + } + } + if (attributes != null) { + return attributes; + } else { + return Collections.emptyMap(); + } + } + + public String getAttribute(String prefix, String key) { + for (int i = prefix.length() - 1; i >= 0; i--) { + ProductRepositoryMapping mapping = getMapping(prefix.substring(0, i)); + if (mapping != null) { + String value = mapping.getAttributes().get(key); + if (value != null) { + return value; + } + } + } + return null; + } + +} diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportProvider.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportProvider.java new file mode 100644 index 000000000..7682924fc --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportProvider.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * 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.bugs; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProvider; + +/** + * @author Steffen Pingel + */ +public class SupportProvider implements IProvider { + + private String description; + + private String name; + + private String id; + + private ImageDescriptor icon; + + public SupportProvider() { + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ImageDescriptor getIcon() { + return icon; + } + + public void setIcon(ImageDescriptor icon) { + this.icon = icon; + } + +} diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportProviderManager.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportProviderManager.java new file mode 100644 index 000000000..845f8d098 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportProviderManager.java @@ -0,0 +1,276 @@ +/******************************************************************************* + * 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.bugs; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.mylyn.commons.core.StatusHandler; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProvider; +import org.eclipse.osgi.util.NLS; + +/** + * @author Steffen Pingel + */ +public class SupportProviderManager { + + private static final String ATTRIBUTE_CATEGORY_ID = "categoryId"; //$NON-NLS-1$ + + private static final String ATTRIBUTE_DESCRIPTION = "description"; //$NON-NLS-1$ + + private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$ + + private static final String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$ + + private static final String ATTRIBUTE_NAMESPACE = "namespace"; //$NON-NLS-1$ + + private static final String ATTRIBUTE_PRODUCT_ID = "productId"; //$NON-NLS-1$ + + private static final String ATTRIBUTE_PROVIDER_ID = "providerId"; //$NON-NLS-1$ + + private static final String ATTRIBUTE_REPOSITORY_KIND = "kind"; //$NON-NLS-1$ + + private static final String ATTRIBUTE_REPOSITORY_URL = "url"; //$NON-NLS-1$ + + private static final String ATTRIBUTE_VALUE = "value"; //$NON-NLS-1$ + + private static final String ELEMENT_CATEGORY = "category"; //$NON-NLS-1$ + + private static final String ELEMENT_MAPPING = "mapping"; //$NON-NLS-1$ + + private static final String ELEMENT_PRODUCT = "product"; //$NON-NLS-1$ + + private static final String ELEMENT_PROPERTY = "property"; //$NON-NLS-1$ + + private static final String ELEMENT_PROVIDER = "provider"; //$NON-NLS-1$ + + private static final String ELEMENT_REPOSITORY = "repository"; //$NON-NLS-1$ + + private static final String EXTENSION_ID_PLUGIN_SUPPORT = "org.eclipse.mylyn.tasks.bugs.support"; //$NON-NLS-1$ + + private List<SupportCategory> categories; + + private SupportProduct defaultProduct; + + private Map<String, SupportProduct> productById; + + private Map<String, SupportProvider> providerById; + + public SupportProviderManager() { + readExtensions(); + } + + public void addCategory(SupportCategory category) { + categories.add(category); + } + + public boolean addProduct(SupportProduct product) { + if (providerById.containsKey(product.getId())) { + return false; + } + productById.put(product.getId(), product); + return true; + } + + public boolean addProvider(SupportProvider provider) { + if (providerById.containsKey(provider.getId())) { + return false; + } + providerById.put(provider.getId(), provider); + return true; + } + + public SupportCategory getCategory(String categoryId) { + for (SupportCategory category : categories) { + if (category.getId().equals(categoryId)) { + return category; + } + } + return null; + } + + public SupportProduct getProduct(String productId) { + return productById.get(productId); + } + + public SupportProvider getProvider(String providerId) { + return providerById.get(providerId); + } + + private void readCategory(IConfigurationElement element) { + String id = element.getAttribute(ATTRIBUTE_ID); + SupportCategory category = new SupportCategory(id); + category.setName(element.getAttribute(ATTRIBUTE_NAME)); + category.setDescription(element.getAttribute(ATTRIBUTE_DESCRIPTION)); + categories.add(category); + } + + private void readExtensions() { + categories = new ArrayList<SupportCategory>(); + productById = new HashMap<String, SupportProduct>(); + providerById = new HashMap<String, SupportProvider>(); + defaultProduct = new SupportProduct(); + + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_ID_PLUGIN_SUPPORT); + IExtension[] extensions = extensionPoint.getExtensions(); + for (IExtension extension : extensions) { + IConfigurationElement[] elements = extension.getConfigurationElements(); + for (IConfigurationElement element : elements) { + if (element.getName().equals(ELEMENT_CATEGORY)) { + readCategory(element); + } + } + } + for (IExtension extension : extensions) { + IConfigurationElement[] elements = extension.getConfigurationElements(); + for (IConfigurationElement element : elements) { + if (element.getName().equals(ELEMENT_PROVIDER)) { + readProvider(element); + } + } + } + for (IExtension extension : extensions) { + IConfigurationElement[] elements = extension.getConfigurationElements(); + for (IConfigurationElement element : elements) { + if (element.getName().equals(ELEMENT_PRODUCT)) { + readProduct(element); + } + } + } + for (IExtension extension : extensions) { + IConfigurationElement[] elements = extension.getConfigurationElements(); + for (IConfigurationElement element : elements) { + if (element.getName().equals(ELEMENT_MAPPING)) { + readMapping(element); + } + } + } + } + + private ProductRepositoryMapping readMapping(IConfigurationElement element) { + String namespace = element.getAttribute(ATTRIBUTE_NAMESPACE); + String productId = element.getAttribute(ATTRIBUTE_PRODUCT_ID); + Map<String, String> attributes = new HashMap<String, String>(); + // repository + for (IConfigurationElement attributeElement : element.getChildren(ELEMENT_REPOSITORY)) { + String repositoryUrl = attributeElement.getAttribute(ATTRIBUTE_REPOSITORY_URL); + attributes.put(IRepositoryConstants.REPOSITORY_URL, repositoryUrl); + String connectorKind = attributeElement.getAttribute(ATTRIBUTE_REPOSITORY_KIND); + attributes.put(IRepositoryConstants.CONNECTOR_KIND, connectorKind); + } + // attributes + for (IConfigurationElement attributeElement : element.getChildren(ELEMENT_PROPERTY)) { + String name = attributeElement.getAttribute(ATTRIBUTE_NAME); + String value = attributeElement.getAttribute(ATTRIBUTE_VALUE); + attributes.put(name, value); + } + + if (!attributes.isEmpty()) { + ProductRepositoryMapping mapping = new ProductRepositoryMapping(namespace); + mapping.addAttributes(attributes); + + final SupportProduct product; + if (productId == null) { + product = defaultProduct; + } else { + product = getProduct(productId); + if (product == null) { + StatusHandler.log(new Status( + IStatus.WARNING, + TasksBugsPlugin.ID_PLUGIN, + NLS.bind( + "Mapping contributed by {0} with namespace ''{1}'' ignored, invalid product id ''{1}'' specified", //$NON-NLS-1$ + new String[] { element.getNamespaceIdentifier(), namespace, productId }))); + return null; + } + } + product.addRepositoryMapping(mapping); + return mapping; + } else { + StatusHandler.log(new Status(IStatus.WARNING, TasksBugsPlugin.ID_PLUGIN, NLS.bind( + "Mapping contributed by {0} with namespace ''{1}'' ignored, no attributes specified", //$NON-NLS-1$ + new String[] { element.getNamespaceIdentifier(), namespace }))); + return null; + } + } + + private SupportProduct readProduct(IConfigurationElement element) { + String id = element.getAttribute(ATTRIBUTE_ID); + String providerId = element.getAttribute(ATTRIBUTE_PROVIDER_ID); + IProvider provider = getProvider(providerId); + if (provider == null) { + StatusHandler.log(new Status(IStatus.WARNING, TasksBugsPlugin.ID_PLUGIN, NLS.bind( + "Product contributed by {0} with id ''{1}'' ignored, product id ''{2}'' is invalid", //$NON-NLS-1$ + new String[] { element.getNamespaceIdentifier(), id, providerId }))); + return null; + } + SupportProduct product = new SupportProduct(); + product.setId(id); + product.setProvider(provider); + product.setName(element.getAttribute(ATTRIBUTE_NAME)); + product.setDescription(element.getAttribute(ATTRIBUTE_DESCRIPTION)); + if (!addProduct(product)) { + StatusHandler.log(new Status(IStatus.WARNING, TasksBugsPlugin.ID_PLUGIN, NLS.bind( + "Product contributed by {0} ignored, id ''{1}'' already present", //$NON-NLS-1$ + element.getNamespaceIdentifier(), id))); + return null; + } + productById.put(id, product); + return product; + } + + private SupportProvider readProvider(IConfigurationElement element) { + String id = element.getAttribute(ATTRIBUTE_ID); + SupportProvider provider = new SupportProvider(); + provider.setId(id); + provider.setName(element.getAttribute(ATTRIBUTE_NAME)); + provider.setDescription(element.getAttribute(ATTRIBUTE_DESCRIPTION)); + if (!addProvider(provider)) { + StatusHandler.log(new Status(IStatus.WARNING, TasksBugsPlugin.ID_PLUGIN, NLS.bind( + "Provider contributed by {0} ignored, id ''{1}'' already present", //$NON-NLS-1$ + element.getNamespaceIdentifier(), id))); + return null; + } + String categoryId = element.getAttribute(ATTRIBUTE_CATEGORY_ID); + SupportCategory category = getCategory(categoryId); + if (category == null) { + StatusHandler.log(new Status(IStatus.WARNING, TasksBugsPlugin.ID_PLUGIN, NLS.bind( + "Provider contributed by {0} ignored with id ''{1}'' ignored, category id ''{2}'' is invalid", //$NON-NLS-1$ + new String[] { element.getNamespaceIdentifier(), id, categoryId }))); + return null; + } + providerById.put(id, provider); + category.add(provider); + return provider; + } + + public Collection<SupportProduct> getProducts() { + return Collections.unmodifiableCollection(productById.values()); + } + + public SupportProduct getDefaultProduct() { + return defaultProduct; + } + +} diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportRequest.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportRequest.java new file mode 100644 index 000000000..13093849f --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportRequest.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * 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.bugs; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProduct; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.ISupportRequest; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.ITaskContribution; + +public class SupportRequest implements ISupportRequest { + + private final Map<String, ITaskContribution> contributionByProductId; + + private final IStatus status; + + private final SupportProviderManager providerManager; + + private AttributeTaskMapper defaultContribution; + + public SupportRequest(SupportProviderManager providerManager, IStatus status) { + this.providerManager = providerManager; + this.status = status; + this.contributionByProductId = new HashMap<String, ITaskContribution>(); + process(); + } + + public ITaskContribution getOrCreateContribution(IProduct product) { + ITaskContribution contribution = contributionByProductId.get(product.getId()); + if (contribution == null) { + contribution = new AttributeTaskMapper(status, product); + contributionByProductId.put(product.getId(), contribution); + } + return contribution; +// ITaskContribution contribution = taskContributionByProductId.get(productId); +// if (contribution == null) { +// SupportProduct product = providerManager.getProduct(productId); +// if (product == null) { +// throw new IllegalArgumentException(NLS.bind("Invalid product id ''{0}''", productId)); //$NON-NLS-1$ +// } +// contribution = new AttributeTaskMapper(status, product); +// taskContributionByProductId.put(productId, contribution); +// } +// return contribution; + } + + public ITaskContribution getDefaultContribution() { + if (defaultContribution == null) { + String namespace = getNamespace(); + Map<String, String> attributes = providerManager.getDefaultProduct().getAllAttributes(namespace); + + defaultContribution = new AttributeTaskMapper(status, providerManager.getDefaultProduct()); + defaultContribution.getAttributes().putAll(attributes); + } + return defaultContribution; + } + + public IStatus getStatus() { + return status; + } + + private void process() { + String namespace = getNamespace(); + Collection<SupportProduct> products = providerManager.getProducts(); + for (SupportProduct product : products) { + Map<String, String> productAttributes = product.getAllAttributes(namespace); + if (!productAttributes.isEmpty()) { + // merge global and more specific product attributes + Map<String, String> attributes = providerManager.getDefaultProduct().getAllAttributes(namespace); + attributes.putAll(productAttributes); + + AttributeTaskMapper contribution = (AttributeTaskMapper) getOrCreateContribution(product); + contribution.getAttributes().putAll(attributes); + } + } + } + + private String getNamespace() { + return status.getPlugin(); + } + + public List<ITaskContribution> getContributions() { + return new ArrayList<ITaskContribution>(contributionByProductId.values()); + } + +} diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TaskContributorManager.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TaskContributorManager.java index be4580e9c..57ab61a90 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TaskContributorManager.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TaskContributorManager.java @@ -27,11 +27,14 @@ import org.eclipse.core.runtime.SafeRunner; import org.eclipse.core.runtime.Status; import org.eclipse.mylyn.commons.core.StatusHandler; import org.eclipse.mylyn.internal.provisional.tasks.bugs.AbstractTaskContributor; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.ISupportResponse; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.ITaskContribution; import org.eclipse.mylyn.tasks.core.data.TaskData; /** * @author Steffen Pingel */ +@SuppressWarnings("deprecation") public class TaskContributorManager { private static final String ELEMENT_CLASS = "class"; //$NON-NLS-1$ @@ -46,6 +49,9 @@ public class TaskContributorManager { private final List<AbstractTaskContributor> taskContributors = new CopyOnWriteArrayList<AbstractTaskContributor>(); + public TaskContributorManager() { + } + public void addErrorReporter(AbstractTaskContributor taskContributor) { taskContributors.add(taskContributor); } @@ -63,46 +69,41 @@ public class TaskContributorManager { return defaultTaskContributor.getEditorId(status); } - private synchronized void readExtensions() { - if (readExtensions) { - return; - } - readExtensions = true; + @Deprecated + public void postProcess(final IStatus status, final TaskData taskData) { + readExtensions(); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_ID_TASK_CONTRIBUTORS); - IExtension[] extensions = extensionPoint.getExtensions(); - for (IExtension extension : extensions) { - IConfigurationElement[] elements = extension.getConfigurationElements(); - for (IConfigurationElement element : elements) { - if (element.getName().equals(ELEMENT_TASK_CONTRIBUTOR)) { - readTaskContributor(element); + for (final AbstractTaskContributor contributor : taskContributors) { + SafeRunner.run(new ISafeRunnable() { + public void handleException(Throwable e) { + StatusHandler.log(new Status(IStatus.ERROR, TasksBugsPlugin.ID_PLUGIN, "Task contributor failed", e)); //$NON-NLS-1$ } - } - } - } - private void readTaskContributor(IConfigurationElement element) { - try { - Object object = element.createExecutableExtension(ELEMENT_CLASS); - if (object instanceof AbstractTaskContributor) { - taskContributors.add((AbstractTaskContributor) object); - } else { - StatusHandler.log(new Status(IStatus.WARNING, TasksBugsPlugin.ID_PLUGIN, - "Could not load task contributor extenstion: \"" + object.getClass().getCanonicalName() + "\"" //$NON-NLS-1$ //$NON-NLS-2$ - + " does not implement \"" + AbstractTaskContributor.class.getCanonicalName() + "\"")); //$NON-NLS-1$ //$NON-NLS-2$ - } - } catch (CoreException e) { - StatusHandler.log(new Status(IStatus.WARNING, TasksBugsPlugin.ID_PLUGIN, - "Could not load task contributor extension", e)); //$NON-NLS-1$ + public void run() throws Exception { + contributor.postProcess(status, taskData); + } + }); } } - public void removeErrorReporter(AbstractTaskContributor taskContributor) { - taskContributors.remove(taskContributor); + public void process(final ITaskContribution contribution) { + readExtensions(); + + for (final AbstractTaskContributor contributor : taskContributors) { + SafeRunner.run(new ISafeRunnable() { + public void handleException(Throwable e) { + StatusHandler.log(new Status(IStatus.ERROR, TasksBugsPlugin.ID_PLUGIN, "Task contributor failed", e)); //$NON-NLS-1$ + } + + public void run() throws Exception { + contributor.process(contribution); + } + }); + } + defaultTaskContributor.process(contribution); } - public void postProcess(final IStatus status, final TaskData taskData) { + public void postProcess(final ISupportResponse response) { readExtensions(); for (final AbstractTaskContributor contributor : taskContributors) { @@ -112,13 +113,15 @@ public class TaskContributorManager { } public void run() throws Exception { - contributor.postProcess(status, taskData); + contributor.postProcess(response); } }); } + defaultTaskContributor.postProcess(response); } - public void preProcess(final IStatus status, final Map<String, String> attributes) { + @Deprecated + public void preProcess(final IStatus status, final AttributeTaskMapper contribution) { readExtensions(); final boolean[] handled = new boolean[1]; @@ -132,14 +135,70 @@ public class TaskContributorManager { Map<String, String> contributorAttributes = contributor.getAttributes(status); if (contributorAttributes != null) { handled[0] = true; - attributes.putAll(contributorAttributes); + contribution.getAttributes().putAll(contributorAttributes); } } }); } if (!handled[0]) { - attributes.putAll(defaultTaskContributor.getAttributes(status)); + contribution.getAttributes().putAll(defaultTaskContributor.getAttributes(status)); + } + } + + public void preProcess(final SupportRequest request) { + readExtensions(); + + for (final AbstractTaskContributor contributor : taskContributors) { + SafeRunner.run(new ISafeRunnable() { + public void handleException(Throwable e) { + StatusHandler.log(new Status(IStatus.ERROR, TasksBugsPlugin.ID_PLUGIN, "Task contributor failed", e)); //$NON-NLS-1$ + } + + public void run() throws Exception { + contributor.preProcess(request); + } + }); + } + defaultTaskContributor.preProcess(request); + } + + private synchronized void readExtensions() { + if (readExtensions) { + return; } + readExtensions = true; + + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_ID_TASK_CONTRIBUTORS); + IExtension[] extensions = extensionPoint.getExtensions(); + for (IExtension extension : extensions) { + IConfigurationElement[] elements = extension.getConfigurationElements(); + for (IConfigurationElement element : elements) { + if (element.getName().equals(ELEMENT_TASK_CONTRIBUTOR)) { + readTaskContributor(element); + } + } + } + } + + private void readTaskContributor(IConfigurationElement element) { + try { + Object object = element.createExecutableExtension(ELEMENT_CLASS); + if (object instanceof AbstractTaskContributor) { + taskContributors.add((AbstractTaskContributor) object); + } else { + StatusHandler.log(new Status(IStatus.WARNING, TasksBugsPlugin.ID_PLUGIN, + "Could not load task contributor extenstion: \"" + object.getClass().getCanonicalName() + "\"" //$NON-NLS-1$ //$NON-NLS-2$ + + " does not implement \"" + AbstractTaskContributor.class.getCanonicalName() + "\"")); //$NON-NLS-1$ //$NON-NLS-2$ + } + } catch (CoreException e) { + StatusHandler.log(new Status(IStatus.WARNING, TasksBugsPlugin.ID_PLUGIN, + "Could not load task contributor extension", e)); //$NON-NLS-1$ + } + } + + public void removeErrorReporter(AbstractTaskContributor taskContributor) { + taskContributors.remove(taskContributor); } } diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TaskErrorReporter.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TaskErrorReporter.java index b975b5770..c04c50a42 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TaskErrorReporter.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TaskErrorReporter.java @@ -11,8 +11,6 @@ package org.eclipse.mylyn.internal.tasks.bugs; -import java.util.Map; - import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; @@ -34,9 +32,12 @@ public class TaskErrorReporter { private final TaskContributorManager contributorManager; + private final SupportProviderManager providerManager; + public TaskErrorReporter() { this.contributorManager = new TaskContributorManager(); this.mappingManager = new PluginRepositoryMappingManager(); + this.providerManager = new SupportProviderManager(); } public TaskContributorManager getContributorManager() { @@ -58,25 +59,27 @@ public class TaskErrorReporter { return AbstractErrorReporter.PRIORITY_NONE; } - public void process(IStatus status) { - Assert.isNotNull(status); - AttributeTaskMapper mapper = preProcess(status); - postProcess(mapper); - } +// public void process(IStatus status) { +// Assert.isNotNull(status); +// AttributeTaskMapper mapper = preProcess(status); +// postProcess(mapper); +// } - public AttributeTaskMapper preProcess(IStatus status) { + public SupportRequest preProcess(IStatus status) { Assert.isNotNull(status); - String pluginId = status.getPlugin(); - Map<String, String> attributes = mappingManager.getAllAttributes(pluginId); - contributorManager.preProcess(status, attributes); - return new AttributeTaskMapper(attributes); + //Map<String, String> attributes = mappingManager.getAllAttributes(namespace); + SupportRequest request = new SupportRequest(providerManager, status); + contributorManager.preProcess(request); + return request; } public void postProcess(AttributeTaskMapper mapper) { Assert.isNotNull(mapper); - TaskData taskData; + contributorManager.process(mapper); try { - taskData = mapper.createTaskData(null); + TaskData taskData = mapper.createTaskData(null); + mapper.setTaskData(taskData); + contributorManager.postProcess(mapper); TasksUiInternal.createAndOpenNewTask(taskData); } catch (CoreException e) { StatusHandler.log(new Status(IStatus.ERROR, TasksBugsPlugin.ID_PLUGIN, "Unexpected error reporting error", //$NON-NLS-1$ diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/ReportBugAction.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/ReportBugAction.java index 94476e7aa..a770909b2 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/ReportBugAction.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/ReportBugAction.java @@ -13,28 +13,32 @@ package org.eclipse.mylyn.internal.tasks.bugs.actions; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.mylyn.internal.tasks.ui.actions.NewTaskAction; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.mylyn.internal.tasks.bugs.wizards.ReportBugOrEnhancementWizard; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** - * @author Mik Kersten + * @author Steffen Pingel */ public class ReportBugAction implements IWorkbenchWindowActionDelegate { + private IWorkbenchWindow window; + public void dispose() { } public void init(IWorkbenchWindow window) { + this.window = window; } public void run(IAction action) { -// WizardDialog dialog = new WizardDialog(window.getShell(), new ReportBugOrEnhancementWizard()); -// dialog.open(); - new NewTaskAction().run(action); + WizardDialog dialog = new WizardDialog(window.getShell(), new ReportBugOrEnhancementWizard()); + dialog.open(); } public void selectionChanged(IAction action, ISelection selection) { // ignore } + } diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportErrorPage.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportErrorPage.java index cc8124e03..4932cfcee 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportErrorPage.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportErrorPage.java @@ -12,18 +12,24 @@ package org.eclipse.mylyn.internal.tasks.bugs.wizards; import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProduct; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.ITaskContribution; import org.eclipse.mylyn.internal.tasks.bugs.AttributeTaskMapper; -import org.eclipse.mylyn.tasks.core.TaskRepository; +import org.eclipse.mylyn.internal.tasks.bugs.SupportRequest; +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.layout.GridLayout; import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; @@ -35,22 +41,36 @@ public class ReportErrorPage extends WizardPage { private final IStatus status; - private final AttributeTaskMapper mapper; + private final SupportRequest request; - protected TaskRepository taskRepository; + private final List<AttributeTaskMapper> contributions; - public ReportErrorPage(AttributeTaskMapper mapper, IStatus status) { + private AttributeTaskMapper selectedContribution; + + private Combo contributionCombo; + + public ReportErrorPage(SupportRequest request, IStatus status) { super("reportError"); //$NON-NLS-1$ - this.mapper = mapper; + this.request = request; this.status = status; + this.contributions = new ArrayList<AttributeTaskMapper>(); + addContributions(request.getContributions()); setTitle(Messages.ReportErrorPage_Report_as_Bug); setMessage(MessageFormat.format(Messages.ReportErrorPage_AN_UNEXPETED_ERROR_HAS_OCCURED_IN_PLUGIN, status.getPlugin())); } + private void addContributions(List<ITaskContribution> contributions) { + for (ITaskContribution contribution : contributions) { + if (((AttributeTaskMapper) contribution).isMappingComplete()) { + this.contributions.add((AttributeTaskMapper) contribution); + } + } + } + public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(1, true)); + composite.setLayout(new GridLayout(2, false)); // Group errorGroup = new Group(composite, SWT.NONE); // GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(errorGroup); @@ -62,19 +82,32 @@ public class ReportErrorPage extends WizardPage { Text text = new Text(composite, SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP | SWT.BORDER); text.setText(status.getMessage()); - GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(text); + GridDataFactory.fillDefaults().span(2, 1).grab(true, true).applyTo(text); // space - new Label(composite, SWT.NONE); + label = new Label(composite, SWT.NONE); + GridDataFactory.fillDefaults().span(2, 1).applyTo(label); - if (mapper.isMappingComplete()) { + selectedContribution = null; + if (!contributions.isEmpty()) { final Button defaultRepositoryButton = new Button(composite, SWT.RADIO); - defaultRepositoryButton.setText(Messages.ReportErrorPage_Report_to_ - + mapper.getTaskRepository().getRepositoryLabel()); + defaultRepositoryButton.setText(Messages.ReportErrorPage_Report_to_); defaultRepositoryButton.setSelection(true); + selectedContribution = contributions.get(0); + if (contributions.size() == 1) { + label = new Label(composite, SWT.NONE); + label.setText(getLabel(selectedContribution)); + } else { + contributionCombo = new Combo(composite, SWT.READ_ONLY); + for (AttributeTaskMapper contribution : contributions) { + contributionCombo.add(getLabel(contribution)); + } + contributionCombo.select(0); + } final Button selectRepositoryButton = new Button(composite, SWT.RADIO); selectRepositoryButton.setText(Messages.ReportErrorPage_Select_repository); + GridDataFactory.fillDefaults().span(2, 1).grab(true, true).applyTo(selectRepositoryButton); defaultRepositoryButton.addSelectionListener(new SelectionAdapter() { @Override @@ -82,7 +115,12 @@ public class ReportErrorPage extends WizardPage { if (defaultRepositoryButton.getSelection()) { selectRepositoryButton.setSelection(false); } - taskRepository = mapper.getTaskRepository(); + if (contributionCombo != null) { + contributionCombo.setEnabled(true); + selectedContribution = contributions.get(contributionCombo.getSelectionIndex()); + } else { + selectedContribution = contributions.get(0); + } getContainer().updateButtons(); } }); @@ -92,27 +130,30 @@ public class ReportErrorPage extends WizardPage { public void widgetSelected(SelectionEvent event) { if (selectRepositoryButton.getSelection()) { defaultRepositoryButton.setSelection(false); + if (contributionCombo != null) { + contributionCombo.setEnabled(false); + } } - taskRepository = null; getContainer().updateButtons(); } }); - - taskRepository = mapper.getTaskRepository(); - } else { - taskRepository = null; } setControl(composite); Dialog.applyDialogFont(composite); } + private String getLabel(AttributeTaskMapper contribution) { + IProduct product = contribution.getProduct(); + return NLS.bind("{0} - {1}", product.getProvider().getName(), product.getName()); + } + @Override public boolean canFlipToNextPage() { - return taskRepository == null; + return selectedContribution == null; } - public TaskRepository getTaskRepository() { - return taskRepository; + public AttributeTaskMapper getSelectedContribution() { + return selectedContribution; } @Override diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportErrorWizard.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportErrorWizard.java index 345c5d71a..1778b63a9 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportErrorWizard.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportErrorWizard.java @@ -14,6 +14,8 @@ package org.eclipse.mylyn.internal.tasks.bugs.wizards; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.wizard.Wizard; import org.eclipse.mylyn.internal.tasks.bugs.AttributeTaskMapper; +import org.eclipse.mylyn.internal.tasks.bugs.KeyValueMapping; +import org.eclipse.mylyn.internal.tasks.bugs.SupportRequest; import org.eclipse.mylyn.internal.tasks.bugs.TaskErrorReporter; import org.eclipse.mylyn.internal.tasks.core.ITaskRepositoryFilter; import org.eclipse.mylyn.internal.tasks.ui.wizards.NewTaskPage; @@ -25,7 +27,7 @@ public class ReportErrorWizard extends Wizard { private final IStatus status; - private final AttributeTaskMapper mapper; + private final SupportRequest request; private ReportErrorPage reportErrorPage; @@ -36,25 +38,28 @@ public class ReportErrorWizard extends Wizard { public ReportErrorWizard(TaskErrorReporter taskErrorReporter, IStatus status) { this.taskErrorReporter = taskErrorReporter; this.status = status; - this.mapper = taskErrorReporter.preProcess(status); + this.request = taskErrorReporter.preProcess(status); setWindowTitle(Messages.ReportErrorWizard_Report_as_Bug); } @Override public void addPages() { - reportErrorPage = new ReportErrorPage(mapper, status); + reportErrorPage = new ReportErrorPage(request, status); addPage(reportErrorPage); - newTaskPage = new NewTaskPage(ITaskRepositoryFilter.CAN_CREATE_NEW_TASK, mapper.getTaskMapping()); + KeyValueMapping defaultMapping = new KeyValueMapping( + ((AttributeTaskMapper) request.getDefaultContribution()).getAttributes()); + newTaskPage = new NewTaskPage(ITaskRepositoryFilter.CAN_CREATE_NEW_TASK, defaultMapping); addPage(newTaskPage); } @Override public boolean performFinish() { - if (reportErrorPage.getTaskRepository() != null) { - taskErrorReporter.postProcess(mapper); + if (reportErrorPage.getSelectedContribution() != null) { + taskErrorReporter.postProcess(reportErrorPage.getSelectedContribution()); return true; } else { return newTaskPage.performFinish(); } } + } diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectProductPage.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectProductPage.java index d77b5c75f..db435db7a 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectProductPage.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectProductPage.java @@ -36,7 +36,6 @@ import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.mylyn.internal.tasks.bugs.AttributeTaskMapper; import org.eclipse.mylyn.internal.tasks.bugs.IRepositoryConstants; import org.eclipse.mylyn.internal.tasks.bugs.PluginRepositoryMappingManager; import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; @@ -211,10 +210,10 @@ public class SelectProductPage extends WizardPage { private void addProduct(Map<String, FeatureGroup> featureGroupByName, IBundleGroup bundleGroup) { Map<String, String> attributes = manager.getAllAttributes(bundleGroup.getIdentifier()); - AttributeTaskMapper mapper = new AttributeTaskMapper(attributes); - if (!mapper.isMappingComplete()) { - return; - } +// AttributeTaskMapper mapper = new AttributeTaskMapper(attributes); +// if (!mapper.isMappingComplete()) { +// return; +// } String imageUrl = bundleGroup.getProperty(IBundleGroupConstants.FEATURE_IMAGE); if (imageUrl == null) { |