KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > gui > subdataset > GroupDialog


1 /*
2  * Copyright (C) 2005 - 2006 JasperSoft Corporation. All rights reserved.
3  * http://www.jaspersoft.com.
4  *
5  * Unless you have purchased a commercial license agreement from JasperSoft,
6  * the following license terms apply:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as published by
10  * the Free Software Foundation.
11  *
12  * This program is distributed WITHOUT ANY WARRANTY; and without the
13  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
18  * or write to:
19  *
20  * Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330,
22  * Boston, MA USA 02111-1307
23  *
24  *
25  *
26  *
27  * GroupDialog.java
28  *
29  * Created on 9 maggio 2003, 17.25
30  *
31  */

32
33 package it.businesslogic.ireport.gui.subdataset;
34 import it.businesslogic.ireport.SubDataset;
35 import it.businesslogic.ireport.gui.JRParameterDialog;
36 import it.businesslogic.ireport.util.I18n;
37 /**
38  *
39  * @author Administrator
40  */

41 public class GroupDialog extends javax.swing.JDialog JavaDoc {
42     /** Creates new form JRParameterDialog */
43     private String JavaDoc groupName;
44     private String JavaDoc expression;
45     private int minHeightStartNewPage = 0;
46     private int headerBandHeight = 0;
47     private int footerBandHeight = 0;
48     private boolean startNewPage = false;
49     private boolean startNewColumn = false;
50     private boolean printHeaderEachPage = false;
51     private boolean resetPageNumber = false;
52     
53     private SubDataset subDataset = null;
54         
55     public GroupDialog(java.awt.Dialog JavaDoc dialog, boolean modal) {
56         super( dialog, modal);
57         initComponents();
58         applyI18n();
59         this.jRTextExpressionArea.setText("");
60         
61         javax.swing.KeyStroke JavaDoc escape = javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0, false);
62             javax.swing.Action JavaDoc escapeAction = new javax.swing.AbstractAction JavaDoc() {
63                 public void actionPerformed(java.awt.event.ActionEvent JavaDoc e) {
64                     jButtonCancelActionPerformed(e);
65                 }
66             };
67
68             getRootPane().getInputMap(javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
69             getRootPane().getActionMap().put("ESCAPE", escapeAction);
70
71
72             //to make the default button ...
73
this.getRootPane().setDefaultButton(this.jButtonOK);
74     }
75     
76       
77     /** This method is called from within the constructor to
78      * initialize the form.
79      * WARNING: Do NOT modify this code. The content of this method is
80      * always regenerated by the Form Editor.
81      */

82     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
83
private void initComponents() {
84         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
85
86         jLabel1 = new javax.swing.JLabel JavaDoc();
87         jTextFieldName = new javax.swing.JTextField JavaDoc();
88         jLabel3 = new javax.swing.JLabel JavaDoc();
89         jRTextExpressionArea = new it.businesslogic.ireport.gui.JRTextExpressionArea();
90         jPanel1 = new javax.swing.JPanel JavaDoc();
91         jButtonOK = new javax.swing.JButton JavaDoc();
92         jButtonCancel = new javax.swing.JButton JavaDoc();
93
94         getContentPane().setLayout(new java.awt.GridBagLayout JavaDoc());
95
96         setTitle("Add/modify group");
97         setModal(true);
98         setResizable(false);
99         addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
100             public void windowClosing(java.awt.event.WindowEvent JavaDoc evt) {
101                 closeDialog(evt);
102             }
103         });
104
105         jLabel1.setText("Group name");
106         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
107         gridBagConstraints.gridx = 0;
108         gridBagConstraints.gridy = 0;
109         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
110         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 3, 3);
111         getContentPane().add(jLabel1, gridBagConstraints);
112
113         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
114         gridBagConstraints.gridx = 0;
115         gridBagConstraints.gridy = 1;
116         gridBagConstraints.gridwidth = 2;
117         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
118         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
119         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 3, 3);
120         getContentPane().add(jTextFieldName, gridBagConstraints);
121
122         jLabel3.setText("Group expression");
123         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
124         gridBagConstraints.gridx = 0;
125         gridBagConstraints.gridy = 5;
126         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
127         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 3, 3);
128         getContentPane().add(jLabel3, gridBagConstraints);
129
130         jRTextExpressionArea.setBorder(javax.swing.BorderFactory.createEtchedBorder());
131         jRTextExpressionArea.setPreferredSize(new java.awt.Dimension JavaDoc(300, 70));
132         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
133         gridBagConstraints.gridx = 0;
134         gridBagConstraints.gridy = 6;
135         gridBagConstraints.gridwidth = 2;
136         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
137         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
138         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 3, 3);
139         getContentPane().add(jRTextExpressionArea, gridBagConstraints);
140
141         jPanel1.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.RIGHT));
142
143         jButtonOK.setText("OK");
144         jButtonOK.setMnemonic('o');
145         jButtonOK.addActionListener(new java.awt.event.ActionListener JavaDoc() {
146             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
147                 jButtonOKActionPerformed(evt);
148             }
149         });
150
151         jPanel1.add(jButtonOK);
152
153         jButtonCancel.setText("Cancel");
154         jButtonCancel.setMnemonic('c');
155         jButtonCancel.addActionListener(new java.awt.event.ActionListener JavaDoc() {
156             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
157                 jButtonCancelActionPerformed(evt);
158             }
159         });
160
161         jPanel1.add(jButtonCancel);
162
163         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
164         gridBagConstraints.gridx = 0;
165         gridBagConstraints.gridy = 9;
166         gridBagConstraints.gridwidth = 2;
167         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
168         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
169         gridBagConstraints.weightx = 1.0;
170         gridBagConstraints.weighty = 1.0;
171         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 3, 3);
172         getContentPane().add(jPanel1, gridBagConstraints);
173
174         pack();
175         java.awt.Dimension JavaDoc screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
176         java.awt.Dimension JavaDoc dialogSize = getSize();
177         setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
178     }// </editor-fold>//GEN-END:initComponents
179

180     private void jButtonCancelActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
181
setVisible(false);
182         this.setDialogResult( javax.swing.JOptionPane.CANCEL_OPTION);
183         dispose();
184     }//GEN-LAST:event_jButtonCancelActionPerformed
185

186     private void jButtonOKActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonOKActionPerformed
187

188         if (this.jTextFieldName.getText().trim().length() <= 0)
189         {
190             javax.swing.JOptionPane.showMessageDialog(this,
191                     I18n.getString( "messages.jRGroupDialog.notValidGroupName","Please insert a valid group name!"),
192                     I18n.getString( "messages.jRGroupDialog.notValidGroupNameCaption","Invalid name!"),
193                     javax.swing.JOptionPane.WARNING_MESSAGE );
194             return;
195         }
196         
197         setGroupName( this.jTextFieldName.getText() );
198         // TODO: Control height!
199
/*
200         setHeaderBandHeight( (int)this.jNumberFieldHeaderBand.getValue());
201         setFooterBandHeight( (int)this.jNumberFieldFooterBand.getValue());
202         setMinHeightStartNewPage( (int)this.jNumberFieldMinStartNewPage.getValue());
203         
204         setStartNewColumn( jCheckBoxStartNewColumn.isSelected());
205         setStartNewPage( jCheckBoxStartNewPage.isSelected());
206         setPrintHeaderEachPage( jCheckBoxPrintHeaderEachPage.isSelected());
207         setResetPageNumber( jCheckBoxResetPageNumber.isSelected());
208         */

209         setExpression( jRTextExpressionArea.getText() );
210         
211         setVisible(false);
212         this.setDialogResult( javax.swing.JOptionPane.OK_OPTION);
213         dispose();
214     }//GEN-LAST:event_jButtonOKActionPerformed
215

216     /** Closes the dialog */
217     private void closeDialog(java.awt.event.WindowEvent JavaDoc evt) {//GEN-FIRST:event_closeDialog
218
setVisible(false);
219         this.setDialogResult( javax.swing.JOptionPane.CLOSED_OPTION);
220         dispose();
221     }//GEN-LAST:event_closeDialog
222

223     /**
224      * @param args the command line arguments
225      */

226     public static void main(String JavaDoc args[]) {
227         new JRParameterDialog(new javax.swing.JFrame JavaDoc(), true).setVisible(true);
228     }
229     
230     /** Setter for property tmpParameter.
231      * @param tmpParameter New value of property tmpParameter.
232      *
233      */

234     public void setGroup(it.businesslogic.ireport.Group group) {
235         this.jTextFieldName.setText( new String JavaDoc(group.getName() ));
236         /*
237         this.jCheckBoxStartNewPage.setSelected( group.isIsStartNewPage() );
238         this.jCheckBoxStartNewColumn.setSelected( group.isIsStartNewColumn() );
239         this.jCheckBoxPrintHeaderEachPage.setSelected( group.isIsReprintHeaderOnEachPage());
240         this.jCheckBoxResetPageNumber.setSelected( group.isIsResetPageNumber() );
241         */

242         if (group.getGroupExpression() != null)
243         {
244             this.jRTextExpressionArea.setText( new String JavaDoc(group.getGroupExpression()).trim());
245         }
246         else
247         {
248             this.jRTextExpressionArea.setText( "");
249         }
250         
251         /*
252         try {
253         this.jNumberFieldMinStartNewPage.setValue( group.getMinHeightToStartNewPage() );
254         this.jNumberFieldHeaderBand.setValue( group.getGroupHeader().getHeight());
255         this.jNumberFieldFooterBand.setValue( group.getGroupFooter().getHeight());
256         } catch (Exception ex) {}
257         */

258     }
259     
260     /** Getter for property dialogResult.
261      * @return Value of property dialogResult.
262      *
263      */

264     public int getDialogResult() {
265         return dialogResult;
266     }
267     
268     /** Setter for property dialogResult.
269      * @param dialogResult New value of property dialogResult.
270      *
271      */

272     public void setDialogResult(int dialogResult) {
273         this.dialogResult = dialogResult;
274     }
275     
276     /** Getter for property expression.
277      * @return Value of property expression.
278      *
279      */

280     public java.lang.String JavaDoc getExpression() {
281         return expression;
282     }
283     
284     /** Setter for property expression.
285      * @param expression New value of property expression.
286      *
287      */

288     public void setExpression(java.lang.String JavaDoc expression) {
289         this.expression = expression;
290     }
291     
292     /** Getter for property footerBandHeight.
293      * @return Value of property footerBandHeight.
294      *
295      */

296     public int getFooterBandHeight() {
297         return footerBandHeight;
298     }
299     
300     /** Setter for property footerBandHeight.
301      * @param footerBandHeight New value of property footerBandHeight.
302      *
303      */

304     public void setFooterBandHeight(int footerBandHeight) {
305         this.footerBandHeight = footerBandHeight;
306     }
307     
308     /** Getter for property groupName.
309      * @return Value of property groupName.
310      *
311      */

312     public java.lang.String JavaDoc getGroupName() {
313         return groupName;
314     }
315     
316     /** Setter for property groupName.
317      * @param groupName New value of property groupName.
318      *
319      */

320     public void setGroupName(java.lang.String JavaDoc groupName) {
321         this.groupName = groupName;
322     }
323     
324     /** Getter for property headerBandHeight.
325      * @return Value of property headerBandHeight.
326      *
327      */

328     public int getHeaderBandHeight() {
329         return headerBandHeight;
330     }
331     
332     /** Setter for property headerBandHeight.
333      * @param headerBandHeight New value of property headerBandHeight.
334      *
335      */

336     public void setHeaderBandHeight(int headerBandHeight) {
337         this.headerBandHeight = headerBandHeight;
338     }
339     
340     /** Getter for property minHeightStartNewPage.
341      * @return Value of property minHeightStartNewPage.
342      *
343      */

344     public int getMinHeightStartNewPage() {
345         return minHeightStartNewPage;
346     }
347     
348     /** Setter for property minHeightStartNewPage.
349      * @param minHeightStartNewPage New value of property minHeightStartNewPage.
350      *
351      */

352     public void setMinHeightStartNewPage(int minHeightStartNewPage) {
353         this.minHeightStartNewPage = minHeightStartNewPage;
354     }
355     
356     /** Getter for property printHeaderEachPage.
357      * @return Value of property printHeaderEachPage.
358      *
359      */

360     public boolean isPrintHeaderEachPage() {
361         return printHeaderEachPage;
362     }
363     
364     /** Setter for property printHeaderEachPage.
365      * @param printHeaderEachPage New value of property printHeaderEachPage.
366      *
367      */

368     public void setPrintHeaderEachPage(boolean printHeaderEachPage) {
369         this.printHeaderEachPage = printHeaderEachPage;
370     }
371     
372     /** Getter for property resetPageNumber.
373      * @return Value of property resetPageNumber.
374      *
375      */

376     public boolean isResetPageNumber() {
377         return resetPageNumber;
378     }
379     
380     /** Setter for property resetPageNumber.
381      * @param resetPageNumber New value of property resetPageNumber.
382      *
383      */

384     public void setResetPageNumber(boolean resetPageNumber) {
385         this.resetPageNumber = resetPageNumber;
386     }
387     
388     /** Getter for property startNewColumn.
389      * @return Value of property startNewColumn.
390      *
391      */

392     public boolean isStartNewColumn() {
393         return startNewColumn;
394     }
395     
396     /** Setter for property startNewColumn.
397      * @param startNewColumn New value of property startNewColumn.
398      *
399      */

400     public void setStartNewColumn(boolean startNewColumn) {
401         this.startNewColumn = startNewColumn;
402     }
403     
404     /** Getter for property startNewPage.
405      * @return Value of property startNewPage.
406      *
407      */

408     public boolean isStartNewPage() {
409         return startNewPage;
410     }
411     
412     /** Setter for property startNewPage.
413      * @param startNewPage New value of property startNewPage.
414      *
415      */

416     public void setStartNewPage(boolean startNewPage) {
417         this.startNewPage = startNewPage;
418     }
419     
420     // Variables declaration - do not modify//GEN-BEGIN:variables
421
private javax.swing.JButton JavaDoc jButtonCancel;
422     private javax.swing.JButton JavaDoc jButtonOK;
423     private javax.swing.JLabel JavaDoc jLabel1;
424     private javax.swing.JLabel JavaDoc jLabel3;
425     private javax.swing.JPanel JavaDoc jPanel1;
426     private it.businesslogic.ireport.gui.JRTextExpressionArea jRTextExpressionArea;
427     private javax.swing.JTextField JavaDoc jTextFieldName;
428     // End of variables declaration//GEN-END:variables
429

430     private int dialogResult;
431
432     public SubDataset getSubDataset() {
433         return subDataset;
434     }
435
436     public void setSubDataset(SubDataset subDataset) {
437         this.subDataset = subDataset;
438         jRTextExpressionArea.setSubDataset( subDataset);
439     }
440     
441     public void applyI18n(){
442                 // Start autogenerated code ----------------------
443
jButtonCancel.setText(I18n.getString("groupDialog.buttonCancel","Cancel"));
444                 jButtonOK.setText(I18n.getString("groupDialog.buttonOK","OK"));
445                 jLabel1.setText(I18n.getString("groupDialog.label1","Group name"));
446                 jLabel3.setText(I18n.getString("groupDialog.label3","Group expression"));
447                 // End autogenerated code ----------------------
448
}
449 }
450
Popular Tags