KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > crosstab > gui > CrosstabWizardDialog


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  * CrosstabWizardDialog.java
28  *
29  * Created on January 27, 2006, 12:11 PM
30  *
31  */

32
33 package it.businesslogic.ireport.crosstab.gui;
34
35 import it.businesslogic.ireport.CrosstabReportElement;
36 import it.businesslogic.ireport.Report;
37 import it.businesslogic.ireport.SubDataset;
38 import it.businesslogic.ireport.TextFieldReportElement;
39 import it.businesslogic.ireport.chart.Dataset;
40 import it.businesslogic.ireport.crosstab.CrosstabCell;
41 import it.businesslogic.ireport.crosstab.CrosstabColumnGroup;
42 import it.businesslogic.ireport.crosstab.CrosstabGroup;
43 import it.businesslogic.ireport.crosstab.CrosstabRowGroup;
44 import it.businesslogic.ireport.crosstab.Measure;
45 import it.businesslogic.ireport.gui.subdataset.SubDatasetDialog;
46 import it.businesslogic.ireport.util.Misc;
47 import java.awt.Color JavaDoc;
48 import java.awt.Point JavaDoc;
49 import java.util.Vector JavaDoc;
50 import javax.swing.JLabel JavaDoc;
51 import it.businesslogic.ireport.util.I18n;
52
53 /**
54  *
55  * @author gtoffoli
56  */

57 public class CrosstabWizardDialog extends javax.swing.JDialog JavaDoc {
58     
59     private CrosstabReportElement crosstabReportElement = null;
60     
61     private SubDataset crosstabSubDataset = null;
62     private int currentStep = -1;
63     
64     private int dialogResult = javax.swing.JOptionPane.CLOSED_OPTION;
65     
66     private Report report = null;
67     
68     private Vector JavaDoc stepsPanels = new Vector JavaDoc();
69     private Vector JavaDoc stepsLabels = new Vector JavaDoc();
70     
71     /** Creates new form NewJDialog */
72     public CrosstabWizardDialog(java.awt.Frame JavaDoc parent, boolean modal) {
73         super(parent, modal);
74         initComponents();
75         
76         stepsPanels.add(jPanelStep0);
77         stepsPanels.add(jPanelStep1);
78         stepsPanels.add(jPanelStep2);
79         stepsPanels.add(jPanelStep3);
80         stepsPanels.add(jPanelStep4);
81         stepsPanels.add(jPanelStep5);
82         
83         stepsLabels.add(jLabelStep1);
84         stepsLabels.add(jLabelStep2);
85         stepsLabels.add(jLabelStep3);
86         stepsLabels.add(jLabelStep4);
87         stepsLabels.add(jLabelStep5);
88         stepsLabels.add(jLabelStep6);
89         
90         groupByFieldPanel2.addVoidItem();
91         groupByFieldPanel4.addVoidItem();
92         
93         groupByFieldPanel1.addActionListener(new java.awt.event.ActionListener JavaDoc() {
94             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
95                 groupByFieldPanel1CancelActionPerformed(evt);
96             }
97         });
98         
99         groupByFieldPanel2.addActionListener(new java.awt.event.ActionListener JavaDoc() {
100             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
101                 groupByFieldPanel2CancelActionPerformed(evt);
102             }
103         });
104         
105         groupByFieldPanel3.addActionListener(new java.awt.event.ActionListener JavaDoc() {
106             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
107                 groupByFieldPanel3CancelActionPerformed(evt);
108             }
109         });
110         
111         groupByFieldPanel4.addActionListener(new java.awt.event.ActionListener JavaDoc() {
112             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
113                 groupByFieldPanel4CancelActionPerformed(evt);
114             }
115         });
116         
117         applyI18n();
118         goNext();
119         
120         pack();
121         Misc.centerFrame(this);
122     }
123     
124     public void groupByFieldPanel1CancelActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
125         if (getCurrentStep() == 1) updateButtons();
126     }
127     
128     public void groupByFieldPanel2CancelActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
129         
130     }
131     
132     public void groupByFieldPanel3CancelActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
133         if (getCurrentStep() == 2) updateButtons();
134     }
135     
136     public void groupByFieldPanel4CancelActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
137     }
138     
139     /** This method is called from within the constructor to
140      * initialize the form.
141      * WARNING: Do NOT modify this code. The content of this method is
142      * always regenerated by the Form Editor.
143      */

144     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
145
private void initComponents() {
146         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
147
148         jPanelBase = new javax.swing.JPanel JavaDoc();
149         jPanelSteps = new javax.swing.JPanel JavaDoc();
150         jLabel1 = new javax.swing.JLabel JavaDoc();
151         jLabelStep1 = new javax.swing.JLabel JavaDoc();
152         jLabelStep2 = new javax.swing.JLabel JavaDoc();
153         jLabelStep3 = new javax.swing.JLabel JavaDoc();
154         jLabelStep4 = new javax.swing.JLabel JavaDoc();
155         jLabelStep5 = new javax.swing.JLabel JavaDoc();
156         jLabelStep6 = new javax.swing.JLabel JavaDoc();
157         jSeparator2 = new javax.swing.JSeparator JavaDoc();
158         jLabel7 = new javax.swing.JLabel JavaDoc();
159         jPanelContent = new javax.swing.JPanel JavaDoc();
160         jPanel1 = new javax.swing.JPanel JavaDoc();
161         jLabelStepDescription = new javax.swing.JLabel JavaDoc();
162         jSeparator4 = new javax.swing.JSeparator JavaDoc();
163         jPanelStepContainer = new javax.swing.JPanel JavaDoc();
164         jPanelStep0 = new javax.swing.JPanel JavaDoc();
165         jLabel2 = new javax.swing.JLabel JavaDoc();
166         jComboBoxSubdataset = new javax.swing.JComboBox JavaDoc();
167         jButtonNewSubDataset = new javax.swing.JButton JavaDoc();
168         jPanelStep1 = new javax.swing.JPanel JavaDoc();
169         jLabel3 = new javax.swing.JLabel JavaDoc();
170         groupByFieldPanel1 = new it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel();
171         groupByFieldPanel2 = new it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel();
172         jPanel3 = new javax.swing.JPanel JavaDoc();
173         jPanelStep2 = new javax.swing.JPanel JavaDoc();
174         jLabel4 = new javax.swing.JLabel JavaDoc();
175         groupByFieldPanel3 = new it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel();
176         groupByFieldPanel4 = new it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel();
177         jPanel4 = new javax.swing.JPanel JavaDoc();
178         jPanelStep3 = new javax.swing.JPanel JavaDoc();
179         jLabel5 = new javax.swing.JLabel JavaDoc();
180         jLabelDetailField = new javax.swing.JLabel JavaDoc();
181         jComboBoxDetailField = new javax.swing.JComboBox JavaDoc();
182         jLabelDetailField1 = new javax.swing.JLabel JavaDoc();
183         jComboBoxDetailFieldFunction = new javax.swing.JComboBox JavaDoc();
184         jPanel5 = new javax.swing.JPanel JavaDoc();
185         jPanelStep4 = new javax.swing.JPanel JavaDoc();
186         jLabel6 = new javax.swing.JLabel JavaDoc();
187         jCheckBoxTotalRows = new javax.swing.JCheckBox JavaDoc();
188         jCheckBoxTotalColumns = new javax.swing.JCheckBox JavaDoc();
189         jCheckBoxPrintGrid = new javax.swing.JCheckBox JavaDoc();
190         jPanel6 = new javax.swing.JPanel JavaDoc();
191         jPanelStep5 = new javax.swing.JPanel JavaDoc();
192         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
193         jTextArea1 = new javax.swing.JTextArea JavaDoc();
194         jSeparator3 = new javax.swing.JSeparator JavaDoc();
195         jPanelContentButtons = new javax.swing.JPanel JavaDoc();
196         jPanel2 = new javax.swing.JPanel JavaDoc();
197         jButtonPrev = new javax.swing.JButton JavaDoc();
198         jButtonNext = new javax.swing.JButton JavaDoc();
199         jButtonFinish = new javax.swing.JButton JavaDoc();
200         jButtonCancel = new javax.swing.JButton JavaDoc();
201
202         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
203         jPanelBase.setLayout(new java.awt.GridBagLayout JavaDoc());
204
205         jPanelSteps.setLayout(new java.awt.GridBagLayout JavaDoc());
206
207         jLabel1.setText("Steps");
208         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
209         gridBagConstraints.gridx = 0;
210         gridBagConstraints.gridy = 1;
211         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
212         gridBagConstraints.insets = new java.awt.Insets JavaDoc(8, 8, 0, 0);
213         jPanelSteps.add(jLabel1, gridBagConstraints);
214
215         jLabelStep1.setText("1. SubDataset selection");
216         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
217         gridBagConstraints.gridx = 0;
218         gridBagConstraints.gridy = 5;
219         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
220         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 8, 0, 0);
221         jPanelSteps.add(jLabelStep1, gridBagConstraints);
222
223         jLabelStep2.setText("2. Rows");
224         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
225         gridBagConstraints.gridx = 0;
226         gridBagConstraints.gridy = 6;
227         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
228         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 8, 0, 0);
229         jPanelSteps.add(jLabelStep2, gridBagConstraints);
230
231         jLabelStep3.setText("3. Columns");
232         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
233         gridBagConstraints.gridx = 0;
234         gridBagConstraints.gridy = 7;
235         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
236         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 8, 0, 0);
237         jPanelSteps.add(jLabelStep3, gridBagConstraints);
238
239         jLabelStep4.setText("4. Detail");
240         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
241         gridBagConstraints.gridx = 0;
242         gridBagConstraints.gridy = 8;
243         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
244         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 8, 0, 0);
245         jPanelSteps.add(jLabelStep4, gridBagConstraints);
246
247         jLabelStep5.setText("5. Layout");
248         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
249         gridBagConstraints.gridx = 0;
250         gridBagConstraints.gridy = 9;
251         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
252         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 8, 0, 0);
253         jPanelSteps.add(jLabelStep5, gridBagConstraints);
254
255         jLabelStep6.setText("6. Finish");
256         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
257         gridBagConstraints.gridx = 0;
258         gridBagConstraints.gridy = 10;
259         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
260         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 8, 0, 0);
261         jPanelSteps.add(jLabelStep6, gridBagConstraints);
262
263         jSeparator2.setBackground(new java.awt.Color JavaDoc(204, 204, 255));
264         jSeparator2.setForeground(new java.awt.Color JavaDoc(0, 0, 0));
265         jSeparator2.setMaximumSize(new java.awt.Dimension JavaDoc(32767, 2));
266         jSeparator2.setMinimumSize(new java.awt.Dimension JavaDoc(2, 2));
267         jSeparator2.setPreferredSize(new java.awt.Dimension JavaDoc(1, 2));
268         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
269         gridBagConstraints.gridx = 0;
270         gridBagConstraints.gridy = 2;
271         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
272         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 0, 4, 0);
273         jPanelSteps.add(jSeparator2, gridBagConstraints);
274
275         jLabel7.setBackground(new java.awt.Color JavaDoc(207, 217, 231));
276         jLabel7.setIcon(new javax.swing.ImageIcon JavaDoc(getClass().getResource("/it/businesslogic/ireport/icons/wizard.jpg")));
277         jLabel7.setVerticalAlignment(javax.swing.SwingConstants.TOP);
278         jLabel7.setOpaque(true);
279         jLabel7.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
280         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
281         gridBagConstraints.gridx = 0;
282         gridBagConstraints.gridy = 0;
283         gridBagConstraints.gridheight = 20;
284         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
285         gridBagConstraints.weightx = 1.0;
286         gridBagConstraints.weighty = 1.0;
287         jPanelSteps.add(jLabel7, gridBagConstraints);
288
289         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
290         gridBagConstraints.gridx = 0;
291         gridBagConstraints.gridy = 0;
292         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
293         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
294         gridBagConstraints.weighty = 1.0;
295         jPanelBase.add(jPanelSteps, gridBagConstraints);
296
297         jPanelContent.setLayout(new java.awt.GridBagLayout JavaDoc());
298
299         jPanel1.setLayout(new java.awt.GridBagLayout JavaDoc());
300
301         jPanel1.setMinimumSize(new java.awt.Dimension JavaDoc(40, 40));
302         jPanel1.setPreferredSize(new java.awt.Dimension JavaDoc(280, 40));
303         jLabelStepDescription.setText("Steps");
304         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
305         gridBagConstraints.gridx = 0;
306         gridBagConstraints.gridy = 1;
307         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
308         gridBagConstraints.weightx = 1.0;
309         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 8, 0, 0);
310         jPanel1.add(jLabelStepDescription, gridBagConstraints);
311
312         jSeparator4.setBackground(new java.awt.Color JavaDoc(204, 204, 255));
313         jSeparator4.setForeground(new java.awt.Color JavaDoc(0, 0, 0));
314         jSeparator4.setMaximumSize(new java.awt.Dimension JavaDoc(32767, 2));
315         jSeparator4.setMinimumSize(new java.awt.Dimension JavaDoc(2, 2));
316         jSeparator4.setPreferredSize(new java.awt.Dimension JavaDoc(1, 2));
317         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
318         gridBagConstraints.gridx = 0;
319         gridBagConstraints.gridy = 3;
320         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
321         gridBagConstraints.weightx = 1.0;
322         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 4, 4, 4);
323         jPanel1.add(jSeparator4, gridBagConstraints);
324
325         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
326         gridBagConstraints.gridx = 0;
327         gridBagConstraints.gridy = 0;
328         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
329         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
330         gridBagConstraints.weightx = 1.0;
331         jPanelContent.add(jPanel1, gridBagConstraints);
332
333         jPanelStepContainer.setLayout(new java.awt.BorderLayout JavaDoc());
334
335         jPanelStepContainer.setPreferredSize(new java.awt.Dimension JavaDoc(220, 180));
336         jPanelStep0.setLayout(new java.awt.GridBagLayout JavaDoc());
337
338         jLabel2.setText("Available subdataset");
339         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
340         gridBagConstraints.gridx = 0;
341         gridBagConstraints.gridy = 0;
342         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
343         gridBagConstraints.weightx = 1.0;
344         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 8, 0, 8);
345         jPanelStep0.add(jLabel2, gridBagConstraints);
346
347         jComboBoxSubdataset.addActionListener(new java.awt.event.ActionListener JavaDoc() {
348             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
349                 jComboBoxSubdatasetActionPerformed(evt);
350             }
351         });
352
353         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
354         gridBagConstraints.gridx = 0;
355         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
356         gridBagConstraints.weightx = 1.0;
357         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 8, 0, 8);
358         jPanelStep0.add(jComboBoxSubdataset, gridBagConstraints);
359
360         jButtonNewSubDataset.setText("Create new subdataset");
361         jButtonNewSubDataset.setActionCommand("Create a new subdataset");
362         jButtonNewSubDataset.addActionListener(new java.awt.event.ActionListener JavaDoc() {
363             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
364                 jButtonNewSubDatasetActionPerformed(evt);
365             }
366         });
367
368         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
369         gridBagConstraints.gridx = 0;
370         gridBagConstraints.gridy = 3;
371         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
372         gridBagConstraints.insets = new java.awt.Insets JavaDoc(8, 8, 0, 8);
373         jPanelStep0.add(jButtonNewSubDataset, gridBagConstraints);
374
375         jPanelStepContainer.add(jPanelStep0, java.awt.BorderLayout.CENTER);
376
377         jPanelStep1.setLayout(new java.awt.GridBagLayout JavaDoc());
378
379         jLabel3.setIcon(new javax.swing.ImageIcon JavaDoc(getClass().getResource("/it/businesslogic/ireport/icons/crosstab/wizard_rows.png")));
380         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
381         gridBagConstraints.gridx = 0;
382         jPanelStep1.add(jLabel3, gridBagConstraints);
383
384         groupByFieldPanel1.setTitle("Row group 1");
385         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
386         gridBagConstraints.gridx = 0;
387         gridBagConstraints.gridy = 1;
388         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
389         gridBagConstraints.weightx = 1.0;
390         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 4, 4, 4);
391         jPanelStep1.add(groupByFieldPanel1, gridBagConstraints);
392
393         groupByFieldPanel2.setTitle("Row group 2");
394         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
395         gridBagConstraints.gridx = 0;
396         gridBagConstraints.gridy = 2;
397         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
398         gridBagConstraints.weightx = 1.0;
399         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 4, 4, 4);
400         jPanelStep1.add(groupByFieldPanel2, gridBagConstraints);
401
402         jPanel3.setLayout(new java.awt.GridBagLayout JavaDoc());
403
404         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
405         gridBagConstraints.gridx = 0;
406         gridBagConstraints.weighty = 1.0;
407         jPanelStep1.add(jPanel3, gridBagConstraints);
408
409         jPanelStepContainer.add(jPanelStep1, java.awt.BorderLayout.CENTER);
410
411         jPanelStep2.setLayout(new java.awt.GridBagLayout JavaDoc());
412
413         jPanelStep2.setMinimumSize(new java.awt.Dimension JavaDoc(250, 231));
414         jPanelStep2.setOpaque(false);
415         jPanelStep2.setPreferredSize(new java.awt.Dimension JavaDoc(250, 250));
416         jLabel4.setIcon(new javax.swing.ImageIcon JavaDoc(getClass().getResource("/it/businesslogic/ireport/icons/crosstab/wizard_columns.png")));
417         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
418         gridBagConstraints.gridx = 0;
419         jPanelStep2.add(jLabel4, gridBagConstraints);
420
421         groupByFieldPanel3.setTitle("Column group 1");
422         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
423         gridBagConstraints.gridx = 0;
424         gridBagConstraints.gridy = 1;
425         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
426         gridBagConstraints.weightx = 1.0;
427         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 4, 4, 4);
428         jPanelStep2.add(groupByFieldPanel3, gridBagConstraints);
429
430         groupByFieldPanel4.setTitle("Column group 2");
431         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
432         gridBagConstraints.gridx = 0;
433         gridBagConstraints.gridy = 2;
434         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
435         gridBagConstraints.weightx = 1.0;
436         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 4, 4, 4);
437         jPanelStep2.add(groupByFieldPanel4, gridBagConstraints);
438
439         jPanel4.setLayout(new java.awt.GridBagLayout JavaDoc());
440
441         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
442         gridBagConstraints.gridx = 0;
443         gridBagConstraints.weighty = 1.0;
444         jPanelStep2.add(jPanel4, gridBagConstraints);
445
446         jPanelStepContainer.add(jPanelStep2, java.awt.BorderLayout.CENTER);
447
448         jPanelStep3.setLayout(new java.awt.GridBagLayout JavaDoc());
449
450         jLabel5.setIcon(new javax.swing.ImageIcon JavaDoc(getClass().getResource("/it/businesslogic/ireport/icons/crosstab/wizard_details.png")));
451         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
452         gridBagConstraints.gridx = 0;
453         gridBagConstraints.gridwidth = 2;
454         jPanelStep3.add(jLabel5, gridBagConstraints);
455
456         jLabelDetailField.setText("Detail field");
457         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
458         gridBagConstraints.gridx = 0;
459         gridBagConstraints.gridy = 1;
460         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
461         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 4, 0, 0);
462         jPanelStep3.add(jLabelDetailField, gridBagConstraints);
463
464         jComboBoxDetailField.setPreferredSize(new java.awt.Dimension JavaDoc(55, 20));
465         jComboBoxDetailField.addActionListener(new java.awt.event.ActionListener JavaDoc() {
466             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
467                 jComboBoxDetailFieldActionPerformed(evt);
468             }
469         });
470
471         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
472         gridBagConstraints.gridx = 1;
473         gridBagConstraints.gridy = 1;
474         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
475         gridBagConstraints.weightx = 1.0;
476         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 4, 0, 4);
477         jPanelStep3.add(jComboBoxDetailField, gridBagConstraints);
478
479         jLabelDetailField1.setText("Function");
480         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
481         gridBagConstraints.gridx = 0;
482         gridBagConstraints.gridy = 2;
483         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
484         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 4, 0, 0);
485         jPanelStep3.add(jLabelDetailField1, gridBagConstraints);
486
487         jComboBoxDetailFieldFunction.setPreferredSize(new java.awt.Dimension JavaDoc(55, 20));
488         jComboBoxDetailFieldFunction.addActionListener(new java.awt.event.ActionListener JavaDoc() {
489             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
490                 jComboBoxDetailFieldActionPerformed1(evt);
491             }
492         });
493
494         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
495         gridBagConstraints.gridx = 1;
496         gridBagConstraints.gridy = 2;
497         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
498         gridBagConstraints.weightx = 1.0;
499         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 4, 0, 4);
500         jPanelStep3.add(jComboBoxDetailFieldFunction, gridBagConstraints);
501
502         jPanel5.setLayout(new java.awt.GridBagLayout JavaDoc());
503
504         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
505         gridBagConstraints.gridx = 0;
506         gridBagConstraints.weighty = 1.0;
507         jPanelStep3.add(jPanel5, gridBagConstraints);
508
509         jPanelStepContainer.add(jPanelStep3, java.awt.BorderLayout.CENTER);
510
511         jPanelStep4.setLayout(new java.awt.GridBagLayout JavaDoc());
512
513         jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
514         jLabel6.setIcon(new javax.swing.ImageIcon JavaDoc(getClass().getResource("/it/businesslogic/ireport/icons/crosstab/wizard_totals.png")));
515         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
516         gridBagConstraints.gridx = 0;
517         gridBagConstraints.gridwidth = 2;
518         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
519         gridBagConstraints.weightx = 1.0;
520         jPanelStep4.add(jLabel6, gridBagConstraints);
521
522         jCheckBoxTotalRows.setSelected(true);
523         jCheckBoxTotalRows.setText("Add row group totals");
524         jCheckBoxTotalRows.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
525         jCheckBoxTotalRows.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
526         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
527         gridBagConstraints.gridx = 0;
528         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
529         gridBagConstraints.insets = new java.awt.Insets JavaDoc(8, 8, 8, 8);
530         jPanelStep4.add(jCheckBoxTotalRows, gridBagConstraints);
531
532         jCheckBoxTotalColumns.setSelected(true);
533         jCheckBoxTotalColumns.setText("Add column group totals");
534         jCheckBoxTotalColumns.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
535         jCheckBoxTotalColumns.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
536         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
537         gridBagConstraints.gridx = 0;
538         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
539         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 8, 8, 8);
540         jPanelStep4.add(jCheckBoxTotalColumns, gridBagConstraints);
541
542         jCheckBoxPrintGrid.setSelected(true);
543         jCheckBoxPrintGrid.setText("Show grid lines");
544         jCheckBoxPrintGrid.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
545         jCheckBoxPrintGrid.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
546         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
547         gridBagConstraints.gridx = 0;
548         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
549         gridBagConstraints.insets = new java.awt.Insets JavaDoc(8, 8, 8, 8);
550         jPanelStep4.add(jCheckBoxPrintGrid, gridBagConstraints);
551
552         jPanel6.setLayout(new java.awt.GridBagLayout JavaDoc());
553
554         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
555         gridBagConstraints.gridx = 0;
556         gridBagConstraints.weightx = 1.0;
557         gridBagConstraints.weighty = 1.0;
558         jPanelStep4.add(jPanel6, gridBagConstraints);
559
560         jPanelStepContainer.add(jPanelStep4, java.awt.BorderLayout.CENTER);
561
562         jPanelStep5.setLayout(new java.awt.GridBagLayout JavaDoc());
563
564         jScrollPane1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
565         jTextArea1.setColumns(20);
566         jTextArea1.setEditable(false);
567         jTextArea1.setRows(5);
568         jTextArea1.setText("You have successfully entered all the required information to\ncreate a crosstab.\n\nTo save this settings, click Finish");
569         jTextArea1.setOpaque(false);
570         jScrollPane1.setViewportView(jTextArea1);
571
572         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
573         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
574         gridBagConstraints.weightx = 1.0;
575         gridBagConstraints.weighty = 1.0;
576         gridBagConstraints.insets = new java.awt.Insets JavaDoc(20, 10, 10, 10);
577         jPanelStep5.add(jScrollPane1, gridBagConstraints);
578
579         jPanelStepContainer.add(jPanelStep5, java.awt.BorderLayout.CENTER);
580
581         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
582         gridBagConstraints.gridx = 0;
583         gridBagConstraints.gridy = 1;
584         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
585         gridBagConstraints.weightx = 1.0;
586         gridBagConstraints.weighty = 1.0;
587         jPanelContent.add(jPanelStepContainer, gridBagConstraints);
588
589         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
590         gridBagConstraints.gridx = 1;
591         gridBagConstraints.gridy = 0;
592         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
593         gridBagConstraints.weightx = 1.0;
594         gridBagConstraints.weighty = 1.0;
595         jPanelBase.add(jPanelContent, gridBagConstraints);
596
597         jSeparator3.setBackground(new java.awt.Color JavaDoc(204, 204, 255));
598         jSeparator3.setForeground(new java.awt.Color JavaDoc(0, 0, 0));
599         jSeparator3.setMaximumSize(new java.awt.Dimension JavaDoc(32767, 2));
600         jSeparator3.setMinimumSize(new java.awt.Dimension JavaDoc(2, 2));
601         jSeparator3.setPreferredSize(new java.awt.Dimension JavaDoc(1, 2));
602         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
603         gridBagConstraints.gridx = 0;
604         gridBagConstraints.gridy = 2;
605         gridBagConstraints.gridwidth = 2;
606         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
607         jPanelBase.add(jSeparator3, gridBagConstraints);
608
609         jPanelContentButtons.setLayout(new java.awt.GridBagLayout JavaDoc());
610
611         jPanelContentButtons.setMinimumSize(new java.awt.Dimension JavaDoc(10, 30));
612         jPanelContentButtons.setPreferredSize(new java.awt.Dimension JavaDoc(10, 40));
613         jPanel2.setLayout(new java.awt.BorderLayout JavaDoc());
614
615         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
616         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
617         gridBagConstraints.weightx = 1.0;
618         jPanelContentButtons.add(jPanel2, gridBagConstraints);
619
620         jButtonPrev.setText("< Prev");
621         jButtonPrev.setEnabled(false);
622         jButtonPrev.addActionListener(new java.awt.event.ActionListener JavaDoc() {
623             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
624                 jButtonPrevActionPerformed(evt);
625             }
626         });
627
628         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
629         gridBagConstraints.insets = new java.awt.Insets JavaDoc(8, 2, 8, 2);
630         jPanelContentButtons.add(jButtonPrev, gridBagConstraints);
631
632         jButtonNext.setText("Next >");
633         jButtonNext.setEnabled(false);
634         jButtonNext.addActionListener(new java.awt.event.ActionListener JavaDoc() {
635             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
636                 jButtonNextActionPerformed(evt);
637             }
638         });
639
640         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
641         gridBagConstraints.insets = new java.awt.Insets JavaDoc(8, 2, 8, 2);
642         jPanelContentButtons.add(jButtonNext, gridBagConstraints);
643
644         jButtonFinish.setText("Finish");
645         jButtonFinish.addActionListener(new java.awt.event.ActionListener JavaDoc() {
646             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
647                 jButtonFinishActionPerformed(evt);
648             }
649         });
650
651         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
652         gridBagConstraints.insets = new java.awt.Insets JavaDoc(8, 2, 8, 2);
653         jPanelContentButtons.add(jButtonFinish, gridBagConstraints);
654
655         jButtonCancel.setText("Cancel");
656         jButtonCancel.addActionListener(new java.awt.event.ActionListener JavaDoc() {
657             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
658                 jButtonCancelActionPerformed(evt);
659             }
660         });
661
662         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
663         gridBagConstraints.insets = new java.awt.Insets JavaDoc(8, 2, 8, 4);
664         jPanelContentButtons.add(jButtonCancel, gridBagConstraints);
665
666         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
667         gridBagConstraints.gridx = 0;
668         gridBagConstraints.gridwidth = 2;
669         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
670         gridBagConstraints.weightx = 1.0;
671         jPanelBase.add(jPanelContentButtons, gridBagConstraints);
672
673         getContentPane().add(jPanelBase, java.awt.BorderLayout.CENTER);
674
675         pack();
676     }// </editor-fold>//GEN-END:initComponents
677

678     public void applyStandardBlackBox(CrosstabCell cell)
679     {
680         cell.getBox().setRightBorderColor(Color.BLACK);
681         cell.getBox().setRightBorder("1Point");
682         cell.getBox().setBottomBorderColor(Color.BLACK);
683         cell.getBox().setBottomBorder("1Point");
684     }
685     
686     public void addTextfieldElement(CrosstabCell cell, String JavaDoc expression, String JavaDoc expressionClass)
687     {
688         TextFieldReportElement tf = new TextFieldReportElement(0,0,cell.getWidth(),cell.getHeight());
689         tf.setRelativePosition(new Point JavaDoc(0,0));
690         tf.setCell(cell);
691         tf.setText( expression );
692         tf.setMatchingClassExpression( expressionClass , true);
693         tf.setVerticalAlign("Middle");
694         tf.setAlign("Center");
695         getCrosstabReportElement().getElements().add(tf);
696     }
697     
698     /**
699      * This method is used to avoid similar names for group and measures.
700      * If add = 0, no suffix is appended if the name is unique.
701      * Return baseName if baseName is unique, otherwise baseNameX where X > 0
702      */

703     public String JavaDoc getGroupMeasureName(String JavaDoc baseName, int add)
704     {
705         String JavaDoc name = baseName + ((add == 0) ? "" : ""+add);
706         add++;
707         
708         for (int i=0; i<getCrosstabReportElement().getRowGroups().size(); ++i)
709         {
710             CrosstabGroup cg = (CrosstabGroup)getCrosstabReportElement().getRowGroups().elementAt(i);
711             if (cg.getName().equals(name))
712             {
713                 return getGroupMeasureName(baseName, add);
714             }
715         }
716         
717         for (int i=0; i<getCrosstabReportElement().getColumnGroups().size(); ++i)
718         {
719             CrosstabGroup cg = (CrosstabGroup)getCrosstabReportElement().getColumnGroups().elementAt(i);
720             if (cg.getName().equals(name))
721             {
722                 return getGroupMeasureName(baseName, add);
723             }
724         }
725         
726         for (int i=0; i<getCrosstabReportElement().getMeasures().size(); ++i)
727         {
728             Measure cm = (Measure)getCrosstabReportElement().getMeasures().elementAt(i);
729             if (cm.getName().equals(name))
730             {
731                 return getGroupMeasureName(baseName, add);
732             }
733         }
734         
735         return name;
736     }
737         
738     private void jButtonFinishActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonFinishActionPerformed
739

740         try {
741             
742         SubDataset sd = (SubDataset)jComboBoxSubdataset.getSelectedItem();
743         if (!(sd instanceof Report))
744         {
745             Dataset dataset = new Dataset();
746             dataset.setSubDataset(sd);
747             dataset.setConnectionExpression("$P{REPORT_CONNECTION}");
748             dataset.setUseConnection(true);
749             getCrosstabReportElement().setDataset( dataset );
750             getCrosstabReportElement().setUseDataset(true);
751         }
752             
753             
754         // 1. Add the first row group.
755
CrosstabCell cell = (CrosstabCell)this.getCrosstabReportElement().getCells().elementAt(0);
756         cell.setWidth(50);
757         cell.setHeight(30);
758         
759         if (jCheckBoxPrintGrid.isSelected())
760         {
761             applyStandardBlackBox(cell);
762         }
763         
764         CrosstabGroup group = new CrosstabRowGroup();
765         group.setName( getGroupMeasureName(groupByFieldPanel1.getFieldName(),0) );
766         group.setBucketExpression( groupByFieldPanel1.getExpression() );
767         group.setBucketExpressionClass( groupByFieldPanel1.getExpressionClass());
768         CrosstabCell headerCell = new CrosstabCell();
769         headerCell.setName(group.getName()+" header");
770         headerCell.setType(CrosstabCell.HEADER_CELL);
771         headerCell.setWidth( group.getSize() );
772         headerCell.setHeight( 30 );
773         
774         if (jCheckBoxPrintGrid.isSelected())
775         {
776             headerCell.getBox().setLeftBorder("1Point");
777             headerCell.getBox().setLeftBorderColor(Color.BLACK);
778             applyStandardBlackBox(headerCell);
779         }
780         applyStandardBlackBox(headerCell);
781         group.setHeaderCell(headerCell);
782         addTextfieldElement(headerCell, "$V{" + group.getName() + "}", group.getBucketExpressionClass());
783         
784         CrosstabCell totalHeaderCell = new CrosstabCell();
785         totalHeaderCell.setName(group.getName()+" total header");
786         totalHeaderCell.setType(CrosstabCell.HEADER_CELL);
787         totalHeaderCell.setWidth( group.getSize() );
788         if (jCheckBoxTotalRows.isSelected())
789         {
790             group.setTotalPosition("End");
791             totalHeaderCell.setHeight(30);
792             addTextfieldElement(totalHeaderCell, "\"" + group.getName() + " total\"", "java.lang.String");
793         }
794         else
795         {
796             totalHeaderCell.setHeight(0);
797         }
798         if (jCheckBoxPrintGrid.isSelected())
799         {
800             totalHeaderCell.getBox().setLeftBorder("1Point");
801             totalHeaderCell.getBox().setLeftBorderColor(Color.BLACK);
802             applyStandardBlackBox(totalHeaderCell);
803         }
804         group.setTotalCell(totalHeaderCell);
805         
806         getCrosstabReportElement().getCells().add( group.getHeaderCell());
807         getCrosstabReportElement().getCells().add( group.getTotalCell());
808         
809         getCrosstabReportElement().getRowGroups().add(group);
810
811         // 2. Add the second row group. ----------------------------------------------------
812
if (groupByFieldPanel2.getFieldName() != null && !groupByFieldPanel2.getFieldName().equals(""))
813         {
814             group = new CrosstabRowGroup();
815             group.setName( getGroupMeasureName(groupByFieldPanel2.getFieldName(),0));
816             group.setBucketExpression( groupByFieldPanel2.getExpression() );
817             group.setBucketExpressionClass( groupByFieldPanel2.getExpressionClass());
818             headerCell = new CrosstabCell();
819             headerCell.setName(group.getName()+" header");
820             headerCell.setType(CrosstabCell.HEADER_CELL);
821             headerCell.setWidth( group.getSize() );
822             headerCell.setHeight( 30 );
823             group.setHeaderCell(headerCell);
824             if (jCheckBoxPrintGrid.isSelected()) applyStandardBlackBox(headerCell);
825             addTextfieldElement(headerCell, "$V{" + group.getName() + "}", group.getBucketExpressionClass());
826
827             totalHeaderCell = new CrosstabCell();
828             totalHeaderCell.setName(group.getName()+" total header");
829             totalHeaderCell.setType(CrosstabCell.HEADER_CELL);
830             totalHeaderCell.setWidth( group.getSize() );
831
832
833             if (jCheckBoxTotalRows.isSelected())
834             {
835                 group.setTotalPosition("End");
836                 totalHeaderCell.setHeight(30);
837                 addTextfieldElement(totalHeaderCell, "\"" + group.getName() + " total\"", "java.lang.String");
838             }
839             else
840             {
841                 totalHeaderCell.setHeight(0);
842             }
843             group.setTotalCell(totalHeaderCell);
844             if (jCheckBoxPrintGrid.isSelected()) applyStandardBlackBox(totalHeaderCell);
845             
846             getCrosstabReportElement().getCells().add( group.getHeaderCell());
847             getCrosstabReportElement().getCells().add( group.getTotalCell());
848
849             getCrosstabReportElement().getRowGroups().add(group);
850         }
851         
852         // 3. Add the first column group -------------------------------------------------
853

854         group = new CrosstabColumnGroup();
855         group.setName( getGroupMeasureName(groupByFieldPanel3.getFieldName(),0));
856         group.setBucketExpression( groupByFieldPanel3.getExpression() );
857         group.setBucketExpressionClass( groupByFieldPanel3.getExpressionClass());
858         headerCell = new CrosstabCell();
859         headerCell.setName(group.getName()+" header");
860         headerCell.setType(CrosstabCell.HEADER_CELL);
861         headerCell.setHeight( group.getSize() );
862         headerCell.setWidth( 50 );
863         if (jCheckBoxPrintGrid.isSelected())
864         {
865             headerCell.getBox().setTopBorder("1Point");
866             headerCell.getBox().setTopBorderColor(Color.BLACK);
867             applyStandardBlackBox(headerCell);
868         }
869         group.setHeaderCell(headerCell);
870         addTextfieldElement(headerCell, "$V{" + group.getName() + "}", group.getBucketExpressionClass());
871         
872         totalHeaderCell = new CrosstabCell();
873         totalHeaderCell.setName(group.getName()+" total header");
874         totalHeaderCell.setType(CrosstabCell.HEADER_CELL);
875         totalHeaderCell.setHeight( group.getSize() );
876         if (jCheckBoxTotalColumns.isSelected())
877         {
878             group.setTotalPosition("End");
879             totalHeaderCell.setWidth(50);
880             addTextfieldElement(totalHeaderCell, "\"" + group.getName() + " total\"", "java.lang.String");
881         }
882         else
883         {
884             totalHeaderCell.setWidth(0);
885         }
886         if (jCheckBoxPrintGrid.isSelected())
887         {
888             totalHeaderCell.getBox().setTopBorder("1Point");
889             totalHeaderCell.getBox().setTopBorderColor(Color.BLACK);
890             applyStandardBlackBox(totalHeaderCell);
891         }
892         group.setTotalCell(totalHeaderCell);
893         
894         getCrosstabReportElement().getCells().add( group.getHeaderCell());
895         getCrosstabReportElement().getCells().add( group.getTotalCell());
896         
897         getCrosstabReportElement().getColumnGroups().add(group);
898         
899         // 4. Add the first column group -------------------------------------------------
900
if (groupByFieldPanel4.getFieldName() != null && !groupByFieldPanel4.getFieldName().equals(""))
901         {
902             group = new CrosstabColumnGroup();
903             group.setName( getGroupMeasureName(groupByFieldPanel4.getFieldName(),0));
904             group.setBucketExpression( groupByFieldPanel4.getExpression() );
905             group.setBucketExpressionClass( groupByFieldPanel4.getExpressionClass());
906             
907             headerCell = new CrosstabCell();
908             headerCell.setName(group.getName()+" header");
909             headerCell.setType(CrosstabCell.HEADER_CELL);
910             headerCell.setHeight( group.getSize() );
911             headerCell.setWidth( 50 );
912             if (jCheckBoxPrintGrid.isSelected())
913             {
914                 applyStandardBlackBox(headerCell);
915             }
916             group.setHeaderCell(headerCell);
917             addTextfieldElement(headerCell, "$V{" + group.getName() + "}", group.getBucketExpressionClass());
918
919             totalHeaderCell = new CrosstabCell();
920             totalHeaderCell.setName(group.getName()+" total header");
921             totalHeaderCell.setType(CrosstabCell.HEADER_CELL);
922             totalHeaderCell.setHeight( group.getSize() );
923             if (jCheckBoxTotalColumns.isSelected())
924             {
925                 group.setTotalPosition("End");
926                 totalHeaderCell.setWidth(50);
927                 addTextfieldElement(totalHeaderCell, "\"" + group.getName() + " total\"", "java.lang.String");
928             }
929             else
930             {
931                 totalHeaderCell.setWidth(0);
932             }
933             group.setTotalCell(totalHeaderCell);
934             if (jCheckBoxPrintGrid.isSelected()) applyStandardBlackBox(totalHeaderCell);
935
936             getCrosstabReportElement().getCells().add( group.getHeaderCell());
937             getCrosstabReportElement().getCells().add( group.getTotalCell());
938
939             getCrosstabReportElement().getColumnGroups().add(group);
940
941             
942         }
943         // 5. Create measure -------------------------------------------------
944
WizardFieldObject wfo = (WizardFieldObject)this.jComboBoxDetailField.getSelectedItem();
945         Measure measure = new Measure( getGroupMeasureName(wfo.getName()+"_"+ this.jComboBoxDetailFieldFunction.getSelectedItem(),0) );
946         measure.setClassType( wfo.getExpressionClass(null) );
947         measure.setCalculation( this.jComboBoxDetailFieldFunction.getSelectedItem()+"");
948         measure.setExpression( wfo.getExpression("") );
949         this.getCrosstabReportElement().getMeasures().add(measure);
950         
951         // Add maincell elements...
952
addTextfieldElement(cell, "$V{" + measure.getName() + "}", measure.getClassType());
953         
954         setDialogResult(javax.swing.JOptionPane.OK_OPTION);
955         setVisible(false);
956         
957         } catch (Exception JavaDoc ex)
958         {
959             ex.printStackTrace();
960         }
961         
962         setDialogResult(javax.swing.JOptionPane.OK_OPTION);
963         setVisible(false);
964         
965         
966         
967     }//GEN-LAST:event_jButtonFinishActionPerformed
968

969     private void jButtonNewSubDatasetActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonNewSubDatasetActionPerformed
970

971         SubDatasetDialog sds = new SubDatasetDialog(this,true);
972         sds.setVisible(true);
973         this.setReport( report );
974     }//GEN-LAST:event_jButtonNewSubDatasetActionPerformed
975

976     private void jComboBoxDetailFieldActionPerformed1(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jComboBoxDetailFieldActionPerformed1
977
// TODO add your handling code here:
978
}//GEN-LAST:event_jComboBoxDetailFieldActionPerformed1
979

980     private void jComboBoxDetailFieldActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jComboBoxDetailFieldActionPerformed
981

982         if (jComboBoxDetailField.getSelectedIndex() < 0 || !(jComboBoxDetailField.getSelectedItem() instanceof WizardFieldObject))
983         {
984             jComboBoxDetailFieldFunction.removeAllItems();
985         }
986         else
987         {
988             WizardFieldObject wfo = (WizardFieldObject)jComboBoxDetailField.getSelectedItem();
989             Misc.updateComboBox(jComboBoxDetailFieldFunction, wfo.getFunctions());
990             if (jComboBoxDetailFieldFunction.getItemCount() > 0)
991             {
992                 jComboBoxDetailFieldFunction.setSelectedIndex(0);
993             }
994         }
995         
996         if (getCurrentStep() == 3) this.updateButtons();
997         
998     }//GEN-LAST:event_jComboBoxDetailFieldActionPerformed
999

1000    private void jButtonPrevActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonPrevActionPerformed
1001

1002        this.goPrevious();
1003        
1004    }//GEN-LAST:event_jButtonPrevActionPerformed
1005

1006    private void jButtonNextActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonNextActionPerformed
1007

1008        this.goNext();
1009        
1010    }//GEN-LAST:event_jButtonNextActionPerformed
1011

1012    private void jButtonCancelActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
1013

1014        dialogResult = javax.swing.JOptionPane.CLOSED_OPTION;
1015        this.setVisible(false);
1016        this.dispose();
1017        
1018    }//GEN-LAST:event_jButtonCancelActionPerformed
1019

1020    private void jComboBoxSubdatasetActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jComboBoxSubdatasetActionPerformed
1021

1022        if (jComboBoxSubdataset.getSelectedItem() != null &&
1023            jComboBoxSubdataset.getSelectedItem() instanceof SubDataset)
1024        {
1025            setCrosstabSubDataset((SubDataset)jComboBoxSubdataset.getSelectedItem());
1026        }
1027        if (getCurrentStep() == 0) updateButtons();
1028    }//GEN-LAST:event_jComboBoxSubdatasetActionPerformed
1029

1030    public void goNext()
1031    {
1032        
1033        if (currentStep < getStepsPanels().size()-1)
1034        {
1035            currentStep++;
1036        }
1037        
1038        setCurrentStepLabel(currentStep);
1039        
1040        jPanelStepContainer.removeAll();
1041        jPanelStepContainer.add( (java.awt.Component JavaDoc)getStepsPanels().elementAt(currentStep), java.awt.BorderLayout.CENTER);
1042        jPanelStepContainer.updateUI();
1043        if (currentStep == 0)
1044        {
1045            jLabelStepDescription.setText("Step 1: Choose a subdataset or create a new one");
1046        }
1047        else if (currentStep == 1)
1048        {
1049            jLabelStepDescription.setText("Step 2: Define row group(s)");
1050        }
1051        else if (currentStep == 2)
1052        {
1053            jLabelStepDescription.setText("Step 3: Define column group(s)");
1054        }
1055        else if (currentStep == 3)
1056        {
1057            jLabelStepDescription.setText("Step 4: Define detail");
1058        }
1059        else if (currentStep == 4)
1060        {
1061            jLabelStepDescription.setText("Step 5: Choose a layout");
1062        }
1063        else if (currentStep == 5)
1064        {
1065            jLabelStepDescription.setText("Step 6: Finish");
1066        }
1067        updateButtons();
1068    }
1069    
1070    public void goPrevious()
1071    {
1072        if (currentStep > 0)
1073        {
1074            currentStep--;
1075        }
1076        
1077        jPanelStepContainer.removeAll();
1078        jPanelStepContainer.add( (java.awt.Component JavaDoc)getStepsPanels().elementAt(currentStep), java.awt.BorderLayout.CENTER);
1079        jPanelStepContainer.updateUI();
1080        
1081        setCurrentStepLabel(currentStep);
1082        
1083        updateButtons();
1084    }
1085    
1086    public void setCurrentStepLabel(int step)
1087    {
1088        for (int i=0; i<stepsLabels.size(); ++i)
1089        {
1090            JLabel JavaDoc label = (JLabel JavaDoc)stepsLabels.get(i);
1091            label.setFont( new java.awt.Font JavaDoc( label.getFont().getName(),
1092                                              ( i == step) ? java.awt.Font.BOLD : 0,
1093                                              label.getFont().getSize()));
1094            label.updateUI();
1095        }
1096    }
1097    
1098    
1099    public void updateButtons()
1100    {
1101        jButtonFinish.setEnabled( canFinish( ));
1102        jButtonPrev.setEnabled( canGoPrevious());
1103        jButtonNext.setEnabled( canGoNext() );
1104        
1105    }
1106    
1107    public boolean canGoPrevious()
1108    {
1109        return (getCurrentStep() > 0);
1110    }
1111    
1112    public boolean canGoNext()
1113    {
1114        if (getCurrentStep() == 0)
1115        {
1116            if (jComboBoxSubdataset.getSelectedItem() == null || !(jComboBoxSubdataset.getSelectedItem() instanceof SubDataset))
1117            {
1118                return false;
1119            }
1120        }
1121        else if (getCurrentStep() == 1)
1122        {
1123            if (groupByFieldPanel1.getFieldName() == null || groupByFieldPanel1.getFieldName().equals(""))
1124            {
1125                return false;
1126            }
1127        }
1128        else if (getCurrentStep() == 2)
1129        {
1130            if (groupByFieldPanel3.getFieldName() == null || groupByFieldPanel3.getFieldName().equals(""))
1131            {
1132                return false;
1133            }
1134        }
1135        else if (getCurrentStep() == 3)
1136        {
1137            if (jComboBoxDetailField.getSelectedIndex() < 0 || !(jComboBoxDetailField.getSelectedItem() instanceof WizardFieldObject))
1138            {
1139                return false;
1140            }
1141        }
1142        else if (getCurrentStep() == 4)
1143        {
1144            return true;
1145        }
1146        else if (getCurrentStep() == 5)
1147        {
1148            return false;
1149        }
1150        
1151        
1152        return true;
1153    }
1154    
1155    public boolean canFinish()
1156    {
1157        return (getCurrentStep() > 3 || (getCurrentStep() == 3 && canGoNext()));
1158    }
1159
1160    public int getCurrentStep() {
1161        return currentStep;
1162    }
1163
1164    public void setCurrentStep(int currentStep) {
1165        this.currentStep = currentStep;
1166    }
1167
1168    public SubDataset getCrosstabSubDataset() {
1169        return crosstabSubDataset;
1170    }
1171
1172    public void setCrosstabSubDataset(SubDataset crosstabSubDataset) {
1173        this.crosstabSubDataset = crosstabSubDataset;
1174        this.groupByFieldPanel1.populateBySubdataset(crosstabSubDataset);
1175        this.groupByFieldPanel2.populateBySubdataset(crosstabSubDataset, true);
1176        this.groupByFieldPanel3.populateBySubdataset(crosstabSubDataset);
1177        this.groupByFieldPanel4.populateBySubdataset(crosstabSubDataset, true);
1178        
1179        
1180        // Populate the field...
1181
jComboBoxDetailField.removeAllItems();
1182        for (int i=0; i<crosstabSubDataset.getFields().size(); ++i)
1183        {
1184           jComboBoxDetailField.addItem(new WizardFieldObject(crosstabSubDataset.getFields().get(i)));
1185        }
1186        for (int i=0; i<crosstabSubDataset.getVariables().size(); ++i)
1187        {
1188            jComboBoxDetailField.addItem(new WizardFieldObject(crosstabSubDataset.getVariables().get(i)));
1189        }
1190        for (int i=0; i<crosstabSubDataset.getParameters().size(); ++i)
1191        {
1192            jComboBoxDetailField.addItem(new WizardFieldObject(crosstabSubDataset.getParameters().get(i)));
1193        }
1194        
1195        if (jComboBoxDetailField.getItemCount() > 0)
1196        {
1197            jComboBoxDetailField.setSelectedIndex(0);
1198        }
1199        
1200        
1201    }
1202
1203    public Vector JavaDoc getStepsPanels() {
1204        return stepsPanels;
1205    }
1206
1207    public void setStepsPanels(Vector JavaDoc stepsPanels) {
1208        this.stepsPanels = stepsPanels;
1209    }
1210
1211    public Report getReport() {
1212        return report;
1213    }
1214
1215    public void setReport(Report report) {
1216        this.report = report;
1217        
1218        
1219        Misc.updateComboBox(jComboBoxSubdataset, getReport().getSubDatasets(), false);
1220        jComboBoxSubdataset.insertItemAt( report, 0);
1221        if (jComboBoxSubdataset.getItemCount() > 0)
1222        {
1223            jComboBoxSubdataset.setSelectedIndex(0);
1224        }
1225        
1226    }
1227
1228    public int getDialogResult() {
1229        return dialogResult;
1230    }
1231
1232    public void setDialogResult(int dialogResult) {
1233        this.dialogResult = dialogResult;
1234    }
1235
1236    public CrosstabReportElement getCrosstabReportElement() {
1237        return crosstabReportElement;
1238    }
1239
1240    public void setCrosstabReportElement(CrosstabReportElement crosstabReportElement) {
1241        this.crosstabReportElement = crosstabReportElement;
1242    }
1243    
1244    
1245    // Variables declaration - do not modify//GEN-BEGIN:variables
1246
private it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel groupByFieldPanel1;
1247    private it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel groupByFieldPanel2;
1248    private it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel groupByFieldPanel3;
1249    private it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel groupByFieldPanel4;
1250    private javax.swing.JButton JavaDoc jButtonCancel;
1251    private javax.swing.JButton JavaDoc jButtonFinish;
1252    private javax.swing.JButton JavaDoc jButtonNewSubDataset;
1253    private javax.swing.JButton JavaDoc jButtonNext;
1254    private javax.swing.JButton JavaDoc jButtonPrev;
1255    private javax.swing.JCheckBox JavaDoc jCheckBoxPrintGrid;
1256    private javax.swing.JCheckBox JavaDoc jCheckBoxTotalColumns;
1257    private javax.swing.JCheckBox JavaDoc jCheckBoxTotalRows;
1258    private javax.swing.JComboBox JavaDoc jComboBoxDetailField;
1259    private javax.swing.JComboBox JavaDoc jComboBoxDetailFieldFunction;
1260    private javax.swing.JComboBox JavaDoc jComboBoxSubdataset;
1261    private javax.swing.JLabel JavaDoc jLabel1;
1262    private javax.swing.JLabel JavaDoc jLabel2;
1263    private javax.swing.JLabel JavaDoc jLabel3;
1264    private javax.swing.JLabel JavaDoc jLabel4;
1265    private javax.swing.JLabel JavaDoc jLabel5;
1266    private javax.swing.JLabel JavaDoc jLabel6;
1267    private javax.swing.JLabel JavaDoc jLabel7;
1268    private javax.swing.JLabel JavaDoc jLabelDetailField;
1269    private javax.swing.JLabel JavaDoc jLabelDetailField1;
1270    private javax.swing.JLabel JavaDoc jLabelStep1;
1271    private javax.swing.JLabel JavaDoc jLabelStep2;
1272    private javax.swing.JLabel JavaDoc jLabelStep3;
1273    private javax.swing.JLabel JavaDoc jLabelStep4;
1274    private javax.swing.JLabel JavaDoc jLabelStep5;
1275    private javax.swing.JLabel JavaDoc jLabelStep6;
1276    private javax.swing.JLabel JavaDoc jLabelStepDescription;
1277    private javax.swing.JPanel JavaDoc jPanel1;
1278    private javax.swing.JPanel JavaDoc jPanel2;
1279    private javax.swing.JPanel JavaDoc jPanel3;
1280    private javax.swing.JPanel JavaDoc jPanel4;
1281    private javax.swing.JPanel JavaDoc jPanel5;
1282    private javax.swing.JPanel JavaDoc jPanel6;
1283    private javax.swing.JPanel JavaDoc jPanelBase;
1284    private javax.swing.JPanel JavaDoc jPanelContent;
1285    private javax.swing.JPanel JavaDoc jPanelContentButtons;
1286    private javax.swing.JPanel JavaDoc jPanelStep0;
1287    private javax.swing.JPanel JavaDoc jPanelStep1;
1288    private javax.swing.JPanel JavaDoc jPanelStep2;
1289    private javax.swing.JPanel JavaDoc jPanelStep3;
1290    private javax.swing.JPanel JavaDoc jPanelStep4;
1291    private javax.swing.JPanel JavaDoc jPanelStep5;
1292    private javax.swing.JPanel JavaDoc jPanelStepContainer;
1293    private javax.swing.JPanel JavaDoc jPanelSteps;
1294    private javax.swing.JScrollPane JavaDoc jScrollPane1;
1295    private javax.swing.JSeparator JavaDoc jSeparator2;
1296    private javax.swing.JSeparator JavaDoc jSeparator3;
1297    private javax.swing.JSeparator JavaDoc jSeparator4;
1298    private javax.swing.JTextArea JavaDoc jTextArea1;
1299    // End of variables declaration//GEN-END:variables
1300

1301    public void applyI18n(){
1302                // Start autogenerated code ----------------------
1303
jCheckBoxPrintGrid.setText(I18n.getString("crosstabWizardDialog.checkBoxPrintGrid","Show grid lines"));
1304                jCheckBoxTotalColumns.setText(I18n.getString("crosstabWizardDialog.checkBoxTotalColumns","Add column group totals"));
1305                jCheckBoxTotalRows.setText(I18n.getString("crosstabWizardDialog.checkBoxTotalRows","Add row group totals"));
1306                // End autogenerated code ----------------------
1307
// Start autogenerated code ----------------------
1308
jButtonCancel.setText(I18n.getString("crosstabWizardDialog.buttonCancel","Cancel"));
1309                jButtonFinish.setText(I18n.getString("crosstabWizardDialog.buttonFinish","Finish"));
1310                jButtonNewSubDataset.setText(I18n.getString("crosstabWizardDialog.buttonNewSubDataset","Create new subdataset"));
1311                jButtonNext.setText(I18n.getString("crosstabWizardDialog.buttonNext","Next >"));
1312                jButtonPrev.setText(I18n.getString("crosstabWizardDialog.buttonPrev","< Prev"));
1313                jLabel1.setText(I18n.getString("crosstabWizardDialog.label1","Steps"));
1314                jLabel2.setText(I18n.getString("crosstabWizardDialog.label2","Available subdataset"));
1315                jLabelDetailField.setText(I18n.getString("crosstabWizardDialog.labelDetailField","Detail field"));
1316                jLabelDetailField1.setText(I18n.getString("crosstabWizardDialog.labelDetailField1","Function"));
1317                jLabelStep1.setText(I18n.getString("crosstabWizardDialog.labelStep1","1. SubDataset selection"));
1318                jLabelStep2.setText(I18n.getString("crosstabWizardDialog.labelStep2","2. Rows"));
1319                jLabelStep3.setText(I18n.getString("crosstabWizardDialog.labelStep3","3. Columns"));
1320                jLabelStep4.setText(I18n.getString("crosstabWizardDialog.labelStep4","4. Detail"));
1321                jLabelStep5.setText(I18n.getString("crosstabWizardDialog.labelStep5","5. Layout"));
1322                jLabelStep6.setText(I18n.getString("crosstabWizardDialog.labelStep6","6. Finish"));
1323                jLabelStepDescription.setText(I18n.getString("crosstabWizardDialog.labelStepDescription","Steps"));
1324                // End autogenerated code ----------------------
1325
}
1326}
1327
Popular Tags