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: * SubDatasetDialog.java
028: *
029: * Created on 5 dicembre 2005, 20.17
030: *
031: */
032:
033: package it.businesslogic.ireport.gui.subdataset;
034:
035: import it.businesslogic.ireport.SubDataset;
036: import it.businesslogic.ireport.gui.MainFrame;
037: import it.businesslogic.ireport.gui.DatasetPropertiesDialog;
038: import it.businesslogic.ireport.gui.ReportQueryDialog;
039: import it.businesslogic.ireport.gui.ValuesDialog;
040: import it.businesslogic.ireport.gui.event.ReportSubDatasetChangedEvent;
041: import it.businesslogic.ireport.gui.sheet.Tag;
042: import it.businesslogic.ireport.util.Misc;
043: import java.util.Enumeration;
044: import it.businesslogic.ireport.util.I18n;
045:
046: /**
047: *
048: * @author Administrator
049: */
050: public class SubDatasetDialog extends javax.swing.JDialog {
051:
052: private SubDataset subDataset = null;
053: private int dialogResult = javax.swing.JOptionPane.CANCEL_OPTION;
054:
055: /** Creates new form SubDatasetDialog */
056: public SubDatasetDialog(java.awt.Frame parent, boolean modal) {
057: super (parent, modal);
058: initComponents();
059: afterInit();
060: }
061:
062: public SubDatasetDialog(java.awt.Dialog parent, boolean modal) {
063: super (parent, modal);
064: initComponents();
065: afterInit();
066: }
067:
068: public void afterInit() {
069: //this.setSize(620, 320);
070:
071: this .pack();
072: // Open in center...
073: it.businesslogic.ireport.util.Misc.centerFrame(this );
074:
075: this .jComboBoxWhenResourceMissingType.addItem(new Tag("Null",
076: it.businesslogic.ireport.util.I18n.getString(
077: "whenResourceMissingType.Null", "Null")));
078: this .jComboBoxWhenResourceMissingType.addItem(new Tag("Empty",
079: it.businesslogic.ireport.util.I18n.getString(
080: "whenResourceMissingType.Empty", "Empty")));
081: this .jComboBoxWhenResourceMissingType.addItem(new Tag("Key",
082: it.businesslogic.ireport.util.I18n.getString(
083: "whenResourceMissingType.Key", "Key")));
084: this .jComboBoxWhenResourceMissingType.addItem(new Tag("Error",
085: it.businesslogic.ireport.util.I18n.getString(
086: "whenResourceMissingType.Error", "Error")));
087:
088: applyI18n();
089:
090: it.businesslogic.ireport.util.Misc.setComboboxSelectedTagValue(
091: jComboBoxWhenResourceMissingType, "Null");
092:
093: boolean found = true;
094: for (int i = 1; found; ++i) {
095: found = false;
096: Enumeration e = it.businesslogic.ireport.gui.MainFrame
097: .getMainInstance().getActiveReportFrame()
098: .getReport().getSubDatasets().elements();
099: while (e.hasMoreElements() && !found) {
100: SubDataset dataset = (SubDataset) e.nextElement();
101: if (dataset.getName().equals("SubDataset" + i)) {
102: found = true;
103: }
104: }
105: if (!found) {
106: jTextFieldName.setText("SubDataset" + i);
107: }
108: }
109:
110: jTextFieldResourceBoundle
111: .setText(it.businesslogic.ireport.gui.MainFrame
112: .getMainInstance().getActiveReportFrame()
113: .getReport().getResourceBundleBaseName());
114:
115: }
116:
117: /** This method is called from within the constructor to
118: * initialize the form.
119: * WARNING: Do NOT modify this code. The content of this method is
120: * always regenerated by the Form Editor.
121: */
122: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
123: private void initComponents() {
124: java.awt.GridBagConstraints gridBagConstraints;
125:
126: jPanel4 = new javax.swing.JPanel();
127: jLabelName = new javax.swing.JLabel();
128: jTextFieldName = new javax.swing.JTextField();
129: jLabelResourceBoundle = new javax.swing.JLabel();
130: jTextFieldResourceBoundle = new javax.swing.JTextField();
131: jLabelScriptletClass = new javax.swing.JLabel();
132: jTextFieldScriptletClass = new javax.swing.JTextField();
133: jLabelWhenResourceMissingType = new javax.swing.JLabel();
134: jComboBoxWhenResourceMissingType = new javax.swing.JComboBox();
135: jPanel2 = new javax.swing.JPanel();
136: jLabel1 = new javax.swing.JLabel();
137: jButtonOk = new javax.swing.JButton();
138: jButtonCancel = new javax.swing.JButton();
139: jLabelScriptletClass1 = new javax.swing.JLabel();
140: jRTextExpressionAreaFilterExpression = new it.businesslogic.ireport.gui.JRTextExpressionArea();
141: jPanel1 = new javax.swing.JPanel();
142: jButtonFields = new javax.swing.JButton();
143: jButtonVariables = new javax.swing.JButton();
144: jButtonParameters = new javax.swing.JButton();
145: jSeparator1 = new javax.swing.JSeparator();
146: jButtonQuery = new javax.swing.JButton();
147: jButtonGroups = new javax.swing.JButton();
148: jSeparator2 = new javax.swing.JSeparator();
149: jButtonProperties = new javax.swing.JButton();
150: jPanel6 = new javax.swing.JPanel();
151:
152: getContentPane().setLayout(new java.awt.GridBagLayout());
153:
154: setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
155: setTitle("SubDataset");
156: jPanel4.setLayout(new java.awt.GridBagLayout());
157:
158: jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(
159: javax.swing.BorderFactory.createEtchedBorder(),
160: "Subdataset properties",
161: javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
162: javax.swing.border.TitledBorder.DEFAULT_POSITION,
163: new java.awt.Font("Dialog", 0, 11)));
164: jLabelName
165: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
166: jLabelName.setText("Datasource name");
167: gridBagConstraints = new java.awt.GridBagConstraints();
168: gridBagConstraints.gridx = 0;
169: gridBagConstraints.gridy = 0;
170: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
171: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
172: jPanel4.add(jLabelName, gridBagConstraints);
173:
174: gridBagConstraints = new java.awt.GridBagConstraints();
175: gridBagConstraints.gridx = 1;
176: gridBagConstraints.gridy = 0;
177: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
178: gridBagConstraints.weightx = 1.0;
179: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
180: jPanel4.add(jTextFieldName, gridBagConstraints);
181:
182: jLabelResourceBoundle
183: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
184: jLabelResourceBoundle.setText("Resource Boundle");
185: gridBagConstraints = new java.awt.GridBagConstraints();
186: gridBagConstraints.gridx = 0;
187: gridBagConstraints.gridy = 1;
188: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
189: gridBagConstraints.insets = new java.awt.Insets(16, 4, 0, 0);
190: jPanel4.add(jLabelResourceBoundle, gridBagConstraints);
191:
192: gridBagConstraints = new java.awt.GridBagConstraints();
193: gridBagConstraints.gridx = 1;
194: gridBagConstraints.gridy = 1;
195: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
196: gridBagConstraints.weightx = 1.0;
197: gridBagConstraints.insets = new java.awt.Insets(16, 4, 4, 4);
198: jPanel4.add(jTextFieldResourceBoundle, gridBagConstraints);
199:
200: jLabelScriptletClass
201: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
202: jLabelScriptletClass.setText("Scriptlet class");
203: gridBagConstraints = new java.awt.GridBagConstraints();
204: gridBagConstraints.gridx = 0;
205: gridBagConstraints.gridy = 8;
206: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
207: gridBagConstraints.insets = new java.awt.Insets(16, 4, 4, 0);
208: jPanel4.add(jLabelScriptletClass, gridBagConstraints);
209:
210: jTextFieldScriptletClass
211: .addActionListener(new java.awt.event.ActionListener() {
212: public void actionPerformed(
213: java.awt.event.ActionEvent evt) {
214: jTextFieldScriptletClassActionPerformed(evt);
215: }
216: });
217:
218: gridBagConstraints = new java.awt.GridBagConstraints();
219: gridBagConstraints.gridx = 1;
220: gridBagConstraints.gridy = 8;
221: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
222: gridBagConstraints.weightx = 1.0;
223: gridBagConstraints.insets = new java.awt.Insets(16, 4, 4, 4);
224: jPanel4.add(jTextFieldScriptletClass, gridBagConstraints);
225:
226: jLabelWhenResourceMissingType
227: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
228: jLabelWhenResourceMissingType
229: .setText("When resource missing type");
230: gridBagConstraints = new java.awt.GridBagConstraints();
231: gridBagConstraints.gridx = 0;
232: gridBagConstraints.gridy = 5;
233: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
234: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
235: jPanel4.add(jLabelWhenResourceMissingType, gridBagConstraints);
236:
237: gridBagConstraints = new java.awt.GridBagConstraints();
238: gridBagConstraints.gridx = 1;
239: gridBagConstraints.gridy = 5;
240: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
241: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
242: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
243: jPanel4.add(jComboBoxWhenResourceMissingType,
244: gridBagConstraints);
245:
246: jPanel2.setLayout(new java.awt.GridBagLayout());
247:
248: jLabel1
249: .setIcon(new javax.swing.ImageIcon(
250: getClass()
251: .getResource(
252: "/it/businesslogic/ireport/icons/subdatasource.png")));
253: gridBagConstraints = new java.awt.GridBagConstraints();
254: gridBagConstraints.gridx = 0;
255: gridBagConstraints.gridy = 0;
256: gridBagConstraints.gridwidth = 2;
257: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
258: gridBagConstraints.weightx = 1.0;
259: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
260: jPanel2.add(jLabel1, gridBagConstraints);
261:
262: jButtonOk.setText("Create");
263: jButtonOk
264: .addActionListener(new java.awt.event.ActionListener() {
265: public void actionPerformed(
266: java.awt.event.ActionEvent evt) {
267: jButtonOkActionPerformed(evt);
268: }
269: });
270:
271: gridBagConstraints = new java.awt.GridBagConstraints();
272: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
273: gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 4);
274: jPanel2.add(jButtonOk, gridBagConstraints);
275:
276: jButtonCancel.setText("Cancel");
277: jButtonCancel
278: .addActionListener(new java.awt.event.ActionListener() {
279: public void actionPerformed(
280: java.awt.event.ActionEvent evt) {
281: jButtonCancelActionPerformed(evt);
282: }
283: });
284:
285: gridBagConstraints = new java.awt.GridBagConstraints();
286: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
287: gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 4);
288: jPanel2.add(jButtonCancel, gridBagConstraints);
289:
290: gridBagConstraints = new java.awt.GridBagConstraints();
291: gridBagConstraints.gridx = 0;
292: gridBagConstraints.gridy = 99;
293: gridBagConstraints.gridwidth = 2;
294: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
295: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
296: gridBagConstraints.weightx = 1.0;
297: jPanel4.add(jPanel2, gridBagConstraints);
298:
299: jLabelScriptletClass1
300: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
301: jLabelScriptletClass1.setText("Filter expression");
302: gridBagConstraints = new java.awt.GridBagConstraints();
303: gridBagConstraints.gridx = 0;
304: gridBagConstraints.gridy = 9;
305: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
306: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
307: gridBagConstraints.insets = new java.awt.Insets(2, 4, 4, 0);
308: jPanel4.add(jLabelScriptletClass1, gridBagConstraints);
309: jLabelScriptletClass1.getAccessibleContext().setAccessibleName(
310: "Filter expression");
311:
312: jRTextExpressionAreaFilterExpression
313: .setBorder(javax.swing.BorderFactory
314: .createEtchedBorder());
315: jRTextExpressionAreaFilterExpression.setCaretVisible(false);
316: jRTextExpressionAreaFilterExpression.setElectricScroll(0);
317: jRTextExpressionAreaFilterExpression
318: .setMinimumSize(new java.awt.Dimension(657, 50));
319: jRTextExpressionAreaFilterExpression
320: .setPreferredSize(new java.awt.Dimension(325, 100));
321: gridBagConstraints = new java.awt.GridBagConstraints();
322: gridBagConstraints.gridx = 1;
323: gridBagConstraints.gridy = 9;
324: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
325: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
326: gridBagConstraints.weightx = 1.0;
327: gridBagConstraints.weighty = 1.0;
328: gridBagConstraints.insets = new java.awt.Insets(0, 3, 3, 3);
329: jPanel4.add(jRTextExpressionAreaFilterExpression,
330: gridBagConstraints);
331:
332: gridBagConstraints = new java.awt.GridBagConstraints();
333: gridBagConstraints.gridx = 0;
334: gridBagConstraints.gridy = 0;
335: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
336: gridBagConstraints.weightx = 1.0;
337: gridBagConstraints.weighty = 1.0;
338: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
339: getContentPane().add(jPanel4, gridBagConstraints);
340:
341: jPanel1.setLayout(new java.awt.GridBagLayout());
342:
343: jPanel1.setBorder(javax.swing.BorderFactory
344: .createTitledBorder(javax.swing.BorderFactory
345: .createEtchedBorder()));
346: jButtonFields.setText("Fields");
347: jButtonFields.setEnabled(false);
348: jButtonFields
349: .addActionListener(new java.awt.event.ActionListener() {
350: public void actionPerformed(
351: java.awt.event.ActionEvent evt) {
352: jButtonFieldsActionPerformed(evt);
353: }
354: });
355:
356: gridBagConstraints = new java.awt.GridBagConstraints();
357: gridBagConstraints.gridx = 0;
358: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
359: gridBagConstraints.weightx = 1.0;
360: gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
361: jPanel1.add(jButtonFields, gridBagConstraints);
362:
363: jButtonVariables.setText("Variables");
364: jButtonVariables.setEnabled(false);
365: jButtonVariables
366: .addActionListener(new java.awt.event.ActionListener() {
367: public void actionPerformed(
368: java.awt.event.ActionEvent evt) {
369: jButtonVariablesActionPerformed(evt);
370: }
371: });
372:
373: gridBagConstraints = new java.awt.GridBagConstraints();
374: gridBagConstraints.gridx = 0;
375: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
376: gridBagConstraints.weightx = 1.0;
377: gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
378: jPanel1.add(jButtonVariables, gridBagConstraints);
379:
380: jButtonParameters.setText("Parameters");
381: jButtonParameters.setEnabled(false);
382: jButtonParameters
383: .addActionListener(new java.awt.event.ActionListener() {
384: public void actionPerformed(
385: java.awt.event.ActionEvent evt) {
386: jButtonParametersActionPerformed(evt);
387: }
388: });
389:
390: gridBagConstraints = new java.awt.GridBagConstraints();
391: gridBagConstraints.gridx = 0;
392: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
393: gridBagConstraints.weightx = 1.0;
394: gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
395: jPanel1.add(jButtonParameters, gridBagConstraints);
396:
397: jSeparator1.setMinimumSize(new java.awt.Dimension(0, 2));
398: jSeparator1.setPreferredSize(new java.awt.Dimension(2, 2));
399: jSeparator1.setRequestFocusEnabled(false);
400: gridBagConstraints = new java.awt.GridBagConstraints();
401: gridBagConstraints.gridx = 0;
402: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
403: gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 0);
404: jPanel1.add(jSeparator1, gridBagConstraints);
405:
406: jButtonQuery.setText("Query");
407: jButtonQuery.setEnabled(false);
408: jButtonQuery
409: .addActionListener(new java.awt.event.ActionListener() {
410: public void actionPerformed(
411: java.awt.event.ActionEvent evt) {
412: jButtonQueryActionPerformed(evt);
413: }
414: });
415:
416: gridBagConstraints = new java.awt.GridBagConstraints();
417: gridBagConstraints.gridx = 0;
418: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
419: gridBagConstraints.weightx = 1.0;
420: gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
421: jPanel1.add(jButtonQuery, gridBagConstraints);
422:
423: jButtonGroups.setText("Groups");
424: jButtonGroups.setEnabled(false);
425: jButtonGroups
426: .addActionListener(new java.awt.event.ActionListener() {
427: public void actionPerformed(
428: java.awt.event.ActionEvent evt) {
429: jButtonGroupsActionPerformed(evt);
430: }
431: });
432:
433: gridBagConstraints = new java.awt.GridBagConstraints();
434: gridBagConstraints.gridx = 0;
435: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
436: gridBagConstraints.weightx = 1.0;
437: gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
438: jPanel1.add(jButtonGroups, gridBagConstraints);
439:
440: jSeparator2.setMinimumSize(new java.awt.Dimension(0, 2));
441: jSeparator2.setPreferredSize(new java.awt.Dimension(2, 2));
442: jSeparator2.setRequestFocusEnabled(false);
443: gridBagConstraints = new java.awt.GridBagConstraints();
444: gridBagConstraints.gridx = 0;
445: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
446: gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 0);
447: jPanel1.add(jSeparator2, gridBagConstraints);
448:
449: jButtonProperties.setText("Properties");
450: jButtonProperties.setEnabled(false);
451: jButtonProperties
452: .addActionListener(new java.awt.event.ActionListener() {
453: public void actionPerformed(
454: java.awt.event.ActionEvent evt) {
455: jButtonParametersActionPerformed1(evt);
456: }
457: });
458:
459: gridBagConstraints = new java.awt.GridBagConstraints();
460: gridBagConstraints.gridx = 0;
461: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
462: gridBagConstraints.weightx = 1.0;
463: gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
464: jPanel1.add(jButtonProperties, gridBagConstraints);
465:
466: gridBagConstraints = new java.awt.GridBagConstraints();
467: gridBagConstraints.gridx = 0;
468: gridBagConstraints.weighty = 1.0;
469: jPanel1.add(jPanel6, gridBagConstraints);
470:
471: gridBagConstraints = new java.awt.GridBagConstraints();
472: gridBagConstraints.gridx = 1;
473: gridBagConstraints.gridy = 0;
474: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
475: gridBagConstraints.weighty = 1.0;
476: gridBagConstraints.insets = new java.awt.Insets(6, 4, 6, 4);
477: getContentPane().add(jPanel1, gridBagConstraints);
478:
479: pack();
480: }// </editor-fold>//GEN-END:initComponents
481:
482: private void jTextFieldScriptletClassActionPerformed(
483: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldScriptletClassActionPerformed
484: // TODO add your handling code here:
485: }//GEN-LAST:event_jTextFieldScriptletClassActionPerformed
486:
487: private void jButtonParametersActionPerformed1(
488: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonParametersActionPerformed1
489:
490: DatasetPropertiesDialog pd = new DatasetPropertiesDialog(this ,
491: true);
492: pd.setDataset(this .getSubDataset());
493: pd.updateProperties();
494:
495: pd.setVisible(true);
496:
497: }//GEN-LAST:event_jButtonParametersActionPerformed1
498:
499: private void jButtonGroupsActionPerformed(
500: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGroupsActionPerformed
501: GroupsDialog grd = new GroupsDialog(this , true);
502: grd.setSubDataset(this .getSubDataset());
503: grd.setVisible(true);
504: }//GEN-LAST:event_jButtonGroupsActionPerformed
505:
506: private void jButtonQueryActionPerformed(
507: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonQueryActionPerformed
508:
509: ReportQueryDialog rqd = new ReportQueryDialog(MainFrame
510: .getMainInstance(), true);
511: rqd.setSubDataset(this .getSubDataset());
512: rqd.setVisible(true);
513: jRTextExpressionAreaFilterExpression.setText(rqd
514: .getSubDataset().getFilterExpression());
515: }//GEN-LAST:event_jButtonQueryActionPerformed
516:
517: private void jButtonParametersActionPerformed(
518: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonParametersActionPerformed
519: openValuesDialog("Parameters");
520: }//GEN-LAST:event_jButtonParametersActionPerformed
521:
522: private void jButtonVariablesActionPerformed(
523: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVariablesActionPerformed
524: openValuesDialog("Variables");
525: }//GEN-LAST:event_jButtonVariablesActionPerformed
526:
527: private void jButtonFieldsActionPerformed(
528: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFieldsActionPerformed
529:
530: openValuesDialog("Fields");
531:
532: }//GEN-LAST:event_jButtonFieldsActionPerformed
533:
534: public void openValuesDialog(String tab) {
535: ValuesDialog vd = new ValuesDialog(this , true);
536: vd.getValuesPanel().setSubDataset(getSubDataset());
537: vd.setTitle(getSubDataset() + ": values");
538: vd.getValuesPanel().gotoTab(tab);
539: getSubDataset().addSubDatasetObjectChangedListener(vd);
540: vd.setVisible(true);
541: getSubDataset().removeSubDatasetObjectChangedListener(vd);
542: }
543:
544: private void jButtonCancelActionPerformed(
545: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
546:
547: this .setDialogResult(javax.swing.JOptionPane.CANCEL_OPTION);
548: setVisible(false);
549: dispose();
550:
551: }//GEN-LAST:event_jButtonCancelActionPerformed
552:
553: private void jButtonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOkActionPerformed
554:
555: if (this .jTextFieldName.getText().trim().length() <= 0) {
556: javax.swing.JOptionPane
557: .showMessageDialog(
558: this ,
559: I18n
560: .getString(
561: "messages.subDatasetDialog.notValidName",
562: "Please insert a valid SubDataset name!"),
563: I18n
564: .getString(
565: "messages.subDatasetDialog.notValidNameCaption",
566: "Invalid name!"),
567: javax.swing.JOptionPane.WARNING_MESSAGE);
568: return;
569: }
570:
571: String newName = this .jTextFieldName.getText().trim();
572: // check for duplicate name....
573: Enumeration e = it.businesslogic.ireport.gui.MainFrame
574: .getMainInstance().getActiveReportFrame().getReport()
575: .getSubDatasets().elements();
576: while (e.hasMoreElements()) {
577: SubDataset dataset = (SubDataset) e.nextElement();
578: if (dataset.getName().equals(newName)
579: && dataset != getSubDataset()) {
580: javax.swing.JOptionPane
581: .showMessageDialog(
582: this ,
583: I18n
584: .getFormattedString(
585: "messages.subDatasetDialog.nameAlreadyInUse",
586: "The name \"{0}\" is already in use!\nPlease change it.",
587: new Object[] { newName }),
588: I18n
589: .getString(
590: "messages.subDatasetDialog.notValidNameCaption",
591: "Invalid name!"),
592: javax.swing.JOptionPane.WARNING_MESSAGE);
593: return;
594: }
595: }
596:
597: if (getSubDataset() == null) {
598: this .subDataset = new SubDataset();
599: }
600:
601: SubDataset subdataset = getSubDataset();
602: subdataset.setName(jTextFieldName.getText());
603: subdataset
604: .setScriptletClass(jTextFieldScriptletClass.getText());
605: subdataset.setResourceBundleBaseName(jTextFieldResourceBoundle
606: .getText());
607: subdataset
608: .setFilterExpression(jRTextExpressionAreaFilterExpression
609: .getText());
610:
611: if (jComboBoxWhenResourceMissingType.getSelectedItem() != null) {
612: Tag val = (Tag) jComboBoxWhenResourceMissingType
613: .getSelectedItem();
614: subdataset.setWhenResourceMissingType(val.getValue() + "");
615: }
616:
617: if (this .jButtonOk.getText().equals(
618: I18n.getString("subDatasetDialog.buttonCreate",
619: "Create"))) {
620: if (this .getParent() instanceof SubDatasetsDialog) {
621: ((SubDatasetsDialog) this .getParent())
622: .addSubDataset(this .getSubDataset());
623: }
624: this .setSubDataset(subdataset);
625: MainFrame.getMainInstance().getActiveReportFrame()
626: .getReport().addSubDataset(subdataset);
627: return;
628: } else {
629: MainFrame
630: .getMainInstance()
631: .getActiveReportFrame()
632: .getReport()
633: .fireReportSubDatasetChangedListenerReportSubDatasetChanged(
634: new ReportSubDatasetChangedEvent(
635: MainFrame.getMainInstance()
636: .getActiveReportFrame()
637: .getReport(),
638: getSubDataset(),
639: ReportSubDatasetChangedEvent.CHANGED,
640: ReportSubDatasetChangedEvent.OBJECT_SUBDATASET));
641: }
642: MainFrame.getMainInstance().getActiveReportFrame().getReport()
643: .incrementReportChanges();
644: this .setDialogResult(javax.swing.JOptionPane.OK_OPTION);
645: setVisible(false);
646: dispose();
647:
648: }//GEN-LAST:event_jButtonOkActionPerformed
649:
650: /**
651: * @param args the command line arguments
652: */
653: public static void main(String args[]) {
654: java.awt.EventQueue.invokeLater(new Runnable() {
655: public void run() {
656: new SubDatasetDialog(new javax.swing.JFrame(), true)
657: .setVisible(true);
658: }
659: });
660: }
661:
662: // Variables declaration - do not modify//GEN-BEGIN:variables
663: private javax.swing.JButton jButtonCancel;
664: private javax.swing.JButton jButtonFields;
665: private javax.swing.JButton jButtonGroups;
666: private javax.swing.JButton jButtonOk;
667: private javax.swing.JButton jButtonParameters;
668: private javax.swing.JButton jButtonProperties;
669: private javax.swing.JButton jButtonQuery;
670: private javax.swing.JButton jButtonVariables;
671: private javax.swing.JComboBox jComboBoxWhenResourceMissingType;
672: private javax.swing.JLabel jLabel1;
673: private javax.swing.JLabel jLabelName;
674: private javax.swing.JLabel jLabelResourceBoundle;
675: private javax.swing.JLabel jLabelScriptletClass;
676: private javax.swing.JLabel jLabelScriptletClass1;
677: private javax.swing.JLabel jLabelWhenResourceMissingType;
678: private javax.swing.JPanel jPanel1;
679: private javax.swing.JPanel jPanel2;
680: private javax.swing.JPanel jPanel4;
681: private javax.swing.JPanel jPanel6;
682: private it.businesslogic.ireport.gui.JRTextExpressionArea jRTextExpressionAreaFilterExpression;
683: private javax.swing.JSeparator jSeparator1;
684: private javax.swing.JSeparator jSeparator2;
685: private javax.swing.JTextField jTextFieldName;
686: private javax.swing.JTextField jTextFieldResourceBoundle;
687: private javax.swing.JTextField jTextFieldScriptletClass;
688:
689: // End of variables declaration//GEN-END:variables
690:
691: public SubDataset getSubDataset() {
692: return subDataset;
693: }
694:
695: public void setSubDataset(SubDataset subDataset) {
696: this .subDataset = subDataset;
697: this .jTextFieldName.setText(subDataset.getName());
698: this .jTextFieldScriptletClass.setText(subDataset
699: .getScriptletClass());
700: this .jTextFieldResourceBoundle.setText(subDataset
701: .getResourceBundleBaseName());
702: this .jRTextExpressionAreaFilterExpression.setText(subDataset
703: .getFilterExpression());
704: if (subDataset != null) {
705: jRTextExpressionAreaFilterExpression
706: .setSubDataset(subDataset);
707: }
708:
709: Misc.setComboboxSelectedTagValue(
710: jComboBoxWhenResourceMissingType, subDataset
711: .getWhenResourceMissingType());
712: jButtonFields.setEnabled(true);
713: jButtonVariables.setEnabled(true);
714: jButtonParameters.setEnabled(true);
715: jButtonQuery.setEnabled(true);
716: jButtonGroups.setEnabled(true);
717: jButtonProperties.setEnabled(true);
718: this .jButtonOk.setText(I18n.getString(
719: "subDatasetDialog.buttonOk", "Ok"));
720: }
721:
722: public int getDialogResult() {
723: return dialogResult;
724: }
725:
726: public void setDialogResult(int dialogResult) {
727: this .dialogResult = dialogResult;
728: }
729:
730: public void applyI18n() {
731: // Start autogenerated code ----------------------
732: jButtonCancel.setText(I18n.getString(
733: "subDatasetDialog.buttonCancel", "Cancel"));
734: jButtonFields.setText(I18n.getString(
735: "subDatasetDialog.buttonFields", "Fields"));
736: jButtonGroups.setText(I18n.getString(
737: "subDatasetDialog.buttonGroups", "Groups"));
738: jButtonOk.setText(I18n.getString(
739: "subDatasetDialog.buttonCreate", "Create"));
740: jButtonParameters.setText(I18n.getString(
741: "subDatasetDialog.buttonParameters", "Parameters"));
742: jButtonProperties.setText(I18n.getString(
743: "subDatasetDialog.buttonProperties", "Properties"));
744: jButtonQuery.setText(I18n.getString(
745: "subDatasetDialog.buttonQuery", "Query"));
746: jButtonVariables.setText(I18n.getString(
747: "subDatasetDialog.buttonVariables", "Variables"));
748: jLabelName.setText(I18n.getString("subDatasetDialog.labelName",
749: "Datasource name"));
750: jLabelResourceBoundle.setText(I18n.getString(
751: "subDatasetDialog.labelResourceBoundle",
752: "Resource Boundle"));
753: jLabelScriptletClass.setText(I18n.getString(
754: "subDatasetDialog.labelScriptletClass",
755: "Scriptlet class"));
756: jLabelScriptletClass1.setText(I18n.getString(
757: "subDatasetDialog.labelScriptletClass1",
758: "Filter expression"));
759: jLabelWhenResourceMissingType.setText(I18n.getString(
760: "subDatasetDialog.labelWhenResourceMissingType",
761: "When resource missing type"));
762: // End autogenerated code ----------------------
763:
764: ((javax.swing.border.TitledBorder) jPanel4.getBorder())
765: .setTitle(I18n
766: .getString(
767: "subDatasetDialog.panelBorder.SubdatasetProperties",
768: "Subdataset properties"));
769:
770: //
771: this .setTitle(I18n.getString("subDatasetDialog.title",
772: "SubDataset"));
773: //
774: }
775:
776: public static final int COMPONENT_NONE = 0;
777: public static final int COMPONENT_FILTER_EXPRESSION = 1;
778: public static final int COMPONENT_SCRIPTLET_EXPRESSION = 2;
779: public static final int COMPONENT_DATASET_NAME = 3;
780: public static final int COMPONENT_RESOURCE_BUNDLE = 4;
781:
782: /**
783: * This method set the focus on a specific component.
784: * Valid constants are something like:
785: * FIELD_XXX
786: */
787: public void setFocusedExpression(int expID) {
788: switch (expID) {
789: case COMPONENT_FILTER_EXPRESSION:
790: Misc
791: .selectTextAndFocusArea(jRTextExpressionAreaFilterExpression);
792: break;
793: case COMPONENT_SCRIPTLET_EXPRESSION:
794: Misc.selectTextAndFocusArea(jTextFieldScriptletClass);
795: break;
796: case COMPONENT_DATASET_NAME:
797: Misc.selectTextAndFocusArea(jTextFieldName);
798: break;
799: case COMPONENT_RESOURCE_BUNDLE:
800: Misc.selectTextAndFocusArea(jTextFieldResourceBoundle);
801: break;
802: }
803: }
804: }
|