initial quantum version
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / CopyAction.java
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/CopyAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/CopyAction.java
new file mode 100644 (file)
index 0000000..27fe957
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Created on 28-jul-2003
+ *
+ */
+package com.quantum.view;
+
+import com.quantum.QuantumPlugin;
+import com.quantum.view.tableview.TableView;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+
+public final class CopyAction extends Action {
+       private final TableView view;
+       private final Table table;
+       public CopyAction(TableView view, Table table) {
+               super();
+               this.view = view;
+               this.table = table;
+       }
+       public void run() {
+               TableItem items[] = table.getSelection();
+               StringBuffer text = new StringBuffer();
+               for (int i = 0; i < items.length; i++) {
+                       int columns = table.getColumnCount();
+                       for (int col = 0; col < columns; col++) {
+                               text.append(items[i].getText(col));
+                               text.append('\t');
+                       }
+                       text.append('\n');
+               }
+               QuantumPlugin.getDefault().getSysClip().setContents(
+                       new Object[] { text.toString()},
+                       new Transfer[] { TextTransfer.getInstance()});
+       }
+}
\ No newline at end of file