001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: *
025: *
026: *
027: * QueryExecuterDialog.java
028: *
029: * Created on 9 maggio 2003, 17.25
030: *
031: */
032:
033: package it.businesslogic.ireport.gui.queryexecuters;
034:
035: import it.businesslogic.ireport.util.*;
036: import it.businesslogic.ireport.*;
037:
038: /**
039: *
040: * @author Administrator
041: */
042: public class QueryExecuterDialog extends javax.swing.JDialog {
043: /** Creates new form JRParameterDialog */
044: private QueryExecuterDef queryExecuterDef = null;
045:
046: public QueryExecuterDialog(java.awt.Frame parent, boolean modal) {
047: super (parent, modal);
048: initComponents();
049: applyI18n();
050:
051: javax.swing.KeyStroke escape = javax.swing.KeyStroke
052: .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
053: false);
054: javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
055: public void actionPerformed(java.awt.event.ActionEvent e) {
056: jButtonCancelActionPerformed(e);
057: }
058: };
059:
060: getRootPane().getInputMap(
061: javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
062: escape, "ESCAPE");
063: getRootPane().getActionMap().put("ESCAPE", escapeAction);
064:
065: //to make the default button ...
066: this .getRootPane().setDefaultButton(this .jButtonOK);
067: }
068:
069: /** This method is called from within the constructor to
070: * initialize the form.
071: * WARNING: Do NOT modify this code. The content of this method is
072: * always regenerated by the Form Editor.
073: */
074: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
075: private void initComponents() {
076: java.awt.GridBagConstraints gridBagConstraints;
077:
078: jLabel1 = new javax.swing.JLabel();
079: jTextFieldLanguage = new javax.swing.JTextField();
080: jLabel4 = new javax.swing.JLabel();
081: jTextFieldFactoryClass = new javax.swing.JTextField();
082: jLabelFieldsProvider = new javax.swing.JLabel();
083: jTextFieldFactoryClass1 = new javax.swing.JTextField();
084: jPanel1 = new javax.swing.JPanel();
085: jButtonOK = new javax.swing.JButton();
086: jButtonCancel = new javax.swing.JButton();
087:
088: getContentPane().setLayout(new java.awt.GridBagLayout());
089:
090: setTitle("Add/modify property");
091: setModal(true);
092: addWindowListener(new java.awt.event.WindowAdapter() {
093: public void windowClosing(java.awt.event.WindowEvent evt) {
094: closeDialog(evt);
095: }
096: });
097:
098: jLabel1.setText("Language");
099: jLabel1.setMaximumSize(new java.awt.Dimension(1000, 100));
100: jLabel1.setMinimumSize(new java.awt.Dimension(100, 15));
101: jLabel1.setPreferredSize(new java.awt.Dimension(100, 15));
102: gridBagConstraints = new java.awt.GridBagConstraints();
103: gridBagConstraints.gridx = 0;
104: gridBagConstraints.gridy = 0;
105: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
106: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
107: gridBagConstraints.weightx = 1.0;
108: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
109: getContentPane().add(jLabel1, gridBagConstraints);
110:
111: gridBagConstraints = new java.awt.GridBagConstraints();
112: gridBagConstraints.gridx = 0;
113: gridBagConstraints.gridy = 1;
114: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
115: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
116: gridBagConstraints.weightx = 1.0;
117: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
118: getContentPane().add(jTextFieldLanguage, gridBagConstraints);
119:
120: jLabel4.setText("Factory class");
121: gridBagConstraints = new java.awt.GridBagConstraints();
122: gridBagConstraints.gridx = 0;
123: gridBagConstraints.gridy = 2;
124: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
125: gridBagConstraints.weightx = 1.0;
126: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
127: getContentPane().add(jLabel4, gridBagConstraints);
128:
129: gridBagConstraints = new java.awt.GridBagConstraints();
130: gridBagConstraints.gridx = 0;
131: gridBagConstraints.gridy = 3;
132: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
133: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
134: gridBagConstraints.weightx = 1.0;
135: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
136: getContentPane()
137: .add(jTextFieldFactoryClass, gridBagConstraints);
138:
139: jLabelFieldsProvider
140: .setText("Fields provider class (optional)");
141: gridBagConstraints = new java.awt.GridBagConstraints();
142: gridBagConstraints.gridx = 0;
143: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
144: gridBagConstraints.weightx = 1.0;
145: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
146: getContentPane().add(jLabelFieldsProvider, gridBagConstraints);
147:
148: gridBagConstraints = new java.awt.GridBagConstraints();
149: gridBagConstraints.gridx = 0;
150: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
151: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
152: gridBagConstraints.weightx = 1.0;
153: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
154: getContentPane().add(jTextFieldFactoryClass1,
155: gridBagConstraints);
156:
157: jPanel1.setLayout(new java.awt.FlowLayout(
158: java.awt.FlowLayout.RIGHT));
159:
160: jPanel1.setMinimumSize(new java.awt.Dimension(200, 35));
161: jPanel1.setPreferredSize(new java.awt.Dimension(250, 35));
162: jButtonOK.setMnemonic('o');
163: jButtonOK.setText("OK");
164: jButtonOK
165: .addActionListener(new java.awt.event.ActionListener() {
166: public void actionPerformed(
167: java.awt.event.ActionEvent evt) {
168: jButtonOKActionPerformed(evt);
169: }
170: });
171:
172: jPanel1.add(jButtonOK);
173:
174: jButtonCancel.setMnemonic('c');
175: jButtonCancel.setText("Cancel");
176: jButtonCancel
177: .addActionListener(new java.awt.event.ActionListener() {
178: public void actionPerformed(
179: java.awt.event.ActionEvent evt) {
180: jButtonCancelActionPerformed(evt);
181: }
182: });
183:
184: jPanel1.add(jButtonCancel);
185:
186: gridBagConstraints = new java.awt.GridBagConstraints();
187: gridBagConstraints.gridx = 0;
188: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
189: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
190: gridBagConstraints.weightx = 1.0;
191: gridBagConstraints.weighty = 1.0;
192: getContentPane().add(jPanel1, gridBagConstraints);
193:
194: java.awt.Dimension screenSize = java.awt.Toolkit
195: .getDefaultToolkit().getScreenSize();
196: setBounds((screenSize.width - 320) / 2,
197: (screenSize.height - 177) / 2, 320, 177);
198: }// </editor-fold>//GEN-END:initComponents
199:
200: private void jButtonCancelActionPerformed(
201: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
202: setVisible(false);
203: this .setDialogResult(javax.swing.JOptionPane.CANCEL_OPTION);
204: dispose();
205: }//GEN-LAST:event_jButtonCancelActionPerformed
206:
207: private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
208:
209: if (this .jTextFieldLanguage.getText().trim().length() <= 0) {
210: javax.swing.JOptionPane
211: .showMessageDialog(
212: this ,
213: I18n
214: .getString(
215: "messages.queryExecuterDialog.notValidLanguage",
216: "Please insert a valid language name!"),
217: I18n
218: .getString(
219: "messages.queryExecuterDialog.notValidLanguageCaption",
220: "Invalid language!"),
221: javax.swing.JOptionPane.WARNING_MESSAGE);
222: return;
223: }
224:
225: if (this .jTextFieldFactoryClass.getText().trim().length() <= 0) {
226: javax.swing.JOptionPane
227: .showMessageDialog(
228: this ,
229: I18n
230: .getString(
231: "messages.queryExecuterDialog.notValidFactoryName",
232: "Please insert a valid Factory class name!"),
233: I18n
234: .getString(
235: "messages.queryExecuterDialog.notValidFactoryNameCaption",
236: "Invalid class name!"),
237: javax.swing.JOptionPane.WARNING_MESSAGE);
238: return;
239: }
240:
241: if (queryExecuterDef == null)
242: queryExecuterDef = new QueryExecuterDef();
243: queryExecuterDef.setLanguage(jTextFieldLanguage.getText()
244: .trim());
245: queryExecuterDef.setClassName(jTextFieldFactoryClass.getText()
246: .trim());
247: queryExecuterDef.setFieldsProvider(jTextFieldFactoryClass1
248: .getText().trim());
249:
250: setVisible(false);
251: this .setDialogResult(javax.swing.JOptionPane.OK_OPTION);
252: dispose();
253: }//GEN-LAST:event_jButtonOKActionPerformed
254:
255: /** Closes the dialog */
256: private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
257: setVisible(false);
258: this .setDialogResult(javax.swing.JOptionPane.CLOSED_OPTION);
259: dispose();
260: }//GEN-LAST:event_closeDialog
261:
262: /**
263: * @param args the command line arguments
264: */
265: public static void main(String args[]) {
266: new QueryExecuterDialog(new javax.swing.JFrame(), true)
267: .setVisible(true);
268: }
269:
270: /** Getter for property dialogResult.
271: * @return Value of property dialogResult.
272: *
273: */
274: public int getDialogResult() {
275: return dialogResult;
276: }
277:
278: /** Setter for property dialogResult.
279: * @param dialogResult New value of property dialogResult.
280: *
281: */
282: public void setDialogResult(int dialogResult) {
283: this .dialogResult = dialogResult;
284: }
285:
286: // Variables declaration - do not modify//GEN-BEGIN:variables
287: private javax.swing.JButton jButtonCancel;
288: private javax.swing.JButton jButtonOK;
289: private javax.swing.JLabel jLabel1;
290: private javax.swing.JLabel jLabel4;
291: private javax.swing.JLabel jLabelFieldsProvider;
292: private javax.swing.JPanel jPanel1;
293: private javax.swing.JTextField jTextFieldFactoryClass;
294: private javax.swing.JTextField jTextFieldFactoryClass1;
295: private javax.swing.JTextField jTextFieldLanguage;
296: // End of variables declaration//GEN-END:variables
297:
298: private int dialogResult;
299:
300: public QueryExecuterDef getQueryExecuterDef() {
301: return queryExecuterDef;
302: }
303:
304: public void setQueryExecuterDef(QueryExecuterDef queryExecuterDef) {
305: this .queryExecuterDef = queryExecuterDef;
306: this .jTextFieldLanguage.setText(queryExecuterDef.getLanguage());
307: this .jTextFieldFactoryClass.setText(queryExecuterDef
308: .getClassName());
309: this .jTextFieldFactoryClass1.setText(queryExecuterDef
310: .getFieldsProvider());
311: }
312:
313: public void applyI18n() {
314: // Start autogenerated code ----------------------
315: jButtonCancel.setText(I18n.getString(
316: "queryExecuterDialog.buttonCancel", "Cancel"));
317: jButtonOK.setText(I18n.getString(
318: "queryExecuterDialog.buttonOK", "OK"));
319: jLabel1.setText(I18n.getString("queryExecuterDialog.label1",
320: "Language"));
321: jLabel4.setText(I18n.getString("queryExecuterDialog.label4",
322: "Factory class"));
323:
324: jLabelFieldsProvider.setText(I18n.getString(
325: "queryExecuterDialog.labelFieldsProviderClass",
326: "Fields Provider class (optional)"));
327: // End autogenerated code ----------------------
328: setTitle(I18n.getString("queryExecuterDialog.title",
329: "Query executers"));
330: jButtonCancel.setMnemonic(I18n.getString(
331: "queryExecuterDialog.buttonCancelMnemonic", "c")
332: .charAt(0));
333: jButtonOK.setMnemonic(I18n.getString(
334: "queryExecuterDialog.buttonOKMnemonic", "o").charAt(0));
335: }
336: }
|