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
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
}\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