|
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 91-99
Link Here
|
| 91 |
import org.eclipse.mylyn.tasks.core.TaskContainerDelta; |
92 |
import org.eclipse.mylyn.tasks.core.TaskContainerDelta; |
| 92 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
93 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
| 93 |
import org.eclipse.mylyn.tasks.core.AbstractTask.RepositoryTaskSyncState; |
94 |
import org.eclipse.mylyn.tasks.core.AbstractTask.RepositoryTaskSyncState; |
|
|
95 |
import org.eclipse.mylyn.tasks.ui.AbstractDuplicateDetector; |
| 94 |
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; |
96 |
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; |
| 95 |
import org.eclipse.mylyn.tasks.ui.TasksUiUtil; |
97 |
import org.eclipse.mylyn.tasks.ui.TasksUiUtil; |
|
|
98 |
import org.eclipse.mylyn.tasks.ui.search.SearchHitCollector; |
| 96 |
import org.eclipse.osgi.util.NLS; |
99 |
import org.eclipse.osgi.util.NLS; |
|
|
100 |
import org.eclipse.search.ui.NewSearchUI; |
| 97 |
import org.eclipse.swt.SWT; |
101 |
import org.eclipse.swt.SWT; |
| 98 |
import org.eclipse.swt.custom.CCombo; |
102 |
import org.eclipse.swt.custom.CCombo; |
| 99 |
import org.eclipse.swt.custom.StyledText; |
103 |
import org.eclipse.swt.custom.StyledText; |
|
Lines 187-192
Link Here
|
| 187 |
private static final String LABEL_DEFAULT_EDITOR = "Default Editor"; |
191 |
private static final String LABEL_DEFAULT_EDITOR = "Default Editor"; |
| 188 |
|
192 |
|
| 189 |
private static final String LABEL_TEXT_EDITOR = "Text Editor"; |
193 |
private static final String LABEL_TEXT_EDITOR = "Text Editor"; |
|
|
194 |
|
| 195 |
private static final String LABEL_NO_DETECTOR = "No duplicate detector available."; |
| 190 |
|
196 |
|
| 191 |
protected static final String CONTEXT_MENU_ID = "#MylarRepositoryEditor"; |
197 |
protected static final String CONTEXT_MENU_ID = "#MylarRepositoryEditor"; |
| 192 |
|
198 |
|
|
Lines 209-217
Link Here
|
| 209 |
private static final String LABEL_BUTTON_SUBMIT = "Submit"; |
215 |
private static final String LABEL_BUTTON_SUBMIT = "Submit"; |
| 210 |
|
216 |
|
| 211 |
private static final String LABEL_COPY_TO_CLIPBOARD = "Copy to Clipboard"; |
217 |
private static final String LABEL_COPY_TO_CLIPBOARD = "Copy to Clipboard"; |
| 212 |
|
218 |
|
| 213 |
private static final String LABEL_SAVE = "Save..."; |
219 |
private static final String LABEL_SAVE = "Save..."; |
| 214 |
|
220 |
|
|
|
221 |
private static final String LABEL_SEARCH_DUPS = "Search for Duplicates"; |
| 222 |
|
| 223 |
private static final String LABEL_SELECT_DETECTOR = "Select duplicate detector:"; |
| 224 |
|
| 215 |
private RepositoryTaskEditorInput editorInput; |
225 |
private RepositoryTaskEditorInput editorInput; |
| 216 |
|
226 |
|
| 217 |
private TaskEditor parentEditor = null; |
227 |
private TaskEditor parentEditor = null; |
|
Lines 248-256
Link Here
|
| 248 |
|
258 |
|
| 249 |
private boolean attachContextEnabled = true; |
259 |
private boolean attachContextEnabled = true; |
| 250 |
|
260 |
|
|
|
261 |
protected Button searchForDuplicates; |
| 262 |
|
| 263 |
protected CCombo duplicateDetectorChooser; |
| 264 |
|
| 265 |
protected Label duplicateDetectorLabel; |
| 266 |
|
| 251 |
protected enum SECTION_NAME { |
267 |
protected enum SECTION_NAME { |
| 252 |
ATTRIBTUES_SECTION("Attributes"), ATTACHMENTS_SECTION("Attachments"), DESCRIPTION_SECTION("Description"), COMMENTS_SECTION( |
268 |
ATTRIBTUES_SECTION("Attributes"), ATTACHMENTS_SECTION("Attachments"), DESCRIPTION_SECTION("Description"), COMMENTS_SECTION( |
| 253 |
"Comments"), NEWCOMMENT_SECTION("New Comment"), ACTIONS_SECTION("Actions"), PEOPLE_SECTION("People"); |
269 |
"Comments"), NEWCOMMENT_SECTION("New Comment"), ACTIONS_SECTION("Actions"), PEOPLE_SECTION("People"), RELATEDBUGS_SECTION( |
|
|
270 |
"Related Bugs"); |
| 254 |
|
271 |
|
| 255 |
private String prettyName; |
272 |
private String prettyName; |
| 256 |
|
273 |
|
|
Lines 286-292
Link Here
|
| 286 |
} |
303 |
} |
| 287 |
}; |
304 |
}; |
| 288 |
|
305 |
|
| 289 |
|
|
|
| 290 |
private final ITaskListChangeListener TASKLIST_CHANGE_LISTENER = new ITaskListChangeListener() { |
306 |
private final ITaskListChangeListener TASKLIST_CHANGE_LISTENER = new ITaskListChangeListener() { |
| 291 |
|
307 |
|
| 292 |
public void containersChanged(Set<TaskContainerDelta> containers) { |
308 |
public void containersChanged(Set<TaskContainerDelta> containers) { |
|
Lines 294-300
Link Here
|
| 294 |
for (TaskContainerDelta taskContainerDelta : containers) { |
310 |
for (TaskContainerDelta taskContainerDelta : containers) { |
| 295 |
if (repositoryTask != null && repositoryTask.equals(taskContainerDelta.getContainer())) { |
311 |
if (repositoryTask != null && repositoryTask.equals(taskContainerDelta.getContainer())) { |
| 296 |
if (taskContainerDelta.getKind().equals(TaskContainerDelta.Kind.CONTENT)) { |
312 |
if (taskContainerDelta.getKind().equals(TaskContainerDelta.Kind.CONTENT)) { |
| 297 |
taskToRefresh = (AbstractTask)taskContainerDelta.getContainer(); |
313 |
taskToRefresh = (AbstractTask) taskContainerDelta.getContainer(); |
| 298 |
break; |
314 |
break; |
| 299 |
} |
315 |
} |
| 300 |
} |
316 |
} |
|
Lines 322-331
Link Here
|
| 322 |
} |
338 |
} |
| 323 |
} |
339 |
} |
| 324 |
}); |
340 |
}); |
| 325 |
} |
341 |
} |
| 326 |
} |
342 |
} |
| 327 |
}; |
343 |
}; |
| 328 |
|
|
|
| 329 |
|
344 |
|
| 330 |
private List<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>(); |
345 |
private List<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>(); |
| 331 |
|
346 |
|
|
Lines 657-662
Link Here
|
| 657 |
createAttributeLayout(attribComp); |
672 |
createAttributeLayout(attribComp); |
| 658 |
createCustomAttributeLayout(attribComp); |
673 |
createCustomAttributeLayout(attribComp); |
| 659 |
|
674 |
|
|
|
675 |
createRelatedBugsSection(editorComposite); |
| 676 |
|
| 660 |
if (showAttachments) { |
677 |
if (showAttachments) { |
| 661 |
createAttachmentLayout(editorComposite); |
678 |
createAttachmentLayout(editorComposite); |
| 662 |
} |
679 |
} |
|
Lines 929-934
Link Here
|
| 929 |
} |
946 |
} |
| 930 |
|
947 |
|
| 931 |
/** |
948 |
/** |
|
|
949 |
* Adds a related bugs section to the bug editor |
| 950 |
*/ |
| 951 |
protected void createRelatedBugsSection(Composite composite) { |
| 952 |
Section relatedBugsSection = createSection(editorComposite, getSectionLabel(SECTION_NAME.RELATEDBUGS_SECTION)); |
| 953 |
Composite relatedBugsComposite = toolkit.createComposite(relatedBugsSection); |
| 954 |
relatedBugsComposite.setLayout(new GridLayout(4, false)); |
| 955 |
relatedBugsComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); |
| 956 |
relatedBugsSection.setClient(relatedBugsComposite); |
| 957 |
|
| 958 |
List<AbstractDuplicateDetector> allCollectors = getDuplicateSearchCollectorsList(); |
| 959 |
if (allCollectors != null) { |
| 960 |
duplicateDetectorLabel = new Label(relatedBugsComposite, SWT.LEFT); |
| 961 |
duplicateDetectorLabel.setText(LABEL_SELECT_DETECTOR); |
| 962 |
|
| 963 |
duplicateDetectorChooser = new CCombo(relatedBugsComposite, SWT.FLAT | SWT.READ_ONLY | SWT.BORDER); |
| 964 |
|
| 965 |
duplicateDetectorChooser.setLayoutData(GridDataFactory.swtDefaults().hint(150, SWT.DEFAULT).create()); |
| 966 |
duplicateDetectorChooser.setFont(TEXT_FONT); |
| 967 |
|
| 968 |
Collections.sort(allCollectors, new Comparator<AbstractDuplicateDetector>() { |
| 969 |
|
| 970 |
public int compare(AbstractDuplicateDetector c1, AbstractDuplicateDetector c2) { |
| 971 |
return c1.getName().compareToIgnoreCase(c2.getName()); |
| 972 |
} |
| 973 |
|
| 974 |
}); |
| 975 |
|
| 976 |
for (AbstractDuplicateDetector detector : allCollectors) { |
| 977 |
duplicateDetectorChooser.add(detector.getName()); |
| 978 |
} |
| 979 |
|
| 980 |
duplicateDetectorChooser.select(0); |
| 981 |
duplicateDetectorChooser.setEnabled(true); |
| 982 |
duplicateDetectorChooser.setData(allCollectors); |
| 983 |
|
| 984 |
if (allCollectors.size() > 0) { |
| 985 |
|
| 986 |
searchForDuplicates = toolkit.createButton(relatedBugsComposite, LABEL_SEARCH_DUPS, SWT.NONE); |
| 987 |
GridData searchDuplicatesButtonData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); |
| 988 |
searchForDuplicates.setLayoutData(searchDuplicatesButtonData); |
| 989 |
searchForDuplicates.addListener(SWT.Selection, new Listener() { |
| 990 |
public void handleEvent(Event e) { |
| 991 |
searchForDuplicates(); |
| 992 |
} |
| 993 |
}); |
| 994 |
} |
| 995 |
} |
| 996 |
else { |
| 997 |
Label label = new Label(relatedBugsComposite, SWT.LEFT); |
| 998 |
label.setText(LABEL_NO_DETECTOR); |
| 999 |
|
| 1000 |
} |
| 1001 |
|
| 1002 |
} |
| 1003 |
|
| 1004 |
protected SearchHitCollector getDuplicateSearchCollector(String name) { |
| 1005 |
return null; |
| 1006 |
} |
| 1007 |
|
| 1008 |
protected List<AbstractDuplicateDetector> getDuplicateSearchCollectorsList() { |
| 1009 |
// return TasksUiPlugin.getDefault().getDuplicateSearchCollectorsList(); |
| 1010 |
return null; |
| 1011 |
} |
| 1012 |
|
| 1013 |
public boolean searchForDuplicates() { |
| 1014 |
|
| 1015 |
String duplicateDetectorName = duplicateDetectorChooser.getItem(duplicateDetectorChooser.getSelectionIndex()); |
| 1016 |
|
| 1017 |
// called so that the description text is set on taskData before we |
| 1018 |
// search for duplicates |
| 1019 |
this.saveTaskOffline(new NullProgressMonitor()); |
| 1020 |
|
| 1021 |
SearchHitCollector collector = getDuplicateSearchCollector(duplicateDetectorName); |
| 1022 |
if (collector != null) { |
| 1023 |
NewSearchUI.runQueryInBackground(collector); |
| 1024 |
return true; |
| 1025 |
} |
| 1026 |
|
| 1027 |
return false; |
| 1028 |
} |
| 1029 |
|
| 1030 |
/** |
| 932 |
* Adds content assist to the given text field. |
1031 |
* Adds content assist to the given text field. |
| 933 |
* |
1032 |
* |
| 934 |
* @param text |
1033 |
* @param text |
|
Lines 1237-1243
Link Here
|
| 1237 |
popupMenu.addMenuListener(new IMenuListener() { |
1336 |
popupMenu.addMenuListener(new IMenuListener() { |
| 1238 |
public void menuAboutToShow(IMenuManager manager) { |
1337 |
public void menuAboutToShow(IMenuManager manager) { |
| 1239 |
popupMenu.removeAll(); |
1338 |
popupMenu.removeAll(); |
| 1240 |
|
1339 |
|
| 1241 |
ISelection selection = attachmentsTableViewer.getSelection(); |
1340 |
ISelection selection = attachmentsTableViewer.getSelection(); |
| 1242 |
if (selection.isEmpty()) { |
1341 |
if (selection.isEmpty()) { |
| 1243 |
return; |
1342 |
return; |
|
Lines 1264-1275
Link Here
|
| 1264 |
popupMenu.add(copyToClipAction); |
1363 |
popupMenu.add(copyToClipAction); |
| 1265 |
} |
1364 |
} |
| 1266 |
popupMenu.add(new Separator("actions")); |
1365 |
popupMenu.add(new Separator("actions")); |
| 1267 |
|
1366 |
|
| 1268 |
// TODO: use workbench mechanism for this? |
1367 |
// TODO: use workbench mechanism for this? |
| 1269 |
ObjectActionContributorManager.getManager().contributeObjectActions( |
1368 |
ObjectActionContributorManager.getManager().contributeObjectActions( |
| 1270 |
AbstractRepositoryTaskEditor.this, popupMenu, attachmentsTableViewer); |
1369 |
AbstractRepositoryTaskEditor.this, popupMenu, attachmentsTableViewer); |
| 1271 |
} |
1370 |
} |
| 1272 |
}); |
1371 |
}); |
| 1273 |
} else { |
1372 |
} else { |
| 1274 |
Label label = toolkit.createLabel(attachmentsComposite, "No attachments"); |
1373 |
Label label = toolkit.createLabel(attachmentsComposite, "No attachments"); |
| 1275 |
registerDropListener(label); |
1374 |
registerDropListener(label); |
|
Lines 1282-1288
Link Here
|
| 1282 |
/* Launch a NewAttachemntWizard */ |
1381 |
/* Launch a NewAttachemntWizard */ |
| 1283 |
Button addAttachmentButton = toolkit.createButton(attachmentControlsComposite, "Attach File...", SWT.PUSH); |
1382 |
Button addAttachmentButton = toolkit.createButton(attachmentControlsComposite, "Attach File...", SWT.PUSH); |
| 1284 |
|
1383 |
|
| 1285 |
AbstractTask task = TasksUiPlugin.getTaskListManager().getTaskList().getTask(repository.getUrl(), taskData.getId()); |
1384 |
AbstractTask task = TasksUiPlugin.getTaskListManager().getTaskList().getTask(repository.getUrl(), |
|
|
1385 |
taskData.getId()); |
| 1286 |
if (task == null) { |
1386 |
if (task == null) { |
| 1287 |
addAttachmentButton.setEnabled(false); |
1387 |
addAttachmentButton.setEnabled(false); |
| 1288 |
} |
1388 |
} |
|
Lines 1898-1904
Link Here
|
| 1898 |
|
1998 |
|
| 1899 |
toolkit.createLabel(buttonComposite, " "); |
1999 |
toolkit.createLabel(buttonComposite, " "); |
| 1900 |
|
2000 |
|
| 1901 |
AbstractTask task = TasksUiPlugin.getTaskListManager().getTaskList().getTask(repository.getUrl(), taskData.getId()); |
2001 |
AbstractTask task = TasksUiPlugin.getTaskListManager().getTaskList().getTask(repository.getUrl(), |
|
|
2002 |
taskData.getId()); |
| 1902 |
if (attachContextEnabled && task != null) { |
2003 |
if (attachContextEnabled && task != null) { |
| 1903 |
addAttachContextButton(buttonComposite, task); |
2004 |
addAttachContextButton(buttonComposite, task); |
| 1904 |
} |
2005 |
} |
|
Lines 2533-2541
Link Here
|
| 2533 |
"Task could not be created. No additional information was provided by the connector.")); |
2634 |
"Task could not be created. No additional information was provided by the connector.")); |
| 2534 |
} |
2635 |
} |
| 2535 |
} else { |
2636 |
} else { |
| 2536 |
modifiedTask = (AbstractTask) TasksUiPlugin.getTaskListManager() |
2637 |
modifiedTask = (AbstractTask) TasksUiPlugin.getTaskListManager().getTaskList().getTask( |
| 2537 |
.getTaskList() |
2638 |
repository.getUrl(), taskData.getId()); |
| 2538 |
.getTask(repository.getUrl(), taskData.getId()); |
|
|
| 2539 |
} |
2639 |
} |
| 2540 |
|
2640 |
|
| 2541 |
// Synchronization accounting... |
2641 |
// Synchronization accounting... |