1 18 19 package org.objectweb.jac.aspects.gui; 20 21 import java.awt.datatransfer.DataFlavor ; 22 import java.awt.datatransfer.StringSelection ; 23 import java.awt.datatransfer.Transferable ; 24 import java.util.List ; 25 import java.util.StringTokenizer ; 26 import java.util.Vector ; 27 import org.apache.log4j.Logger; 28 import org.objectweb.jac.core.NameRepository; 29 import org.objectweb.jac.core.Wrappee; 30 31 34 35 public class Transfer 36 { 37 static final Logger logger = Logger.getLogger("gui.dnd"); 38 39 43 public static Transferable getJACTransfer(Wrappee[] wrappees) { 44 String names=""; 45 for(int i=0;i<wrappees.length;i++) { 46 names=names+NameRepository.get().getName(wrappees[i]); 47 if(i+1<wrappees.length) 48 names=names+","; 49 } 50 return new StringSelection (names); 51 } 52 53 57 public static List getTransferedWrappees(Transferable transferable) { 58 Vector ret = new Vector (); 59 try { 60 String names = ""; 61 StringTokenizer st = new StringTokenizer ( 62 (String )transferable.getTransferData(DataFlavor.stringFlavor),","); 63 while(st.hasMoreTokens()) { 64 String s = st.nextToken(); 65 ret.add(NameRepository.get().getObject(s)); 66 } 67 } catch(Exception e) { 68 logger.error("getTransferedWrappees "+transferable,e); 69 } 70 return ret; 71 } 72 73 } 74 75 | Popular Tags |