diff options
author | mkersten | 2007-06-07 18:46:12 +0000 |
---|---|---|
committer | mkersten | 2007-06-07 18:46:12 +0000 |
commit | 498ef850601aac16bde56c5f896ac9d00f780a1a (patch) | |
tree | 5d484f39078bbc1db8928fd36e2ae9d8af68f8e0 /org.eclipse.mylyn.bugzilla.ui | |
parent | 497c8061cb819fd12dbdccfdd3be4942a13770a7 (diff) | |
download | org.eclipse.mylyn.tasks-498ef850601aac16bde56c5f896ac9d00f780a1a.tar.gz org.eclipse.mylyn.tasks-498ef850601aac16bde56c5f896ac9d00f780a1a.tar.xz org.eclipse.mylyn.tasks-498ef850601aac16bde56c5f896ac9d00f780a1a.zip |
NEW - bug 187602: Provide extension point for specifying duplicate detectors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=187602
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui')
4 files changed, 121 insertions, 20 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/plugin.xml b/org.eclipse.mylyn.bugzilla.ui/plugin.xml index d74f0deca..9d637ff52 100644 --- a/org.eclipse.mylyn.bugzilla.ui/plugin.xml +++ b/org.eclipse.mylyn.bugzilla.ui/plugin.xml @@ -38,4 +38,15 @@ <newWizardShortcut id="org.eclipse.mylar.bugzilla.bugWizard"/> </perspectiveExtension> </extension> + + + + <extension + point="org.eclipse.mylar.tasks.ui.duplicateDetectors"> + <detector class="org.eclipse.mylar.internal.bugzilla.ui.search.StackTraceDuplicateDetector" + name="Stack Trace"> + </detector> + + </extension> + </plugin> diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/DummySearchHitProvider.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/DummySearchHitProvider.java new file mode 100644 index 000000000..19c813c74 --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/DummySearchHitProvider.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2006 University Of British Columbia 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: + * University Of British Columbia - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylar.internal.bugzilla.ui.editor; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.mylar.tasks.core.AbstractRepositoryTask; +import org.eclipse.mylar.tasks.core.ITaskFactory; +import org.eclipse.mylar.tasks.core.QueryHitCollector; +import org.eclipse.mylar.tasks.core.RepositoryTaskData; +import org.eclipse.mylar.tasks.core.TaskList; + +public class DummySearchHitProvider extends QueryHitCollector { + + public DummySearchHitProvider(TaskList tasklist) { + super(tasklist, new ITaskFactory() { + + public AbstractRepositoryTask createTask(RepositoryTaskData taskData, boolean synchData, + boolean forced, IProgressMonitor monitor) throws CoreException { + return null; + } + }); + // ignore + } + + +} diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java index 59ac5c2b8..2c9bd85b1 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java @@ -10,17 +10,14 @@ *******************************************************************************/ package org.eclipse.mylar.internal.bugzilla.ui.editor; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; +import java.util.List; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.fieldassist.ContentProposalAdapter; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.mylar.core.MylarStatusHandler; -import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryQuery; import org.eclipse.mylar.tasks.core.RepositoryTaskAttribute; -import org.eclipse.mylar.tasks.ui.TaskFactory; +import org.eclipse.mylar.tasks.ui.AbstractDuplicateDetector; import org.eclipse.mylar.tasks.ui.TasksUiPlugin; import org.eclipse.mylar.tasks.ui.editors.AbstractNewRepositoryTaskEditor; import org.eclipse.mylar.tasks.ui.search.SearchHitCollector; @@ -102,23 +99,21 @@ public class NewBugzillaTaskEditor extends AbstractNewRepositoryTaskEditor { } @Override - public SearchHitCollector getDuplicateSearchCollector(String searchString) { - String queryUrl = ""; - try { - queryUrl = repository.getUrl() + "/buglist.cgi?long_desc_type=allwordssubstr&long_desc=" - + URLEncoder.encode(searchString, repository.getCharacterEncoding()); - } catch (UnsupportedEncodingException e) { - MylarStatusHandler.log(e, "Error during duplicate detection"); - return null; - } - - queryUrl += "&product=" + taskData.getProduct(); + public SearchHitCollector getDuplicateSearchCollector(String name) { + String duplicateDetectorName = name.equals("default") ? "Stack Trace" : name; + List<AbstractDuplicateDetector> allDetectors = getDuplicateSearchCollectorsList(); - BugzillaRepositoryQuery bugzillaQuery = new BugzillaRepositoryQuery(repository.getUrl(), queryUrl, "search"); + for (AbstractDuplicateDetector detector : allDetectors) { + if (detector.getName().equals(duplicateDetectorName)) { + return detector.getSearchHitCollector(repository, taskData); + } + } + // didn't find it + return null; + } - SearchHitCollector collector = new SearchHitCollector(TasksUiPlugin.getTaskListManager().getTaskList(), - repository, bugzillaQuery, new TaskFactory(repository)); - return collector; + protected List<AbstractDuplicateDetector> getDuplicateSearchCollectorsList() { + return TasksUiPlugin.getDefault().getDuplicateSearchCollectorsList(); } @Override diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/StackTraceDuplicateDetector.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/StackTraceDuplicateDetector.java new file mode 100644 index 000000000..aa180d418 --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/StackTraceDuplicateDetector.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2006 Mylar 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.mylar.internal.bugzilla.ui.search; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.mylar.core.MylarStatusHandler; +import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryQuery; +import org.eclipse.mylar.tasks.core.RepositoryTaskData; +import org.eclipse.mylar.tasks.core.TaskRepository; +import org.eclipse.mylar.tasks.ui.AbstractDuplicateDetector; +import org.eclipse.mylar.tasks.ui.TaskFactory; +import org.eclipse.mylar.tasks.ui.TasksUiPlugin; +import org.eclipse.mylar.tasks.ui.editors.AbstractNewRepositoryTaskEditor; +import org.eclipse.mylar.tasks.ui.search.SearchHitCollector; + +/** + * @author Meghan Allen + */ +public class StackTraceDuplicateDetector extends AbstractDuplicateDetector { + + private static final String NO_STACK_MESSAGE = "Unable to locate a stack trace in the description text."; + + @Override + public SearchHitCollector getSearchHitCollector(TaskRepository repository, RepositoryTaskData taskData) { + String queryUrl = ""; + String searchString = AbstractNewRepositoryTaskEditor.getStackTraceFromDescription(taskData.getDescription()); + + if (searchString == null) { + MessageDialog.openWarning(null, "No Stack Trace Found", NO_STACK_MESSAGE); + return null; + } + + try { + queryUrl = repository.getUrl() + "/buglist.cgi?long_desc_type=allwordssubstr&long_desc=" + + URLEncoder.encode(searchString, repository.getCharacterEncoding()); + } catch (UnsupportedEncodingException e) { + MylarStatusHandler.log(e, "Error during duplicate detection"); + return null; + } + + queryUrl += "&product=" + taskData.getProduct(); + + BugzillaRepositoryQuery bugzillaQuery = new BugzillaRepositoryQuery(repository.getUrl(), queryUrl, "search"); + + SearchHitCollector collector = new SearchHitCollector(TasksUiPlugin.getTaskListManager().getTaskList(), + repository, bugzillaQuery, new TaskFactory(repository)); + return collector; + } + +} |