]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@22451 ac1ea38d-2e2b...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 28 Sep 2011 06:19:01 +0000 (06:19 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 28 Sep 2011 06:19:01 +0000 (06:19 +0000)
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/values/ValueView.java

index 353d640b5ef57530a621c2152daab46f2623b712..f3151bd9b8c33252a0449fa25d4f96cc8c354a0c 100644 (file)
@@ -202,16 +202,21 @@ public class InputFactory extends SysdynElementFactory {
             String text = SysdynElementUtils.getInputReference(e);\r
             double scale = 0.235;\r
             AffineTransform at = ElementUtils.getTransform(e);\r
-            node.init(text, font, color, originX, font.getSize2D() * scale, scale);\r
+            node.init(text, font, color, originX, originY, scale);\r
             node.setBackgroundColor(fillColor);\r
             node.setBorderColor(borderColor);\r
             node.setHorizontalAlignment((byte) horizontalAlignment.ordinal());\r
             node.setBorderWidth((float) 0);\r
             node.setEditable(false);\r
             node.setShowSelection(false);\r
-            \r
-            if(at != null)\r
+\r
+            if(at != null) {\r
                 node.setTransform(at);\r
+                // Use affinetransform to move the name of the valve below the valve symbol\r
+                AffineTransform at2 = (AffineTransform) at.clone();\r
+                at2.translate(0, font.getSize2D() * scale);\r
+                node.setTransform(at2);\r
+            }\r
         }\r
 \r
         @Override\r
index 0ecb3a306992f53000ebe5368cb228a1936b6bff..4eaefba7a98d8b9bf387f198115d1281ca1b1717 100644 (file)
@@ -18,6 +18,11 @@ import java.util.List;
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
 import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.dnd.Clipboard;\r
+import org.eclipse.swt.dnd.TextTransfer;\r
+import org.eclipse.swt.dnd.Transfer;\r
+import org.eclipse.swt.events.KeyEvent;\r
+import org.eclipse.swt.events.KeyListener;\r
 import org.eclipse.swt.layout.GridData;\r
 import org.eclipse.swt.widgets.Composite;\r
 import org.eclipse.swt.widgets.Event;\r
@@ -71,6 +76,63 @@ public class ValueView  extends ViewPart {
                        }\r
                }; \r
                getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener);\r
+               \r
+               \r
+               /*\r
+                * A primitive copy paste to support exporting data from table to excel\r
+                * \r
+                * columnName\tcolumnName\tcolumnName\n\r
+                * value\tvalue\tvalue\n\r
+                * ...\r
+                * value\tvalue\tvalue\n\r
+                * \r
+                */\r
+                \r
+               KeyListener kl = new KeyListener() {\r
+            \r
+            @Override\r
+            public void keyReleased(KeyEvent e) {\r
+                \r
+            }\r
+            \r
+            @Override\r
+            public void keyPressed(KeyEvent e) {\r
+                if (e.stateMask == SWT.CTRL && e.keyCode == 99)\r
+                {\r
+                    System.out.println("CTRL C is pressed");\r
+                    \r
+                    Clipboard cb = new Clipboard(e.display);\r
+                    \r
+                    TextTransfer textTransfer = TextTransfer.getInstance();\r
+                    \r
+                    StringBuilder sb = new StringBuilder();\r
+                    int columnCount = table.getColumnCount();\r
+                    for(int i = 0; i < columnCount; i++) {\r
+                        TableColumn tc = table.getColumn(i);\r
+                        sb.append(tc.getText());\r
+                        if(i < columnCount - 1)\r
+                            sb.append("\t");\r
+                        else\r
+                            sb.append("\n");\r
+                    }\r
+                    \r
+                    \r
+                    for(TableItem ti : table.getSelection())\r
+                        for(int i = 0; i < columnCount; i++) {\r
+                            sb.append(ti.getText(i));\r
+                            if(i < columnCount - 1)\r
+                                sb.append("\t");\r
+                            else\r
+                                sb.append("\n");\r
+                        }\r
+                    \r
+                    cb.setContents(new Object[]{sb.toString()}, new Transfer[]{textTransfer});\r
+                }\r
+            }\r
+        };\r
+        \r
+        table.addKeyListener(kl);\r
+        \r
 \r
        }\r
 \r