1 19 20 package org.netbeans.modules.web.core.palette; 21 import java.awt.datatransfer.DataFlavor ; 22 import java.awt.datatransfer.Transferable ; 23 import org.netbeans.spi.palette.DragAndDropHandler; 24 import org.openide.text.ActiveEditorDrop; 25 import org.openide.util.Lookup; 26 import org.openide.util.datatransfer.ExTransferable; 27 28 32 public class JSPDragAndDropHandler extends DragAndDropHandler { 33 34 public JSPDragAndDropHandler() { 35 } 36 37 public void customize(ExTransferable t, Lookup item) { 38 39 ActiveEditorDrop drop = (ActiveEditorDrop) item.lookup(ActiveEditorDrop.class); 40 if (drop == null) { 41 String body = (String ) item.lookup(String .class); 42 drop = new JSPEditorDropDefault(body); 43 } 44 45 JSPPaletteItemTransferable s = new JSPPaletteItemTransferable(drop); 46 t.put(s); 47 48 } 49 50 public boolean canDrop(Lookup targetCategory, DataFlavor [] flavors, int dndAction) { 51 return false; 52 } 53 54 public boolean doDrop(Lookup targetCategory, Transferable item, int dndAction, int dropIndex) { 55 return false; 56 } 57 58 private static class JSPPaletteItemTransferable extends ExTransferable.Single { 59 60 private ActiveEditorDrop drop; 61 62 JSPPaletteItemTransferable(ActiveEditorDrop drop) { 63 super(ActiveEditorDrop.FLAVOR); 64 65 this.drop = drop; 66 } 67 68 public Object getData () { 69 return drop; 70 } 71 72 } 73 74 } 75 | Popular Tags |