1 15 16 package org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel; 17 18 import org.apache.ojb.tools.mapping.reversedb2.dnd2.*; 19 import java.awt.Component ; 20 import java.awt.datatransfer.Transferable ; 21 import java.awt.Image ; 22 import org.apache.ojb.broker.metadata.AttributeDescriptorBase; 23 27 public class OjbMetaTreeNodesDragWorker implements DragCopyCutWorkerInterface 28 { 29 30 31 public OjbMetaTreeNodesDragWorker() 32 { 33 } 34 35 42 public void exportDone(Component c, int action) 43 { 44 } 45 46 53 public void exportStarted(Component c, int action) 54 { 55 } 56 57 63 public int getAcceptableActions(Component c) 64 { 65 if (c instanceof javax.swing.JTree 66 && ((javax.swing.JTree )c).getModel() instanceof OjbMetaDataTreeModel) 67 return DnDWorkerConstants.DRAG_COPY | DnDWorkerConstants.DRAG_LINK; 68 else return DnDWorkerConstants.NONE; 69 } 70 71 80 public Image getDragImage(Component c, Transferable t, int action) 81 { 82 return null; 83 } 84 85 93 public Transferable getTransferable(Component c) 94 { 95 if (c instanceof javax.swing.JTree 96 && ((javax.swing.JTree )c).getModel() instanceof OjbMetaDataTreeModel) 97 { 98 try 99 { 100 javax.swing.JTree tree = (javax.swing.JTree )c; 101 OjbMetaDataTreeModel model = (OjbMetaDataTreeModel)tree.getModel(); 102 AttributeDescriptorBase descriptors[] = new AttributeDescriptorBase[tree.getSelectionCount()]; 103 for (int i = 0; tree.getSelectionPaths() != null && i < tree.getSelectionPaths().length; i++) 104 { 105 Object o = ((OjbMetaTreeNode)tree.getSelectionPaths()[i].getLastPathComponent()).getAssociatedDescriptor(); 106 if (o instanceof AttributeDescriptorBase) 107 { 108 System.err.println(" adding Node" + o); 109 descriptors[i] = (AttributeDescriptorBase) o; 110 } 111 } 112 return new OjbMetadataTransferable(descriptors); 113 } 114 catch (Throwable t) 115 { 116 t.printStackTrace(); 117 } 118 } 119 return null; 120 } 121 122 } 123 | Popular Tags |