KickJava   Java API By Example, From Geeks To Geeks.

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


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  * FilterExpressionDialog.java
28  *
29  * Created on 9 maggio 2003, 17.25
30  *
31  */

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

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

87     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
88
private void initComponents() {
89         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
90
91         jLabel1 = new javax.swing.JLabel JavaDoc();
92         jRTextExpressionAreaFilterExpression = new it.businesslogic.ireport.gui.JRTextExpressionArea();
93         jPanel1 = new javax.swing.JPanel JavaDoc();
94         jButtonOK = new javax.swing.JButton JavaDoc();
95         jButtonCancel = new javax.swing.JButton JavaDoc();
96
97         getContentPane().setLayout(new java.awt.GridBagLayout JavaDoc());
98
99         setTitle("Add/modify field");
100         setModal(true);
101         addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
102             public void windowClosing(java.awt.event.WindowEvent JavaDoc evt) {
103                 closeDialog(evt);
104             }
105         });
106
107         jLabel1.setText("Filter expression");
108         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
109         gridBagConstraints.gridx = 0;
110         gridBagConstraints.gridy = 0;
111         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
112         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 3, 3);
113         getContentPane().add(jLabel1, gridBagConstraints);
114
115         jRTextExpressionAreaFilterExpression.setBorder(javax.swing.BorderFactory.createEtchedBorder());
116         jRTextExpressionAreaFilterExpression.setCaretVisible(false);
117         jRTextExpressionAreaFilterExpression.setElectricScroll(0);
118         jRTextExpressionAreaFilterExpression.setMinimumSize(new java.awt.Dimension JavaDoc(657, 50));
119         jRTextExpressionAreaFilterExpression.setPreferredSize(new java.awt.Dimension JavaDoc(600, 200));
120         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
121         gridBagConstraints.gridx = 0;
122         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
123         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
124         gridBagConstraints.weightx = 1.0;
125         gridBagConstraints.weighty = 1.0;
126         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 3, 3, 3);
127         getContentPane().add(jRTextExpressionAreaFilterExpression, gridBagConstraints);
128
129         jPanel1.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.RIGHT));
130
131         jButtonOK.setText("OK");
132         jButtonOK.setMnemonic('o');
133         jButtonOK.addActionListener(new java.awt.event.ActionListener JavaDoc() {
134             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
135                 jButtonOKActionPerformed(evt);
136             }
137         });
138
139         jPanel1.add(jButtonOK);
140
141         jButtonCancel.setText("Cancel");
142         jButtonCancel.setMnemonic('c');
143         jButtonCancel.addActionListener(new java.awt.event.ActionListener JavaDoc() {
144             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
145                 jButtonCancelActionPerformed(evt);
146             }
147         });
148
149         jPanel1.add(jButtonCancel);
150
151         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
152         gridBagConstraints.gridx = 0;
153         gridBagConstraints.gridy = 7;
154         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
155         gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
156         gridBagConstraints.weightx = 1.0;
157         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 3, 3);
158         getContentPane().add(jPanel1, gridBagConstraints);
159
160         pack();
161         java.awt.Dimension JavaDoc screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
162         java.awt.Dimension JavaDoc dialogSize = getSize();
163         setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
164     }// </editor-fold>//GEN-END:initComponents
165

166     private void jButtonCancelActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
167
setVisible(false);
168         this.setDialogResult( javax.swing.JOptionPane.CANCEL_OPTION);
169         dispose();
170     }//GEN-LAST:event_jButtonCancelActionPerformed
171

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

174         filterExpression = jRTextExpressionAreaFilterExpression.getText();
175         setVisible(false);
176         this.setDialogResult( javax.swing.JOptionPane.OK_OPTION);
177         dispose();
178     }//GEN-LAST:event_jButtonOKActionPerformed
179

180     /** Closes the dialog */
181     private void closeDialog(java.awt.event.WindowEvent JavaDoc evt) {//GEN-FIRST:event_closeDialog
182
setVisible(false);
183         this.setDialogResult( javax.swing.JOptionPane.CLOSED_OPTION);
184         dispose();
185     }//GEN-LAST:event_closeDialog
186

187     
188    
189     /** Getter for property dialogResult.
190      * @return Value of property dialogResult.
191      *
192      */

193     public int getDialogResult() {
194         return dialogResult;
195     }
196     
197     /** Setter for property dialogResult.
198      * @param dialogResult New value of property dialogResult.
199      *
200      */

201     public void setDialogResult(int dialogResult) {
202         this.dialogResult = dialogResult;
203     }
204     
205     // Variables declaration - do not modify//GEN-BEGIN:variables
206
private javax.swing.JButton JavaDoc jButtonCancel;
207     private javax.swing.JButton JavaDoc jButtonOK;
208     private javax.swing.JLabel JavaDoc jLabel1;
209     private javax.swing.JPanel JavaDoc jPanel1;
210     private it.businesslogic.ireport.gui.JRTextExpressionArea jRTextExpressionAreaFilterExpression;
211     // End of variables declaration//GEN-END:variables
212

213     private int dialogResult;
214
215     public String JavaDoc getFilterExpression() {
216         return filterExpression;
217     }
218
219     public void setFilterExpression(String JavaDoc filterExpression) {
220         setFilterExpression(filterExpression, null);
221     }
222     
223     public void setFilterExpression(String JavaDoc filterExpression, SubDataset subDataset) {
224         this.filterExpression = filterExpression;
225         jRTextExpressionAreaFilterExpression.setText(filterExpression);
226         if (subDataset != null) jRTextExpressionAreaFilterExpression.setSubDataset(subDataset);
227     }
228     
229     public void applyI18n(){
230                 // Start autogenerated code ----------------------
231
jButtonCancel.setText(I18n.getString("filterExpressionDialog.buttonCancel","Cancel"));
232                 jButtonOK.setText(I18n.getString("filterExpressionDialog.buttonOK","OK"));
233                 jLabel1.setText(I18n.getString("filterExpressionDialog.label1","Filter expression"));
234                 // End autogenerated code ----------------------
235
}
236 }
237
Popular Tags