1 package org.apache.ojb.tools.mapping.reversedb2.dnd2; 2 3 17 18 import java.awt.Component ; 19 import java.awt.datatransfer.Transferable ; 20 import java.awt.Image ; 21 import org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.*; 22 import org.apache.ojb.tools.mapping.reversedb2.datatransfer.*; 23 24 28 public class ReverseDbNodesDragWorker implements DragCopyCutWorkerInterface 29 { 30 31 32 public ReverseDbNodesDragWorker () 33 { 34 } 35 36 public void exportDone (Component c, int action) 37 { 38 System.err.println("exportDone"); 39 } 40 41 public void exportStarted (Component c, int action) 42 { 43 System.err.println("exportStarted"); 44 } 45 46 public int getAcceptableActions (Component c) 47 { 48 return DnDWorkerConstants.DRAG_COPY | DnDWorkerConstants.DRAG_LINK; 49 } 50 51 public Image getDragImage (Component c, Transferable t, int action) 52 { 53 return null; 54 } 55 56 public Transferable getTransferable (Component c) 57 { 58 System.err.println("getTransferable()"); 59 try 60 { 61 if (c instanceof javax.swing.JTree ) 62 { 63 System.err.println(" e is a JTree"); 64 javax.swing.JTree jtree = (javax.swing.JTree )c; 65 if (jtree.getModel() instanceof DatabaseMetaDataTreeModel) 66 { 67 System.err.println(" and has a DatabaseMetaDataTreeModel"); 68 ReverseDbTreeNode[] selectedNodes = 69 new ReverseDbTreeNode[jtree.getSelectionCount()]; 70 for (int i = 0; jtree.getSelectionPaths() != null && i < jtree.getSelectionPaths().length; i++) 71 { 72 System.err.println(" adding Node" + jtree.getSelectionPaths()[i].getLastPathComponent()); 73 selectedNodes[i] = (ReverseDbTreeNode) jtree.getSelectionPaths()[i].getLastPathComponent(); 74 } 75 return new TransferableDBMetaTreeNodes(selectedNodes); 76 } 77 } 78 } 79 catch (Throwable t) 80 { 81 t.printStackTrace(); 82 } 83 System.err.println(" returning null"); 84 return null; 85 } 86 87 } 88 | Popular Tags |