Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 156061 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/tasks/ui/editors/AbstractNewRepositoryTaskEditor.java (-74 lines)
Lines 82-99 Link Here
82
82
83
	private static final String LABEL_CREATE = "Create New";
83
	private static final String LABEL_CREATE = "Create New";
84
84
85
	private static final String LABEL_SEARCH_DUPS = "Search for Duplicates";
86
87
	private static final String LABEL_SELECT_DETECTOR = "Select duplicate detector:";
88
89
	private static final String ERROR_CREATING_BUG_REPORT = "Error creating bug report";
85
	private static final String ERROR_CREATING_BUG_REPORT = "Error creating bug report";
90
86
91
	protected Button searchForDuplicates;
92
93
	protected CCombo duplicateDetectorChooser;
94
95
	protected Label duplicateDetectorLabel;
96
97
	protected DatePicker scheduledForDate;
87
	protected DatePicker scheduledForDate;
98
88
99
	protected Spinner estimatedTime;
89
	protected Spinner estimatedTime;
Lines 419-467 Link Here
419
	@Override
409
	@Override
420
	protected void addActionButtons(Composite buttonComposite) {
410
	protected void addActionButtons(Composite buttonComposite) {
421
		FormToolkit toolkit = new FormToolkit(buttonComposite.getDisplay());
411
		FormToolkit toolkit = new FormToolkit(buttonComposite.getDisplay());
422
423
		List<AbstractDuplicateDetector> allCollectors = getDuplicateSearchCollectorsList();
424
		if (allCollectors != null) {
425
			duplicateDetectorLabel = new Label(buttonComposite, SWT.LEFT);
426
			duplicateDetectorLabel.setText(LABEL_SELECT_DETECTOR);
427
428
			duplicateDetectorChooser = new CCombo(buttonComposite, SWT.FLAT | SWT.READ_ONLY | SWT.BORDER);
429
430
			duplicateDetectorChooser.setLayoutData(GridDataFactory.swtDefaults().hint(150, SWT.DEFAULT).create());
431
			duplicateDetectorChooser.setFont(TEXT_FONT);
432
433
			Collections.sort(allCollectors, new Comparator<AbstractDuplicateDetector>() {
434
435
				public int compare(AbstractDuplicateDetector c1, AbstractDuplicateDetector c2) {
436
					return c1.getName().compareToIgnoreCase(c2.getName());
437
				}
438
439
			});
440
441
			for (AbstractDuplicateDetector detector : allCollectors) {
442
				duplicateDetectorChooser.add(detector.getName());
443
			}
444
445
			duplicateDetectorChooser.select(0);
446
			duplicateDetectorChooser.setEnabled(true);
447
			duplicateDetectorChooser.setData(allCollectors);
448
		}
449
450
		if (allCollectors != null && allCollectors.size() > 0) {
451
452
			searchForDuplicates = toolkit.createButton(buttonComposite, LABEL_SEARCH_DUPS, SWT.NONE);
453
			GridData searchDuplicatesButtonData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
454
			searchForDuplicates.setLayoutData(searchDuplicatesButtonData);
455
			searchForDuplicates.addListener(SWT.Selection, new Listener() {
456
				public void handleEvent(Event e) {
457
					searchForDuplicates();
458
				}
459
			});
460
		}
461
462
		Label spacer = new Label(buttonComposite, SWT.NULL);
463
		spacer.setText("");
464
465
		submitButton = toolkit.createButton(buttonComposite, LABEL_CREATE, SWT.NONE);
412
		submitButton = toolkit.createButton(buttonComposite, LABEL_CREATE, SWT.NONE);
466
		GridData submitButtonData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
413
		GridData submitButtonData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
467
		submitButton.setLayoutData(submitButtonData);
414
		submitButton.setLayoutData(submitButtonData);
Lines 506-527 Link Here
506
		return true;
453
		return true;
507
	}
454
	}
508
455
509
	public boolean searchForDuplicates() {
510
511
		String duplicateDetectorName = duplicateDetectorChooser.getItem(duplicateDetectorChooser.getSelectionIndex());
512
513
		// called so that the description text is set on taskData before we
514
		// search for duplicates
515
		this.saveTaskOffline(new NullProgressMonitor());
516
517
		SearchHitCollector collector = getDuplicateSearchCollector(duplicateDetectorName);
518
		if (collector != null) {
519
			NewSearchUI.runQueryInBackground(collector);
520
			return true;
521
		}
522
523
		return false;
524
	}
525
456
526
	@Override
457
	@Override
527
	protected void createPeopleLayout(Composite composite) {
458
	protected void createPeopleLayout(Composite composite) {
Lines 559-569 Link Here
559
		return newTask;
490
		return newTask;
560
	}
491
	}
561
492
562
	protected abstract SearchHitCollector getDuplicateSearchCollector(String name);
563
564
	protected List<AbstractDuplicateDetector> getDuplicateSearchCollectorsList() {
565
		return TasksUiPlugin.getDefault().getDuplicateSearchCollectorsList();
566
	}
567
493
568
	@Override
494
	@Override
569
	public void doSave(IProgressMonitor monitor) {
495
	public void doSave(IProgressMonitor monitor) {
(-)src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java (-1 / +102 lines)
Lines 14-19 Link Here
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Arrays;
15
import java.util.Arrays;
16
import java.util.Collections;
16
import java.util.Collections;
17
import java.util.Comparator;
17
import java.util.Date;
18
import java.util.Date;
18
import java.util.HashMap;
19
import java.util.HashMap;
19
import java.util.HashSet;
20
import java.util.HashSet;
Lines 92-100 Link Here
92
import org.eclipse.mylyn.tasks.core.TaskContainerDelta;
93
import org.eclipse.mylyn.tasks.core.TaskContainerDelta;
93
import org.eclipse.mylyn.tasks.core.TaskRepository;
94
import org.eclipse.mylyn.tasks.core.TaskRepository;
94
import org.eclipse.mylyn.tasks.core.AbstractTask.RepositoryTaskSyncState;
95
import org.eclipse.mylyn.tasks.core.AbstractTask.RepositoryTaskSyncState;
96
import org.eclipse.mylyn.tasks.ui.AbstractDuplicateDetector;
95
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
97
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
96
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
98
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
99
import org.eclipse.mylyn.tasks.ui.search.SearchHitCollector;
97
import org.eclipse.osgi.util.NLS;
100
import org.eclipse.osgi.util.NLS;
101
import org.eclipse.search.ui.NewSearchUI;
98
import org.eclipse.swt.SWT;
102
import org.eclipse.swt.SWT;
99
import org.eclipse.swt.custom.CCombo;
103
import org.eclipse.swt.custom.CCombo;
100
import org.eclipse.swt.custom.StyledText;
104
import org.eclipse.swt.custom.StyledText;
Lines 188-193 Link Here
188
	private static final String LABEL_DEFAULT_EDITOR = "Default Editor";
192
	private static final String LABEL_DEFAULT_EDITOR = "Default Editor";
189
193
190
	private static final String LABEL_TEXT_EDITOR = "Text Editor";
194
	private static final String LABEL_TEXT_EDITOR = "Text Editor";
195
	
196
	private static final String LABEL_NO_DETECTOR = "No duplicate detector available.";
191
197
192
	protected static final String CONTEXT_MENU_ID = "#MylarRepositoryEditor";
198
	protected static final String CONTEXT_MENU_ID = "#MylarRepositoryEditor";
193
199
Lines 213-218 Link Here
213
219
214
	private static final String LABEL_SAVE = "Save...";
220
	private static final String LABEL_SAVE = "Save...";
215
221
222
	private static final String LABEL_SEARCH_DUPS = "Search for Duplicates";
223
224
	private static final String LABEL_SELECT_DETECTOR = "Select duplicate detector:";
225
216
	private RepositoryTaskEditorInput editorInput;
226
	private RepositoryTaskEditorInput editorInput;
217
227
218
	private TaskEditor parentEditor = null;
228
	private TaskEditor parentEditor = null;
Lines 249-257 Link Here
249
259
250
	private boolean attachContextEnabled = true;
260
	private boolean attachContextEnabled = true;
251
261
262
	protected Button searchForDuplicates;
263
264
	protected CCombo duplicateDetectorChooser;
265
266
	protected Label duplicateDetectorLabel;
267
252
	protected enum SECTION_NAME {
268
	protected enum SECTION_NAME {
253
		ATTRIBTUES_SECTION("Attributes"), ATTACHMENTS_SECTION("Attachments"), DESCRIPTION_SECTION("Description"), COMMENTS_SECTION(
269
		ATTRIBTUES_SECTION("Attributes"), ATTACHMENTS_SECTION("Attachments"), DESCRIPTION_SECTION("Description"), COMMENTS_SECTION(
254
				"Comments"), NEWCOMMENT_SECTION("New Comment"), ACTIONS_SECTION("Actions"), PEOPLE_SECTION("People");
270
				"Comments"), NEWCOMMENT_SECTION("New Comment"), ACTIONS_SECTION("Actions"), PEOPLE_SECTION("People"), RELATEDBUGS_SECTION(
271
				"Related Bugs");
255
272
256
		private String prettyName;
273
		private String prettyName;
257
274
Lines 674-679 Link Here
674
		createAttributeLayout(attribComp);
691
		createAttributeLayout(attribComp);
675
		createCustomAttributeLayout(attribComp);
692
		createCustomAttributeLayout(attribComp);
676
693
694
		createRelatedBugsSection(editorComposite);
695
677
		if (showAttachments) {
696
		if (showAttachments) {
678
			createAttachmentLayout(editorComposite);
697
			createAttachmentLayout(editorComposite);
679
		}
698
		}
Lines 946-951 Link Here
946
	}
965
	}
947
966
948
	/**
967
	/**
968
	 * Adds a related bugs section to the bug editor
969
	 */
970
	protected void createRelatedBugsSection(Composite composite) {
971
		Section relatedBugsSection = createSection(editorComposite, getSectionLabel(SECTION_NAME.RELATEDBUGS_SECTION));
972
		Composite relatedBugsComposite = toolkit.createComposite(relatedBugsSection);
973
		relatedBugsComposite.setLayout(new GridLayout(4, false));
974
		relatedBugsComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
975
		relatedBugsSection.setClient(relatedBugsComposite);
976
977
		List<AbstractDuplicateDetector> allCollectors = getDuplicateSearchCollectorsList();
978
		if (allCollectors != null) {
979
			duplicateDetectorLabel = new Label(relatedBugsComposite, SWT.LEFT);
980
			duplicateDetectorLabel.setText(LABEL_SELECT_DETECTOR);
981
982
			duplicateDetectorChooser = new CCombo(relatedBugsComposite, SWT.FLAT | SWT.READ_ONLY | SWT.BORDER);
983
984
			duplicateDetectorChooser.setLayoutData(GridDataFactory.swtDefaults().hint(150, SWT.DEFAULT).create());
985
			duplicateDetectorChooser.setFont(TEXT_FONT);
986
987
			Collections.sort(allCollectors, new Comparator<AbstractDuplicateDetector>() {
988
989
				public int compare(AbstractDuplicateDetector c1, AbstractDuplicateDetector c2) {
990
					return c1.getName().compareToIgnoreCase(c2.getName());
991
				}
992
993
			});
994
995
			for (AbstractDuplicateDetector detector : allCollectors) {
996
				duplicateDetectorChooser.add(detector.getName());
997
			}
998
999
			duplicateDetectorChooser.select(0);
1000
			duplicateDetectorChooser.setEnabled(true);
1001
			duplicateDetectorChooser.setData(allCollectors);
1002
1003
			if (allCollectors.size() > 0) {
1004
1005
				searchForDuplicates = toolkit.createButton(relatedBugsComposite, LABEL_SEARCH_DUPS, SWT.NONE);
1006
				GridData searchDuplicatesButtonData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1007
				searchForDuplicates.setLayoutData(searchDuplicatesButtonData);
1008
				searchForDuplicates.addListener(SWT.Selection, new Listener() {
1009
					public void handleEvent(Event e) {
1010
						searchForDuplicates();
1011
					}
1012
				});
1013
			}
1014
		}
1015
		else {
1016
			Label label = new Label(relatedBugsComposite, SWT.LEFT);
1017
			label.setText(LABEL_NO_DETECTOR);
1018
			
1019
		}
1020
1021
	}
1022
1023
	protected SearchHitCollector getDuplicateSearchCollector(String name) {
1024
		return null;
1025
	}
1026
1027
	protected List<AbstractDuplicateDetector> getDuplicateSearchCollectorsList() {
1028
		//	return TasksUiPlugin.getDefault().getDuplicateSearchCollectorsList();
1029
		return null;
1030
	}
1031
1032
	public boolean searchForDuplicates() {
1033
1034
		String duplicateDetectorName = duplicateDetectorChooser.getItem(duplicateDetectorChooser.getSelectionIndex());
1035
1036
		// called so that the description text is set on taskData before we
1037
		// search for duplicates
1038
		this.saveTaskOffline(new NullProgressMonitor());
1039
1040
		SearchHitCollector collector = getDuplicateSearchCollector(duplicateDetectorName);
1041
		if (collector != null) {
1042
			NewSearchUI.runQueryInBackground(collector);
1043
			return true;
1044
		}
1045
1046
		return false;
1047
	}
1048
1049
	/**
949
	 * Adds content assist to the given text field.
1050
	 * Adds content assist to the given text field.
950
	 * 
1051
	 * 
951
	 * @param text
1052
	 * @param text
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java (-1 / +28 lines)
Lines 33-44 Link Here
33
import org.eclipse.mylyn.tasks.core.RepositoryOperation;
33
import org.eclipse.mylyn.tasks.core.RepositoryOperation;
34
import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute;
34
import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute;
35
import org.eclipse.mylyn.tasks.core.TaskComment;
35
import org.eclipse.mylyn.tasks.core.TaskComment;
36
import org.eclipse.mylyn.tasks.ui.AbstractDuplicateDetector;
36
import org.eclipse.mylyn.tasks.ui.DatePicker;
37
import org.eclipse.mylyn.tasks.ui.DatePicker;
37
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
38
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
38
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
39
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
39
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditor;
40
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditor;
40
import org.eclipse.mylyn.tasks.ui.editors.RepositoryTaskSelection;
41
import org.eclipse.mylyn.tasks.ui.editors.RepositoryTaskSelection;
41
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
42
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
43
import org.eclipse.mylyn.tasks.ui.search.SearchHitCollector;
42
import org.eclipse.swt.SWT;
44
import org.eclipse.swt.SWT;
43
import org.eclipse.swt.events.ModifyEvent;
45
import org.eclipse.swt.events.ModifyEvent;
44
import org.eclipse.swt.events.ModifyListener;
46
import org.eclipse.swt.events.ModifyListener;
Lines 357-363 Link Here
357
		try {
359
		try {
358
			operation = BUGZILLA_OPERATION.valueOf(repositoryOperation.getKnobName());
360
			operation = BUGZILLA_OPERATION.valueOf(repositoryOperation.getKnobName());
359
		} catch (RuntimeException e) {
361
		} catch (RuntimeException e) {
360
			StatusManager.log(e, "Unrecognized operatoin: " + repositoryOperation.getKnobName());
362
			StatusManager.log(e, "Unrecognized operation: " + repositoryOperation.getKnobName());
361
			operation = null;
363
			operation = null;
362
		}
364
		}
363
365
Lines 722-725 Link Here
722
			return null;
724
			return null;
723
		}
725
		}
724
	}
726
	}
727
	
728
	@Override
729
	/**
730
	 * This method is duplicated in NewBugzillaTaskEditor for now.
731
	 */
732
	public SearchHitCollector getDuplicateSearchCollector(String name) {
733
		String duplicateDetectorName = name.equals("default") ? "Stack Trace" : name;
734
		java.util.List<AbstractDuplicateDetector> allDetectors = getDuplicateSearchCollectorsList();
735
736
		for (AbstractDuplicateDetector detector : allDetectors) {
737
			if (detector.getName().equals(duplicateDetectorName)) {
738
				return detector.getSearchHitCollector(repository, taskData);
739
			}
740
		}
741
		// didn't find it
742
		return null;
743
	}
744
745
	@Override
746
	/**
747
	 * This method is duplicated in NewBugzillaTaskEditor for now.
748
	 */
749
	protected java.util.List<AbstractDuplicateDetector> getDuplicateSearchCollectorsList() {
750
		return TasksUiPlugin.getDefault().getDuplicateSearchCollectorsList();
751
	}
725
}
752
}
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java (+7 lines)
Lines 100-105 Link Here
100
	}
100
	}
101
101
102
	@Override
102
	@Override
103
	/**
104
	 * This method is duplicated in BugzillaTaskEditor for now.
105
	 */
103
	public SearchHitCollector getDuplicateSearchCollector(String name) {
106
	public SearchHitCollector getDuplicateSearchCollector(String name) {
104
		String duplicateDetectorName = name.equals("default") ? "Stack Trace" : name;
107
		String duplicateDetectorName = name.equals("default") ? "Stack Trace" : name;
105
		List<AbstractDuplicateDetector> allDetectors = getDuplicateSearchCollectorsList();
108
		List<AbstractDuplicateDetector> allDetectors = getDuplicateSearchCollectorsList();
Lines 113-118 Link Here
113
		return null;
116
		return null;
114
	}
117
	}
115
118
119
	@Override
120
	/**
121
	 * This method is duplicated in BugzillaTaskEditor for now.
122
	 */
116
	protected List<AbstractDuplicateDetector> getDuplicateSearchCollectorsList() {
123
	protected List<AbstractDuplicateDetector> getDuplicateSearchCollectorsList() {
117
		return TasksUiPlugin.getDefault().getDuplicateSearchCollectorsList();
124
		return TasksUiPlugin.getDefault().getDuplicateSearchCollectorsList();
118
	}
125
	}

Return to bug 156061