KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > gui > JRLinkParameterDialog


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

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

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

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

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

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

185         if (this.jTextFieldName.getText().trim().length() <= 0)
186         {
187             javax.swing.JOptionPane.showMessageDialog(this,
188                     I18n.getString( "messages.jRLinkParameterDialog.notValidParameterName","Please insert a valid parameter name!"),
189                     I18n.getString( "messages.jRLinkParameterDialog.notValidParameterNameCaption","Invalid parameter!"),
190                     javax.swing.JOptionPane.WARNING_MESSAGE );
191             return;
192         }
193         
194         tmpParameter = new it.businesslogic.ireport.JRLinkParameter( this.jTextFieldName.getText(),this.jRTextExpressionAreaDefaultExpression.getText());
195         setVisible(false);
196         this.setDialogResult( javax.swing.JOptionPane.OK_OPTION);
197         dispose();
198     }//GEN-LAST:event_jButtonOKActionPerformed
199

200     /** Closes the dialog */
201     private void closeDialog(java.awt.event.WindowEvent JavaDoc evt) {//GEN-FIRST:event_closeDialog
202
setVisible(false);
203         this.setDialogResult( javax.swing.JOptionPane.CLOSED_OPTION);
204         dispose();
205     }//GEN-LAST:event_closeDialog
206

207     /**
208      * @param args the command line arguments
209      */

210     public static void main(String JavaDoc args[]) {
211         new JRParameterDialog(new javax.swing.JFrame JavaDoc(), true).setVisible(true);
212     }
213     
214     /** Getter for property tmpParameter.
215      * @return Value of property tmpParameter.
216      *
217      */

218     public it.businesslogic.ireport.JRLinkParameter getParameter() {
219         return tmpParameter;
220     }
221     
222     /** Setter for property tmpParameter.
223      * @param tmpParameter New value of property tmpParameter.
224      *
225      */

226     public void setParameter(it.businesslogic.ireport.JRLinkParameter tmpParameter) {
227         this.jTextFieldName.setText( new String JavaDoc(tmpParameter.getName()));
228         this.jRTextExpressionAreaDefaultExpression.setText( new String JavaDoc(tmpParameter.getExpression()));
229     }
230     
231     /** Getter for property dialogResult.
232      * @return Value of property dialogResult.
233      *
234      */

235     public int getDialogResult() {
236         return dialogResult;
237     }
238     
239     /** Setter for property dialogResult.
240      * @param dialogResult New value of property dialogResult.
241      *
242      */

243     public void setDialogResult(int dialogResult) {
244         this.dialogResult = dialogResult;
245     }
246     
247     // Variables declaration - do not modify//GEN-BEGIN:variables
248
private javax.swing.JButton JavaDoc jButtonCancel;
249     private javax.swing.JButton JavaDoc jButtonOK;
250     private javax.swing.JLabel JavaDoc jLabel1;
251     private javax.swing.JLabel JavaDoc jLabel3;
252     private javax.swing.JPanel JavaDoc jPanel1;
253     private javax.swing.JPanel JavaDoc jPanel2;
254     private it.businesslogic.ireport.gui.JRTextExpressionArea jRTextExpressionAreaDefaultExpression;
255     private javax.swing.JTextField JavaDoc jTextFieldName;
256     // End of variables declaration//GEN-END:variables
257

258     private int dialogResult;
259     
260     public void applyI18n(){
261                 // Start autogenerated code ----------------------
262
jButtonCancel.setText(I18n.getString("jRLinkParameterDialog.buttonCancel","Cancel"));
263                 jButtonOK.setText(I18n.getString("jRLinkParameterDialog.buttonOK","OK"));
264                 jLabel1.setText(I18n.getString("jRLinkParameterDialog.label1","Link parameter name"));
265                 jLabel3.setText(I18n.getString("jRLinkParameterDialog.label3","Value expression"));
266                 // End autogenerated code ----------------------
267
}
268 }
269
Popular Tags