|
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 |