Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaxsun McCarthy Huggan2017-04-07 17:48:00 -0400
committerJaxsun McCarthy Huggan2017-04-07 17:48:00 -0400
commit1cf6eac9ee42682d4011c22f86b11051542475a5 (patch)
treed6933d42363e2b636bda2e9959d876b29667d023
parent6941c63bda477183df09a54326ecf19a7de78fb3 (diff)
downloadorg.eclipse.mylyn.tasks-1cf6eac9ee42682d4011c22f86b11051542475a5.tar.gz
org.eclipse.mylyn.tasks-1cf6eac9ee42682d4011c22f86b11051542475a5.tar.xz
org.eclipse.mylyn.tasks-1cf6eac9ee42682d4011c22f86b11051542475a5.zip
378863: support replying to selected part of a comment only
Support StyledText controls embedded in Composites. Change-Id: I96f7eb87a47a3ecbb31dcecf0ce5bb720155fa05 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=378863
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java
index e8cec3ed6..766ac78f6 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java
@@ -524,14 +524,26 @@ public class TaskEditorCommentPart extends AbstractTaskEditorPart {
String replyText = taskComment.getText();
if (hasTextControl()) {
Control textControl = commentTextEditor.getControl();
- if (textControl instanceof StyledText) {
- String selectedText = ((StyledText) textControl).getSelectionText();
+ String selectedText = getSelectedText(textControl);
+ if (!Strings.isNullOrEmpty(selectedText)) {
+ replyText = selectedText;
+ }
+ }
+ return replyText;
+ }
+
+ private String getSelectedText(Control control) {
+ if (control instanceof StyledText) {
+ return ((StyledText) control).getSelectionText();
+ } else if (control instanceof Composite) {
+ for (Control child : ((Composite) control).getChildren()) {
+ String selectedText = getSelectedText(child);
if (!Strings.isNullOrEmpty(selectedText)) {
- replyText = selectedText;
+ return selectedText;
}
}
}
- return replyText;
+ return null;
}
private boolean hasTextControl() {

Back to the top