diff options
author | spingel | 2009-05-31 11:13:04 +0000 |
---|---|---|
committer | spingel | 2009-05-31 11:13:04 +0000 |
commit | cc11a510023e0b0fe02dfa960424775b60dfb394 (patch) | |
tree | b816f9e619606cba12a235c9be48f2e90fbdd060 /org.eclipse.mylyn.tasks.bugs/src | |
parent | f347854fce40b8cf22a4dd15a63e3763262b6965 (diff) | |
download | org.eclipse.mylyn.tasks-cc11a510023e0b0fe02dfa960424775b60dfb394.tar.gz org.eclipse.mylyn.tasks-cc11a510023e0b0fe02dfa960424775b60dfb394.tar.xz org.eclipse.mylyn.tasks-cc11a510023e0b0fe02dfa960424775b60dfb394.zip |
NEW - bug 277401: support reporting bugs to places other than task repositories
https://bugs.eclipse.org/bugs/show_bug.cgi?id=277401
Diffstat (limited to 'org.eclipse.mylyn.tasks.bugs/src')
12 files changed, 161 insertions, 370 deletions
diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/AbstractSupportHandler.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/AbstractSupportHandler.java new file mode 100644 index 000000000..46acb1d50 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/AbstractSupportHandler.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * 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.IProgressMonitor; + +/** + * @author Steffen Pingel + * @since 3.2 + */ +public class AbstractSupportHandler { + + /** + * @since 3.2 + */ + public void preProcess(ISupportRequest request) { + } + + /** + * @since 3.2 + */ + public void process(ITaskContribution contribution, IProgressMonitor monitor) { + } + + /** + * @since 3.2 + */ + public void postProcess(ISupportResponse response, IProgressMonitor monitor) { + } + +} 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 16c1673af..332317079 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 @@ -20,7 +20,9 @@ import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput; /** * @author Steffen Pingel * @since 3.0 + * @deprecated use {@link AbstractSupportHandler} instead, as of 3.2 all taskContributor extensions are ignored */ +@Deprecated public abstract class AbstractTaskContributor { /** @@ -30,9 +32,8 @@ public abstract class AbstractTaskContributor { } /** - * @deprecated use {@link #contribute(ISTatus, ITaskContribution)} instead + * @since 3.0 */ - @Deprecated public abstract Map<String, String> getAttributes(IStatus status); /** @@ -41,8 +42,8 @@ public abstract class AbstractTaskContributor { * @param status * the status * @return id of editor + * @since 3.0 */ - @Deprecated public String getEditorId(IStatus status) { return null; } @@ -54,9 +55,8 @@ public abstract class AbstractTaskContributor { } /** - * @deprecated use {@link #postProcess(ISupportResponse)} instead + * @since 3.0 */ - @Deprecated public void postProcess(IStatus status, TaskData taskData) { } 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 index 5002135b4..0e56d271c 100644 --- 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 @@ -32,6 +32,10 @@ public interface ITaskContribution { public abstract IStatus getStatus(); + public abstract boolean isHandled(); + public abstract void setAttribute(String name, String value); + public abstract void setHandled(boolean handled); + } 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 4bbd6baf4..ab3b86c5a 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 @@ -40,6 +40,8 @@ public class AttributeTaskMapper implements ITaskContribution, ISupportResponse private TaskData taskData; + private boolean handled; + public AttributeTaskMapper(IStatus status, IProduct product) { Assert.isNotNull(status); Assert.isNotNull(product); @@ -106,4 +108,12 @@ public class AttributeTaskMapper implements ITaskContribution, ISupportResponse this.taskData = taskData; } + public boolean isHandled() { + return handled; + } + + public void setHandled(boolean handled) { + this.handled = handled; + } + } 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/DefaultSupportHandler.java index b34037f8e..48339bbec 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/DefaultSupportHandler.java @@ -14,14 +14,14 @@ package org.eclipse.mylyn.internal.tasks.bugs; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Date; -import java.util.HashMap; import java.util.Map; import org.eclipse.core.runtime.IBundleGroup; import org.eclipse.core.runtime.IProduct; +import org.eclipse.core.runtime.IProgressMonitor; 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.AbstractSupportHandler; import org.eclipse.mylyn.internal.provisional.tasks.bugs.ISupportRequest; import org.eclipse.mylyn.internal.provisional.tasks.bugs.ISupportResponse; import org.eclipse.mylyn.internal.provisional.tasks.bugs.ITaskContribution; @@ -39,8 +39,7 @@ import org.osgi.framework.Bundle; /** * @author Steffen Pingel */ -@SuppressWarnings("deprecation") -public class DefaultTaskContributor extends AbstractTaskContributor { +public class DefaultSupportHandler extends AbstractSupportHandler { @Override public void preProcess(ISupportRequest request) { @@ -52,7 +51,7 @@ public class DefaultTaskContributor extends AbstractTaskContributor { } @Override - public void process(ITaskContribution contribution) { + public void process(ITaskContribution contribution, IProgressMonitor monitor) { if (contribution.getAttribute(IRepositoryConstants.DESCRIPTION) == null) { String description = getDescription(contribution.getStatus()); if (description != null) { @@ -62,7 +61,7 @@ public class DefaultTaskContributor extends AbstractTaskContributor { } @Override - public void postProcess(ISupportResponse response) { + public void postProcess(ISupportResponse response, IProgressMonitor monitor) { IStatus contribution = response.getStatus(); TaskData taskData = response.getTaskData(); if (contribution instanceof ProductStatus) { @@ -145,13 +144,6 @@ public class DefaultTaskContributor extends AbstractTaskContributor { } } - @Override - public Map<String, String> getAttributes(IStatus status) { - Map<String, String> attributes = new HashMap<String, String>(); - attributes.put(IRepositoryConstants.DESCRIPTION, getDescription(status)); - return attributes; - } - public String getDescription(IStatus status) { if (status instanceof ProductStatus) { SupportProduct product = (SupportProduct) ((ProductStatus) status).getProduct(); diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/PluginRepositoryMapping.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/PluginRepositoryMapping.java deleted file mode 100644 index 117d040bc..000000000 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/PluginRepositoryMapping.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * 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.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author Steffen Pingel - */ -public class PluginRepositoryMapping { - - private final List<String> prefixes = new ArrayList<String>(); - - private final Map<String, String> attributes = new HashMap<String, String>(); - - public void addPrefix(String prefix) { - prefixes.add(prefix); - } - - public void addAttributes(Map<String, String> attributes) { - this.attributes.putAll(attributes); - } - - public void removePrefix(String prefix) { - prefixes.remove(prefix); - } - - public Map<String, String> getAttributes() { - return Collections.unmodifiableMap(attributes); - } - - public List<String> getPrefixes() { - return Collections.unmodifiableList(prefixes); - } - -} 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 deleted file mode 100644 index 441b44726..000000000 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/PluginRepositoryMappingManager.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * 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.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -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; - -/** - * @author Steffen Pingel - */ -public class PluginRepositoryMappingManager { - - 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$ - - private static final String ELEMENT_BRANDING = "branding"; //$NON-NLS-1$ - - 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$ - - private static final String ATTRIBUTE_REPOSITORY_KIND = "kind"; //$NON-NLS-1$ - - private static final String ATTRIBUTE_BRANDING_NAME = "name"; //$NON-NLS-1$ - - private static final String ATTRIBUTE_BRANDING_DESCRIPTION = "description"; //$NON-NLS-1$ - - 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; - - public PluginRepositoryMappingManager() { - readExtensions(); - } - - private void readMapping(IConfigurationElement element) { - String pluginIdPrefix = element.getAttribute(ATTRIBUTE_PLUGIN_ID_PREFIX); - 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); - } - // branding - for (IConfigurationElement attributeElement : element.getChildren(ELEMENT_BRANDING)) { - attributes.put("brandingName", attributeElement.getAttribute(ATTRIBUTE_BRANDING_NAME)); //$NON-NLS-1$ - String description = attributeElement.getAttribute(ATTRIBUTE_BRANDING_DESCRIPTION); - if (description != null) { - attributes.put("brandingDescription", description); //$NON-NLS-1$ - } - String category = attributeElement.getAttribute(ATTRIBUTE_BRANDING_CATEGORY); - if (category != null) { - attributes.put("brandingCategory", category); //$NON-NLS-1$ - } - } - - if (!attributes.isEmpty()) { - PluginRepositoryMapping pluginRepositoryMapping = new PluginRepositoryMapping(); - pluginRepositoryMapping.addAttributes(attributes); - pluginRepositoryMapping.addPrefix(pluginIdPrefix); - addPluginRepositoryMapping(pluginRepositoryMapping); - } else { - StatusHandler.log(new Status(IStatus.ERROR, TasksBugsPlugin.ID_PLUGIN, "Missing attributes in " //$NON-NLS-1$ - + EXTENSION_ID_PLUGIN_REPOSITORY_MAPPING + " extension for id \"" + ATTRIBUTE_PLUGIN_ID_PREFIX //$NON-NLS-1$ - + "\"")); //$NON-NLS-1$ - } - } - - private void addPluginRepositoryMapping(PluginRepositoryMapping pluginRepositoryMapping) { - List<String> prefixs = pluginRepositoryMapping.getPrefixes(); - for (String prefix : prefixs) { - mappingByPrefix.put(prefix, pluginRepositoryMapping); - } - } - - private synchronized void readExtensions() { - mappingByPrefix = new TreeMap<String, PluginRepositoryMapping>(); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_ID_PLUGIN_REPOSITORY_MAPPING); - IExtension[] extensions = extensionPoint.getExtensions(); - for (IExtension extension : extensions) { - IConfigurationElement[] elements = extension.getConfigurationElements(); - for (IConfigurationElement element : elements) { - if (element.getName().equals(ELEMENT_MAPPING)) { - readMapping(element); - } - } - } - } - - public PluginRepositoryMapping getMapping(String prefix) { - return mappingByPrefix.get(prefix); - } - - public String getAttribute(String prefix, String key) { - for (int i = prefix.length() - 1; i >= 0; i--) { - PluginRepositoryMapping mapping = getMapping(prefix.substring(0, i)); - if (mapping != null) { - String value = mapping.getAttributes().get(key); - if (value != null) { - return value; - } - } - } - return null; - } - - public Map<String, String> getAllAttributes(String prefix) { - Map<String, String> attributes = new HashMap<String, String>(); - for (int i = 0; i <= prefix.length(); i++) { - PluginRepositoryMapping mapping = getMapping(prefix.substring(0, i)); - if (mapping != null) { - attributes.putAll(mapping.getAttributes()); - } - } - return attributes; - } - - public boolean hasMappings() { - return !mappingByPrefix.isEmpty(); - } - -} 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/SupportHandlerManager.java index 57ab61a90..8d5272d68 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/SupportHandlerManager.java @@ -12,7 +12,6 @@ package org.eclipse.mylyn.internal.tasks.bugs; import java.util.List; -import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import org.eclipse.core.runtime.CoreException; @@ -20,135 +19,84 @@ 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.IProgressMonitor; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; 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.AbstractSupportHandler; 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 { +public class SupportHandlerManager { private static final String ELEMENT_CLASS = "class"; //$NON-NLS-1$ - private static final String ELEMENT_TASK_CONTRIBUTOR = "contributor"; //$NON-NLS-1$ + private static final String ELEMENT_TASK_HANDLER = "handler"; //$NON-NLS-1$ - private static final String EXTENSION_ID_TASK_CONTRIBUTORS = "org.eclipse.mylyn.tasks.bugs.taskContributors"; //$NON-NLS-1$ + private static final String EXTENSION_ID_TASK_CONTRIBUTORS = "org.eclipse.mylyn.tasks.bugs.support"; //$NON-NLS-1$ - private final DefaultTaskContributor defaultTaskContributor = new DefaultTaskContributor(); + private final DefaultSupportHandler defaultSupportHandler = new DefaultSupportHandler(); private boolean readExtensions; - private final List<AbstractTaskContributor> taskContributors = new CopyOnWriteArrayList<AbstractTaskContributor>(); + private final List<AbstractSupportHandler> taskContributors = new CopyOnWriteArrayList<AbstractSupportHandler>(); - public TaskContributorManager() { + public SupportHandlerManager() { } - public void addErrorReporter(AbstractTaskContributor taskContributor) { + public void addErrorReporter(AbstractSupportHandler taskContributor) { taskContributors.add(taskContributor); } - public String getEditorId(IStatus status) { + public void process(final ITaskContribution contribution, final IProgressMonitor monitor) { readExtensions(); - for (AbstractTaskContributor contributor : taskContributors) { - String editorId = contributor.getEditorId(status); - if (editorId != null) { - return editorId; - } - } - - return defaultTaskContributor.getEditorId(status); - } - - @Deprecated - public void postProcess(final IStatus status, final TaskData taskData) { - 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.postProcess(status, taskData); - } - }); - } - } - - public void process(final ITaskContribution contribution) { - readExtensions(); - - for (final AbstractTaskContributor contributor : taskContributors) { + for (final AbstractSupportHandler 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); + contributor.process(contribution, monitor); } }); + if (contribution.isHandled()) { + break; + } } - defaultTaskContributor.process(contribution); - } - - public void postProcess(final ISupportResponse response) { - 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.postProcess(response); - } - }); + if (!contribution.isHandled()) { + defaultSupportHandler.process(contribution, monitor); } - defaultTaskContributor.postProcess(response); } - @Deprecated - public void preProcess(final IStatus status, final AttributeTaskMapper contribution) { + public void postProcess(final ISupportResponse response, final IProgressMonitor monitor) { readExtensions(); - final boolean[] handled = new boolean[1]; - for (final AbstractTaskContributor contributor : taskContributors) { + for (final AbstractSupportHandler 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 { - Map<String, String> contributorAttributes = contributor.getAttributes(status); - if (contributorAttributes != null) { - handled[0] = true; - contribution.getAttributes().putAll(contributorAttributes); - } + contributor.postProcess(response, monitor); } }); } - if (!handled[0]) { - contribution.getAttributes().putAll(defaultTaskContributor.getAttributes(status)); - } + defaultSupportHandler.postProcess(response, monitor); } public void preProcess(final SupportRequest request) { readExtensions(); - for (final AbstractTaskContributor contributor : taskContributors) { + for (final AbstractSupportHandler 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$ @@ -159,7 +107,7 @@ public class TaskContributorManager { } }); } - defaultTaskContributor.preProcess(request); + defaultSupportHandler.preProcess(request); } private synchronized void readExtensions() { @@ -174,7 +122,7 @@ public class TaskContributorManager { for (IExtension extension : extensions) { IConfigurationElement[] elements = extension.getConfigurationElements(); for (IConfigurationElement element : elements) { - if (element.getName().equals(ELEMENT_TASK_CONTRIBUTOR)) { + if (element.getName().equals(ELEMENT_TASK_HANDLER)) { readTaskContributor(element); } } @@ -184,12 +132,12 @@ public class TaskContributorManager { private void readTaskContributor(IConfigurationElement element) { try { Object object = element.createExecutableExtension(ELEMENT_CLASS); - if (object instanceof AbstractTaskContributor) { - taskContributors.add((AbstractTaskContributor) object); + if (object instanceof AbstractSupportHandler) { + taskContributors.add((AbstractSupportHandler) 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$ + + " does not implement \"" + AbstractSupportHandler.class.getCanonicalName() + "\"")); //$NON-NLS-1$ //$NON-NLS-2$ } } catch (CoreException e) { StatusHandler.log(new Status(IStatus.WARNING, TasksBugsPlugin.ID_PLUGIN, @@ -197,7 +145,7 @@ public class TaskContributorManager { } } - public void removeErrorReporter(AbstractTaskContributor taskContributor) { + public void removeErrorReporter(AbstractSupportHandler 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 7f52fbd46..54b051c6a 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 @@ -13,95 +13,102 @@ package org.eclipse.mylyn.internal.tasks.bugs; 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.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Status; +import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.mylyn.commons.core.AbstractErrorReporter; import org.eclipse.mylyn.commons.core.StatusHandler; +import org.eclipse.mylyn.internal.provisional.commons.ui.CommonUiUtil; +import org.eclipse.mylyn.internal.provisional.commons.ui.ICoreRunnable; import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil; import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProduct; -import org.eclipse.mylyn.internal.tasks.bugs.wizards.ProductStatus; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.ITaskContribution; import org.eclipse.mylyn.internal.tasks.bugs.wizards.ReportErrorWizard; import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; import org.eclipse.mylyn.tasks.core.data.TaskData; +import org.eclipse.swt.widgets.Display; /** * @author Steffen Pingel */ public class TaskErrorReporter { - private final PluginRepositoryMappingManager mappingManager; - - private final TaskContributorManager contributorManager; + private final SupportHandlerManager handlerManager; private final SupportProviderManager providerManager; public TaskErrorReporter() { - this.contributorManager = new TaskContributorManager(); - this.mappingManager = new PluginRepositoryMappingManager(); + this.handlerManager = new SupportHandlerManager(); this.providerManager = new SupportProviderManager(); } - public TaskContributorManager getContributorManager() { - return contributorManager; - } - - public PluginRepositoryMappingManager getMappingManager() { - return mappingManager; + public SupportHandlerManager getHandlerManager() { + return handlerManager; } - public int getPriority(IStatus status) { - Assert.isNotNull(status); - String pluginId = status.getPlugin(); - for (int i = 0; i <= pluginId.length(); i++) { - if (mappingManager.getMapping(pluginId.substring(0, i)) != null) { - return AbstractErrorReporter.PRIORITY_DEFAULT; - } - } - return AbstractErrorReporter.PRIORITY_NONE; - } - -// public void process(IStatus status) { -// Assert.isNotNull(status); -// AttributeTaskMapper mapper = preProcess(status); -// postProcess(mapper); -// } - public SupportRequest preProcess(IStatus status, IProduct product) { Assert.isNotNull(status); //Map<String, String> attributes = mappingManager.getAllAttributes(namespace); SupportRequest request = new SupportRequest(providerManager, status, product); - contributorManager.preProcess(request); + handlerManager.preProcess(request); return request; } - public void postProcess(AttributeTaskMapper mapper) { - Assert.isNotNull(mapper); - contributorManager.process(mapper); + public boolean process(final ITaskContribution response, IRunnableContext context) { + Assert.isNotNull(response); + ICoreRunnable runner = new ICoreRunnable() { + public void run(IProgressMonitor monitor) throws CoreException { + try { + monitor.beginTask("Processing support request", IProgressMonitor.UNKNOWN); + process((AttributeTaskMapper) response, monitor); + } finally { + monitor.done(); + } + } + }; try { - TaskData taskData = mapper.createTaskData(null); - mapper.setTaskData(taskData); - contributorManager.postProcess(mapper); - TasksUiInternal.createAndOpenNewTask(taskData); + CommonUiUtil.run(context, runner); } catch (CoreException e) { - StatusHandler.log(new Status(IStatus.ERROR, TasksBugsPlugin.ID_PLUGIN, "Unexpected error reporting error", //$NON-NLS-1$ - e)); + TasksUiInternal.logAndDisplayStatus("Error Reporting", new Status(IStatus.ERROR, TasksBugsPlugin.ID_PLUGIN, + "Unexpected error while creating task for error report", e)); + return false; + } catch (OperationCanceledException e) { + return false; } + return true; } - public void handle(final IStatus status) { - if (status instanceof ProductStatus) { - SupportRequest request = preProcess(status, ((ProductStatus) status).getProduct()); - postProcess((AttributeTaskMapper) request.getDefaultContribution()); - } else { - ReportErrorWizard wizard = new ReportErrorWizard(TaskErrorReporter.this, status); - WizardDialog dialog = new WizardDialog(WorkbenchUtil.getShell(), wizard); - dialog.setBlockOnOpen(false); - dialog.setPageSize(500, 200); - dialog.open(); + public void process(AttributeTaskMapper mapper, IProgressMonitor monitor) throws CoreException { + Assert.isNotNull(mapper); + handlerManager.process(mapper, monitor); + if (!mapper.isHandled()) { + final TaskData taskData = mapper.createTaskData(monitor); + mapper.setTaskData(taskData); + handlerManager.postProcess(mapper, monitor); + // XXX open task asynchronously to make sure the workbench is active + Display.getDefault().asyncExec(new Runnable() { + public void run() { + try { + TasksUiInternal.createAndOpenNewTask(taskData); + } catch (CoreException e) { + StatusHandler.log(new Status(IStatus.ERROR, TasksBugsPlugin.ID_PLUGIN, + "Unexpected error while creating task", e)); //$NON-NLS-1$ + } + } + }); } } + public void handle(final IStatus status) { + ReportErrorWizard wizard = new ReportErrorWizard(this, status); + WizardDialog dialog = new WizardDialog(WorkbenchUtil.getShell(), wizard); + dialog.setBlockOnOpen(false); + dialog.setPageSize(500, 200); + dialog.open(); + } + public SupportProviderManager getProviderManager() { return providerManager; } diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromMarkerHandler.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromMarkerHandler.java index 64fcb7f71..d164ada20 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromMarkerHandler.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromMarkerHandler.java @@ -16,9 +16,9 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil; import org.eclipse.mylyn.tasks.core.TaskMapping; import org.eclipse.mylyn.tasks.ui.TasksUiUtil; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.views.markers.MarkerViewHandler; import org.eclipse.ui.views.markers.internal.MarkerType; import org.eclipse.ui.views.markers.internal.MarkerTypesModel; @@ -62,7 +62,7 @@ public class NewTaskFromMarkerHandler extends MarkerViewHandler { }; - TasksUiUtil.openNewTaskEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), mapping, null); + TasksUiUtil.openNewTaskEditor(WorkbenchUtil.getShell(), mapping, null); return null; } diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportBugOrEnhancementWizard.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportBugOrEnhancementWizard.java index 2ab559ad3..46f8fc2d2 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportBugOrEnhancementWizard.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ReportBugOrEnhancementWizard.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.wizard.IWizardPage; @@ -24,6 +25,8 @@ import org.eclipse.mylyn.internal.tasks.bugs.AbstractSupportElement; import org.eclipse.mylyn.internal.tasks.bugs.SupportProduct; import org.eclipse.mylyn.internal.tasks.bugs.SupportProvider; import org.eclipse.mylyn.internal.tasks.bugs.SupportProviderManager; +import org.eclipse.mylyn.internal.tasks.bugs.SupportRequest; +import org.eclipse.mylyn.internal.tasks.bugs.TaskErrorReporter; import org.eclipse.mylyn.internal.tasks.bugs.TasksBugsPlugin; import org.eclipse.mylyn.tasks.ui.TasksUiImages; @@ -77,7 +80,7 @@ public class ReportBugOrEnhancementWizard extends Wizard { public ReportBugOrEnhancementWizard() { setForcePreviousAndNextButtons(true); - setNeedsProgressMonitor(false); + setNeedsProgressMonitor(true); setWindowTitle(Messages.ReportBugOrEnhancementWizard_Report_Bug_or_Enhancement); setDefaultPageImageDescriptor(TasksUiImages.BANNER_REPORT_BUG); } @@ -109,14 +112,10 @@ public class ReportBugOrEnhancementWizard extends Wizard { return false; } - // delay run this until after the dialog has been closed - getShell().getDisplay().asyncExec(new Runnable() { - public void run() { - TasksBugsPlugin.getTaskErrorReporter().handle(new ProductStatus((IProduct) product)); - } - }); - - return true; + TaskErrorReporter reporter = TasksBugsPlugin.getTaskErrorReporter(); + IStatus status = new ProductStatus((IProduct) product); + SupportRequest request = reporter.preProcess(status, ((ProductStatus) status).getProduct()); + return reporter.process(request.getDefaultContribution(), getContainer()); } } 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 7d1da1a10..0ab9b88b4 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 @@ -42,6 +42,7 @@ public class ReportErrorWizard extends Wizard { this.request = taskErrorReporter.preProcess(status, null); setWindowTitle(Messages.ReportErrorWizard_Report_as_Bug); setDefaultPageImageDescriptor(TasksUiImages.BANNER_REPORT_BUG); + setNeedsProgressMonitor(true); } @Override @@ -57,8 +58,7 @@ public class ReportErrorWizard extends Wizard { @Override public boolean performFinish() { if (reportErrorPage.getSelectedContribution() != null) { - taskErrorReporter.postProcess(reportErrorPage.getSelectedContribution()); - return true; + return taskErrorReporter.process(reportErrorPage.getSelectedContribution(), getContainer()); } else { return newTaskPage.performFinish(); } |