Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2007-06-18 05:02:53 +0000
committermkersten2007-06-18 05:02:53 +0000
commitc445ce1c78b940a0586a3ded6b7cc894f2ab64fe (patch)
treef3f0b16dea07d51514a71e04b633846a986831e1
parentd4c4bd1648accbd5c5ea5a15ca6c8b609ca9a8cd (diff)
downloadorg.eclipse.mylyn.tasks-c445ce1c78b940a0586a3ded6b7cc894f2ab64fe.tar.gz
org.eclipse.mylyn.tasks-c445ce1c78b940a0586a3ded6b7cc894f2ab64fe.tar.xz
org.eclipse.mylyn.tasks-c445ce1c78b940a0586a3ded6b7cc894f2ab64fe.zip
RESOLVED - bug 156061: Search for duplicates should be available in existing task editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=156061
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java29
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java7
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractNewRepositoryTaskEditor.java74
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java104
4 files changed, 138 insertions, 76 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java
index b53898606..46ee0499e 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java
@@ -33,12 +33,14 @@ import org.eclipse.mylyn.tasks.core.AbstractTask;
import org.eclipse.mylyn.tasks.core.RepositoryOperation;
import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute;
import org.eclipse.mylyn.tasks.core.TaskComment;
+import org.eclipse.mylyn.tasks.ui.AbstractDuplicateDetector;
import org.eclipse.mylyn.tasks.ui.DatePicker;
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditor;
import org.eclipse.mylyn.tasks.ui.editors.RepositoryTaskSelection;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
+import org.eclipse.mylyn.tasks.ui.search.SearchHitCollector;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -357,7 +359,7 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor {
try {
operation = BUGZILLA_OPERATION.valueOf(repositoryOperation.getKnobName());
} catch (RuntimeException e) {
- StatusManager.log(e, "Unrecognized operatoin: " + repositoryOperation.getKnobName());
+ StatusManager.log(e, "Unrecognized operation: " + repositoryOperation.getKnobName());
operation = null;
}
@@ -722,4 +724,29 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor {
return null;
}
}
+
+ @Override
+ /**
+ * This method is duplicated in NewBugzillaTaskEditor for now.
+ */
+ public SearchHitCollector getDuplicateSearchCollector(String name) {
+ String duplicateDetectorName = name.equals("default") ? "Stack Trace" : name;
+ java.util.List<AbstractDuplicateDetector> allDetectors = getDuplicateSearchCollectorsList();
+
+ for (AbstractDuplicateDetector detector : allDetectors) {
+ if (detector.getName().equals(duplicateDetectorName)) {
+ return detector.getSearchHitCollector(repository, taskData);
+ }
+ }
+ // didn't find it
+ return null;
+ }
+
+ @Override
+ /**
+ * This method is duplicated in NewBugzillaTaskEditor for now.
+ */
+ protected java.util.List<AbstractDuplicateDetector> getDuplicateSearchCollectorsList() {
+ return TasksUiPlugin.getDefault().getDuplicateSearchCollectorsList();
+ }
} \ No newline at end of file
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 aa1d16e86..b5af165eb 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
@@ -100,6 +100,9 @@ public class NewBugzillaTaskEditor extends AbstractNewRepositoryTaskEditor {
}
@Override
+ /**
+ * This method is duplicated in BugzillaTaskEditor for now.
+ */
public SearchHitCollector getDuplicateSearchCollector(String name) {
String duplicateDetectorName = name.equals("default") ? "Stack Trace" : name;
List<AbstractDuplicateDetector> allDetectors = getDuplicateSearchCollectorsList();
@@ -113,6 +116,10 @@ public class NewBugzillaTaskEditor extends AbstractNewRepositoryTaskEditor {
return null;
}
+ @Override
+ /**
+ * This method is duplicated in BugzillaTaskEditor for now.
+ */
protected List<AbstractDuplicateDetector> getDuplicateSearchCollectorsList() {
return TasksUiPlugin.getDefault().getDuplicateSearchCollectorsList();
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractNewRepositoryTaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractNewRepositoryTaskEditor.java
index 0d6d5715e..89bf40741 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractNewRepositoryTaskEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractNewRepositoryTaskEditor.java
@@ -82,18 +82,8 @@ public abstract class AbstractNewRepositoryTaskEditor extends AbstractRepository
private static final String LABEL_CREATE = "Create New";
- private static final String LABEL_SEARCH_DUPS = "Search for Duplicates";
-
- private static final String LABEL_SELECT_DETECTOR = "Select duplicate detector:";
-
private static final String ERROR_CREATING_BUG_REPORT = "Error creating bug report";
- protected Button searchForDuplicates;
-
- protected CCombo duplicateDetectorChooser;
-
- protected Label duplicateDetectorLabel;
-
protected DatePicker scheduledForDate;
protected Spinner estimatedTime;
@@ -419,49 +409,6 @@ public abstract class AbstractNewRepositoryTaskEditor extends AbstractRepository
@Override
protected void addActionButtons(Composite buttonComposite) {
FormToolkit toolkit = new FormToolkit(buttonComposite.getDisplay());
-
- List<AbstractDuplicateDetector> allCollectors = getDuplicateSearchCollectorsList();
- if (allCollectors != null) {
- duplicateDetectorLabel = new Label(buttonComposite, SWT.LEFT);
- duplicateDetectorLabel.setText(LABEL_SELECT_DETECTOR);
-
- duplicateDetectorChooser = new CCombo(buttonComposite, SWT.FLAT | SWT.READ_ONLY | SWT.BORDER);
-
- duplicateDetectorChooser.setLayoutData(GridDataFactory.swtDefaults().hint(150, SWT.DEFAULT).create());
- duplicateDetectorChooser.setFont(TEXT_FONT);
-
- Collections.sort(allCollectors, new Comparator<AbstractDuplicateDetector>() {
-
- public int compare(AbstractDuplicateDetector c1, AbstractDuplicateDetector c2) {
- return c1.getName().compareToIgnoreCase(c2.getName());
- }
-
- });
-
- for (AbstractDuplicateDetector detector : allCollectors) {
- duplicateDetectorChooser.add(detector.getName());
- }
-
- duplicateDetectorChooser.select(0);
- duplicateDetectorChooser.setEnabled(true);
- duplicateDetectorChooser.setData(allCollectors);
- }
-
- if (allCollectors != null && allCollectors.size() > 0) {
-
- searchForDuplicates = toolkit.createButton(buttonComposite, LABEL_SEARCH_DUPS, SWT.NONE);
- GridData searchDuplicatesButtonData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- searchForDuplicates.setLayoutData(searchDuplicatesButtonData);
- searchForDuplicates.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- searchForDuplicates();
- }
- });
- }
-
- Label spacer = new Label(buttonComposite, SWT.NULL);
- spacer.setText("");
-
submitButton = toolkit.createButton(buttonComposite, LABEL_CREATE, SWT.NONE);
GridData submitButtonData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
submitButton.setLayoutData(submitButtonData);
@@ -506,22 +453,6 @@ public abstract class AbstractNewRepositoryTaskEditor extends AbstractRepository
return true;
}
- public boolean searchForDuplicates() {
-
- String duplicateDetectorName = duplicateDetectorChooser.getItem(duplicateDetectorChooser.getSelectionIndex());
-
- // called so that the description text is set on taskData before we
- // search for duplicates
- this.saveTaskOffline(new NullProgressMonitor());
-
- SearchHitCollector collector = getDuplicateSearchCollector(duplicateDetectorName);
- if (collector != null) {
- NewSearchUI.runQueryInBackground(collector);
- return true;
- }
-
- return false;
- }
@Override
protected void createPeopleLayout(Composite composite) {
@@ -559,11 +490,6 @@ public abstract class AbstractNewRepositoryTaskEditor extends AbstractRepository
return newTask;
}
- protected abstract SearchHitCollector getDuplicateSearchCollector(String name);
-
- protected List<AbstractDuplicateDetector> getDuplicateSearchCollectorsList() {
- return TasksUiPlugin.getDefault().getDuplicateSearchCollectorsList();
- }
@Override
public void doSave(IProgressMonitor monitor) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java
index 3d147cca1..c33446e7f 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java
@@ -14,6 +14,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -92,9 +93,12 @@ import org.eclipse.mylyn.tasks.core.TaskComment;
import org.eclipse.mylyn.tasks.core.TaskContainerDelta;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.AbstractTask.RepositoryTaskSyncState;
+import org.eclipse.mylyn.tasks.ui.AbstractDuplicateDetector;
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
+import org.eclipse.mylyn.tasks.ui.search.SearchHitCollector;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.StyledText;
@@ -188,6 +192,8 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage {
private static final String LABEL_DEFAULT_EDITOR = "Default Editor";
private static final String LABEL_TEXT_EDITOR = "Text Editor";
+
+ private static final String LABEL_NO_DETECTOR = "No duplicate detector available.";
protected static final String CONTEXT_MENU_ID = "#MylarRepositoryEditor";
@@ -213,6 +219,10 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage {
private static final String LABEL_SAVE = "Save...";
+ private static final String LABEL_SEARCH_DUPS = "Search for Duplicates";
+
+ private static final String LABEL_SELECT_DETECTOR = "Select duplicate detector:";
+
private RepositoryTaskEditorInput editorInput;
private TaskEditor parentEditor = null;
@@ -249,9 +259,16 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage {
private boolean attachContextEnabled = true;
+ protected Button searchForDuplicates;
+
+ protected CCombo duplicateDetectorChooser;
+
+ protected Label duplicateDetectorLabel;
+
protected enum SECTION_NAME {
ATTRIBTUES_SECTION("Attributes"), ATTACHMENTS_SECTION("Attachments"), DESCRIPTION_SECTION("Description"), COMMENTS_SECTION(
- "Comments"), NEWCOMMENT_SECTION("New Comment"), ACTIONS_SECTION("Actions"), PEOPLE_SECTION("People");
+ "Comments"), NEWCOMMENT_SECTION("New Comment"), ACTIONS_SECTION("Actions"), PEOPLE_SECTION("People"), RELATEDBUGS_SECTION(
+ "Related Tasks");
private String prettyName;
@@ -674,6 +691,8 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage {
createAttributeLayout(attribComp);
createCustomAttributeLayout(attribComp);
+ createRelatedBugsSection(editorComposite);
+
if (showAttachments) {
createAttachmentLayout(editorComposite);
}
@@ -946,6 +965,89 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage {
}
/**
+ * Adds a related bugs section to the bug editor
+ */
+ protected void createRelatedBugsSection(Composite composite) {
+ Section relatedBugsSection = createSection(editorComposite, getSectionLabel(SECTION_NAME.RELATEDBUGS_SECTION));
+ Composite relatedBugsComposite = toolkit.createComposite(relatedBugsSection);
+ relatedBugsComposite.setLayout(new GridLayout(4, false));
+ relatedBugsComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ relatedBugsSection.setClient(relatedBugsComposite);
+ relatedBugsSection.setExpanded(repositoryTask == null);
+
+ List<AbstractDuplicateDetector> allCollectors = getDuplicateSearchCollectorsList();
+ if (allCollectors != null) {
+ duplicateDetectorLabel = new Label(relatedBugsComposite, SWT.LEFT);
+ duplicateDetectorLabel.setText(LABEL_SELECT_DETECTOR);
+
+ duplicateDetectorChooser = new CCombo(relatedBugsComposite, SWT.FLAT | SWT.READ_ONLY | SWT.BORDER);
+
+ duplicateDetectorChooser.setLayoutData(GridDataFactory.swtDefaults().hint(150, SWT.DEFAULT).create());
+ duplicateDetectorChooser.setFont(TEXT_FONT);
+
+ Collections.sort(allCollectors, new Comparator<AbstractDuplicateDetector>() {
+
+ public int compare(AbstractDuplicateDetector c1, AbstractDuplicateDetector c2) {
+ return c1.getName().compareToIgnoreCase(c2.getName());
+ }
+
+ });
+
+ for (AbstractDuplicateDetector detector : allCollectors) {
+ duplicateDetectorChooser.add(detector.getName());
+ }
+
+ duplicateDetectorChooser.select(0);
+ duplicateDetectorChooser.setEnabled(true);
+ duplicateDetectorChooser.setData(allCollectors);
+
+ if (allCollectors.size() > 0) {
+
+ searchForDuplicates = toolkit.createButton(relatedBugsComposite, LABEL_SEARCH_DUPS, SWT.NONE);
+ GridData searchDuplicatesButtonData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ searchForDuplicates.setLayoutData(searchDuplicatesButtonData);
+ searchForDuplicates.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ searchForDuplicates();
+ }
+ });
+ }
+ }
+ else {
+ Label label = new Label(relatedBugsComposite, SWT.LEFT);
+ label.setText(LABEL_NO_DETECTOR);
+
+ }
+
+ }
+
+ protected SearchHitCollector getDuplicateSearchCollector(String name) {
+ return null;
+ }
+
+ protected List<AbstractDuplicateDetector> getDuplicateSearchCollectorsList() {
+ // return TasksUiPlugin.getDefault().getDuplicateSearchCollectorsList();
+ return null;
+ }
+
+ public boolean searchForDuplicates() {
+
+ String duplicateDetectorName = duplicateDetectorChooser.getItem(duplicateDetectorChooser.getSelectionIndex());
+
+ // called so that the description text is set on taskData before we
+ // search for duplicates
+ this.saveTaskOffline(new NullProgressMonitor());
+
+ SearchHitCollector collector = getDuplicateSearchCollector(duplicateDetectorName);
+ if (collector != null) {
+ NewSearchUI.runQueryInBackground(collector);
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
* Adds content assist to the given text field.
*
* @param text

Back to the top