diff options
author | spingel | 2008-06-04 04:44:35 +0000 |
---|---|---|
committer | spingel | 2008-06-04 04:44:35 +0000 |
commit | 546813099c0f5af30bca1967effd556450e26845 (patch) | |
tree | f14824f5f160b1c8d10dc621f7315e6a7a0d9448 /org.eclipse.mylyn.tasks.bugs | |
parent | 1f7caab5eba527ad033a6d69a7ba006fda40fe36 (diff) | |
download | org.eclipse.mylyn.tasks-546813099c0f5af30bca1967effd556450e26845.tar.gz org.eclipse.mylyn.tasks-546813099c0f5af30bca1967effd556450e26845.tar.xz org.eclipse.mylyn.tasks-546813099c0f5af30bca1967effd556450e26845.zip |
NEW - bug 212209: provide a flexible bug reporting facility
https://bugs.eclipse.org/bugs/show_bug.cgi?id=212209
Diffstat (limited to 'org.eclipse.mylyn.tasks.bugs')
16 files changed, 447 insertions, 265 deletions
diff --git a/org.eclipse.mylyn.tasks.bugs/plugin.xml b/org.eclipse.mylyn.tasks.bugs/plugin.xml index e753e51c1..5e10bced8 100644 --- a/org.eclipse.mylyn.tasks.bugs/plugin.xml +++ b/org.eclipse.mylyn.tasks.bugs/plugin.xml @@ -23,7 +23,7 @@ <extension point="org.eclipse.mylyn.commons.core.errorReporters"> <errorReporter - class="org.eclipse.mylyn.internal.tasks.bugs.TasksBugsPlugin$Reporter" + class="org.eclipse.mylyn.internal.tasks.bugs.TasksBugsPlugin$DialogReporter" id="org.eclipse.mylyn.tasks.bugs.errorReporter" label="Report Error as Bug"> </errorReporter> 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 cc71a23a7..5f40bd7fe 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,14 +11,10 @@ package org.eclipse.mylyn.internal.tasks.bugs; import java.util.Date; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.mylyn.internal.tasks.core.deprecated.DefaultTaskSchema; -import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskData; -import org.eclipse.mylyn.internal.tasks.core.deprecated.TaskSelection; import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; import org.eclipse.mylyn.tasks.core.ITaskMapping; import org.eclipse.mylyn.tasks.core.TaskMapping; @@ -30,7 +26,6 @@ import org.eclipse.mylyn.tasks.ui.TasksUi; /** * @author Steffen Pingel */ -@SuppressWarnings("deprecation") public class AttributeTaskMapper { private final Map<String, String> attributes; @@ -56,23 +51,6 @@ public class AttributeTaskMapper { return taskRepository; } - public TaskSelection createTaskSelection() { - TaskSelection selection = new TaskSelection("", ""); - applyTo(selection.getLegacyTaskData()); - return selection; - } - - public void applyTo(RepositoryTaskData taskData) { - DefaultTaskSchema schema = new DefaultTaskSchema(taskData); - for (Entry<String, String> entry : attributes.entrySet()) { - if (IRepositoryConstants.PRODUCT.equals(entry.getKey())) { - schema.setProduct(entry.getValue()); - } else if (IRepositoryConstants.COMPONENT.equals(entry.getKey())) { - schema.setComponent(entry.getValue()); - } - } - } - @SuppressWarnings("restriction") public TaskData createTaskData(IProgressMonitor monitor) throws CoreException { ITaskMapping taskMapping = getTaskMapping(); 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 514618ec0..33e07f61c 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 @@ -10,11 +10,13 @@ package org.eclipse.mylyn.internal.tasks.bugs; import java.io.PrintWriter; import java.io.StringWriter; +import java.util.Date; import java.util.HashMap; import java.util.Map; import org.eclipse.core.runtime.IBundleGroup; import org.eclipse.core.runtime.IStatus; +import org.eclipse.mylyn.internal.tasks.bugs.wizards.ErrorLogStatus; import org.eclipse.mylyn.internal.tasks.bugs.wizards.FeatureStatus; import org.eclipse.mylyn.tasks.bugs.AbstractTaskContributor; import org.eclipse.mylyn.tasks.ui.editors.TaskEditor; @@ -25,39 +27,78 @@ import org.osgi.framework.Bundle; */ public class DefaultTaskContributor extends AbstractTaskContributor { + public void appendErrorDetails(StringBuilder sb, IStatus status, Date date) { + sb.append("\n\n-- Error Details --"); + if (date != null) { + sb.append("\nDate: "); + sb.append(date); + } + sb.append("\nMessage: "); + sb.append(status.getMessage()); + sb.append("\nSeverity: "); + sb.append(getSeverityText(status.getSeverity())); + sb.append("\nPlugin: "); + sb.append(status.getPlugin()); + } + @Override public Map<String, String> getAttributes(IStatus status) { Map<String, String> attributes = new HashMap<String, String>(); + attributes.put(IRepositoryConstants.DESCRIPTION, getDescription(status)); + return attributes; + } + + public String getDescription(IStatus status) { if (status instanceof FeatureStatus) { StringBuilder sb = new StringBuilder(); sb.append("\n\n\n"); - sb.append("-- Installed Plug-ins --\n"); - IBundleGroup bundleGroup = ((FeatureStatus) status).getBundleGroup(); + sb.append("-- Installed Features and Plug-ins --\n"); + IBundleGroup[] bundleGroups = ((FeatureStatus) status).getBundleGroup(); + for (IBundleGroup bundleGroup : bundleGroups) { + sb.append(bundleGroup.getIdentifier()); + sb.append(" "); + sb.append(bundleGroup.getVersion()); + sb.append("\n"); - sb.append(bundleGroup.getIdentifier()); - sb.append(" "); - sb.append(bundleGroup.getVersion()); - - Bundle[] bundles = bundleGroup.getBundles(); - if (bundles != null) { - for (Bundle bundle : bundles) { - sb.append(bundle.getBundleId()); + Bundle[] bundles = bundleGroup.getBundles(); + if (bundles != null) { + for (Bundle bundle : bundles) { + sb.append(" "); + sb.append(bundle.getSymbolicName()); + String version = (String) bundle.getHeaders().get("Bundle-Version"); + if (version != null) { + sb.append(" "); + sb.append(version); + } + sb.append("\n"); + } } } - attributes.put(IRepositoryConstants.DESCRIPTION, sb.toString()); - + return sb.toString(); + } else if (status instanceof ErrorLogStatus) { + ErrorLogStatus errorLogStatus = (ErrorLogStatus) status; + StringBuilder sb = new StringBuilder(); + appendErrorDetails(sb, errorLogStatus, errorLogStatus.getDate()); + if (errorLogStatus.getLogSessionData() != null) { + sb.append("\nSession Data:\n"); + sb.append(errorLogStatus.getLogSessionData()); + } + if (errorLogStatus.getStack() != null) { + sb.append("\nException Stack Trace:\n"); + sb.append(errorLogStatus.getStack()); + } + return sb.toString(); } else { StringBuilder sb = new StringBuilder(); - sb.append("\n\n-- Error Details --\n"); + appendErrorDetails(sb, status, new Date()); if (status.getException() != null) { - sb.append("\nStack Trace:\n"); + sb.append("\nException Stack Trace:\n"); StringWriter writer = new StringWriter(); status.getException().printStackTrace(new PrintWriter(writer)); sb.append(writer.getBuffer()); } - attributes.put(IRepositoryConstants.DESCRIPTION, sb.toString()); + return sb.toString(); } - return attributes; } @Override @@ -65,4 +106,18 @@ public class DefaultTaskContributor extends AbstractTaskContributor { return TaskEditor.ID_EDITOR; } -} + private String getSeverityText(int severity) { + switch (severity) { + case IStatus.ERROR: + return "Error"; + case IStatus.WARNING: + return "Warning"; + case IStatus.INFO: + return "Info"; + case IStatus.OK: + return "OK"; + } + return "?"; //$NON-NLS-1$ + } + +}
\ No newline at end of file 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 691b92ce8..58c9e00e1 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 @@ -13,17 +13,27 @@ package org.eclipse.mylyn.internal.tasks.bugs; */ public class IRepositoryConstants { - public static final String REPOSITORY_URL = "repositoryUrl"; + @Deprecated + public static final String BRANDING = "branding"; + + public static final String COMPONENT = "component"; public static final String CONNECTOR_KIND = "repositoryKind"; - public static final String COMPONENT = "component"; + public static final String DESCRIPTION = "description"; public static final String PRODUCT = "product"; - @Deprecated - public static final String BRANDING = "branding"; + public static final String PRODUCT_CATEGORY = "productCategory"; - public static final String DESCRIPTION = "description"; + public static final String PRODUCT_DESCRIPTION = "productDescription"; + + public static final String PRODUCT_NAME = "productName"; + + public static final String PRODUCT_TITLE = "productTitle"; + + public static final String REPOSITORY_KIND = "repositoryKind"; + + public static final String REPOSITORY_URL = "repositoryUrl"; } 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 47d06ef0f..b51b7e618 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 @@ -84,90 +84,8 @@ public class TaskErrorReporter { ReportErrorWizard wizard = new ReportErrorWizard(TaskErrorReporter.this, status); WizardDialog dialog = new WizardDialog(TasksUiInternal.getShell(), wizard); dialog.setBlockOnOpen(false); + dialog.setPageSize(500, 200); dialog.open(); } - // legacy support -// TaskRepository taskRepository = mapper.getTaskRepository(); -// if (taskRepository != null) { -// AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector( -// taskRepository.getConnectorKind()); -// if (connector instanceof AbstractLegacyRepositoryConnector) { -// try { -// if (openLegacyTaskEditor(status, taskRepository, mapper)) { -// return; -// } -// } catch (OperationCanceledException e) { -// return; -// } -// } -// } -// -// @Deprecated -// private boolean openLegacyTaskEditor(IStatus status, TaskRepository taskRepository, AttributeTaskMapper mapper) { -// RepositoryTaskData taskData = createLegacyTaskData(taskRepository, mapper); -// if (taskData != null) { -// taskData.setSummary(status.getMessage()); -// -// TaskContributorManager manager = new TaskContributorManager(); -// manager.updateAttributes(taskData, status); -// -// String editorId = manager.getEditorId(status); -// -// NewTaskEditorInput editorInput = new NewTaskEditorInput(taskRepository, taskData); -// IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); -// TasksUiUtil.openEditor(editorInput, editorId, page); -// return true; -// } -// return false; -// } -// -// @Deprecated -// private RepositoryTaskData createLegacyTaskData(final TaskRepository taskRepository, AttributeTaskMapper mapper) { -// AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector( -// taskRepository.getConnectorKind()); -// if (!(connector instanceof AbstractLegacyRepositoryConnector)) { -// return null; -// } -// final AbstractTaskDataHandler taskDataHandler = ((AbstractLegacyRepositoryConnector) connector).getLegacyTaskDataHandler(); -// if (taskDataHandler == null) { -// return null; -// } -// -// AbstractAttributeFactory attributeFactory = taskDataHandler.getAttributeFactory( -// taskRepository.getRepositoryUrl(), taskRepository.getConnectorKind(), AbstractTask.DEFAULT_TASK_KIND); -// -// final RepositoryTaskData taskData = new RepositoryTaskData(attributeFactory, taskRepository.getConnectorKind(), -// taskRepository.getRepositoryUrl(), TasksUiPlugin.getDefault().getNextNewRepositoryTaskId()); -// taskData.setNew(true); -// -// mapper.applyTo(taskData); -// -// try { -// IRunnableWithProgress runnable = new IRunnableWithProgress() { -// public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { -// try { -// if (!taskDataHandler.initializeTaskData(taskRepository, taskData, monitor)) { -// throw new InvocationTargetException(new Exception()); -// } -// } catch (CoreException e) { -// throw new InvocationTargetException(e); -// } catch (OperationCanceledException e) { -// throw new InterruptedException(); -// } -// } -// }; -// -// PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runnable); -// } catch (InvocationTargetException e) { -// return null; -// } catch (InterruptedException e) { -// throw new OperationCanceledException(); -// } -// -// taskDataHandler.cloneTaskData(mapper.createTaskSelection().getLegacyTaskData(), taskData); -// -// return taskData; -// } - } diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TasksBugsPlugin.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TasksBugsPlugin.java index 2ae9d6014..5afe0d594 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TasksBugsPlugin.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/TasksBugsPlugin.java @@ -9,8 +9,11 @@ package org.eclipse.mylyn.internal.tasks.bugs; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.mylyn.commons.core.AbstractErrorReporter; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; @@ -21,7 +24,7 @@ import org.osgi.framework.BundleContext; */ public class TasksBugsPlugin extends AbstractUIPlugin { - public static class Reporter extends AbstractErrorReporter { + public static class BugReporter extends AbstractErrorReporter { @Override public int getPriority(IStatus status) { @@ -44,6 +47,45 @@ public class TasksBugsPlugin extends AbstractUIPlugin { } } + public static class DialogReporter extends AbstractErrorReporter { + + private static final String ERROR_MESSAGE = "Please report the following error at:\n" + + "http://bugs.eclipse.org/bugs/enter_bug.cgi?product=Mylyn\n\n" + + "Or via the popup menu in the Error Log view (see Window -> Show View)"; + + private boolean errorDialogOpen; + + @Override + public int getPriority(IStatus status) { + return AbstractErrorReporter.PRIORITY_DEFAULT; + } + + @Override + public void handle(final IStatus status) { + if (Platform.isRunning()) { + final IWorkbench workbench = PlatformUI.getWorkbench(); + if (workbench != null) { + Display display = workbench.getDisplay(); + if (display != null && !display.isDisposed()) { + display.asyncExec(new Runnable() { + public void run() { + try { + if (!errorDialogOpen) { + errorDialogOpen = true; + Shell shell = Display.getDefault().getActiveShell(); + ErrorDialog.openError(shell, "Mylyn Error", ERROR_MESSAGE, status); + } + } finally { + errorDialogOpen = false; + } + } + }); + } + } + } + } + } + public static final String ID_PLUGIN = "org.eclipse.mylyn.tasks.bugs"; private static TasksBugsPlugin INSTANCE; diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromErrorAction.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromErrorAction.java index 0446a18d5..79a396223 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromErrorAction.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/actions/NewTaskFromErrorAction.java @@ -11,16 +11,13 @@ package org.eclipse.mylyn.internal.tasks.bugs.actions; -import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.mylyn.internal.tasks.bugs.TasksBugsPlugin; -import org.eclipse.swt.widgets.Shell; +import org.eclipse.mylyn.internal.tasks.bugs.wizards.ErrorLogStatus; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.internal.views.log.LogEntry; /** @@ -71,18 +68,14 @@ public class NewTaskFromErrorAction implements IObjectActionDelegate { } private void createTask(LogEntry entry) { - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - boolean includeChildren = false; - - if (entry.hasChildren() - && MessageDialog.openQuestion(shell, "Report Bug", "Include children of this entry in the report?")) { - includeChildren = true; - } - StringBuilder sb = new StringBuilder(); - buildDescriptionFromLogEntry(entry, sb, includeChildren); + buildDescriptionFromLogEntry(entry, sb, true); - Status status = new Status(entry.getSeverity(), entry.getPluginId(), entry.getMessage()); + ErrorLogStatus status = new ErrorLogStatus(entry.getSeverity(), entry.getPluginId(), entry.getCode(), + entry.getMessage()); + status.setDate(entry.getDate()); + status.setStack(entry.getStack()); + status.setLogSessionData(entry.getSession().getSessionData()); TasksBugsPlugin.getTaskErrorReporter().handle(status); } diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/BundleGroupContainer.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/BundleGroupContainer.java new file mode 100644 index 000000000..720b35b95 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/BundleGroupContainer.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Mylyn project committers and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.mylyn.internal.tasks.bugs.wizards; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.IBundleGroup; + +/** + * A container for features that map to the same name. + * + * @author Steffen Pingel + */ +public class BundleGroupContainer { + + private final List<IBundleGroup> groups; + + private final String name; + + public BundleGroupContainer(String name) { + this.name = name; + this.groups = new ArrayList<IBundleGroup>(); + } + + public void addBundleGroup(IBundleGroup bundleGroup) { + groups.add(bundleGroup); + } + + public List<IBundleGroup> getGroups() { + return groups; + } + + public String getName() { + return name; + } + +}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ErrorLogStatus.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ErrorLogStatus.java new file mode 100644 index 000000000..d27738653 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/ErrorLogStatus.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Mylyn project committers and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.mylyn.internal.tasks.bugs.wizards; + +import java.util.Date; + +import org.eclipse.core.runtime.MultiStatus; + +/** + * @author Steffen Pingel + */ +public class ErrorLogStatus extends MultiStatus { + + private String logSessionData; + + private String stack; + + private Date date; + + public ErrorLogStatus(int severity, String pluginId, int code, String message) { + super(pluginId, code, message, null); + + setSeverity(severity); + } + + public String getLogSessionData() { + return logSessionData; + } + + public void setLogSessionData(String logSessionData) { + this.logSessionData = logSessionData; + } + + public String getStack() { + return stack; + } + + public void setStack(String stack) { + this.stack = stack; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + +} diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/FeatureGroup.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/FeatureGroup.java new file mode 100644 index 000000000..1507ffe03 --- /dev/null +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/FeatureGroup.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Mylyn project committers and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.mylyn.internal.tasks.bugs.wizards; + +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.Assert; +import org.eclipse.core.runtime.IBundleGroup; + +/** + * @author Steffen Pingel + */ +public class FeatureGroup { + + private final Map<String, BundleGroupContainer> containerByName; + + private final List<IBundleGroup> bundleGroups; + + private final String name; + + private final String description; + + private final String title; + + private final String category; + + public FeatureGroup(String name, String description, String title, String category) { + Assert.isNotNull(name); + Assert.isNotNull(category); + this.name = name; + this.description = description; + this.title = title; + this.category = category; + this.containerByName = new HashMap<String, BundleGroupContainer>(); + this.bundleGroups = new ArrayList<IBundleGroup>(); + } + + public void addBundleGroup(IBundleGroup bundleGroup, String featureName) { + BundleGroupContainer container = containerByName.get(featureName); + if (container == null) { + container = new BundleGroupContainer(featureName); + container.addBundleGroup(bundleGroup); + containerByName.put(featureName, container); + } else { + container.addBundleGroup(bundleGroup); + } + bundleGroups.add(bundleGroup); + } + + public Collection<BundleGroupContainer> getContainers() { + return containerByName.values(); + } + + public List<IBundleGroup> getBundleGroups() { + return bundleGroups; + } + + public String getCategory() { + return category; + } + + public String getDescription() { + return description; + } + + public String getName() { + return name; + } + + public String getTitle() { + return title; + } + + public boolean requiresSelection() { + return containerByName.size() > 1; + } + +} 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/FeatureStatus.java index 5637669ab..1c2b30eac 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/FeatureStatus.java @@ -17,15 +17,15 @@ import org.eclipse.core.runtime.Status; */ public class FeatureStatus extends Status { - private final IBundleGroup bundleGroup; + private final IBundleGroup[] bundleGroups; - public FeatureStatus(IBundleGroup bundleGroup) { - super(IStatus.INFO, bundleGroup.getIdentifier(), ""); - this.bundleGroup = bundleGroup; + public FeatureStatus(String id, IBundleGroup[] bundleGroups) { + super(IStatus.INFO, id, ""); + this.bundleGroups = bundleGroups; } - public IBundleGroup getBundleGroup() { - return bundleGroup; + public IBundleGroup[] getBundleGroup() { + return bundleGroups; } - + } 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 7b7c4e3c0..65e985813 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 @@ -44,33 +44,48 @@ public class ReportBugOrEnhancementWizard extends Wizard { return getSelectedBundleGroup() != null; } - public IBundleGroup getSelectedBundleGroup() { + public IBundleGroup[] getSelectedBundleGroup() { IWizardPage page = getContainer().getCurrentPage(); if (page instanceof SelectProductPage) { - if (page.isPageComplete() && !((SelectProductPage)page).canFlipToNextPage()) { - return ((SelectProductPage)page).getSelectedBundleGroup(); + if (page.isPageComplete() && !((SelectProductPage) page).canFlipToNextPage()) { + return ((SelectProductPage) page).getSelectedBundleGroups(); } } else if (page instanceof SelectFeaturePage) { if (page.isPageComplete()) { - return ((SelectFeaturePage)page).getSelectedBundleGroup(); - } + return ((SelectFeaturePage) page).getSelectedBundleGroups(); + } } return null; } - + @Override public boolean performFinish() { - final IBundleGroup bundle = getSelectedBundleGroup(); - Assert.isNotNull(bundle); - + final IBundleGroup[] bundles = getSelectedBundleGroup(); + Assert.isNotNull(bundles); + // delay run this until after the dialog has been closed getShell().getDisplay().asyncExec(new Runnable() { public void run() { - TasksBugsPlugin.getTaskErrorReporter().handle(new FeatureStatus(bundle)); - } + 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)); + } }); - + 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 370f1f95d..e927e3474 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 @@ -19,8 +19,8 @@ import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; /** * @author Steffen Pingel @@ -37,27 +37,25 @@ public class ReportErrorPage extends WizardPage { super("reportError"); this.mapper = mapper; this.status = status; - setTitle("Unexpected Error"); - setMessage("An unexcpeted error has occured"); + setTitle("Report as Bug"); + setMessage("An unexpected error has occured in plug-in " + status.getPlugin() + ""); } public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, true)); - Group errorGroup = new Group(composite, SWT.NONE); - GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(errorGroup); - errorGroup.setText("Error"); - errorGroup.setLayout(new GridLayout(1, true)); +// Group errorGroup = new Group(composite, SWT.NONE); +// GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(errorGroup); +// errorGroup.setText("Details"); +// errorGroup.setLayout(new GridLayout(1, true)); - Label label = new Label(errorGroup, SWT.NONE); - label.setText(status.getMessage()); + Label label = new Label(composite, SWT.NONE); + label.setText("Details:"); - label = new Label(composite, SWT.NONE); - label.setText("Plug-in: " + status.getPlugin()); - -// Link link = new Link(composite, SWT.NONE); -// link.setText("<a href=\"errorlog\">Show in error log</a>"); + 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); // space new Label(composite, SWT.NONE); 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 83925fd49..363af640d 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 @@ -34,7 +34,7 @@ public class ReportErrorWizard extends Wizard { this.taskErrorReporter = taskErrorReporter; this.status = status; this.mapper = taskErrorReporter.preProcess(status); - setWindowTitle("Report Error"); + setWindowTitle("Report as Bug"); } @SuppressWarnings("restriction") diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectFeaturePage.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectFeaturePage.java index 16d81588a..d985a9bc4 100644 --- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectFeaturePage.java +++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectFeaturePage.java @@ -12,7 +12,6 @@ import java.net.MalformedURLException; import java.net.URL; import org.eclipse.core.runtime.IBundleGroup; -import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; @@ -28,7 +27,7 @@ import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.mylyn.tasks.ui.TasksUi; +import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridLayout; @@ -40,7 +39,7 @@ import org.eclipse.ui.branding.IBundleGroupConstants; */ public class SelectFeaturePage extends WizardPage { - private static final int TABLE_HEIGHT = IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH; + private static final int TABLE_HEIGHT = 200; private IBundleGroup selectedBundleGroup; @@ -74,7 +73,11 @@ public class SelectFeaturePage extends WizardPage { } TableViewer viewer = new TableViewer(container, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, TABLE_HEIGHT).applyTo(viewer.getControl()); + GridDataFactory.fillDefaults() + .align(SWT.FILL, SWT.FILL) + .grab(true, true) + .hint(SWT.DEFAULT, TABLE_HEIGHT) + .applyTo(viewer.getControl()); viewer.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { @@ -98,7 +101,7 @@ public class SelectFeaturePage extends WizardPage { } return null; } - + @Override public String getText(Object element) { if (element instanceof IBundleGroup) { @@ -109,7 +112,7 @@ public class SelectFeaturePage extends WizardPage { } }); - viewer.setInput(TasksUi.getRepositoryManager().getRepositoryConnectors()); + viewer.setInput(TasksUiPlugin.getRepositoryManager().getRepositoryConnectors()); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { @@ -150,8 +153,8 @@ public class SelectFeaturePage extends WizardPage { super.dispose(); } - public IBundleGroup getSelectedBundleGroup() { - return selectedBundleGroup; + public IBundleGroup[] getSelectedBundleGroups() { + return new IBundleGroup[] { selectedBundleGroup }; } }
\ No newline at end of file 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 4629721b9..8428f1a1e 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 @@ -10,15 +10,12 @@ package org.eclipse.mylyn.internal.tasks.bugs.wizards; import java.net.MalformedURLException; import java.net.URL; -import java.util.ArrayList; 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.Platform; -import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; @@ -38,7 +35,7 @@ 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.tasks.ui.TasksUi; +import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridLayout; @@ -50,58 +47,15 @@ import org.eclipse.ui.branding.IBundleGroupConstants; */ public class SelectProductPage extends WizardPage { - private static final int TABLE_HEIGHT = IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH; + private static final int TABLE_HEIGHT = 200; - /** - * A container for bundles that map to the same name. - */ - private class BundleGroupContainer { - - private final IBundleGroup displayGroup; - - private final List<IBundleGroup> groups; - - private final String name; - - public BundleGroupContainer(String name, IBundleGroup displayGroup) { - this.name = name; - this.displayGroup = displayGroup; - this.groups = new ArrayList<IBundleGroup>(); - this.groups.add(displayGroup); - } - - public IBundleGroup getDisplayGroup() { - return displayGroup; - } - - public void addBundleGroup(IBundleGroup bundleGroup) { - for (IBundleGroup group : groups) { - if (group.getName().equals(bundleGroup.getName())) { - return; - } - } - groups.add(bundleGroup); - } - - public List<IBundleGroup> getGroups() { - return groups; - } - - private String getName() { - return name; - } - - public boolean requiresSelection() { - return groups.size() > 1; - } - - } + private static final String DEFAULT_CATEGORY = "Other"; private ImageRegistry imageRegistry; private final PluginRepositoryMappingManager manager; - private BundleGroupContainer selectedBundleGroupContainer; + private FeatureGroup selectedFeatureGroup; public SelectProductPage(String pageName, PluginRepositoryMappingManager manager) { super(pageName); @@ -111,7 +65,7 @@ public class SelectProductPage extends WizardPage { @Override public boolean canFlipToNextPage() { - return selectedBundleGroupContainer != null && selectedBundleGroupContainer.requiresSelection(); + return selectedFeatureGroup != null && selectedFeatureGroup.requiresSelection(); } public void createControl(Composite parent) { @@ -121,10 +75,14 @@ public class SelectProductPage extends WizardPage { imageRegistry = new ImageRegistry(getShell().getDisplay()); - final Map<String, BundleGroupContainer> containerByName = getProducts(); + final Map<String, FeatureGroup> containerByName = getProducts(); TableViewer viewer = new TableViewer(composite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, TABLE_HEIGHT).applyTo(viewer.getControl()); + GridDataFactory.fillDefaults() + .align(SWT.FILL, SWT.FILL) + .grab(true, true) + .hint(SWT.DEFAULT, TABLE_HEIGHT) + .applyTo(viewer.getControl()); viewer.setContentProvider(new IStructuredContentProvider() { public void dispose() { @@ -142,8 +100,8 @@ public class SelectProductPage extends WizardPage { @Override public Image getImage(Object element) { - if (element instanceof BundleGroupContainer) { - BundleGroupContainer product = (BundleGroupContainer) element; + if (element instanceof FeatureGroup) { + FeatureGroup product = (FeatureGroup) element; return imageRegistry.get(product.getName()); } return null; @@ -151,25 +109,28 @@ public class SelectProductPage extends WizardPage { @Override public String getText(Object element) { - if (element instanceof BundleGroupContainer) { - BundleGroupContainer product = (BundleGroupContainer) element; + if (element instanceof FeatureGroup) { + FeatureGroup product = (FeatureGroup) element; + if (product.getTitle() != null) { + return product.getName() + "\n " + product.getTitle(); + } return product.getName(); } return ""; } }); - viewer.setInput(TasksUi.getRepositoryManager().getRepositoryConnectors()); + viewer.setInput(TasksUiPlugin.getRepositoryManager().getRepositoryConnectors()); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); - if (selection.getFirstElement() instanceof BundleGroupContainer) { - selectedBundleGroupContainer = (BundleGroupContainer) selection.getFirstElement(); - if (selectedBundleGroupContainer.requiresSelection()) { + if (selection.getFirstElement() instanceof FeatureGroup) { + selectedFeatureGroup = (FeatureGroup) selection.getFirstElement(); + if (selectedFeatureGroup.requiresSelection()) { setMessage(null); } else { - setMessage(selectedBundleGroupContainer.getDisplayGroup().getDescription()); + setMessage(selectedFeatureGroup.getDescription()); } setPageComplete(true); } else { @@ -195,7 +156,18 @@ public class SelectProductPage extends WizardPage { viewer.getTable().showSelection(); viewer.getTable().setFocus(); - viewer.setSorter(new ViewerSorter()); + viewer.setSorter(new ViewerSorter() { + @Override + public int compare(Viewer viewer, Object o1, Object o2) { + FeatureGroup g1 = (FeatureGroup) o1; + FeatureGroup g2 = (FeatureGroup) o2; + int i = g1.getCategory().compareTo(g2.getCategory()); + if (i != 0) { + return i; + } + return g1.getName().compareTo(g2.getName()); + } + }); setControl(composite); } @@ -218,8 +190,8 @@ public class SelectProductPage extends WizardPage { return null; } - private Map<String, BundleGroupContainer> getProducts() { - final Map<String, BundleGroupContainer> containerByName = new HashMap<String, BundleGroupContainer>(); + private Map<String, FeatureGroup> getProducts() { + final Map<String, FeatureGroup> containerByName = new HashMap<String, FeatureGroup>(); IBundleGroupProvider[] providers = Platform.getBundleGroupProviders(); if (providers != null) { for (IBundleGroupProvider provider : providers) { @@ -231,7 +203,7 @@ public class SelectProductPage extends WizardPage { return containerByName; } - private void addProduct(Map<String, BundleGroupContainer> containerByName, IBundleGroup bundleGroup) { + private void addProduct(Map<String, FeatureGroup> featureGroupByName, IBundleGroup bundleGroup) { Map<String, String> attributes = manager.getAllAttributes(bundleGroup.getIdentifier()); AttributeTaskMapper mapper = new AttributeTaskMapper(attributes); @@ -244,11 +216,28 @@ public class SelectProductPage extends WizardPage { return; } - String productName = attributes.get(IRepositoryConstants.BRANDING); + String productDescription = attributes.get(IRepositoryConstants.PRODUCT_DESCRIPTION); + if (productDescription == null) { + productDescription = bundleGroup.getDescription(); + } + + String productName = attributes.get(IRepositoryConstants.PRODUCT_NAME); if (productName == null) { productName = bundleGroup.getName(); } + String productTitle = attributes.get(IRepositoryConstants.PRODUCT_TITLE); + + String productCategory = attributes.get(IRepositoryConstants.PRODUCT_CATEGORY); + if (productCategory == null) { + productCategory = DEFAULT_CATEGORY; + } + + String branding = attributes.get(IRepositoryConstants.BRANDING); + if (branding == null) { + branding = bundleGroup.getName(); + } + try { ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(new URL(imageUrl)); imageRegistry.put(productName, imageDescriptor); @@ -257,25 +246,19 @@ public class SelectProductPage extends WizardPage { return; } - BundleGroupContainer container = containerByName.get(productName); + FeatureGroup container = featureGroupByName.get(productName); if (container == null) { - container = new BundleGroupContainer(productName, bundleGroup); - containerByName.put(productName, container); + container = new FeatureGroup(productName, productDescription, productTitle, productCategory); + container.addBundleGroup(bundleGroup, branding); + featureGroupByName.put(productName, container); } else { - container.addBundleGroup(bundleGroup); - } - } - - public IBundleGroup getSelectedBundleGroup() { - if (selectedBundleGroupContainer != null) { - return selectedBundleGroupContainer.getGroups().get(0); + container.addBundleGroup(bundleGroup, branding); } - return null; } public IBundleGroup[] getSelectedBundleGroups() { - if (selectedBundleGroupContainer != null) { - return selectedBundleGroupContainer.getGroups().toArray(new IBundleGroup[0]); + if (selectedFeatureGroup != null) { + return selectedFeatureGroup.getBundleGroups().toArray(new IBundleGroup[0]); } return null; } |