You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2022/10/28 10:03:26 UTC
[uima-ruta] branch bugfix/111-Support-copy-paste-clipboard-for-feature-values-in-annotation-browser-view updated: Issue #111: Support copy/paste clipboard for feature values in annotation browser view
This is an automated email from the ASF dual-hosted git repository.
pkluegl pushed a commit to branch bugfix/111-Support-copy-paste-clipboard-for-feature-values-in-annotation-browser-view
in repository https://gitbox.apache.org/repos/asf/uima-ruta.git
The following commit(s) were added to refs/heads/bugfix/111-Support-copy-paste-clipboard-for-feature-values-in-annotation-browser-view by this push:
new a8f70cbc Issue #111: Support copy/paste clipboard for feature values in annotation browser view
a8f70cbc is described below
commit a8f70cbc53a7b999e45f714159c644b0c5dfea18
Author: Peter Klügl <pe...@averbis.com>
AuthorDate: Fri Oct 28 12:03:15 2022 +0200
Issue #111: Support copy/paste clipboard for feature values in annotation browser view
- fix clipboard
---
.../view/tree/AnnotationTreeViewPage.java | 35 +++++++++++++++-------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/AnnotationTreeViewPage.java b/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/AnnotationTreeViewPage.java
index f464d466..12efdd0d 100644
--- a/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/AnnotationTreeViewPage.java
+++ b/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/AnnotationTreeViewPage.java
@@ -269,23 +269,19 @@ public class AnnotationTreeViewPage extends Page implements MouseListener, IDoub
@Override
public void keyPressed(KeyEvent e) {
+
int keyCode = e.keyCode;
// backspace or delete: delete annotations
if (keyCode == SWT.BS || keyCode == SWT.DEL) {
deleteSelectedAnnotations();
}
// ctrl and c: copy type name to clipboard
- if ((e.stateMask & SWT.CTRL) == SWT.CTRL && keyCode == 'c') {
+ if (e.stateMask == SWT.CTRL && (e.keyCode == 'c' || e.keyCode == 'C')) {
TreeItem[] selection = treeView.getTree().getSelection();
- if (selection != null && selection.length == 1) {
- Object obj = selection[0].getData();
- if (obj instanceof TypeTreeNode) {
- TypeTreeNode typeTreeNode = (TypeTreeNode) obj;
- Type type = typeTreeNode.getType();
- TextTransfer textTransfer = TextTransfer.getInstance();
- clipboard.setContents(new Object[] { type.getName() },
- new Transfer[] { textTransfer });
- }
+ if (selection != null) {
+ Object[] contents = getContents(selection);
+ TextTransfer textTransfer = TextTransfer.getInstance();
+ clipboard.setContents(contents, new Transfer[] { textTransfer });
}
}
// ctrl and c: copy type name to clipboard:
@@ -302,6 +298,25 @@ public class AnnotationTreeViewPage extends Page implements MouseListener, IDoub
}
}
+ private Object[] getContents(TreeItem[] selection) {
+
+ List<String> list = new ArrayList<>();
+ for (TreeItem item : selection) {
+ Object data = item.getData();
+ if(data instanceof TypeTreeNode) {
+ list.add(((TypeTreeNode) data).getType().getName());
+ } else if(data instanceof PrimitiveFeatureTreeNode) {
+ list.add(((PrimitiveFeatureTreeNode) data).getValue());
+ } else if(data instanceof AnnotationTreeNode) {
+ list.add(((AnnotationTreeNode) data).getAnnotation().getCoveredText());
+ } else if(data instanceof ITreeNode) {
+ list.add(((ITreeNode) data).getName());
+ }
+ }
+
+ return new Object[]{StringUtils.join(list, "\n")};
+ }
+
});
styleListener = new TreeViewAnnotationStyleChangeListener();