KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nqadmin > swingSet > formatting > FormattingTests


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

33
34 package com.nqadmin.swingSet.formatting;
35
36 import com.nqadmin.swingSet.SSDBNav;
37 import java.util.Locale JavaDoc;
38
39
40 /**
41  *
42  * @author dags
43  */

44 public class FormattingTests extends javax.swing.JFrame JavaDoc implements SSDBNav {
45     
46     /** Creates new form FormattingTests */
47     public FormattingTests() {
48         initComponents();
49     }
50     
51     /** This method is called from within the constructor to
52      * initialize the form.
53      * WARNING: Do NOT modify this code. The content of this method is
54      * always regenerated by the Form Editor.
55      */

56     private void initComponents() {//GEN-BEGIN:initComponents
57
sSConnection1 = new com.nqadmin.swingSet.datasources.SSConnection();
58         sSJdbcRowSetImpl1 = new com.nqadmin.swingSet.datasources.SSJdbcRowSetImpl();
59         rowSetHelperPopup1 = new com.nqadmin.swingSet.formatting.helpers.RowSetHelperPopup();
60         helperPopup1 = new com.nqadmin.swingSet.formatting.helpers.HelperPopup();
61         helperPopup2 = new com.nqadmin.swingSet.formatting.helpers.HelperPopup();
62         helperPopup3 = new com.nqadmin.swingSet.formatting.helpers.HelperPopup();
63         sSDataNavigator1 = new com.nqadmin.swingSet.SSDataNavigator();
64         jPanel1 = new javax.swing.JPanel JavaDoc();
65         sSFormattedTextField1 = new com.nqadmin.swingSet.formatting.SSFormattedTextField();
66         sSFormattedTextField2 = new com.nqadmin.swingSet.formatting.SSFormattedTextField();
67         sSDateField1 = new com.nqadmin.swingSet.formatting.SSDateField();
68         sSDateField2 = new com.nqadmin.swingSet.formatting.SSDateField();
69         sSBooleanField1 = new com.nqadmin.swingSet.formatting.SSBooleanField();
70         sSFormattedTextField3 = new com.nqadmin.swingSet.formatting.SSFormattedTextField();
71         sSIntegerField1 = new com.nqadmin.swingSet.formatting.SSIntegerField();
72         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
73         sSMemoField1 = new com.nqadmin.swingSet.formatting.SSMemoField();
74         jLabel1 = new javax.swing.JLabel JavaDoc();
75         jLabel2 = new javax.swing.JLabel JavaDoc();
76         jLabel3 = new javax.swing.JLabel JavaDoc();
77         jLabel5 = new javax.swing.JLabel JavaDoc();
78         jLabel6 = new javax.swing.JLabel JavaDoc();
79         jLabel7 = new javax.swing.JLabel JavaDoc();
80         jLabel8 = new javax.swing.JLabel JavaDoc();
81
82         sSConnection1.setDriverName("org.postgresql.Driver");
83         sSConnection1.setUrl("jdbc:postgresql://localhost/mag");
84         sSConnection1.setUsername("dags");
85         try {
86             sSConnection1.createConnection();
87         }
88         catch(java.lang.ClassNotFoundException JavaDoc nfe) {
89             System.out.println(nfe);
90         }
91         catch(java.lang.Exception JavaDoc ex) {
92             System.out.println(ex);
93         }
94
95         sSJdbcRowSetImpl1.setSSConnection(sSConnection1);
96         sSJdbcRowSetImpl1.setCommand("select * from accounts ORDER BY account_id");
97
98         try {
99             sSJdbcRowSetImpl1.execute();
100         }
101         catch (java.sql.SQLException JavaDoc se) {
102             System.out.println(se);
103         }
104
105         rowSetHelperPopup1.setConnection(sSConnection1);
106         rowSetHelperPopup1.setDataColumn("account_id");
107         rowSetHelperPopup1.setListColumn("account_name");
108         rowSetHelperPopup1.setOrderBy("account_name");
109         rowSetHelperPopup1.setRowSet(sSJdbcRowSetImpl1);
110
111         helperPopup1.setConnection(sSConnection1);
112         helperPopup1.setDataColumn("account_id");
113         helperPopup1.setListColumn("account_name");
114         helperPopup1.setOrderBy("account_name");
115         helperPopup1.setTable("accounts");
116
117         helperPopup2.setColumnType(1);
118         helperPopup2.setConnection(sSConnection1);
119         helperPopup2.setDataColumn("currency_id");
120         helperPopup2.setListColumn("currency_name");
121         helperPopup2.setOrderBy("currency_name");
122         helperPopup2.setTable("currencies");
123         
124         helperPopup3.setColumnType(0);
125         helperPopup3.setConnection(sSConnection1);
126         helperPopup3.setDataColumn("account_type_id");
127         helperPopup3.setListColumn("account_type_name");
128         helperPopup3.setOrderBy("account_type_name");
129         helperPopup3.setTable("accounts_types");
130         
131
132         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
133         sSDataNavigator1.setDBNav(this);
134         sSDataNavigator1.setFocusable(false);
135         sSDataNavigator1.setSSRowSet(sSJdbcRowSetImpl1);
136         getContentPane().add(sSDataNavigator1, java.awt.BorderLayout.SOUTH);
137
138         jPanel1.setLayout(null);
139
140         sSFormattedTextField1.setColumns(10);
141         sSFormattedTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
142         sSFormattedTextField1.setColumnName("account_id");
143         sSFormattedTextField1.setHelper(rowSetHelperPopup1);
144         sSFormattedTextField1.setNavigator(sSDataNavigator1);
145         sSFormattedTextField1.addActionListener(new java.awt.event.ActionListener JavaDoc() {
146             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
147                 sSFormattedTextField1ActionPerformed(evt);
148             }
149         });
150
151         jPanel1.add(sSFormattedTextField1);
152         sSFormattedTextField1.setBounds(120, 30, 70, 19);
153
154         sSFormattedTextField2.setColumnName("account_name");
155         sSFormattedTextField2.setNavigator(sSDataNavigator1);
156         jPanel1.add(sSFormattedTextField2);
157         sSFormattedTextField2.setBounds(120, 60, 310, 19);
158
159         sSDateField1.setColumnName("valid_since");
160         sSDateField1.setNavigator(sSDataNavigator1);
161         jPanel1.add(sSDateField1);
162         sSDateField1.setBounds(120, 120, 110, 19);
163
164         sSDateField2.setColumnName("valid_until");
165         sSDateField2.setNavigator(sSDataNavigator1);
166
167         jPanel1.add(sSDateField2);
168         sSDateField2.setBounds(120, 150, 110, 19);
169
170         sSBooleanField1.setText("Habilitada");
171         sSBooleanField1.setColumnName("is_enabled");
172         sSBooleanField1.setNavigator(sSDataNavigator1);
173         sSBooleanField1.setRowSet(sSJdbcRowSetImpl1);
174         jPanel1.add(sSBooleanField1);
175         sSBooleanField1.setBounds(210, 30, 110, 23);
176
177         sSFormattedTextField3.setColumns(6);
178         sSFormattedTextField3.setColumnName("currency_id");
179         sSFormattedTextField3.setHelper(helperPopup2);
180         sSFormattedTextField3.setNavigator(sSDataNavigator1);
181         sSFormattedTextField3.setSSRowSet(sSJdbcRowSetImpl1);
182         jPanel1.add(sSFormattedTextField3);
183         sSFormattedTextField3.setBounds(120, 90, 70, 19);
184
185         sSIntegerField1.setColumnName("account_type_id");
186         sSIntegerField1.setHelper(helperPopup3);
187         sSIntegerField1.setNavigator(sSDataNavigator1);
188         sSIntegerField1.setSSRowSet(sSJdbcRowSetImpl1);
189         jPanel1.add(sSIntegerField1);
190         sSIntegerField1.setBounds(120, 180, 60, 19);
191
192         sSMemoField1.setColumnName("instructions");
193         sSMemoField1.setNavigator(sSDataNavigator1);
194         sSMemoField1.setNextFocusableComponent(sSFormattedTextField1);
195         sSMemoField1.setRowSet(sSJdbcRowSetImpl1);
196         jScrollPane1.setViewportView(sSMemoField1);
197
198         jPanel1.add(jScrollPane1);
199         jScrollPane1.setBounds(120, 210, 430, 100);
200
201         jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
202         jLabel1.setText("Cuenta");
203         jPanel1.add(jLabel1);
204         jLabel1.setBounds(10, 30, 100, 15);
205
206         jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
207         jLabel2.setText("Denominacion");
208         jPanel1.add(jLabel2);
209         jLabel2.setBounds(10, 60, 100, 15);
210
211         jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
212         jLabel3.setText("Moneda");
213         jPanel1.add(jLabel3);
214         jLabel3.setBounds(10, 90, 100, 15);
215
216         jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
217         jLabel5.setText("Vigente desde");
218         jPanel1.add(jLabel5);
219         jLabel5.setBounds(10, 120, 100, 15);
220
221         jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
222         jLabel6.setText("Vigente Hasta");
223         jPanel1.add(jLabel6);
224         jLabel6.setBounds(10, 150, 100, 15);
225
226         jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
227         jLabel7.setText("Tipo");
228         jPanel1.add(jLabel7);
229         jLabel7.setBounds(10, 180, 100, 15);
230
231         jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
232         jLabel8.setText("Instrucciones");
233         jPanel1.add(jLabel8);
234         jLabel8.setBounds(10, 210, 100, 15);
235
236         getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
237
238         java.awt.Dimension JavaDoc screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
239         setBounds((screenSize.width-594)/2, (screenSize.height-376)/2, 594, 376);
240     }//GEN-END:initComponents
241

242     private void sSFormattedTextField1ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_sSFormattedTextField1ActionPerformed
243
// TODO add your handling code here:
244
}//GEN-LAST:event_sSFormattedTextField1ActionPerformed
245

246     /**
247      * @param args the command line arguments
248      */

249     public static void main(String JavaDoc args[]) {
250         java.awt.EventQueue.invokeLater(new Runnable JavaDoc() {
251             public void run() {
252                 new FormattingTests().setVisible(true);
253             }
254         });
255     }
256     
257     // Variables declaration - do not modify//GEN-BEGIN:variables
258
com.nqadmin.swingSet.formatting.helpers.HelperPopup helperPopup1;
259     com.nqadmin.swingSet.formatting.helpers.HelperPopup helperPopup2;
260     com.nqadmin.swingSet.formatting.helpers.HelperPopup helperPopup3;
261     javax.swing.JLabel JavaDoc jLabel1;
262     javax.swing.JLabel JavaDoc jLabel2;
263     javax.swing.JLabel JavaDoc jLabel3;
264     javax.swing.JLabel JavaDoc jLabel5;
265     javax.swing.JLabel JavaDoc jLabel6;
266     javax.swing.JLabel JavaDoc jLabel7;
267     javax.swing.JLabel JavaDoc jLabel8;
268     javax.swing.JPanel JavaDoc jPanel1;
269     javax.swing.JScrollPane JavaDoc jScrollPane1;
270     com.nqadmin.swingSet.formatting.helpers.RowSetHelperPopup rowSetHelperPopup1;
271     com.nqadmin.swingSet.formatting.SSBooleanField sSBooleanField1;
272     com.nqadmin.swingSet.datasources.SSConnection sSConnection1;
273     com.nqadmin.swingSet.SSDataNavigator sSDataNavigator1;
274     com.nqadmin.swingSet.formatting.SSDateField sSDateField1;
275     com.nqadmin.swingSet.formatting.SSDateField sSDateField2;
276     com.nqadmin.swingSet.formatting.SSFormattedTextField sSFormattedTextField1;
277     com.nqadmin.swingSet.formatting.SSFormattedTextField sSFormattedTextField2;
278     com.nqadmin.swingSet.formatting.SSFormattedTextField sSFormattedTextField3;
279     com.nqadmin.swingSet.formatting.SSIntegerField sSIntegerField1;
280     com.nqadmin.swingSet.datasources.SSJdbcRowSetImpl sSJdbcRowSetImpl1;
281     com.nqadmin.swingSet.formatting.SSMemoField sSMemoField1;
282     // End of variables declaration//GEN-END:variables
283

284     public void performNavigationOps(int _navigationType) {
285         System.out.println("performNavigationOps");
286     }
287     
288     public void performRefreshOps() {
289     }
290     
291     public void performPreInsertOps() {
292         System.out.println("performPreInsertOps");
293         
294         sSFormattedTextField1.setValue(new Integer JavaDoc(99999999));
295         sSFormattedTextField2.setValue(new String JavaDoc("nombre de la nueva cuenta"));
296         sSFormattedTextField3.setValue(new String JavaDoc("ARS"));
297         sSDateField1.setValue(new java.sql.Date JavaDoc(2000));
298         sSDateField2.setValue(new java.sql.Date JavaDoc(2001));
299         sSIntegerField1.setValue(new Integer JavaDoc(1));
300         sSMemoField1.setText("Esta es una instruccion de ejemplo");
301         sSBooleanField1.setSelected(true);
302         
303         /*
304         try {
305            
306             rowset.updateInt( "account_id" , new Integer(999999));
307             rowset.updateString( "account_name" , "Nueva Cuenta");
308             rowset.updateString( "currency_id" , "ARS");
309             rowset.updateString( "instructions" , "Aqui van las instrucciones");
310             rowset.updateInt( "account_type_id", new Integer(1));
311             rowset.updateBoolean("is_enabled" , false);
312             rowset.updateDate( "valid_since" , new java.sql.Date(1000));
313             rowset.updateDate( "valid_until" , new java.sql.Date(1001));
314             rowset.insertRow();
315             rowset.moveToCurrentRow();
316              
317             System.out.println("defaults setted");
318                     
319         } catch (java.sql.SQLException se) {
320             System.out.println("performPreInsertOps ---> Exception : " + se);
321         }
322          */

323     }
324     
325     public void performPreDeletionOps() {
326     }
327     
328     public void performPostInsertOps() {
329         System.out.println("performPostInsertOptions");
330     }
331     
332     public void performPostDeletionOps() {
333     }
334     
335     public void performCancelOps() {
336     }
337     
338 }
339
Popular Tags