added file extension php5
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / CopyAction.java
1 /*
2  * Created on 28-jul-2003
3  *
4  */
5 package com.quantum.view;
6
7 import com.quantum.QuantumPlugin;
8 import com.quantum.view.tableview.TableView;
9
10 import org.eclipse.jface.action.Action;
11 import org.eclipse.swt.dnd.TextTransfer;
12 import org.eclipse.swt.dnd.Transfer;
13 import org.eclipse.swt.widgets.Table;
14 import org.eclipse.swt.widgets.TableItem;
15
16
17 public final class CopyAction extends Action {
18         private final Table table;
19         public CopyAction(TableView view, Table table) {
20                 super();
21                 this.table = table;
22         }
23         public void run() {
24                 TableItem items[] = table.getSelection();
25                 StringBuffer text = new StringBuffer();
26                 for (int i = 0; i < items.length; i++) {
27                         int columns = table.getColumnCount();
28                         for (int col = 0; col < columns; col++) {
29                                 text.append(items[i].getText(col));
30                                 text.append('\t');
31                         }
32                         text.append('\n');
33                 }
34                 QuantumPlugin.getDefault().getSysClip().setContents(
35                         new Object[] { text.toString()},
36                         new Transfer[] { TextTransfer.getInstance()});
37         }
38 }