2 * Created on 11/08/2003
5 package com.quantum.actions;
7 import java.util.Iterator;
9 import com.quantum.QuantumPlugin;
10 import com.quantum.model.Column;
11 import com.quantum.model.EntityHolder;
12 import com.quantum.util.NthLevelConverter;
13 import com.quantum.util.QuantumUtil;
14 import com.quantum.util.StringUtil;
15 import com.quantum.view.bookmark.ColumnNode;
17 import org.eclipse.jface.preference.IPreferenceStore;
18 import org.eclipse.swt.dnd.TextTransfer;
19 import org.eclipse.swt.dnd.Transfer;
20 import org.eclipse.ui.IViewPart;
21 import org.eclipse.ui.actions.SelectionListenerAction;
24 public class CustomCopyAction extends SelectionListenerAction {
25 private final IViewPart view;
26 private final int ind;
30 public CustomCopyAction(IViewPart view, int ind) {
37 Iterator iter = getSelectedNonResources().iterator();
38 NthLevelConverter converter = new NthLevelConverter();
39 // Fill up the converter. We iterate the selection items
40 while (iter.hasNext()) {
41 Object current = iter.next();
42 if (current instanceof ColumnNode) {
43 ColumnNode column = (ColumnNode) current;
45 converter.add(column.getColumn().getName(),
46 column.getColumn().getParentEntity().getCondQualifiedName(), 0);
48 } else if (current instanceof EntityHolder) {
49 EntityHolder currentSelec = (EntityHolder) current;
50 converter.add(currentSelec.getEntity().getCondQualifiedName(), null, 1);
51 Column[] columns = currentSelec.getEntity().getColumns();
52 for (int i = 0, length = (columns == null) ? 0 : columns.length;
55 converter.add(columns[i].getName(),
56 currentSelec.getEntity().getCondQualifiedName(), 0);
60 IPreferenceStore store = QuantumPlugin.getDefault().getPreferenceStore();
63 converter.convert(Integer.toString(ind));
65 String template = QuantumUtil.trasposeEscape(store.getString("customCopyTemplate" + Integer.toString(ind)));
66 copyText = StringUtil.substituteString(template, "${table_list}", converter.getTableList());
69 QuantumPlugin.getDefault().getSysClip().setContents(
70 new Object[] { copyText },
71 new Transfer[] { TextTransfer.getInstance()});