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:08:32 UTC

[uima-ruta] branch bugfix/111-Support-copy-paste-clipboard-for-feature-values-in-annotation-browser-view-2 created (now 3e0ff76c)

This is an automated email from the ASF dual-hosted git repository.

pkluegl pushed a change to branch bugfix/111-Support-copy-paste-clipboard-for-feature-values-in-annotation-browser-view-2
in repository https://gitbox.apache.org/repos/asf/uima-ruta.git


      at 3e0ff76c Issue #111: Support copy/paste clipboard for feature values in annotation browser view

This branch includes the following new commits:

     new 3e0ff76c Issue #111: Support copy/paste clipboard for feature values in annotation browser view

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[uima-ruta] 01/01: Issue #111: Support copy/paste clipboard for feature values in annotation browser view

Posted by pk...@apache.org.
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-2
in repository https://gitbox.apache.org/repos/asf/uima-ruta.git

commit 3e0ff76c1bc32dffd4a0b594adc5ddf110606591
Author: Peter Klügl <pe...@averbis.com>
AuthorDate: Fri Oct 28 12:08:05 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..c259bd6c 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();