diff options
author | spingel | 2009-05-20 21:37:11 +0000 |
---|---|---|
committer | spingel | 2009-05-20 21:37:11 +0000 |
commit | 943cfc79210399d0b537b9330a7cc6136de85cc2 (patch) | |
tree | c886e75c677fefed7472cd61b32b5cc7a18c40e1 | |
parent | 25aee119b79ba99c409c11304115ef906f6f182d (diff) | |
download | org.eclipse.mylyn.tasks-943cfc79210399d0b537b9330a7cc6136de85cc2.tar.gz org.eclipse.mylyn.tasks-943cfc79210399d0b537b9330a7cc6136de85cc2.tar.xz org.eclipse.mylyn.tasks-943cfc79210399d0b537b9330a7cc6136de85cc2.zip |
NEW - bug 248778: [releng] backport changes to Eclipse 3.3
https://bugs.eclipse.org/bugs/show_bug.cgi?id=248778
41 files changed, 2349 insertions, 342 deletions
diff --git a/org.eclipse.mylyn-feature/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.mylyn-feature/.settings/org.eclipse.jdt.core.prefs index 7b0bd0cb5..1314ffa2f 100644 --- a/org.eclipse.mylyn-feature/.settings/org.eclipse.jdt.core.prefs +++ b/org.eclipse.mylyn-feature/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,4 @@ -#Thu Apr 24 21:03:23 PDT 2008 +#Tue May 12 20:42:46 PDT 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -124,7 +124,7 @@ org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true org.eclipse.jdt.core.formatter.comment.format_block_comments=false org.eclipse.jdt.core.formatter.comment.format_comments=true org.eclipse.jdt.core.formatter.comment.format_header=false @@ -324,6 +324,8 @@ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false diff --git a/org.eclipse.mylyn-feature/.settings/org.eclipse.mylyn.tasklist.prefs b/org.eclipse.mylyn-feature/.settings/org.eclipse.mylyn.tasklist.prefs deleted file mode 100644 index 8535764ed..000000000 --- a/org.eclipse.mylyn-feature/.settings/org.eclipse.mylyn.tasklist.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Mon Jun 18 17:15:50 PDT 2007 -eclipse.preferences.version=1 -project.repository.kind=bugzilla -project.repository.url=https\://bugs.eclipse.org/bugs diff --git a/org.eclipse.mylyn-feature/feature.properties b/org.eclipse.mylyn-feature/feature.properties index 8c6697b4f..a3db07aaa 100644 --- a/org.eclipse.mylyn-feature/feature.properties +++ b/org.eclipse.mylyn-feature/feature.properties @@ -1,6 +1,6 @@ featureName=Mylyn Task List (Required) description=Provides the Task List for task and time management. -providerName=Eclipse.org +providerName=Eclipse Mylyn copyright=Copyright (c) 2004, 2008 Tasktop Technologies and others. All rights reserved. updateSiteName=Mylyn for Eclipse 3.3 discovery_Mylyn_Extras=Mylyn Extras diff --git a/org.eclipse.mylyn.bugzilla-feature/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.mylyn.bugzilla-feature/.settings/org.eclipse.jdt.core.prefs index 7b0bd0cb5..1314ffa2f 100644 --- a/org.eclipse.mylyn.bugzilla-feature/.settings/org.eclipse.jdt.core.prefs +++ b/org.eclipse.mylyn.bugzilla-feature/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,4 @@ -#Thu Apr 24 21:03:23 PDT 2008 +#Tue May 12 20:42:46 PDT 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -124,7 +124,7 @@ org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true org.eclipse.jdt.core.formatter.comment.format_block_comments=false org.eclipse.jdt.core.formatter.comment.format_comments=true org.eclipse.jdt.core.formatter.comment.format_header=false @@ -324,6 +324,8 @@ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false diff --git a/org.eclipse.mylyn.bugzilla-feature/.settings/org.eclipse.mylyn.tasklist.prefs b/org.eclipse.mylyn.bugzilla-feature/.settings/org.eclipse.mylyn.tasklist.prefs deleted file mode 100644 index 4a0e39c4f..000000000 --- a/org.eclipse.mylyn.bugzilla-feature/.settings/org.eclipse.mylyn.tasklist.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Mon Jun 18 17:13:25 PDT 2007 -eclipse.preferences.version=1 -project.repository.kind=bugzilla -project.repository.url=https\://bugs.eclipse.org/bugs diff --git a/org.eclipse.mylyn.bugzilla-feature/feature.properties b/org.eclipse.mylyn.bugzilla-feature/feature.properties index 16a9725d3..d96b815a7 100644 --- a/org.eclipse.mylyn.bugzilla-feature/feature.properties +++ b/org.eclipse.mylyn.bugzilla-feature/feature.properties @@ -1,6 +1,6 @@ featureName=Mylyn Connector: Bugzilla description=Provides Task List integration, offline support and rich editing for the open source Bugzilla bug tracker. -providerName=Eclipse.org +providerName=Eclipse Mylyn copyright=Copyright (c) 2004, 2008 Tasktop Technologies and others. All rights reserved. updateSiteName=Mylyn for Eclipse 3.3 license=\ diff --git a/org.eclipse.mylyn.tasks.bugs/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.mylyn.tasks.bugs/.settings/org.eclipse.jdt.core.prefs index 7b0bd0cb5..f1554b100 100644 --- a/org.eclipse.mylyn.tasks.bugs/.settings/org.eclipse.jdt.core.prefs +++ b/org.eclipse.mylyn.tasks.bugs/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,4 @@ -#Thu Apr 24 21:03:23 PDT 2008 +#Tue May 12 20:42:43 PDT 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -124,7 +124,7 @@ org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true org.eclipse.jdt.core.formatter.comment.format_block_comments=false org.eclipse.jdt.core.formatter.comment.format_comments=true org.eclipse.jdt.core.formatter.comment.format_header=false @@ -324,6 +324,8 @@ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false diff --git a/org.eclipse.mylyn.tasks.bugs/.settings/org.eclipse.mylyn.tasklist.prefs b/org.eclipse.mylyn.tasks.bugs/.settings/org.eclipse.mylyn.tasklist.prefs deleted file mode 100644 index 0a2cc0b30..000000000 --- a/org.eclipse.mylyn.tasks.bugs/.settings/org.eclipse.mylyn.tasklist.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Mon Jun 18 17:14:59 PDT 2007 -eclipse.preferences.version=1 -project.repository.kind=bugzilla -project.repository.url=https\://bugs.eclipse.org/bugs diff --git a/org.eclipse.mylyn.tasks.bugs/plugin.properties b/org.eclipse.mylyn.tasks.bugs/plugin.properties index 64826c695..797c915c3 100644 --- a/org.eclipse.mylyn.tasks.bugs/plugin.properties +++ b/org.eclipse.mylyn.tasks.bugs/plugin.properties @@ -1,5 +1,5 @@ #Properties file for org.eclipse.mylyn.tasks.bugs -Bundle-Vendor = Eclipse.org +Bundle-Vendor = Eclipse Mylyn Bundle-Name = Mylyn Bug Reporting action.label = Report as Bug diff --git a/org.eclipse.mylyn.tasks.bugs/plugin.xml b/org.eclipse.mylyn.tasks.bugs/plugin.xml index 00129a81f..125ade0ba 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..6543f7d9b 100644 --- a/org.eclipse.mylyn.tasks.bugs/schema/pluginRepositoryMappings.exsd +++ b/org.eclipse.mylyn.tasks.bugs/schema/pluginRepositoryMappings.exsd @@ -13,7 +13,7 @@ <element name="extension"> <annotation> <appinfo> - <meta.element internal="true" /> + <meta.element deprecated="true" internal="true" /> </appinfo> </annotation> <complexType> 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..29d3ebc47 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/schema/support.exsd @@ -0,0 +1,322 @@ +<?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="unbounded"/> + <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"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="description" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="icon" type="string"> + <annotation> + <documentation> + A 32x32 branding icon. + </documentation> + </annotation> + </attribute> + <attribute name="url" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="featureId" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="pluginId" type="string"> + <annotation> + <documentation> + If specified the product is only listed if the referenced plug-in is installed. + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="property"> + <complexType> + <attribute name="name" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="value" 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> + <attribute name="weight" 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="icon" type="string"> + <annotation> + <documentation> + A 32x32 branding icon. + </documentation> + <appinfo> + <meta.attribute kind="resource"/> + </appinfo> + </annotation> + </attribute> + <attribute name="url" type="string"> + <annotation> + <documentation> + + </documentation> + </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..de85c10a1 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/provisional/tasks/bugs/ISupportResponse.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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 IProduct getProduct(); + + public IStatus getStatus(); + + public TaskData getTaskData(); + +} 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/AbstractSupportElement.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/AbstractSupportElement.java new file mode 100644 index 000000000..464be3081 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/AbstractSupportElement.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * 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; + +public class AbstractSupportElement { + + private String description; + + private ImageDescriptor icon; + + private String id; + + private String name; + + private String url; + + public String getDescription() { + return description; + } + + public ImageDescriptor getIcon() { + return icon; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getUrl() { + return url; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setIcon(ImageDescriptor icon) { + this.icon = icon; + } + + public void setId(String id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + + public void setUrl(String url) { + this.url = url; + } + +} 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 c5aa446c0..afa7116c3 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 @@ -18,30 +18,104 @@ 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.IStatus; +import org.eclipse.core.runtime.Platform; 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.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.mylyn.internal.tasks.bugs.wizards.ProductStatus; +import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; +import org.eclipse.mylyn.tasks.core.ITaskMapping; +import org.eclipse.mylyn.tasks.core.TaskMapping; +import org.eclipse.mylyn.tasks.core.data.TaskAttribute; +import org.eclipse.mylyn.tasks.core.data.TaskData; +import org.eclipse.mylyn.tasks.ui.TasksUi; +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) { + String description = getDescription(contribution.getStatus()); + if (description != null) { + contribution.appendToDescription(description); + } + } + + @Override + public void postProcess(ISupportResponse response) { + IStatus contribution = response.getStatus(); + TaskData taskData = response.getTaskData(); + if (contribution instanceof ProductStatus) { + AbstractRepositoryConnector connector = TasksUi.getRepositoryConnector(taskData.getConnectorKind()); + ITaskMapping mapping = connector.getTaskMapping(taskData); + mapping.merge(new TaskMapping() { + @Override + public String getSeverity() { + return "enhancement"; //$NON-NLS-1$ + } + }); + } + if (response.getProduct() != null) { + IBundleGroup bundleGroup = ((SupportProduct) response.getProduct()).getBundleGroup(); + if (bundleGroup != null) { + TaskAttribute attribute = taskData.getRoot().getMappedAttribute(TaskAttribute.VERSION); + if (attribute != null) { + final String version = getBestMatch(bundleGroup.getVersion(), attribute.getOptions()); + if (version.length() > 0) { + AbstractRepositoryConnector connector = TasksUi.getRepositoryConnector(taskData.getConnectorKind()); + ITaskMapping mapping = connector.getTaskMapping(taskData); + mapping.merge(new TaskMapping() { + @Override + public String getVersion() { + return version; + } + }); + } + } + } + } + } + + private String getBestMatch(String version, Map<String, String> options) { + String match = ""; //$NON-NLS-1$ + for (String option : options.values()) { + if (version.startsWith(option) && option.length() > match.length()) { + match = option; + } + } + return match; + } + public void appendErrorDetails(StringBuilder sb, IStatus status, Date date) { - sb.append(Messages.DefaultTaskContributor_Error_DETAILS); + sb.append("\n\n"); + sb.append(Messages.DefaultTaskContributor_Error_Details); if (date != null) { - sb.append(Messages.DefaultTaskContributor_DATE); - sb.append(date); + sb.append("\n"); //$NON-NLS-1$ + sb.append(NLS.bind("Date: {0}", date)); + } + sb.append("\n"); //$NON-NLS-1$ + sb.append(NLS.bind("Message: {0}", status.getMessage())); + sb.append("\n"); //$NON-NLS-1$ + sb.append(NLS.bind("Severity: {0}", getSeverityText(status.getSeverity()))); + IProduct product = Platform.getProduct(); + if (product != null) { + sb.append("\n"); //$NON-NLS-1$ + if (product.getName() != null) { + sb.append(NLS.bind("Product: {0} ({1})", product.getName(), product.getId())); + } else { + sb.append(NLS.bind("Product: {0}", product.getId())); + } } - sb.append(Messages.DefaultTaskContributor_MESSAGE); - sb.append(status.getMessage()); - sb.append(Messages.DefaultTaskContributor_SEVERITY); - sb.append(getSeverityText(status.getSeverity())); - sb.append(Messages.DefaultTaskContributor_PLUGIN); - sb.append(status.getPlugin()); + sb.append("\n"); //$NON-NLS-1$ + sb.append(NLS.bind("Plugin: {0}", status.getPlugin())); } @Override @@ -52,32 +126,35 @@ public class DefaultTaskContributor extends AbstractTaskContributor { } public String getDescription(IStatus status) { - if (status instanceof FeatureStatus) { - StringBuilder sb = new StringBuilder(); - sb.append("\n\n\n"); //$NON-NLS-1$ - sb.append(Messages.DefaultTaskContributor_INSTALLED_FEATURES_AND_PLUGINS); - IBundleGroup[] bundleGroups = ((FeatureStatus) status).getBundleGroup(); - for (IBundleGroup bundleGroup : bundleGroups) { - sb.append(bundleGroup.getIdentifier()); - sb.append(" "); //$NON-NLS-1$ - sb.append(bundleGroup.getVersion()); - sb.append("\n"); //$NON-NLS-1$ + if (status instanceof ProductStatus) { + SupportProduct product = (SupportProduct) ((ProductStatus) status).getProduct(); + if (product.getBundleGroup() != null) { + StringBuilder sb = new StringBuilder(); + sb.append("\n\n\n"); //$NON-NLS-1$ + sb.append(Messages.DefaultTaskContributor_INSTALLED_FEATURES_AND_PLUGINS); + for (IBundleGroup bundleGroup : new IBundleGroup[] { product.getBundleGroup() }) { + sb.append(bundleGroup.getIdentifier()); + sb.append(" "); //$NON-NLS-1$ + sb.append(bundleGroup.getVersion()); + sb.append("\n"); //$NON-NLS-1$ - Bundle[] bundles = bundleGroup.getBundles(); - if (bundles != null) { - for (Bundle bundle : bundles) { - sb.append(" "); //$NON-NLS-1$ - sb.append(bundle.getSymbolicName()); - String version = (String) bundle.getHeaders().get(Messages.DefaultTaskContributor_Bundle_Version); - if (version != null) { - sb.append(" "); //$NON-NLS-1$ - sb.append(version); + Bundle[] bundles = bundleGroup.getBundles(); + if (bundles != null) { + for (Bundle bundle : bundles) { + sb.append(" "); //$NON-NLS-1$ + sb.append(bundle.getSymbolicName()); + String version = (String) bundle.getHeaders().get( + Messages.DefaultTaskContributor_Bundle_Version); + if (version != null) { + sb.append(" "); //$NON-NLS-1$ + sb.append(version); + } + sb.append("\n"); //$NON-NLS-1$ } - sb.append("\n"); //$NON-NLS-1$ } } + return sb.toString(); } - return sb.toString(); } else if (status instanceof ErrorLogStatus) { ErrorLogStatus errorLogStatus = (ErrorLogStatus) status; StringBuilder sb = new StringBuilder(); @@ -102,11 +179,7 @@ public class DefaultTaskContributor extends AbstractTaskContributor { } return sb.toString(); } - } - - @Override - public String getEditorId(IStatus status) { - return TaskEditor.ID_EDITOR; + return null; } private String getSeverityText(int severity) { 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..c4073408c 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,16 +27,29 @@ 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$ + public static final String SEVERITY = "severity"; //$NON-NLS-1$ + + public static final String VERSION = "version"; //$NON-NLS-1$ + + public static final String SUMMARY = "summary"; //$NON-NLS-1$ + + public static final String PRIORITY = "priority"; + } 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..2e3c2d581 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/KeyValueMapping.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * 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.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; + +/** + * @author Steffen Pingel + */ +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 String getComponent() { + return attributes.get(IRepositoryConstants.COMPONENT); + } + + @Override + public String getDescription() { + return attributes.get(IRepositoryConstants.DESCRIPTION); + } + + @Override + public List<String> getKeywords() { + // TODO implement + return null; + } + + @Override + public String getOwner() { + // TODO implement + return null; + } + + @Override + public String getPriority() { + return attributes.get(IRepositoryConstants.PRIORITY); + } + + @Override + public String getProduct() { + return attributes.get(IRepositoryConstants.PRODUCT); + } + + @Override + public String getSeverity() { + return attributes.get(IRepositoryConstants.SEVERITY); + } + + @Override + public String getSummary() { + return attributes.get(IRepositoryConstants.SUMMARY); + } + + @Override + public String getTaskKind() { + // TODO implement + return null; + } + + @Override + public String getVersion() { + return attributes.get(IRepositoryConstants.VERSION); + } + + @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/Messages.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/Messages.java index e735e692f..8b9629510 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/Messages.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/Messages.java @@ -26,16 +26,28 @@ public class Messages extends NLS { } public static String DefaultTaskContributor_Bundle_Version; + public static String DefaultTaskContributor_DATE; + public static String DefaultTaskContributor_Error; - public static String DefaultTaskContributor_Error_DETAILS; + + public static String DefaultTaskContributor_Error_Details; + public static String DefaultTaskContributor_EXCEPTION_STACK_TRACE; + public static String DefaultTaskContributor_Info; + public static String DefaultTaskContributor_INSTALLED_FEATURES_AND_PLUGINS; + public static String DefaultTaskContributor_MESSAGE; + public static String DefaultTaskContributor_OK; + public static String DefaultTaskContributor_PLUGIN; + public static String DefaultTaskContributor_SESSION_DATA; + public static String DefaultTaskContributor_SEVERITY; + public static String DefaultTaskContributor_Warning; } 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..7bb3f9b09 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/ProductRepositoryMapping.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.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 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..2028ff550 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportCategory.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * 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.mylyn.internal.provisional.tasks.bugs.IProvider; + +public class SupportCategory extends AbstractSupportElement { + + private static final int DEFAULT_WEIGHT = 1000; + + private List<IProvider> providers; + + private int weight; + + public SupportCategory() { + setWeight(DEFAULT_WEIGHT); + } + + public void add(IProvider provider) { + if (providers == null) { + providers = new ArrayList<IProvider>(); + } + providers.add(provider); + } + + public void remove(IProvider provider) { + if (providers != null) { + providers.remove(provider); + } + } + + public List<IProvider> getProviders() { + return new ArrayList<IProvider>(providers); + } + + public int getWeight() { + return weight; + } + + public void setWeight(int weight) { + this.weight = weight; + } + +} 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..1c3e2e2a2 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportProduct.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * 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.core.runtime.IBundleGroup; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProduct; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProvider; + +/** + * @author Steffen Pingel + */ +public class SupportProduct extends AbstractSupportElement implements IProduct { + + private IBundleGroup bundleGroup; + + private boolean installed; + + TreeMap<String, ProductRepositoryMapping> mappingByNamespace; + + private String pluginId; + + private IProvider provider; + + public SupportProduct() { + mappingByNamespace = new TreeMap<String, ProductRepositoryMapping>(); + } + + 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 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; + } + + public IBundleGroup getBundleGroup() { + return bundleGroup; + } + + public ProductRepositoryMapping getMapping(String prefix) { + return mappingByNamespace.get(prefix); + } + + public String getPluginId() { + return pluginId; + } + + public IProvider getProvider() { + return provider; + } + + public boolean hasMappings() { + return !mappingByNamespace.isEmpty(); + } + + /** + * @deprecated Use {@link #isInstalled()} instead + */ + public boolean isEnabled() { + return isInstalled(); + } + + public boolean isInstalled() { + return installed; + } + + public void setBundleGroup(IBundleGroup bundleGroup) { + this.bundleGroup = bundleGroup; + } + + /** + * @deprecated Use {@link #setInstalled(boolean)} instead + */ + public void setEnabled(boolean enabled) { + setInstalled(enabled); + } + + public void setInstalled(boolean enabled) { + this.installed = enabled; + } + + public void setPluginId(String pluginId) { + this.pluginId = pluginId; + } + + public void setProvider(IProvider provider) { + this.provider = provider; + } + +} 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..c78130c3c --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportProvider.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * 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.mylyn.internal.provisional.tasks.bugs.IProduct; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProvider; + +/** + * @author Steffen Pingel + */ +public class SupportProvider extends AbstractSupportElement implements IProvider { + + private SupportCategory category; + + private List<IProduct> products; + + public SupportProvider() { + } + + public SupportCategory getCategory() { + return category; + } + + public void setCategory(SupportCategory category) { + this.category = category; + } + + public void add(IProduct provider) { + if (products == null) { + products = new ArrayList<IProduct>(); + } + products.add(provider); + } + + public void remove(IProduct provider) { + if (products != null) { + products.remove(provider); + } + } + + public List<IProduct> getProducts() { + return new ArrayList<IProduct>(products); + } + +} 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..651904603 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportProviderManager.java @@ -0,0 +1,378 @@ +/******************************************************************************* + * 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.net.MalformedURLException; +import java.net.URL; +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.IBundleGroup; +import org.eclipse.core.runtime.IBundleGroupProvider; +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.jface.resource.ImageDescriptor; +import org.eclipse.mylyn.commons.core.StatusHandler; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProvider; +import org.eclipse.osgi.util.NLS; +import org.eclipse.ui.branding.IBundleGroupConstants; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +/** + * @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_FEATURE_ID = "featureId"; //$NON-NLS-1$ + + private static final String ATTRIBUTE_ICON = "icon"; //$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_PLUGIN_ID = "pluginId"; //$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_URL = "url"; //$NON-NLS-1$ + + private static final String ATTRIBUTE_VALUE = "value"; //$NON-NLS-1$ + + private static final String ATTRIBUTE_WEIGHT = "weight"; //$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 HashMap<String, IBundleGroup> bundleGroupById; + + 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; + } + + private IBundleGroup getBundleGroup(String featureId) { + if (bundleGroupById == null) { + bundleGroupById = new HashMap<String, IBundleGroup>(); + IBundleGroupProvider[] providers = Platform.getBundleGroupProviders(); + if (providers != null) { + for (IBundleGroupProvider provider : providers) { + for (IBundleGroup bundleGroup : provider.getBundleGroups()) { + bundleGroupById.put(bundleGroup.getIdentifier(), bundleGroup); + } + } + } + } + return bundleGroupById.get(featureId); + } + + public Collection<SupportCategory> getCategories() { + return Collections.unmodifiableList(categories); + } + + public SupportCategory getCategory(String categoryId) { + for (SupportCategory category : categories) { + if (category.getId().equals(categoryId)) { + return category; + } + } + return null; + } + + public SupportProduct getDefaultProduct() { + return defaultProduct; + } + + public SupportProduct getProduct(String productId) { + return productById.get(productId); + } + + public Collection<SupportProduct> getProducts() { + return Collections.unmodifiableCollection(productById.values()); + } + + public SupportProvider getProvider(String providerId) { + return providerById.get(providerId); + } + + public Collection<SupportProvider> getProviders() { + return Collections.unmodifiableCollection(providerById.values()); + } + + private boolean readAttributes(IConfigurationElement element, AbstractSupportElement item) { + item.setId(element.getAttribute(ATTRIBUTE_ID)); + item.setName(element.getAttribute(ATTRIBUTE_NAME)); + item.setDescription(element.getAttribute(ATTRIBUTE_DESCRIPTION)); + item.setUrl(element.getAttribute(ATTRIBUTE_URL)); + String iconPath = element.getAttribute(ATTRIBUTE_ICON); + if (iconPath != null) { + ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(element.getContributor().getName(), + iconPath); + if (descriptor != null) { + item.setIcon(descriptor); + } + } + + // optionally complement data from referenced feature + String featureId = element.getAttribute(ATTRIBUTE_FEATURE_ID); + if (featureId != null) { + IBundleGroup bundleGroup = getBundleGroup(featureId); + if (bundleGroup == null) { + // indicate that the specified feature was not found + return false; + } else { + if (item.getName() == null) { + item.setName(bundleGroup.getName()); + } + if (item.getDescription() == null) { + item.setDescription(bundleGroup.getDescription()); + } + if (item.getIcon() == null) { + String imageUrl = bundleGroup.getProperty(IBundleGroupConstants.FEATURE_IMAGE); + if (imageUrl != null) { + try { + item.setIcon(ImageDescriptor.createFromURL(new URL(imageUrl))); + } catch (MalformedURLException e) { + // ignore + } + } + } + if (item instanceof SupportProduct) { + ((SupportProduct) item).setBundleGroup(bundleGroup); + } + } + } + return true; + } + + private void readCategory(IConfigurationElement element) { + SupportCategory category = new SupportCategory(); + readAttributes(element, category); + String weight = element.getAttribute(ATTRIBUTE_WEIGHT); + if (weight != null) { + try { + category.setWeight(Integer.parseInt(weight)); + } catch (NumberFormatException e) { + // ignore + } + } + 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); + } + } + } + + // clear cache + bundleGroupById = null; + } + + 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; + } + boolean enabled = true; + String pluginId = element.getAttribute(ATTRIBUTE_PLUGIN_ID); + if (pluginId != null) { + enabled &= Platform.getBundle(pluginId) != null; + } + SupportProduct product = new SupportProduct(); + enabled &= readAttributes(element, product); + // disable products that do not have a corresponding plug-in or feature installed + product.setInstalled(enabled); + product.setProvider(provider); + 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; + } + ((SupportProvider) provider).add(product); + productById.put(id, product); + return product; + } + + private SupportProvider readProvider(IConfigurationElement element) { + String id = element.getAttribute(ATTRIBUTE_ID); + SupportProvider provider = new SupportProvider(); + readAttributes(element, provider); + 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); + provider.setCategory(category); + return provider; + } + +} 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..8d6cc52e1 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/SupportRequest.java @@ -0,0 +1,125 @@ +/******************************************************************************* + * 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; + +/** + * @author Steffen Pingel + */ +public class SupportRequest implements ISupportRequest { + + private final Map<String, ITaskContribution> contributionByProductId; + + private final IStatus status; + + private final SupportProviderManager providerManager; + + private AttributeTaskMapper defaultContribution; + + private final IProduct product; + + public SupportRequest(SupportProviderManager providerManager, IStatus status, IProduct product) { + this.providerManager = providerManager; + this.status = status; + this.contributionByProductId = new HashMap<String, ITaskContribution>(); + if (product != null) { + this.product = product; + this.defaultContribution = process(getNamespace(), (SupportProduct) product); + } else { + this.product = null; + process(); + } + } + + public SupportRequest(SupportProviderManager providerManager, IStatus status) { + this(providerManager, status, null); + } + + 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 IProduct getProduct() { + return product; + } + + public IStatus getStatus() { + return status; + } + + private void process() { + String namespace = getNamespace(); + Collection<SupportProduct> products = providerManager.getProducts(); + for (SupportProduct product : products) { + process(namespace, product); + } + } + + private AttributeTaskMapper process(String namespace, SupportProduct product) { + 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); + return contribution; + } + return null; + } + + 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 1ed4f9903..7f52fbd46 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; @@ -20,6 +18,9 @@ import org.eclipse.core.runtime.Status; 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.WorkbenchUtil; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProduct; +import org.eclipse.mylyn.internal.tasks.bugs.wizards.ProductStatus; 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; @@ -33,9 +34,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() { @@ -57,25 +61,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, IProduct product) { 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, product); + 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$ @@ -84,11 +90,20 @@ public class TaskErrorReporter { } public void handle(final IStatus status) { - ReportErrorWizard wizard = new ReportErrorWizard(TaskErrorReporter.this, status); - WizardDialog dialog = new WizardDialog(TasksUiInternal.getShell(), wizard); - dialog.setBlockOnOpen(false); - dialog.setPageSize(500, 200); - dialog.open(); + 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 SupportProviderManager getProviderManager() { + return providerManager; } } 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 dd7e96b70..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,12 +13,13 @@ 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 { @@ -32,12 +33,12 @@ public class ReportBugAction implements IWorkbenchWindowActionDelegate { } 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/messages.properties b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/messages.properties index 5e461f4d3..fd49b72aa 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/messages.properties +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/messages.properties @@ -1,7 +1,7 @@ DefaultTaskContributor_Bundle_Version=Bundle-Version DefaultTaskContributor_DATE=\nDate: DefaultTaskContributor_Error=Error -DefaultTaskContributor_Error_DETAILS=\n\n-- Error Details -- +DefaultTaskContributor_Error_Details=-- Error Details -- DefaultTaskContributor_EXCEPTION_STACK_TRACE=\nException Stack Trace:\n DefaultTaskContributor_Info=Info DefaultTaskContributor_INSTALLED_FEATURES_AND_PLUGINS=-- Installed Features and Plug-ins --\n diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/FeatureStatus.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ProductStatus.java index 68fcd3ef9..375be230e 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/FeatureStatus.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ProductStatus.java @@ -11,24 +11,24 @@ package org.eclipse.mylyn.internal.tasks.bugs.wizards; -import org.eclipse.core.runtime.IBundleGroup; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProduct; /** * @author Steffen Pingel */ -public class FeatureStatus extends Status { +public class ProductStatus extends Status { - private final IBundleGroup[] bundleGroups; + private final IProduct product; - public FeatureStatus(String id, IBundleGroup[] bundleGroups) { - super(IStatus.INFO, id, ""); //$NON-NLS-1$ - this.bundleGroups = bundleGroups; + public ProductStatus(IProduct product) { + super(IStatus.INFO, product.getId(), ""); //$NON-NLS-1$ + this.product = product; } - public IBundleGroup[] getBundleGroup() { - return bundleGroups; + public IProduct getProduct() { + return product; } } 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 5070aefda..533199c69 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 @@ -11,11 +11,19 @@ package org.eclipse.mylyn.internal.tasks.bugs.wizards; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IBundleGroup; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.Wizard; -import org.eclipse.mylyn.internal.tasks.bugs.PluginRepositoryMappingManager; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProduct; +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.TasksBugsPlugin; import org.eclipse.mylyn.tasks.ui.TasksUiImages; @@ -24,9 +32,48 @@ import org.eclipse.mylyn.tasks.ui.TasksUiImages; */ public class ReportBugOrEnhancementWizard extends Wizard { - private SelectProductPage selectProductPage; + private class SupportContentProvider implements IStructuredContentProvider { + + private SupportProviderManager providerManager; + + private Object input; + + public Object[] getElements(Object inputElement) { + if (inputElement instanceof SupportProvider) { + List<SupportProduct> providerProducts = getProdcuts(inputElement); + return providerProducts.toArray(); + } else if (input == inputElement) { + List<AbstractSupportElement> elements = new ArrayList<AbstractSupportElement>(); + elements.addAll(providerManager.getProviders()); + elements.addAll(providerManager.getCategories()); + return elements.toArray(); + } else { + return new Object[0]; + } + } + + private List<SupportProduct> getProdcuts(Object inputElement) { + Collection<SupportProduct> products = providerManager.getProducts(); + SupportProvider provider = (SupportProvider) inputElement; + List<SupportProduct> providerProducts = new ArrayList<SupportProduct>(); + for (SupportProduct product : products) { + if (provider.equals(product.getProvider()) && product.isInstalled()) { + providerProducts.add(product); + } + } + return providerProducts; + } - private PluginRepositoryMappingManager manager; + public void dispose() { + // ignore + } + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + this.input = newInput; + this.providerManager = TasksBugsPlugin.getTaskErrorReporter().getProviderManager(); + } + + } public ReportBugOrEnhancementWizard() { setForcePreviousAndNextButtons(true); @@ -37,58 +84,39 @@ public class ReportBugOrEnhancementWizard extends Wizard { @Override public void addPages() { - manager = new PluginRepositoryMappingManager(); - selectProductPage = new SelectProductPage("selectBundleGroupProvider", manager); //$NON-NLS-1$ - addPage(selectProductPage); + SelectSupportElementPage page = new SelectSupportElementPage("selectProvider", new SupportContentProvider()); //$NON-NLS-1$ + page.setInput(new Object()); + addPage(page); } @Override public boolean canFinish() { - return getSelectedBundleGroup() != null; + return getSelectedElement() instanceof SupportProduct; } - public IBundleGroup[] getSelectedBundleGroup() { + public AbstractSupportElement getSelectedElement() { IWizardPage page = getContainer().getCurrentPage(); - if (page instanceof SelectProductPage) { - if (page.isPageComplete() && !((SelectProductPage) page).canFlipToNextPage()) { - return ((SelectProductPage) page).getSelectedBundleGroups(); - } - } else if (page instanceof SelectFeaturePage) { - if (page.isPageComplete()) { - return ((SelectFeaturePage) page).getSelectedBundleGroups(); - } + if (page != null) { + return ((SelectSupportElementPage) page).getSelectedElement(); } return null; } @Override public boolean performFinish() { - final IBundleGroup[] bundles = getSelectedBundleGroup(); - Assert.isNotNull(bundles); + final AbstractSupportElement product = getSelectedElement(); + if (!(product instanceof SupportProduct)) { + return false; + } // delay run this until after the dialog has been closed getShell().getDisplay().asyncExec(new Runnable() { public void run() { - String prefix = bundles[0].getIdentifier(); - for (int i = 1; i < bundles.length; i++) { - prefix = getCommonPrefix(prefix, bundles[i].getIdentifier()); - } - TasksBugsPlugin.getTaskErrorReporter().handle(new FeatureStatus(prefix, bundles)); + TasksBugsPlugin.getTaskErrorReporter().handle(new ProductStatus((IProduct) product)); } }); return true; } - private static String getCommonPrefix(String s1, String s2) { - int len = Math.min(s1.length(), s2.length()); - StringBuffer prefix = new StringBuffer(len); - for (int i = 0; i < len; i++) { - if (s1.charAt(i) == s2.charAt(i)) { - prefix.append(s1.charAt(i)); - } - } - return prefix.toString(); - } - } 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..806260935 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,31 @@ 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.setSelection(true); + selectedContribution = contributions.get(0); + if (contributions.size() == 1) { + defaultRepositoryButton.setText(NLS.bind("Report to: {0}", getLabel(selectedContribution))); + GridDataFactory.fillDefaults().span(2, 1).applyTo(defaultRepositoryButton); + } 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).applyTo(selectRepositoryButton); defaultRepositoryButton.addSelectionListener(new SelectionAdapter() { @Override @@ -82,7 +114,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 +129,35 @@ public class ReportErrorPage extends WizardPage { public void widgetSelected(SelectionEvent event) { if (selectRepositoryButton.getSelection()) { defaultRepositoryButton.setSelection(false); + if (contributionCombo != null) { + contributionCombo.setEnabled(false); + } } - taskRepository = null; + selectedContribution = null; getContainer().updateButtons(); } }); - - taskRepository = mapper.getTaskRepository(); - } else { - taskRepository = null; } setControl(composite); Dialog.applyDialogFont(composite); } + private String getLabel(AttributeTaskMapper contribution) { + IProduct product = contribution.getProduct(); + if (product.getName() != null) { + return NLS.bind("{0} - {1}", product.getProvider().getName(), product.getName()); + } else { + return product.getProvider().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..b55713496 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, null); 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) { diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectSupportElementPage.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectSupportElementPage.java new file mode 100644 index 000000000..083609964 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectSupportElementPage.java @@ -0,0 +1,369 @@ +/******************************************************************************* + * 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.wizards; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.ToolBarManager; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.viewers.IOpenListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.OpenEvent; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.Viewer; +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.commons.ui.ControlListItem; +import org.eclipse.mylyn.internal.commons.ui.ControlListViewer; +import org.eclipse.mylyn.internal.commons.ui.NotificationPopupColors; +import org.eclipse.mylyn.internal.provisional.commons.ui.CommonFonts; +import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages; +import org.eclipse.mylyn.internal.provisional.commons.ui.GradientCanvas; +import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil; +import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProvider; +import org.eclipse.mylyn.internal.tasks.bugs.AbstractSupportElement; +import org.eclipse.mylyn.internal.tasks.bugs.SupportCategory; +import org.eclipse.mylyn.internal.tasks.bugs.SupportProduct; +import org.eclipse.mylyn.internal.tasks.bugs.SupportProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.ui.browser.IWorkbenchBrowserSupport; + +/** + * @author Steffen Pingel + */ +@SuppressWarnings("restriction") +public class SelectSupportElementPage extends WizardPage { + + public class SupportElementViewer extends ControlListViewer { + + public SupportElementViewer(Composite parent, int style) { + super(parent, style); + // ignore + } + + @Override + protected ControlListItem doCreateItem(Composite parent, Object element) { + if (element instanceof SupportCategory) { + return new CategoryItem(parent, SWT.NONE, element); + } + return new SupportElementItem(parent, SWT.NONE, element); + } + + } + + private class CategoryItem extends ControlListItem { + + private Label label; + + public CategoryItem(Composite parent, int style, Object element) { + super(parent, style, element); + } + + @Override + protected void createContent() { + FillLayout layout = new FillLayout(); + setLayout(layout); + + GradientCanvas canvas = new GradientCanvas(this, SWT.NONE); + NotificationPopupColors color = new NotificationPopupColors(getDisplay(), JFaceResources.getResources()); + canvas.setBackgroundGradient(new Color[] { color.getGradientBegin(), color.getGradientEnd() }, + new int[] { 100 }, true); + canvas.setLayout(new GridLayout(1, false)); + + label = new Label(canvas, SWT.NONE); + label.setFont(JFaceResources.getHeaderFont()); + label.setBackground(null); + + canvas.setSize(canvas.computeSize(SWT.DEFAULT, SWT.DEFAULT)); + + refresh(); + } + + @Override + protected void refresh() { + AbstractSupportElement data = (AbstractSupportElement) getData(); + label.setText(data.getName()); + } + + @Override + public void setForeground(Color color) { + // ignore + } + + @Override + public void setBackground(Color color) { + // ignore + } + + } + + private class SupportElementItem extends ControlListItem { + + private ToolBar toolBar; + + private Label titleLabel; + + private Label iconLabel; + + private Label descriptionLabel; + + private ToolBarManager toolBarManager; + + public SupportElementItem(Composite parent, int style, Object element) { + super(parent, style, element); + } + + @Override + protected void createContent() { + FormLayout layout = new FormLayout(); + layout.marginHeight = 3; + layout.marginWidth = 3; + setLayout(layout); + + iconLabel = new Label(this, SWT.NONE); + FormData fd = new FormData(); + fd.left = new FormAttachment(0); + iconLabel.setLayoutData(fd); + + titleLabel = new Label(this, SWT.NONE); + titleLabel.setFont(CommonFonts.BOLD); + fd = new FormData(); + fd.left = new FormAttachment(iconLabel, 5); + titleLabel.setLayoutData(fd); + + descriptionLabel = new Label(this, SWT.WRAP); + fd = new FormData(); + fd.top = new FormAttachment(titleLabel, 5); + fd.left = new FormAttachment(iconLabel, 5); + descriptionLabel.setLayoutData(fd); + + toolBarManager = new ToolBarManager(SWT.FLAT); + toolBar = toolBarManager.createControl(this); + fd = new FormData(); + fd.right = new FormAttachment(100); + toolBar.setLayoutData(fd); + + refresh(); + } + + @Override + public void dispose() { + super.dispose(); + toolBarManager.dispose(); + } + + @Override + public void setForeground(Color color) { + super.setForeground(color); + if (isSelected()) { + descriptionLabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW)); + } else { + descriptionLabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); + } + + } + + @Override + protected void refresh() { + AbstractSupportElement data = (AbstractSupportElement) getData(); + iconLabel.setImage(getImage(data)); + titleLabel.setText(data.getName()); + descriptionLabel.setText(data.getDescription()); + + toolBarManager.removeAll(); + final String url = data.getUrl(); + if (url != null) { + Action action = new Action() { + @Override + public void run() { + WorkbenchUtil.openUrl(url, IWorkbenchBrowserSupport.AS_EXTERNAL); + } + }; + action.setImageDescriptor(CommonImages.QUESTION); + toolBarManager.add(action); + } + toolBarManager.update(false); + } + + @Override + public void setHot(boolean hot) { + super.setHot(hot); + updateToolBar(); + } + + @Override + public void setSelected(boolean select) { + super.setSelected(select); + updateToolBar(); + } + + private void updateToolBar() { + if (toolBar != null) { + toolBar.setVisible(isHot() || isSelected()); + } + } + + } + + private static final int TABLE_HEIGHT = 200; + + private AbstractSupportElement selectedElement; + + private ImageRegistry imageRegistry; + + private final IStructuredContentProvider contentProvider; + + private Object input; + + public SelectSupportElementPage(String pageName, IStructuredContentProvider contentProvider) { + super(pageName); + this.contentProvider = contentProvider; + } + + public Image getImage(AbstractSupportElement data) { + if (imageRegistry == null) { + imageRegistry = new ImageRegistry(getShell().getDisplay()); + } + Image image = imageRegistry.get(data.getId()); + if (image == null && data.getIcon() != null) { + imageRegistry.put(data.getId(), data.getIcon()); + image = imageRegistry.get(data.getId()); + } + return image; + } + + public void setInput(Object input) { + this.input = input; + + if (input instanceof IProvider) { + setTitle("Support Provider"); + setMessage("Select a support provider from the list."); + } else { + setTitle("Supported Product"); + setMessage("Select a supported product from the list."); + } + } + + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(1, true); + container.setLayout(layout); + + ControlListViewer viewer = new SupportElementViewer(container, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL); + GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, TABLE_HEIGHT).applyTo(viewer.getControl()); + viewer.setContentProvider(contentProvider); + viewer.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection selection = (IStructuredSelection) event.getSelection(); + Object object = selection.getFirstElement(); + if (object instanceof AbstractSupportElement) { + selectedElement = (AbstractSupportElement) object; + } else { + selectedElement = null; + } + updatePageStatus(); + } + }); + viewer.addOpenListener(new IOpenListener() { + public void open(OpenEvent event) { + if (getWizard().performFinish()) { + ((WizardDialog) getContainer()).close(); + } + } + }); + viewer.setSorter(new ViewerSorter() { + @SuppressWarnings("unchecked") + @Override + public int compare(Viewer viewer, Object o1, Object o2) { + int cat1 = category(o1); + int cat2 = category(o2); + if (cat1 != cat2) { + return cat1 - cat2; + } + if (o1 instanceof AbstractSupportElement && o2 instanceof AbstractSupportElement) { + return getComparator().compare(((AbstractSupportElement) o1).getName(), + ((AbstractSupportElement) o2).getName()); + } + return super.compare(viewer, o1, o2); + } + + @Override + public int category(Object element) { + if (element instanceof SupportCategory) { + return ((SupportCategory) element).getWeight() * 2; + } else if (element instanceof SupportProvider) { + return ((SupportProvider) element).getCategory().getWeight() * 2 + 1; + } + return super.category(element); + } + }); + viewer.setInput(input); + + setPageComplete(false); + setControl(container); + Dialog.applyDialogFont(container); + } + + @Override + public void dispose() { + if (imageRegistry != null) { + imageRegistry.dispose(); + } + super.dispose(); + } + + public AbstractSupportElement getSelectedElement() { + return selectedElement; + } + + private void updatePageStatus() { + if (selectedElement instanceof SupportProvider) { + if (contentProvider.getElements(selectedElement).length > 0) { + setErrorMessage(null); + setPageComplete(true); + } else { + setErrorMessage("The selected provider does not specify supported products."); + setPageComplete(false); + } + } else if (selectedElement instanceof SupportProduct) { + setErrorMessage(null); + setPageComplete(true); + } + } + + @Override + public IWizardPage getNextPage() { + if (selectedElement instanceof SupportProvider) { + SelectSupportElementPage page = new SelectSupportElementPage(selectedElement.getId(), contentProvider); + page.setInput(selectedElement); + page.setWizard(getWizard()); + return page; + } + return null; + } +}
\ No newline at end of file |