diff options
author | spingel | 2009-08-11 17:53:10 +0000 |
---|---|---|
committer | spingel | 2009-08-11 17:53:10 +0000 |
commit | 9fc2bfc477f63be8acb5ddd38aefad976822bfb1 (patch) | |
tree | 815b72a0ee82f4b67958174142fd30f336d64894 | |
parent | b9751be85144ba599c8b47732cb451821c5236a3 (diff) | |
download | org.eclipse.mylyn.tasks-9fc2bfc477f63be8acb5ddd38aefad976822bfb1.tar.gz org.eclipse.mylyn.tasks-9fc2bfc477f63be8acb5ddd38aefad976822bfb1.tar.xz org.eclipse.mylyn.tasks-9fc2bfc477f63be8acb5ddd38aefad976822bfb1.zip |
NEW - bug 280961: supported products should be validated before being displayed in wizard
https://bugs.eclipse.org/bugs/show_bug.cgi?id=280961
3 files changed, 41 insertions, 6 deletions
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 df216b7d3..cb3565932 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 @@ -16,6 +16,7 @@ import java.util.Collection; import java.util.List; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.wizard.IWizardPage; @@ -23,6 +24,7 @@ import org.eclipse.jface.wizard.Wizard; import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProduct; import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProvider; import org.eclipse.mylyn.internal.tasks.bugs.AbstractSupportElement; +import org.eclipse.mylyn.internal.tasks.bugs.AttributeTaskMapper; import org.eclipse.mylyn.internal.tasks.bugs.SupportCategory; import org.eclipse.mylyn.internal.tasks.bugs.SupportProduct; import org.eclipse.mylyn.internal.tasks.bugs.SupportProvider; @@ -30,6 +32,7 @@ import org.eclipse.mylyn.internal.tasks.bugs.SupportProviderManager; import org.eclipse.mylyn.internal.tasks.bugs.SupportRequest; import org.eclipse.mylyn.internal.tasks.bugs.TaskErrorReporter; import org.eclipse.mylyn.internal.tasks.bugs.TasksBugsPlugin; +import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; import org.eclipse.mylyn.tasks.ui.TasksUiImages; /** @@ -45,16 +48,23 @@ public class ReportBugOrEnhancementWizard extends Wizard { public Object[] getElements(Object inputElement) { if (inputElement instanceof SupportProvider) { - List<SupportProduct> providerProducts = getProdcuts(inputElement); + List<SupportProduct> providerProducts = getProducts((SupportProvider) inputElement); return providerProducts.toArray(); } else if (input == inputElement) { List<AbstractSupportElement> elements = new ArrayList<AbstractSupportElement>(); Collection<SupportCategory> categories = providerManager.getCategories(); for (SupportCategory category : categories) { List<IProvider> providers = category.getProviders(); - if (!providers.isEmpty()) { + // filter valid providers + List<IProvider> validProviders = new ArrayList<IProvider>(); + for (IProvider provider : providers) { + if (isValid((SupportProvider) provider)) { + validProviders.add(provider); + } + } + if (!validProviders.isEmpty()) { elements.add(category); - for (IProvider provider : providers) { + for (IProvider provider : validProviders) { elements.add((AbstractSupportElement) provider); } } @@ -65,9 +75,18 @@ public class ReportBugOrEnhancementWizard extends Wizard { } } - private List<SupportProduct> getProdcuts(Object inputElement) { + private boolean isValid(SupportProvider provider) { + Collection<SupportProduct> products = providerManager.getProducts(); + for (SupportProduct product : products) { + if (provider.equals(product.getProvider()) && product.isInstalled()) { + return true; + } + } + return false; + } + + private List<SupportProduct> getProducts(SupportProvider provider) { 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()) { @@ -135,6 +154,12 @@ public class ReportBugOrEnhancementWizard extends Wizard { TaskErrorReporter reporter = TasksBugsPlugin.getTaskErrorReporter(); IStatus status = new ProductStatus((IProduct) product); SupportRequest request = reporter.preProcess(status, ((ProductStatus) status).getProduct()); + if (!((AttributeTaskMapper) request.getDefaultContribution()).isMappingComplete()) { + TasksUiInternal.displayStatus(Messages.ReportBugOrEnhancementWizard_Report_Bug_or_Enhancement, new Status( + IStatus.ERROR, TasksBugsPlugin.ID_PLUGIN, + "Creation of a support request failed. The information for the selected product is incomplete.")); + return false; + } return reporter.process(request.getDefaultContribution(), getContainer()); } diff --git a/org.eclipse.mylyn.tasks.tests/plugin.xml b/org.eclipse.mylyn.tasks.tests/plugin.xml index 039b0b490..ae81b01f1 100644 --- a/org.eclipse.mylyn.tasks.tests/plugin.xml +++ b/org.eclipse.mylyn.tasks.tests/plugin.xml @@ -69,6 +69,12 @@ url="https://bugs.eclipse.org/bugs"> </repository> </mapping> + <provider + categoryId="org.eclipse.mylyn.tasks.tests.category1" + description="Provider that has no products definded" + id="org.eclipse.mylyn.tasks.tests.provider2" + name="Invalid Test Provider"> + </provider> </extension> </plugin> diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java index f0d32dcb8..6970a15e3 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java @@ -711,7 +711,11 @@ public class TasksUiInternal { TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(taskRepository); TaskData taskData = new TaskData(mapper, taskRepository.getConnectorKind(), taskRepository.getRepositoryUrl(), ""); //$NON-NLS-1$ - taskDataHandler.initializeTaskData(taskRepository, taskData, initializationData, monitor); + boolean result = taskDataHandler.initializeTaskData(taskRepository, taskData, initializationData, monitor); + if (!result) { + throw new CoreException(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, + "Initialization of task failed. The provided data is insufficient.")); //$NON-NLS-1$ + } if (selectionData != null) { connector.getTaskMapping(taskData).merge(selectionData); } |