KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nqadmin > swingSet > SSTextArea


1 /* $Id: SSTextArea.java,v 1.14 2005/02/21 16:31:33 prasanth Exp $
2  *
3  * Tab Spacing = 4
4  *
5  * Copyright (c) 2003-2005, The Pangburn Company and Prasanth R. Pasala
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer. Redistributions in binary
13  * form must reproduce the above copyright notice, this list of conditions and
14  * the following disclaimer in the documentation and/or other materials
15  * provided with the distribution. The names of its contributors may not be
16  * used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  */

32
33 package com.nqadmin.swingSet;
34
35 import javax.swing.*;
36 import java.awt.event.*;
37 import java.awt.*;
38 import com.nqadmin.swingSet.datasources.SSRowSet;
39
40 /**
41  * SSTextArea.java
42  *<p>
43  * SwingSet - Open Toolkit For Making Swing Controls Database-Aware
44  *<p><pre>
45  * SSTextArea extends the JTextArea to add SSRowSet binding.
46  *</pre><p>
47  * @author $Author: prasanth $
48  * @version $Revision: 1.14 $
49  */

50 public class SSTextArea extends JTextArea {
51
52     /**
53      * SSRowSet from which component will get/set values.
54      */

55     protected SSRowSet sSRowSet;
56
57     /**
58      * SSRowSet column to which the component will be bound.
59      */

60     protected String JavaDoc columnName = "";
61
62     /**
63      * Empty constructor needed for deserialization.
64      */

65     public SSTextArea() {
66         init();
67     }
68
69     /**
70      * Constructs a new empty SSTextArea with the specified number of rows and columns.
71      *
72      * @param _rows the number of rows >= 0
73      * @param _columns the number of columns >= 0
74      */

75     public SSTextArea(int _rows, int _columns) {
76         super(_rows, _columns);
77         //init(); - NO NEED TO SET DIMENSIONS AS THAT IS THE POINT OF THIS CONSTRUCTOR
78
}
79
80     /**
81      * Creates a multi-line text box and binds it to the specified SSRowSet column.
82      *
83      * @param _sSRowSet datasource to be used.
84      * @param _columnName name of the column to which this text area should be bound
85      */

86     public SSTextArea(SSRowSet _sSRowSet, String JavaDoc _columnName) {
87         sSRowSet = _sSRowSet;
88         columnName = _columnName;
89         init();
90         bind();
91     }
92
93     /**
94      * Sets the SSRowSet column name to which the component is bound.
95      *
96      * @param _columnName column name in the SSRowSet to which the component
97      * is bound
98      */

99     public void setColumnName(String JavaDoc _columnName) {
100         String JavaDoc oldValue = columnName;
101         columnName = _columnName;
102         firePropertyChange("columnName", oldValue, columnName);
103         bind();
104     }
105
106     /**
107      * Returns the SSRowSet column name to which the component is bound.
108      *
109      * @return column name to which the component is bound
110      */

111     public String JavaDoc getColumnName() {
112         return columnName;
113     }
114
115     /**
116      * Sets the SSRowSet to which the component is bound.
117      *
118      * @param _sSRowSet SSRowSet to which the component is bound
119      */

120     public void setSSRowSet(SSRowSet _sSRowSet) {
121         SSRowSet oldValue = sSRowSet;
122         sSRowSet = _sSRowSet;
123         firePropertyChange("sSRowSet", oldValue, sSRowSet);
124         bind();
125     }
126
127     /**
128      * Returns the SSRowSet to which the component is bound.
129      *
130      * @return SSRowSet to which the component is bound
131      */

132     public SSRowSet getSSRowSet() {
133         return sSRowSet;
134     }
135
136     /**
137      * Sets the SSRowSet and column name to which the component is to be bound.
138      *
139      * @param _sSRowSet datasource to be used.
140      * @param _columnName Name of the column to which this check box should be bound
141      */

142     public void bind(SSRowSet _sSRowSet, String JavaDoc _columnName) {
143         SSRowSet oldValue = sSRowSet;
144         sSRowSet = _sSRowSet;
145         firePropertyChange("sSRowSet", oldValue, sSRowSet);
146
147         String JavaDoc oldValue2 = columnName;
148         columnName = _columnName;
149         firePropertyChange("columnName", oldValue2, columnName);
150
151         bind();
152     }
153
154     /**
155      * Initialization code.
156      */

157     protected void init() {
158
159         // SET PREFERRED DIMENSIONS
160
setPreferredSize(new Dimension(200,80));
161     }
162
163     /**
164      * Method for handling binding of component to a SSRowSet column.
165      */

166     protected void bind() {
167
168         // CHECK FOR NULL COLUMN/ROWSET
169
if (columnName==null || columnName.trim().equals("") || sSRowSet==null) {
170                 return;
171             }
172
173         // REMOVE LISTENERS TO PREVENT DUPLICATION
174
// removeListeners();
175

176         // BIND THE TEXT AREA TO THE SPECIFIED COLUMN
177
setDocument(new SSTextDocument(sSRowSet, columnName));
178
179         // ADD BACK LISTENERS
180
// addListeners();;
181

182     }
183
184
185 } // end public class SSTextArea extends JTextArea {
186

187
188
189 /*
190  * $Log: SSTextArea.java,v $
191  * Revision 1.14 2005/02/21 16:31:33 prasanth
192  * In bind checking for empty columnName before binding the component.
193  *
194  * Revision 1.13 2005/02/13 15:38:20 yoda2
195  * Removed redundant PropertyChangeListener and VetoableChangeListener class variables and methods from components with JComponent as an ancestor.
196  *
197  * Revision 1.12 2005/02/12 03:29:26 yoda2
198  * Added bound properties (for beans).
199  *
200  * Revision 1.11 2005/02/11 22:59:46 yoda2
201  * Imported PropertyVetoException and added some bound properties.
202  *
203  * Revision 1.10 2005/02/11 20:16:06 yoda2
204  * Added infrastructure to support property & vetoable change listeners (for beans).
205  *
206  * Revision 1.9 2005/02/10 20:13:03 yoda2
207  * Setter/getter cleanup & method reordering for consistency.
208  *
209  * Revision 1.8 2005/02/09 19:06:06 yoda2
210  * JavaDoc cleanup.
211  *
212  * Revision 1.7 2005/02/07 22:20:10 yoda2
213  * Added constructor to set component dimensions.
214  *
215  * Revision 1.6 2005/02/05 05:16:33 yoda2
216  * API cleanup.
217  *
218  * Revision 1.5 2005/02/04 22:48:54 yoda2
219  * API cleanup & updated Copyright info.
220  *
221  * Revision 1.4 2004/11/11 14:45:48 yoda2
222  * Using TextPad, converted all tabs to "soft" tabs comprised of four actual spaces.
223  *
224  * Revision 1.3 2004/10/25 22:13:43 yoda2
225  * Updated JavaDoc for new datasource abstraction layer in 0.9.0 release.
226  *
227  * Revision 1.2 2004/10/25 19:51:03 prasanth
228  * Modified to use the new SSRowSet instead of RowSet.
229  *
230  * Revision 1.1 2004/10/01 20:43:53 yoda2
231  * Added SSTextArea which is a simple extension of JTextArea with support for sSRowSet binding.
232  *
233  */
Popular Tags