Thursday May 15, 2008

Drag and Drop Text into Palette Window to Create Custom Code CLips

The Common Palette associated with HTML editor has been improved a bit - now it's possible to drag any text and drop it in the palette window to create a new custom code snippet:

Other editors will follow soon. Adding such support to your own palette is quite easy. Just override
org.netbeans.spi.palette.DragAndDropHandler
and let it handle everything:

class MyDragAndDropHandler extends DragAndDropHandler {
    MyDragAndDropHandler() {
       super( true );
    }
    
    public void customize(ExTransferable t, Lookup item) {
    }
}

...

PaletteFactory.createPalette("_path_to_my_palette_root_", 
                             new MyPaletteActions(), 
                             null, 
                             new MyDragAndDropHandler());

About

Stanislav Aubrecht

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today