X-Git-Url: http://git.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/CustomCopyAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/CustomCopyAction.java new file mode 100644 index 0000000..24ea456 --- /dev/null +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/CustomCopyAction.java @@ -0,0 +1,73 @@ +/* + * Created on 11/08/2003 + * + */ +package com.quantum.actions; + +import java.util.Iterator; + +import com.quantum.QuantumPlugin; +import com.quantum.model.Column; +import com.quantum.model.EntityHolder; +import com.quantum.util.NthLevelConverter; +import com.quantum.util.QuantumUtil; +import com.quantum.util.StringUtil; +import com.quantum.view.bookmark.ColumnNode; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.swt.dnd.TextTransfer; +import org.eclipse.swt.dnd.Transfer; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.actions.SelectionListenerAction; + + +public class CustomCopyAction extends SelectionListenerAction { + private final IViewPart view; + private final int ind; + /** + * @param BookmarkView + */ + public CustomCopyAction(IViewPart view, int ind) { + super(null); + this.view = view; + this.ind = ind; + } + public void run() { + String copyText = ""; + Iterator iter = getSelectedNonResources().iterator(); + NthLevelConverter converter = new NthLevelConverter(); + // Fill up the converter. We iterate the selection items + while (iter.hasNext()) { + Object current = iter.next(); + if (current instanceof ColumnNode) { + ColumnNode column = (ColumnNode) current; + if (column != null) { + converter.add(column.getColumn().getName(), + column.getColumn().getParentEntity().getCondQualifiedName(), 0); + } + } else if (current instanceof EntityHolder) { + EntityHolder currentSelec = (EntityHolder) current; + converter.add(currentSelec.getEntity().getCondQualifiedName(), null, 1); + Column[] columns = currentSelec.getEntity().getColumns(); + for (int i = 0, length = (columns == null) ? 0 : columns.length; + i < length; + i++) { + converter.add(columns[i].getName(), + currentSelec.getEntity().getCondQualifiedName(), 0); + } + } + } + IPreferenceStore store = QuantumPlugin.getDefault().getPreferenceStore(); + + + converter.convert(Integer.toString(ind)); + + String template = QuantumUtil.trasposeEscape(store.getString("customCopyTemplate" + Integer.toString(ind))); + copyText = StringUtil.substituteString(template, "${table_list}", converter.getTableList()); + + + QuantumPlugin.getDefault().getSysClip().setContents( + new Object[] { copyText }, + new Transfer[] { TextTransfer.getInstance()}); + } +}