01: /*
02:
03: * Form.java
04:
05: *
06:
07: * Created on October 20, 2006, 3:45 PM
08:
09: *
10:
11: * To change this template, choose Tools | Template Manager
12:
13: * and open the template in the editor.
14:
15: */
16:
17: package org.netbeans.modules.mobility.snippets;
18:
19: import javax.swing.text.BadLocationException;
20:
21: import javax.swing.text.JTextComponent;
22:
23: import org.openide.text.ActiveEditorDrop;
24:
25: /**
26:
27: *
28:
29: * @author bohemius
30:
31: */
32:
33: public class Form implements ActiveEditorDrop {
34:
35: /** Creates a new instance of Form */
36:
37: public Form() {
38:
39: }
40:
41: public boolean handleTransfer(JTextComponent targetComponent) {
42:
43: StringBuffer body = new StringBuffer("");
44:
45: body
46: .append("private javax.microedition.lcdui.Form myForm=null;\n\n");
47:
48: body
49: .append("public javax.microedition.lcdui.Form get_myForm() {\n");
50:
51: body.append(" if (myForm==null)\n");
52:
53: body
54: .append(" myForm=new javax.microedition.lcdui.Form(\"Sample Form\");\n");
55:
56: body.append(" return myForm;\n");
57:
58: body.append("}\n\n");
59:
60: try {
61:
62: SnippetsPaletteUtilities.insert(body.toString(),
63: targetComponent);
64:
65: } catch (BadLocationException ble) {
66:
67: return false;
68:
69: }
70:
71: return true;
72:
73: }
74:
75: }
|