KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > html > palette > items > FILESEL


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.html.palette.items;
21 import javax.swing.text.BadLocationException JavaDoc;
22 import javax.swing.text.JTextComponent JavaDoc;
23 import org.netbeans.modules.html.palette.HTMLPaletteUtilities;
24 import org.openide.text.ActiveEditorDrop;
25
26
27 /**
28  *
29  * @author Libor Kotouc
30  */

31 public class FILESEL implements ActiveEditorDrop {
32
33     private String JavaDoc name = "";
34     private String JavaDoc width = "";
35     private boolean disabled = false;
36
37     public FILESEL() {
38     }
39
40     public boolean handleTransfer(JTextComponent JavaDoc targetComponent) {
41
42         FILESELCustomizer c = new FILESELCustomizer(this);
43         boolean accept = c.showDialog();
44         if (accept) {
45             String JavaDoc body = createBody();
46             try {
47                 HTMLPaletteUtilities.insert(body, targetComponent);
48             } catch (BadLocationException JavaDoc ble) {
49                 accept = false;
50             }
51         }
52         
53         return accept;
54     }
55
56     private String JavaDoc createBody() {
57         
58         String JavaDoc strName = " name=\"" + name + "\""; // NOI18N
59

60         String JavaDoc strWidth = "";
61         if (width.length() > 0)
62             strWidth = " width=\"" + width + "\""; // NOI18N
63

64         String JavaDoc strDisabled = (disabled ? " disabled=\"disabled\"" : ""); // NOI18N
65

66         String JavaDoc fileselBody = "<input type=\"file\"" + strName + " value=\"\"" + strWidth + strDisabled + " />"; // NOI18N
67

68         return fileselBody;
69     }
70
71     public String JavaDoc getName() {
72         return name;
73     }
74
75     public void setName(String JavaDoc name) {
76         this.name = name;
77     }
78
79     public String JavaDoc getWidth() {
80         return width;
81     }
82
83     public void setWidth(String JavaDoc width) {
84         this.width = width;
85     }
86
87     public boolean isDisabled() {
88         return disabled;
89     }
90
91     public void setDisabled(boolean disabled) {
92         this.disabled = disabled;
93     }
94         
95 }
96
Popular Tags