KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > util > CTextField


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18
package org.columba.core.gui.util;
19
20 import javax.swing.JComponent JavaDoc;
21 import javax.swing.JTextField JavaDoc;
22
23 import org.columba.core.gui.base.UndoDocument;
24
25 /**
26  * Additionally registers at the FocusManager.
27  *
28  * @author fdietz
29  */

30
31 public class CTextField extends JTextField JavaDoc {
32     /**
33      *
34      */

35     public CTextField() {
36         super();
37
38         setDocument(new UndoDocument());
39     }
40
41     /**
42      * @param arg0
43      */

44     public CTextField(String JavaDoc arg0) {
45         this();
46
47         setText(arg0);
48     }
49
50     /** ****************** FocusOwner implementation ************************* */
51     public JComponent JavaDoc getComponent() {
52         return this;
53     }
54
55     public boolean isCopyActionEnabled() {
56         if (getSelectedText() == null) {
57             return false;
58         }
59
60         if (getSelectedText().length() > 0) {
61             return true;
62         }
63
64         return false;
65     }
66
67     public boolean isCutActionEnabled() {
68         if (getSelectedText() == null) {
69             return false;
70         }
71
72         if (getSelectedText().length() > 0) {
73             return true;
74         }
75
76         return false;
77     }
78
79     public boolean isDeleteActionEnabled() {
80         if (getSelectedText() == null) {
81             return false;
82         }
83
84         if (getSelectedText().length() > 0) {
85             return true;
86         }
87
88         return false;
89     }
90
91     public boolean isPasteActionEnabled() {
92         return true;
93     }
94
95     public boolean isRedoActionEnabled() {
96         // TODO: use UndoableEditEvent to make this really work
97
return true;
98     }
99
100     public boolean isSelectAllActionEnabled() {
101         return true;
102     }
103
104     public boolean isUndoActionEnabled() {
105         // TODO: use UndoableEditEvent to make this really work
106
return true;
107     }
108
109     public void delete() {
110         replaceSelection("");
111     }
112
113     public void redo() {
114         ((UndoDocument) getDocument()).redo();
115     }
116
117     public void undo() {
118         ((UndoDocument) getDocument()).undo();
119     }
120 }
121
Popular Tags