0001: /*
0002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
0003: * http://www.jaspersoft.com.
0004: *
0005: * Unless you have purchased a commercial license agreement from JasperSoft,
0006: * the following license terms apply:
0007: *
0008: * This program is free software; you can redistribute it and/or modify
0009: * it under the terms of the GNU General Public License version 2 as published by
0010: * the Free Software Foundation.
0011: *
0012: * This program is distributed WITHOUT ANY WARRANTY; and without the
0013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0014: * See the GNU General Public License for more details.
0015: *
0016: * You should have received a copy of the GNU General Public License
0017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
0018: * or write to:
0019: *
0020: * Free Software Foundation, Inc.,
0021: * 59 Temple Place - Suite 330,
0022: * Boston, MA USA 02111-1307
0023: *
0024: *
0025: *
0026: *
0027: * CrosstabWizardDialog.java
0028: *
0029: * Created on January 27, 2006, 12:11 PM
0030: *
0031: */
0032:
0033: package it.businesslogic.ireport.crosstab.gui;
0034:
0035: import it.businesslogic.ireport.CrosstabReportElement;
0036: import it.businesslogic.ireport.Report;
0037: import it.businesslogic.ireport.SubDataset;
0038: import it.businesslogic.ireport.TextFieldReportElement;
0039: import it.businesslogic.ireport.chart.Dataset;
0040: import it.businesslogic.ireport.crosstab.CrosstabCell;
0041: import it.businesslogic.ireport.crosstab.CrosstabColumnGroup;
0042: import it.businesslogic.ireport.crosstab.CrosstabGroup;
0043: import it.businesslogic.ireport.crosstab.CrosstabRowGroup;
0044: import it.businesslogic.ireport.crosstab.Measure;
0045: import it.businesslogic.ireport.gui.subdataset.SubDatasetDialog;
0046: import it.businesslogic.ireport.util.Misc;
0047: import java.awt.Color;
0048: import java.awt.Point;
0049: import java.util.Vector;
0050: import javax.swing.JLabel;
0051: import it.businesslogic.ireport.util.I18n;
0052:
0053: /**
0054: *
0055: * @author gtoffoli
0056: */
0057: public class CrosstabWizardDialog extends javax.swing.JDialog {
0058:
0059: private CrosstabReportElement crosstabReportElement = null;
0060:
0061: private SubDataset crosstabSubDataset = null;
0062: private int currentStep = -1;
0063:
0064: private int dialogResult = javax.swing.JOptionPane.CLOSED_OPTION;
0065:
0066: private Report report = null;
0067:
0068: private Vector stepsPanels = new Vector();
0069: private Vector stepsLabels = new Vector();
0070:
0071: /** Creates new form NewJDialog */
0072: public CrosstabWizardDialog(java.awt.Frame parent, boolean modal) {
0073: super (parent, modal);
0074: initComponents();
0075:
0076: stepsPanels.add(jPanelStep0);
0077: stepsPanels.add(jPanelStep1);
0078: stepsPanels.add(jPanelStep2);
0079: stepsPanels.add(jPanelStep3);
0080: stepsPanels.add(jPanelStep4);
0081: stepsPanels.add(jPanelStep5);
0082:
0083: stepsLabels.add(jLabelStep1);
0084: stepsLabels.add(jLabelStep2);
0085: stepsLabels.add(jLabelStep3);
0086: stepsLabels.add(jLabelStep4);
0087: stepsLabels.add(jLabelStep5);
0088: stepsLabels.add(jLabelStep6);
0089:
0090: groupByFieldPanel2.addVoidItem();
0091: groupByFieldPanel4.addVoidItem();
0092:
0093: groupByFieldPanel1
0094: .addActionListener(new java.awt.event.ActionListener() {
0095: public void actionPerformed(
0096: java.awt.event.ActionEvent evt) {
0097: groupByFieldPanel1CancelActionPerformed(evt);
0098: }
0099: });
0100:
0101: groupByFieldPanel2
0102: .addActionListener(new java.awt.event.ActionListener() {
0103: public void actionPerformed(
0104: java.awt.event.ActionEvent evt) {
0105: groupByFieldPanel2CancelActionPerformed(evt);
0106: }
0107: });
0108:
0109: groupByFieldPanel3
0110: .addActionListener(new java.awt.event.ActionListener() {
0111: public void actionPerformed(
0112: java.awt.event.ActionEvent evt) {
0113: groupByFieldPanel3CancelActionPerformed(evt);
0114: }
0115: });
0116:
0117: groupByFieldPanel4
0118: .addActionListener(new java.awt.event.ActionListener() {
0119: public void actionPerformed(
0120: java.awt.event.ActionEvent evt) {
0121: groupByFieldPanel4CancelActionPerformed(evt);
0122: }
0123: });
0124:
0125: applyI18n();
0126: goNext();
0127:
0128: pack();
0129: Misc.centerFrame(this );
0130: }
0131:
0132: public void groupByFieldPanel1CancelActionPerformed(
0133: java.awt.event.ActionEvent evt) {
0134: if (getCurrentStep() == 1)
0135: updateButtons();
0136: }
0137:
0138: public void groupByFieldPanel2CancelActionPerformed(
0139: java.awt.event.ActionEvent evt) {
0140:
0141: }
0142:
0143: public void groupByFieldPanel3CancelActionPerformed(
0144: java.awt.event.ActionEvent evt) {
0145: if (getCurrentStep() == 2)
0146: updateButtons();
0147: }
0148:
0149: public void groupByFieldPanel4CancelActionPerformed(
0150: java.awt.event.ActionEvent evt) {
0151: }
0152:
0153: /** This method is called from within the constructor to
0154: * initialize the form.
0155: * WARNING: Do NOT modify this code. The content of this method is
0156: * always regenerated by the Form Editor.
0157: */
0158: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
0159: private void initComponents() {
0160: java.awt.GridBagConstraints gridBagConstraints;
0161:
0162: jPanelBase = new javax.swing.JPanel();
0163: jPanelSteps = new javax.swing.JPanel();
0164: jLabel1 = new javax.swing.JLabel();
0165: jLabelStep1 = new javax.swing.JLabel();
0166: jLabelStep2 = new javax.swing.JLabel();
0167: jLabelStep3 = new javax.swing.JLabel();
0168: jLabelStep4 = new javax.swing.JLabel();
0169: jLabelStep5 = new javax.swing.JLabel();
0170: jLabelStep6 = new javax.swing.JLabel();
0171: jSeparator2 = new javax.swing.JSeparator();
0172: jLabel7 = new javax.swing.JLabel();
0173: jPanelContent = new javax.swing.JPanel();
0174: jPanel1 = new javax.swing.JPanel();
0175: jLabelStepDescription = new javax.swing.JLabel();
0176: jSeparator4 = new javax.swing.JSeparator();
0177: jPanelStepContainer = new javax.swing.JPanel();
0178: jPanelStep0 = new javax.swing.JPanel();
0179: jLabel2 = new javax.swing.JLabel();
0180: jComboBoxSubdataset = new javax.swing.JComboBox();
0181: jButtonNewSubDataset = new javax.swing.JButton();
0182: jPanelStep1 = new javax.swing.JPanel();
0183: jLabel3 = new javax.swing.JLabel();
0184: groupByFieldPanel1 = new it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel();
0185: groupByFieldPanel2 = new it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel();
0186: jPanel3 = new javax.swing.JPanel();
0187: jPanelStep2 = new javax.swing.JPanel();
0188: jLabel4 = new javax.swing.JLabel();
0189: groupByFieldPanel3 = new it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel();
0190: groupByFieldPanel4 = new it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel();
0191: jPanel4 = new javax.swing.JPanel();
0192: jPanelStep3 = new javax.swing.JPanel();
0193: jLabel5 = new javax.swing.JLabel();
0194: jLabelDetailField = new javax.swing.JLabel();
0195: jComboBoxDetailField = new javax.swing.JComboBox();
0196: jLabelDetailField1 = new javax.swing.JLabel();
0197: jComboBoxDetailFieldFunction = new javax.swing.JComboBox();
0198: jPanel5 = new javax.swing.JPanel();
0199: jPanelStep4 = new javax.swing.JPanel();
0200: jLabel6 = new javax.swing.JLabel();
0201: jCheckBoxTotalRows = new javax.swing.JCheckBox();
0202: jCheckBoxTotalColumns = new javax.swing.JCheckBox();
0203: jCheckBoxPrintGrid = new javax.swing.JCheckBox();
0204: jPanel6 = new javax.swing.JPanel();
0205: jPanelStep5 = new javax.swing.JPanel();
0206: jLabelResult = new javax.swing.JLabel();
0207: jSeparator3 = new javax.swing.JSeparator();
0208: jPanelContentButtons = new javax.swing.JPanel();
0209: jPanel2 = new javax.swing.JPanel();
0210: jButtonPrev = new javax.swing.JButton();
0211: jButtonNext = new javax.swing.JButton();
0212: jButtonFinish = new javax.swing.JButton();
0213: jButtonCancel = new javax.swing.JButton();
0214:
0215: setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
0216: jPanelBase.setLayout(new java.awt.GridBagLayout());
0217:
0218: jPanelSteps.setLayout(new java.awt.GridBagLayout());
0219:
0220: jLabel1.setText("Steps");
0221: gridBagConstraints = new java.awt.GridBagConstraints();
0222: gridBagConstraints.gridx = 0;
0223: gridBagConstraints.gridy = 1;
0224: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0225: gridBagConstraints.insets = new java.awt.Insets(8, 8, 0, 0);
0226: jPanelSteps.add(jLabel1, gridBagConstraints);
0227:
0228: jLabelStep1.setText("1. SubDataset selection");
0229: gridBagConstraints = new java.awt.GridBagConstraints();
0230: gridBagConstraints.gridx = 0;
0231: gridBagConstraints.gridy = 5;
0232: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0233: gridBagConstraints.insets = new java.awt.Insets(0, 8, 0, 0);
0234: jPanelSteps.add(jLabelStep1, gridBagConstraints);
0235:
0236: jLabelStep2.setText("2. Rows");
0237: gridBagConstraints = new java.awt.GridBagConstraints();
0238: gridBagConstraints.gridx = 0;
0239: gridBagConstraints.gridy = 6;
0240: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0241: gridBagConstraints.insets = new java.awt.Insets(0, 8, 0, 0);
0242: jPanelSteps.add(jLabelStep2, gridBagConstraints);
0243:
0244: jLabelStep3.setText("3. Columns");
0245: gridBagConstraints = new java.awt.GridBagConstraints();
0246: gridBagConstraints.gridx = 0;
0247: gridBagConstraints.gridy = 7;
0248: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0249: gridBagConstraints.insets = new java.awt.Insets(0, 8, 0, 0);
0250: jPanelSteps.add(jLabelStep3, gridBagConstraints);
0251:
0252: jLabelStep4.setText("4. Detail");
0253: gridBagConstraints = new java.awt.GridBagConstraints();
0254: gridBagConstraints.gridx = 0;
0255: gridBagConstraints.gridy = 8;
0256: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0257: gridBagConstraints.insets = new java.awt.Insets(0, 8, 0, 0);
0258: jPanelSteps.add(jLabelStep4, gridBagConstraints);
0259:
0260: jLabelStep5.setText("5. Layout");
0261: gridBagConstraints = new java.awt.GridBagConstraints();
0262: gridBagConstraints.gridx = 0;
0263: gridBagConstraints.gridy = 9;
0264: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0265: gridBagConstraints.insets = new java.awt.Insets(0, 8, 0, 0);
0266: jPanelSteps.add(jLabelStep5, gridBagConstraints);
0267:
0268: jLabelStep6.setText("6. Finish");
0269: gridBagConstraints = new java.awt.GridBagConstraints();
0270: gridBagConstraints.gridx = 0;
0271: gridBagConstraints.gridy = 10;
0272: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0273: gridBagConstraints.insets = new java.awt.Insets(0, 8, 0, 0);
0274: jPanelSteps.add(jLabelStep6, gridBagConstraints);
0275:
0276: jSeparator2.setBackground(new java.awt.Color(204, 204, 255));
0277: jSeparator2.setForeground(new java.awt.Color(0, 0, 0));
0278: jSeparator2.setMaximumSize(new java.awt.Dimension(32767, 2));
0279: jSeparator2.setMinimumSize(new java.awt.Dimension(2, 2));
0280: jSeparator2.setPreferredSize(new java.awt.Dimension(1, 2));
0281: gridBagConstraints = new java.awt.GridBagConstraints();
0282: gridBagConstraints.gridx = 0;
0283: gridBagConstraints.gridy = 2;
0284: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0285: gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 0);
0286: jPanelSteps.add(jSeparator2, gridBagConstraints);
0287:
0288: jLabel7.setBackground(new java.awt.Color(207, 217, 231));
0289: jLabel7.setIcon(new javax.swing.ImageIcon(getClass()
0290: .getResource(
0291: "/it/businesslogic/ireport/icons/wizard.jpg")));
0292: jLabel7.setVerticalAlignment(javax.swing.SwingConstants.TOP);
0293: jLabel7.setOpaque(true);
0294: jLabel7.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
0295: gridBagConstraints = new java.awt.GridBagConstraints();
0296: gridBagConstraints.gridx = 0;
0297: gridBagConstraints.gridy = 0;
0298: gridBagConstraints.gridheight = 20;
0299: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0300: gridBagConstraints.weightx = 1.0;
0301: gridBagConstraints.weighty = 1.0;
0302: jPanelSteps.add(jLabel7, gridBagConstraints);
0303:
0304: gridBagConstraints = new java.awt.GridBagConstraints();
0305: gridBagConstraints.gridx = 0;
0306: gridBagConstraints.gridy = 0;
0307: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0308: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0309: gridBagConstraints.weighty = 1.0;
0310: jPanelBase.add(jPanelSteps, gridBagConstraints);
0311:
0312: jPanelContent.setLayout(new java.awt.GridBagLayout());
0313:
0314: jPanel1.setLayout(new java.awt.GridBagLayout());
0315:
0316: jPanel1.setMinimumSize(new java.awt.Dimension(40, 40));
0317: jPanel1.setPreferredSize(new java.awt.Dimension(280, 40));
0318: jLabelStepDescription.setText("Steps");
0319: gridBagConstraints = new java.awt.GridBagConstraints();
0320: gridBagConstraints.gridx = 0;
0321: gridBagConstraints.gridy = 1;
0322: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0323: gridBagConstraints.weightx = 1.0;
0324: gridBagConstraints.insets = new java.awt.Insets(2, 8, 0, 0);
0325: jPanel1.add(jLabelStepDescription, gridBagConstraints);
0326:
0327: jSeparator4.setBackground(new java.awt.Color(204, 204, 255));
0328: jSeparator4.setForeground(new java.awt.Color(0, 0, 0));
0329: jSeparator4.setMaximumSize(new java.awt.Dimension(32767, 2));
0330: jSeparator4.setMinimumSize(new java.awt.Dimension(2, 2));
0331: jSeparator4.setPreferredSize(new java.awt.Dimension(1, 2));
0332: gridBagConstraints = new java.awt.GridBagConstraints();
0333: gridBagConstraints.gridx = 0;
0334: gridBagConstraints.gridy = 3;
0335: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0336: gridBagConstraints.weightx = 1.0;
0337: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
0338: jPanel1.add(jSeparator4, gridBagConstraints);
0339:
0340: gridBagConstraints = new java.awt.GridBagConstraints();
0341: gridBagConstraints.gridx = 0;
0342: gridBagConstraints.gridy = 0;
0343: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0344: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
0345: gridBagConstraints.weightx = 1.0;
0346: jPanelContent.add(jPanel1, gridBagConstraints);
0347:
0348: jPanelStepContainer.setLayout(new java.awt.BorderLayout());
0349:
0350: jPanelStepContainer.setPreferredSize(new java.awt.Dimension(
0351: 220, 180));
0352: jPanelStep0.setLayout(new java.awt.GridBagLayout());
0353:
0354: jLabel2.setText("Available subdataset");
0355: gridBagConstraints = new java.awt.GridBagConstraints();
0356: gridBagConstraints.gridx = 0;
0357: gridBagConstraints.gridy = 0;
0358: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0359: gridBagConstraints.weightx = 1.0;
0360: gridBagConstraints.insets = new java.awt.Insets(0, 8, 0, 8);
0361: jPanelStep0.add(jLabel2, gridBagConstraints);
0362:
0363: jComboBoxSubdataset
0364: .addActionListener(new java.awt.event.ActionListener() {
0365: public void actionPerformed(
0366: java.awt.event.ActionEvent evt) {
0367: jComboBoxSubdatasetActionPerformed(evt);
0368: }
0369: });
0370:
0371: gridBagConstraints = new java.awt.GridBagConstraints();
0372: gridBagConstraints.gridx = 0;
0373: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0374: gridBagConstraints.weightx = 1.0;
0375: gridBagConstraints.insets = new java.awt.Insets(0, 8, 0, 8);
0376: jPanelStep0.add(jComboBoxSubdataset, gridBagConstraints);
0377:
0378: jButtonNewSubDataset.setText("Create new subdataset");
0379: jButtonNewSubDataset
0380: .setActionCommand("Create a new subdataset");
0381: jButtonNewSubDataset
0382: .addActionListener(new java.awt.event.ActionListener() {
0383: public void actionPerformed(
0384: java.awt.event.ActionEvent evt) {
0385: jButtonNewSubDatasetActionPerformed(evt);
0386: }
0387: });
0388:
0389: gridBagConstraints = new java.awt.GridBagConstraints();
0390: gridBagConstraints.gridx = 0;
0391: gridBagConstraints.gridy = 3;
0392: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0393: gridBagConstraints.insets = new java.awt.Insets(8, 8, 0, 8);
0394: jPanelStep0.add(jButtonNewSubDataset, gridBagConstraints);
0395:
0396: jPanelStepContainer.add(jPanelStep0,
0397: java.awt.BorderLayout.CENTER);
0398:
0399: jPanelStep1.setLayout(new java.awt.GridBagLayout());
0400:
0401: jLabel3
0402: .setIcon(new javax.swing.ImageIcon(
0403: getClass()
0404: .getResource(
0405: "/it/businesslogic/ireport/icons/crosstab/wizard_rows.png")));
0406: gridBagConstraints = new java.awt.GridBagConstraints();
0407: gridBagConstraints.gridx = 0;
0408: jPanelStep1.add(jLabel3, gridBagConstraints);
0409:
0410: groupByFieldPanel1.setTitle("Row group 1");
0411: gridBagConstraints = new java.awt.GridBagConstraints();
0412: gridBagConstraints.gridx = 0;
0413: gridBagConstraints.gridy = 1;
0414: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0415: gridBagConstraints.weightx = 1.0;
0416: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
0417: jPanelStep1.add(groupByFieldPanel1, gridBagConstraints);
0418:
0419: groupByFieldPanel2.setTitle("Row group 2");
0420: gridBagConstraints = new java.awt.GridBagConstraints();
0421: gridBagConstraints.gridx = 0;
0422: gridBagConstraints.gridy = 2;
0423: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0424: gridBagConstraints.weightx = 1.0;
0425: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
0426: jPanelStep1.add(groupByFieldPanel2, gridBagConstraints);
0427:
0428: jPanel3.setLayout(new java.awt.GridBagLayout());
0429:
0430: gridBagConstraints = new java.awt.GridBagConstraints();
0431: gridBagConstraints.gridx = 0;
0432: gridBagConstraints.weighty = 1.0;
0433: jPanelStep1.add(jPanel3, gridBagConstraints);
0434:
0435: jPanelStepContainer.add(jPanelStep1,
0436: java.awt.BorderLayout.CENTER);
0437:
0438: jPanelStep2.setLayout(new java.awt.GridBagLayout());
0439:
0440: jPanelStep2.setMinimumSize(new java.awt.Dimension(250, 231));
0441: jPanelStep2.setOpaque(false);
0442: jPanelStep2.setPreferredSize(new java.awt.Dimension(250, 250));
0443: jLabel4
0444: .setIcon(new javax.swing.ImageIcon(
0445: getClass()
0446: .getResource(
0447: "/it/businesslogic/ireport/icons/crosstab/wizard_columns.png")));
0448: gridBagConstraints = new java.awt.GridBagConstraints();
0449: gridBagConstraints.gridx = 0;
0450: jPanelStep2.add(jLabel4, gridBagConstraints);
0451:
0452: groupByFieldPanel3.setTitle("Column group 1");
0453: gridBagConstraints = new java.awt.GridBagConstraints();
0454: gridBagConstraints.gridx = 0;
0455: gridBagConstraints.gridy = 1;
0456: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0457: gridBagConstraints.weightx = 1.0;
0458: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
0459: jPanelStep2.add(groupByFieldPanel3, gridBagConstraints);
0460:
0461: groupByFieldPanel4.setTitle("Column group 2");
0462: gridBagConstraints = new java.awt.GridBagConstraints();
0463: gridBagConstraints.gridx = 0;
0464: gridBagConstraints.gridy = 2;
0465: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0466: gridBagConstraints.weightx = 1.0;
0467: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
0468: jPanelStep2.add(groupByFieldPanel4, gridBagConstraints);
0469:
0470: jPanel4.setLayout(new java.awt.GridBagLayout());
0471:
0472: gridBagConstraints = new java.awt.GridBagConstraints();
0473: gridBagConstraints.gridx = 0;
0474: gridBagConstraints.weighty = 1.0;
0475: jPanelStep2.add(jPanel4, gridBagConstraints);
0476:
0477: jPanelStepContainer.add(jPanelStep2,
0478: java.awt.BorderLayout.CENTER);
0479:
0480: jPanelStep3.setLayout(new java.awt.GridBagLayout());
0481:
0482: jLabel5
0483: .setIcon(new javax.swing.ImageIcon(
0484: getClass()
0485: .getResource(
0486: "/it/businesslogic/ireport/icons/crosstab/wizard_details.png")));
0487: gridBagConstraints = new java.awt.GridBagConstraints();
0488: gridBagConstraints.gridx = 0;
0489: gridBagConstraints.gridwidth = 2;
0490: jPanelStep3.add(jLabel5, gridBagConstraints);
0491:
0492: jLabelDetailField.setText("Detail field");
0493: gridBagConstraints = new java.awt.GridBagConstraints();
0494: gridBagConstraints.gridx = 0;
0495: gridBagConstraints.gridy = 1;
0496: gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
0497: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
0498: jPanelStep3.add(jLabelDetailField, gridBagConstraints);
0499:
0500: jComboBoxDetailField.setPreferredSize(new java.awt.Dimension(
0501: 55, 20));
0502: jComboBoxDetailField
0503: .addActionListener(new java.awt.event.ActionListener() {
0504: public void actionPerformed(
0505: java.awt.event.ActionEvent evt) {
0506: jComboBoxDetailFieldActionPerformed(evt);
0507: }
0508: });
0509:
0510: gridBagConstraints = new java.awt.GridBagConstraints();
0511: gridBagConstraints.gridx = 1;
0512: gridBagConstraints.gridy = 1;
0513: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0514: gridBagConstraints.weightx = 1.0;
0515: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
0516: jPanelStep3.add(jComboBoxDetailField, gridBagConstraints);
0517:
0518: jLabelDetailField1.setText("Function");
0519: gridBagConstraints = new java.awt.GridBagConstraints();
0520: gridBagConstraints.gridx = 0;
0521: gridBagConstraints.gridy = 2;
0522: gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
0523: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 0);
0524: jPanelStep3.add(jLabelDetailField1, gridBagConstraints);
0525:
0526: jComboBoxDetailFieldFunction
0527: .setPreferredSize(new java.awt.Dimension(55, 20));
0528: jComboBoxDetailFieldFunction
0529: .addActionListener(new java.awt.event.ActionListener() {
0530: public void actionPerformed(
0531: java.awt.event.ActionEvent evt) {
0532: jComboBoxDetailFieldActionPerformed1(evt);
0533: }
0534: });
0535:
0536: gridBagConstraints = new java.awt.GridBagConstraints();
0537: gridBagConstraints.gridx = 1;
0538: gridBagConstraints.gridy = 2;
0539: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0540: gridBagConstraints.weightx = 1.0;
0541: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
0542: jPanelStep3.add(jComboBoxDetailFieldFunction,
0543: gridBagConstraints);
0544:
0545: jPanel5.setLayout(new java.awt.GridBagLayout());
0546:
0547: gridBagConstraints = new java.awt.GridBagConstraints();
0548: gridBagConstraints.gridx = 0;
0549: gridBagConstraints.weighty = 1.0;
0550: jPanelStep3.add(jPanel5, gridBagConstraints);
0551:
0552: jPanelStepContainer.add(jPanelStep3,
0553: java.awt.BorderLayout.CENTER);
0554:
0555: jPanelStep4.setLayout(new java.awt.GridBagLayout());
0556:
0557: jLabel6
0558: .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
0559: jLabel6
0560: .setIcon(new javax.swing.ImageIcon(
0561: getClass()
0562: .getResource(
0563: "/it/businesslogic/ireport/icons/crosstab/wizard_totals.png")));
0564: gridBagConstraints = new java.awt.GridBagConstraints();
0565: gridBagConstraints.gridx = 0;
0566: gridBagConstraints.gridwidth = 2;
0567: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0568: gridBagConstraints.weightx = 1.0;
0569: jPanelStep4.add(jLabel6, gridBagConstraints);
0570:
0571: jCheckBoxTotalRows.setSelected(true);
0572: jCheckBoxTotalRows.setText("Add row group totals");
0573: jCheckBoxTotalRows.setBorder(javax.swing.BorderFactory
0574: .createEmptyBorder(0, 0, 0, 0));
0575: jCheckBoxTotalRows.setMargin(new java.awt.Insets(0, 0, 0, 0));
0576: gridBagConstraints = new java.awt.GridBagConstraints();
0577: gridBagConstraints.gridx = 0;
0578: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0579: gridBagConstraints.insets = new java.awt.Insets(8, 8, 8, 8);
0580: jPanelStep4.add(jCheckBoxTotalRows, gridBagConstraints);
0581:
0582: jCheckBoxTotalColumns.setSelected(true);
0583: jCheckBoxTotalColumns.setText("Add column group totals");
0584: jCheckBoxTotalColumns.setBorder(javax.swing.BorderFactory
0585: .createEmptyBorder(0, 0, 0, 0));
0586: jCheckBoxTotalColumns
0587: .setMargin(new java.awt.Insets(0, 0, 0, 0));
0588: gridBagConstraints = new java.awt.GridBagConstraints();
0589: gridBagConstraints.gridx = 0;
0590: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0591: gridBagConstraints.insets = new java.awt.Insets(0, 8, 8, 8);
0592: jPanelStep4.add(jCheckBoxTotalColumns, gridBagConstraints);
0593:
0594: jCheckBoxPrintGrid.setSelected(true);
0595: jCheckBoxPrintGrid.setText("Show grid lines");
0596: jCheckBoxPrintGrid.setBorder(javax.swing.BorderFactory
0597: .createEmptyBorder(0, 0, 0, 0));
0598: jCheckBoxPrintGrid.setMargin(new java.awt.Insets(0, 0, 0, 0));
0599: gridBagConstraints = new java.awt.GridBagConstraints();
0600: gridBagConstraints.gridx = 0;
0601: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0602: gridBagConstraints.insets = new java.awt.Insets(8, 8, 8, 8);
0603: jPanelStep4.add(jCheckBoxPrintGrid, gridBagConstraints);
0604:
0605: jPanel6.setLayout(new java.awt.GridBagLayout());
0606:
0607: gridBagConstraints = new java.awt.GridBagConstraints();
0608: gridBagConstraints.gridx = 0;
0609: gridBagConstraints.weightx = 1.0;
0610: gridBagConstraints.weighty = 1.0;
0611: jPanelStep4.add(jPanel6, gridBagConstraints);
0612:
0613: jPanelStepContainer.add(jPanelStep4,
0614: java.awt.BorderLayout.CENTER);
0615:
0616: jPanelStep5.setLayout(new java.awt.GridBagLayout());
0617:
0618: jLabelResult.setText(" ");
0619: gridBagConstraints = new java.awt.GridBagConstraints();
0620: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0621: gridBagConstraints.weightx = 1.0;
0622: gridBagConstraints.weighty = 1.0;
0623: gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
0624: jPanelStep5.add(jLabelResult, gridBagConstraints);
0625:
0626: jPanelStepContainer.add(jPanelStep5,
0627: java.awt.BorderLayout.CENTER);
0628:
0629: gridBagConstraints = new java.awt.GridBagConstraints();
0630: gridBagConstraints.gridx = 0;
0631: gridBagConstraints.gridy = 1;
0632: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0633: gridBagConstraints.weightx = 1.0;
0634: gridBagConstraints.weighty = 1.0;
0635: jPanelContent.add(jPanelStepContainer, gridBagConstraints);
0636:
0637: gridBagConstraints = new java.awt.GridBagConstraints();
0638: gridBagConstraints.gridx = 1;
0639: gridBagConstraints.gridy = 0;
0640: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0641: gridBagConstraints.weightx = 1.0;
0642: gridBagConstraints.weighty = 1.0;
0643: jPanelBase.add(jPanelContent, gridBagConstraints);
0644:
0645: jSeparator3.setBackground(new java.awt.Color(204, 204, 255));
0646: jSeparator3.setForeground(new java.awt.Color(0, 0, 0));
0647: jSeparator3.setMaximumSize(new java.awt.Dimension(32767, 2));
0648: jSeparator3.setMinimumSize(new java.awt.Dimension(2, 2));
0649: jSeparator3.setPreferredSize(new java.awt.Dimension(1, 2));
0650: gridBagConstraints = new java.awt.GridBagConstraints();
0651: gridBagConstraints.gridx = 0;
0652: gridBagConstraints.gridy = 2;
0653: gridBagConstraints.gridwidth = 2;
0654: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0655: jPanelBase.add(jSeparator3, gridBagConstraints);
0656:
0657: jPanelContentButtons.setLayout(new java.awt.GridBagLayout());
0658:
0659: jPanelContentButtons.setMinimumSize(new java.awt.Dimension(10,
0660: 30));
0661: jPanelContentButtons.setPreferredSize(new java.awt.Dimension(
0662: 10, 40));
0663: jPanel2.setLayout(new java.awt.BorderLayout());
0664:
0665: gridBagConstraints = new java.awt.GridBagConstraints();
0666: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0667: gridBagConstraints.weightx = 1.0;
0668: jPanelContentButtons.add(jPanel2, gridBagConstraints);
0669:
0670: jButtonPrev.setText("< Prev");
0671: jButtonPrev.setEnabled(false);
0672: jButtonPrev
0673: .addActionListener(new java.awt.event.ActionListener() {
0674: public void actionPerformed(
0675: java.awt.event.ActionEvent evt) {
0676: jButtonPrevActionPerformed(evt);
0677: }
0678: });
0679:
0680: gridBagConstraints = new java.awt.GridBagConstraints();
0681: gridBagConstraints.insets = new java.awt.Insets(8, 2, 8, 2);
0682: jPanelContentButtons.add(jButtonPrev, gridBagConstraints);
0683:
0684: jButtonNext.setText("Next >");
0685: jButtonNext.setEnabled(false);
0686: jButtonNext
0687: .addActionListener(new java.awt.event.ActionListener() {
0688: public void actionPerformed(
0689: java.awt.event.ActionEvent evt) {
0690: jButtonNextActionPerformed(evt);
0691: }
0692: });
0693:
0694: gridBagConstraints = new java.awt.GridBagConstraints();
0695: gridBagConstraints.insets = new java.awt.Insets(8, 2, 8, 2);
0696: jPanelContentButtons.add(jButtonNext, gridBagConstraints);
0697:
0698: jButtonFinish.setText("Finish");
0699: jButtonFinish
0700: .addActionListener(new java.awt.event.ActionListener() {
0701: public void actionPerformed(
0702: java.awt.event.ActionEvent evt) {
0703: jButtonFinishActionPerformed(evt);
0704: }
0705: });
0706:
0707: gridBagConstraints = new java.awt.GridBagConstraints();
0708: gridBagConstraints.insets = new java.awt.Insets(8, 2, 8, 2);
0709: jPanelContentButtons.add(jButtonFinish, gridBagConstraints);
0710:
0711: jButtonCancel.setText("Cancel");
0712: jButtonCancel
0713: .addActionListener(new java.awt.event.ActionListener() {
0714: public void actionPerformed(
0715: java.awt.event.ActionEvent evt) {
0716: jButtonCancelActionPerformed(evt);
0717: }
0718: });
0719:
0720: gridBagConstraints = new java.awt.GridBagConstraints();
0721: gridBagConstraints.insets = new java.awt.Insets(8, 2, 8, 4);
0722: jPanelContentButtons.add(jButtonCancel, gridBagConstraints);
0723:
0724: gridBagConstraints = new java.awt.GridBagConstraints();
0725: gridBagConstraints.gridx = 0;
0726: gridBagConstraints.gridwidth = 2;
0727: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0728: gridBagConstraints.weightx = 1.0;
0729: jPanelBase.add(jPanelContentButtons, gridBagConstraints);
0730:
0731: getContentPane().add(jPanelBase, java.awt.BorderLayout.CENTER);
0732:
0733: pack();
0734: }// </editor-fold>//GEN-END:initComponents
0735:
0736: public void applyStandardBlackBox(CrosstabCell cell) {
0737: cell.getBox().setRightBorderColor(Color.BLACK);
0738: cell.getBox().setRightBorder("1Point");
0739: cell.getBox().setBottomBorderColor(Color.BLACK);
0740: cell.getBox().setBottomBorder("1Point");
0741: }
0742:
0743: public void addTextfieldElement(CrosstabCell cell,
0744: String expression, String expressionClass) {
0745: TextFieldReportElement tf = new TextFieldReportElement(0, 0,
0746: cell.getWidth(), cell.getHeight());
0747: tf.setRelativePosition(new Point(0, 0));
0748: tf.setCell(cell);
0749: tf.setText(expression);
0750: tf.setMatchingClassExpression(expressionClass, true);
0751: tf.setVerticalAlign("Middle");
0752: tf.setAlign("Center");
0753: getCrosstabReportElement().getElements().add(tf);
0754: }
0755:
0756: /**
0757: * This method is used to avoid similar names for group and measures.
0758: * If add = 0, no suffix is appended if the name is unique.
0759: * Return baseName if baseName is unique, otherwise baseNameX where X > 0
0760: */
0761: public String getGroupMeasureName(String baseName, int add) {
0762: String name = baseName + ((add == 0) ? "" : "" + add);
0763: add++;
0764:
0765: for (int i = 0; i < getCrosstabReportElement().getRowGroups()
0766: .size(); ++i) {
0767: CrosstabGroup cg = (CrosstabGroup) getCrosstabReportElement()
0768: .getRowGroups().elementAt(i);
0769: if (cg.getName().equals(name)) {
0770: return getGroupMeasureName(baseName, add);
0771: }
0772: }
0773:
0774: for (int i = 0; i < getCrosstabReportElement()
0775: .getColumnGroups().size(); ++i) {
0776: CrosstabGroup cg = (CrosstabGroup) getCrosstabReportElement()
0777: .getColumnGroups().elementAt(i);
0778: if (cg.getName().equals(name)) {
0779: return getGroupMeasureName(baseName, add);
0780: }
0781: }
0782:
0783: for (int i = 0; i < getCrosstabReportElement().getMeasures()
0784: .size(); ++i) {
0785: Measure cm = (Measure) getCrosstabReportElement()
0786: .getMeasures().elementAt(i);
0787: if (cm.getName().equals(name)) {
0788: return getGroupMeasureName(baseName, add);
0789: }
0790: }
0791:
0792: return name;
0793: }
0794:
0795: private void jButtonFinishActionPerformed(
0796: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFinishActionPerformed
0797:
0798: try {
0799:
0800: SubDataset sd = (SubDataset) jComboBoxSubdataset
0801: .getSelectedItem();
0802: if (!(sd instanceof Report)) {
0803: Dataset dataset = new Dataset();
0804: dataset.setSubDataset(sd);
0805: dataset
0806: .setConnectionExpression("$P{REPORT_CONNECTION}");
0807: dataset.setUseConnection(true);
0808: getCrosstabReportElement().setDataset(dataset);
0809: getCrosstabReportElement().setUseDataset(true);
0810: }
0811:
0812: // 1. Add the first row group.
0813: CrosstabCell cell = (CrosstabCell) this
0814: .getCrosstabReportElement().getCells().elementAt(0);
0815: cell.setWidth(50);
0816: cell.setHeight(30);
0817:
0818: if (jCheckBoxPrintGrid.isSelected()) {
0819: applyStandardBlackBox(cell);
0820: }
0821:
0822: CrosstabGroup group = new CrosstabRowGroup();
0823: group.setName(getGroupMeasureName(groupByFieldPanel1
0824: .getFieldName(), 0));
0825: group.setBucketExpression(groupByFieldPanel1
0826: .getExpression());
0827: group.setBucketExpressionClass(groupByFieldPanel1
0828: .getExpressionClass());
0829: CrosstabCell headerCell = new CrosstabCell();
0830: headerCell.setName(group.getName() + " header");
0831: headerCell.setType(CrosstabCell.HEADER_CELL);
0832: headerCell.setWidth(group.getSize());
0833: headerCell.setHeight(30);
0834:
0835: if (jCheckBoxPrintGrid.isSelected()) {
0836: headerCell.getBox().setLeftBorder("1Point");
0837: headerCell.getBox().setLeftBorderColor(Color.BLACK);
0838: applyStandardBlackBox(headerCell);
0839: }
0840: applyStandardBlackBox(headerCell);
0841: group.setHeaderCell(headerCell);
0842: addTextfieldElement(headerCell, "$V{" + group.getName()
0843: + "}", group.getBucketExpressionClass());
0844:
0845: CrosstabCell totalHeaderCell = new CrosstabCell();
0846: totalHeaderCell.setName(group.getName() + " total header");
0847: totalHeaderCell.setType(CrosstabCell.HEADER_CELL);
0848: totalHeaderCell.setWidth(group.getSize());
0849: if (jCheckBoxTotalRows.isSelected()) {
0850: group.setTotalPosition("End");
0851: totalHeaderCell.setHeight(30);
0852: addTextfieldElement(totalHeaderCell, "\""
0853: + group.getName() + " total\"",
0854: "java.lang.String");
0855: } else {
0856: totalHeaderCell.setHeight(0);
0857: }
0858: if (jCheckBoxPrintGrid.isSelected()) {
0859: totalHeaderCell.getBox().setLeftBorder("1Point");
0860: totalHeaderCell.getBox()
0861: .setLeftBorderColor(Color.BLACK);
0862: applyStandardBlackBox(totalHeaderCell);
0863: }
0864: group.setTotalCell(totalHeaderCell);
0865:
0866: getCrosstabReportElement().getCells().add(
0867: group.getHeaderCell());
0868: getCrosstabReportElement().getCells().add(
0869: group.getTotalCell());
0870:
0871: getCrosstabReportElement().getRowGroups().add(group);
0872:
0873: // 2. Add the second row group. ----------------------------------------------------
0874: if (groupByFieldPanel2.getFieldName() != null
0875: && !groupByFieldPanel2.getFieldName().equals("")) {
0876: group = new CrosstabRowGroup();
0877: group.setName(getGroupMeasureName(groupByFieldPanel2
0878: .getFieldName(), 0));
0879: group.setBucketExpression(groupByFieldPanel2
0880: .getExpression());
0881: group.setBucketExpressionClass(groupByFieldPanel2
0882: .getExpressionClass());
0883: headerCell = new CrosstabCell();
0884: headerCell.setName(group.getName() + " header");
0885: headerCell.setType(CrosstabCell.HEADER_CELL);
0886: headerCell.setWidth(group.getSize());
0887: headerCell.setHeight(30);
0888: group.setHeaderCell(headerCell);
0889: if (jCheckBoxPrintGrid.isSelected())
0890: applyStandardBlackBox(headerCell);
0891: addTextfieldElement(headerCell, "$V{" + group.getName()
0892: + "}", group.getBucketExpressionClass());
0893:
0894: totalHeaderCell = new CrosstabCell();
0895: totalHeaderCell.setName(group.getName()
0896: + " total header");
0897: totalHeaderCell.setType(CrosstabCell.HEADER_CELL);
0898: totalHeaderCell.setWidth(group.getSize());
0899:
0900: if (jCheckBoxTotalRows.isSelected()) {
0901: group.setTotalPosition("End");
0902: totalHeaderCell.setHeight(30);
0903: addTextfieldElement(totalHeaderCell, "\""
0904: + group.getName() + " total\"",
0905: "java.lang.String");
0906: } else {
0907: totalHeaderCell.setHeight(0);
0908: }
0909: group.setTotalCell(totalHeaderCell);
0910: if (jCheckBoxPrintGrid.isSelected())
0911: applyStandardBlackBox(totalHeaderCell);
0912:
0913: getCrosstabReportElement().getCells().add(
0914: group.getHeaderCell());
0915: getCrosstabReportElement().getCells().add(
0916: group.getTotalCell());
0917:
0918: getCrosstabReportElement().getRowGroups().add(group);
0919: }
0920:
0921: // 3. Add the first column group -------------------------------------------------
0922:
0923: group = new CrosstabColumnGroup();
0924: group.setName(getGroupMeasureName(groupByFieldPanel3
0925: .getFieldName(), 0));
0926: group.setBucketExpression(groupByFieldPanel3
0927: .getExpression());
0928: group.setBucketExpressionClass(groupByFieldPanel3
0929: .getExpressionClass());
0930: headerCell = new CrosstabCell();
0931: headerCell.setName(group.getName() + " header");
0932: headerCell.setType(CrosstabCell.HEADER_CELL);
0933: headerCell.setHeight(group.getSize());
0934: headerCell.setWidth(50);
0935: if (jCheckBoxPrintGrid.isSelected()) {
0936: headerCell.getBox().setTopBorder("1Point");
0937: headerCell.getBox().setTopBorderColor(Color.BLACK);
0938: applyStandardBlackBox(headerCell);
0939: }
0940: group.setHeaderCell(headerCell);
0941: addTextfieldElement(headerCell, "$V{" + group.getName()
0942: + "}", group.getBucketExpressionClass());
0943:
0944: totalHeaderCell = new CrosstabCell();
0945: totalHeaderCell.setName(group.getName() + " total header");
0946: totalHeaderCell.setType(CrosstabCell.HEADER_CELL);
0947: totalHeaderCell.setHeight(group.getSize());
0948: if (jCheckBoxTotalColumns.isSelected()) {
0949: group.setTotalPosition("End");
0950: totalHeaderCell.setWidth(50);
0951: addTextfieldElement(totalHeaderCell, "\""
0952: + group.getName() + " total\"",
0953: "java.lang.String");
0954: } else {
0955: totalHeaderCell.setWidth(0);
0956: }
0957: if (jCheckBoxPrintGrid.isSelected()) {
0958: totalHeaderCell.getBox().setTopBorder("1Point");
0959: totalHeaderCell.getBox().setTopBorderColor(Color.BLACK);
0960: applyStandardBlackBox(totalHeaderCell);
0961: }
0962: group.setTotalCell(totalHeaderCell);
0963:
0964: getCrosstabReportElement().getCells().add(
0965: group.getHeaderCell());
0966: getCrosstabReportElement().getCells().add(
0967: group.getTotalCell());
0968:
0969: getCrosstabReportElement().getColumnGroups().add(group);
0970:
0971: // 4. Add the first column group -------------------------------------------------
0972: if (groupByFieldPanel4.getFieldName() != null
0973: && !groupByFieldPanel4.getFieldName().equals("")) {
0974: group = new CrosstabColumnGroup();
0975: group.setName(getGroupMeasureName(groupByFieldPanel4
0976: .getFieldName(), 0));
0977: group.setBucketExpression(groupByFieldPanel4
0978: .getExpression());
0979: group.setBucketExpressionClass(groupByFieldPanel4
0980: .getExpressionClass());
0981:
0982: headerCell = new CrosstabCell();
0983: headerCell.setName(group.getName() + " header");
0984: headerCell.setType(CrosstabCell.HEADER_CELL);
0985: headerCell.setHeight(group.getSize());
0986: headerCell.setWidth(50);
0987: if (jCheckBoxPrintGrid.isSelected()) {
0988: applyStandardBlackBox(headerCell);
0989: }
0990: group.setHeaderCell(headerCell);
0991: addTextfieldElement(headerCell, "$V{" + group.getName()
0992: + "}", group.getBucketExpressionClass());
0993:
0994: totalHeaderCell = new CrosstabCell();
0995: totalHeaderCell.setName(group.getName()
0996: + " total header");
0997: totalHeaderCell.setType(CrosstabCell.HEADER_CELL);
0998: totalHeaderCell.setHeight(group.getSize());
0999: if (jCheckBoxTotalColumns.isSelected()) {
1000: group.setTotalPosition("End");
1001: totalHeaderCell.setWidth(50);
1002: addTextfieldElement(totalHeaderCell, "\""
1003: + group.getName() + " total\"",
1004: "java.lang.String");
1005: } else {
1006: totalHeaderCell.setWidth(0);
1007: }
1008: group.setTotalCell(totalHeaderCell);
1009: if (jCheckBoxPrintGrid.isSelected())
1010: applyStandardBlackBox(totalHeaderCell);
1011:
1012: getCrosstabReportElement().getCells().add(
1013: group.getHeaderCell());
1014: getCrosstabReportElement().getCells().add(
1015: group.getTotalCell());
1016:
1017: getCrosstabReportElement().getColumnGroups().add(group);
1018:
1019: }
1020: // 5. Create measure -------------------------------------------------
1021: WizardFieldObject wfo = (WizardFieldObject) this .jComboBoxDetailField
1022: .getSelectedItem();
1023: Measure measure = new Measure(getGroupMeasureName(wfo
1024: .getName()
1025: + "_"
1026: + this .jComboBoxDetailFieldFunction
1027: .getSelectedItem(), 0));
1028: measure.setClassType(wfo.getExpressionClass(null));
1029: measure.setCalculation(this .jComboBoxDetailFieldFunction
1030: .getSelectedItem()
1031: + "");
1032: measure.setExpression(wfo.getExpression(""));
1033: this .getCrosstabReportElement().getMeasures().add(measure);
1034:
1035: // Add maincell elements...
1036: addTextfieldElement(cell, "$V{" + measure.getName() + "}",
1037: measure.getClassType());
1038:
1039: setDialogResult(javax.swing.JOptionPane.OK_OPTION);
1040: setVisible(false);
1041:
1042: } catch (Exception ex) {
1043: ex.printStackTrace();
1044: }
1045:
1046: setDialogResult(javax.swing.JOptionPane.OK_OPTION);
1047: setVisible(false);
1048:
1049: }//GEN-LAST:event_jButtonFinishActionPerformed
1050:
1051: private void jButtonNewSubDatasetActionPerformed(
1052: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNewSubDatasetActionPerformed
1053:
1054: SubDatasetDialog sds = new SubDatasetDialog(this , true);
1055: sds.setVisible(true);
1056: this .setReport(report);
1057: }//GEN-LAST:event_jButtonNewSubDatasetActionPerformed
1058:
1059: private void jComboBoxDetailFieldActionPerformed1(
1060: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxDetailFieldActionPerformed1
1061: // TODO add your handling code here:
1062: }//GEN-LAST:event_jComboBoxDetailFieldActionPerformed1
1063:
1064: private void jComboBoxDetailFieldActionPerformed(
1065: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxDetailFieldActionPerformed
1066:
1067: if (jComboBoxDetailField.getSelectedIndex() < 0
1068: || !(jComboBoxDetailField.getSelectedItem() instanceof WizardFieldObject)) {
1069: jComboBoxDetailFieldFunction.removeAllItems();
1070: } else {
1071: WizardFieldObject wfo = (WizardFieldObject) jComboBoxDetailField
1072: .getSelectedItem();
1073: Misc.updateComboBox(jComboBoxDetailFieldFunction, wfo
1074: .getFunctions());
1075: if (jComboBoxDetailFieldFunction.getItemCount() > 0) {
1076: jComboBoxDetailFieldFunction.setSelectedIndex(0);
1077: }
1078: }
1079:
1080: if (getCurrentStep() == 3)
1081: this .updateButtons();
1082:
1083: }//GEN-LAST:event_jComboBoxDetailFieldActionPerformed
1084:
1085: private void jButtonPrevActionPerformed(
1086: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPrevActionPerformed
1087:
1088: this .goPrevious();
1089:
1090: }//GEN-LAST:event_jButtonPrevActionPerformed
1091:
1092: private void jButtonNextActionPerformed(
1093: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNextActionPerformed
1094:
1095: this .goNext();
1096:
1097: }//GEN-LAST:event_jButtonNextActionPerformed
1098:
1099: private void jButtonCancelActionPerformed(
1100: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
1101:
1102: dialogResult = javax.swing.JOptionPane.CLOSED_OPTION;
1103: this .setVisible(false);
1104: this .dispose();
1105:
1106: }//GEN-LAST:event_jButtonCancelActionPerformed
1107:
1108: private void jComboBoxSubdatasetActionPerformed(
1109: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxSubdatasetActionPerformed
1110:
1111: if (jComboBoxSubdataset.getSelectedItem() != null
1112: && jComboBoxSubdataset.getSelectedItem() instanceof SubDataset) {
1113: setCrosstabSubDataset((SubDataset) jComboBoxSubdataset
1114: .getSelectedItem());
1115: }
1116: if (getCurrentStep() == 0)
1117: updateButtons();
1118: }//GEN-LAST:event_jComboBoxSubdatasetActionPerformed
1119:
1120: public void goNext() {
1121:
1122: if (currentStep < getStepsPanels().size() - 1) {
1123: currentStep++;
1124: }
1125:
1126: setCurrentStepLabel(currentStep);
1127:
1128: jPanelStepContainer.removeAll();
1129: jPanelStepContainer.add((java.awt.Component) getStepsPanels()
1130: .elementAt(currentStep), java.awt.BorderLayout.CENTER);
1131: jPanelStepContainer.updateUI();
1132: if (currentStep == 0) {
1133: jLabelStepDescription
1134: .setText("Step 1: Choose a subdataset or create a new one");
1135: } else if (currentStep == 1) {
1136: jLabelStepDescription
1137: .setText("Step 2: Define row group(s)");
1138: } else if (currentStep == 2) {
1139: jLabelStepDescription
1140: .setText("Step 3: Define column group(s)");
1141: } else if (currentStep == 3) {
1142: jLabelStepDescription.setText("Step 4: Define detail");
1143: } else if (currentStep == 4) {
1144: jLabelStepDescription.setText("Step 5: Choose a layout");
1145: } else if (currentStep == 5) {
1146: jLabelStepDescription.setText("Step 6: Finish");
1147: }
1148: updateButtons();
1149: }
1150:
1151: public void goPrevious() {
1152: if (currentStep > 0) {
1153: currentStep--;
1154: }
1155:
1156: jPanelStepContainer.removeAll();
1157: jPanelStepContainer.add((java.awt.Component) getStepsPanels()
1158: .elementAt(currentStep), java.awt.BorderLayout.CENTER);
1159: jPanelStepContainer.updateUI();
1160:
1161: setCurrentStepLabel(currentStep);
1162:
1163: updateButtons();
1164: }
1165:
1166: public void setCurrentStepLabel(int step) {
1167: for (int i = 0; i < stepsLabels.size(); ++i) {
1168: JLabel label = (JLabel) stepsLabels.get(i);
1169: label.setFont(new java.awt.Font(label.getFont().getName(),
1170: (i == step) ? java.awt.Font.BOLD : 0, label
1171: .getFont().getSize()));
1172: label.updateUI();
1173: }
1174: }
1175:
1176: public void updateButtons() {
1177: jButtonFinish.setEnabled(canFinish());
1178: jButtonPrev.setEnabled(canGoPrevious());
1179: jButtonNext.setEnabled(canGoNext());
1180:
1181: }
1182:
1183: public boolean canGoPrevious() {
1184: return (getCurrentStep() > 0);
1185: }
1186:
1187: public boolean canGoNext() {
1188: if (getCurrentStep() == 0) {
1189: if (jComboBoxSubdataset.getSelectedItem() == null
1190: || !(jComboBoxSubdataset.getSelectedItem() instanceof SubDataset)) {
1191: return false;
1192: }
1193: } else if (getCurrentStep() == 1) {
1194: if (groupByFieldPanel1.getFieldName() == null
1195: || groupByFieldPanel1.getFieldName().equals("")) {
1196: return false;
1197: }
1198: } else if (getCurrentStep() == 2) {
1199: if (groupByFieldPanel3.getFieldName() == null
1200: || groupByFieldPanel3.getFieldName().equals("")) {
1201: return false;
1202: }
1203: } else if (getCurrentStep() == 3) {
1204: if (jComboBoxDetailField.getSelectedIndex() < 0
1205: || !(jComboBoxDetailField.getSelectedItem() instanceof WizardFieldObject)) {
1206: return false;
1207: }
1208: } else if (getCurrentStep() == 4) {
1209: return true;
1210: } else if (getCurrentStep() == 5) {
1211: return false;
1212: }
1213:
1214: return true;
1215: }
1216:
1217: public boolean canFinish() {
1218: return (getCurrentStep() > 3 || (getCurrentStep() == 3 && canGoNext()));
1219: }
1220:
1221: public int getCurrentStep() {
1222: return currentStep;
1223: }
1224:
1225: public void setCurrentStep(int currentStep) {
1226: this .currentStep = currentStep;
1227: }
1228:
1229: public SubDataset getCrosstabSubDataset() {
1230: return crosstabSubDataset;
1231: }
1232:
1233: public void setCrosstabSubDataset(SubDataset crosstabSubDataset) {
1234: this .crosstabSubDataset = crosstabSubDataset;
1235: this .groupByFieldPanel1
1236: .populateBySubdataset(crosstabSubDataset);
1237: this .groupByFieldPanel2.populateBySubdataset(
1238: crosstabSubDataset, true);
1239: this .groupByFieldPanel3
1240: .populateBySubdataset(crosstabSubDataset);
1241: this .groupByFieldPanel4.populateBySubdataset(
1242: crosstabSubDataset, true);
1243:
1244: // Populate the field...
1245: jComboBoxDetailField.removeAllItems();
1246: for (int i = 0; i < crosstabSubDataset.getFields().size(); ++i) {
1247: jComboBoxDetailField.addItem(new WizardFieldObject(
1248: crosstabSubDataset.getFields().get(i)));
1249: }
1250: for (int i = 0; i < crosstabSubDataset.getVariables().size(); ++i) {
1251: jComboBoxDetailField.addItem(new WizardFieldObject(
1252: crosstabSubDataset.getVariables().get(i)));
1253: }
1254: for (int i = 0; i < crosstabSubDataset.getParameters().size(); ++i) {
1255: jComboBoxDetailField.addItem(new WizardFieldObject(
1256: crosstabSubDataset.getParameters().get(i)));
1257: }
1258:
1259: if (jComboBoxDetailField.getItemCount() > 0) {
1260: jComboBoxDetailField.setSelectedIndex(0);
1261: }
1262:
1263: }
1264:
1265: public Vector getStepsPanels() {
1266: return stepsPanels;
1267: }
1268:
1269: public void setStepsPanels(Vector stepsPanels) {
1270: this .stepsPanels = stepsPanels;
1271: }
1272:
1273: public Report getReport() {
1274: return report;
1275: }
1276:
1277: public void setReport(Report report) {
1278: this .report = report;
1279:
1280: Misc.updateComboBox(jComboBoxSubdataset, getReport()
1281: .getSubDatasets(), false);
1282: jComboBoxSubdataset.insertItemAt(report, 0);
1283: if (jComboBoxSubdataset.getItemCount() > 0) {
1284: jComboBoxSubdataset.setSelectedIndex(0);
1285: }
1286:
1287: }
1288:
1289: public int getDialogResult() {
1290: return dialogResult;
1291: }
1292:
1293: public void setDialogResult(int dialogResult) {
1294: this .dialogResult = dialogResult;
1295: }
1296:
1297: public CrosstabReportElement getCrosstabReportElement() {
1298: return crosstabReportElement;
1299: }
1300:
1301: public void setCrosstabReportElement(
1302: CrosstabReportElement crosstabReportElement) {
1303: this .crosstabReportElement = crosstabReportElement;
1304: }
1305:
1306: // Variables declaration - do not modify//GEN-BEGIN:variables
1307: private it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel groupByFieldPanel1;
1308: private it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel groupByFieldPanel2;
1309: private it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel groupByFieldPanel3;
1310: private it.businesslogic.ireport.crosstab.gui.GroupByFieldPanel groupByFieldPanel4;
1311: private javax.swing.JButton jButtonCancel;
1312: private javax.swing.JButton jButtonFinish;
1313: private javax.swing.JButton jButtonNewSubDataset;
1314: private javax.swing.JButton jButtonNext;
1315: private javax.swing.JButton jButtonPrev;
1316: private javax.swing.JCheckBox jCheckBoxPrintGrid;
1317: private javax.swing.JCheckBox jCheckBoxTotalColumns;
1318: private javax.swing.JCheckBox jCheckBoxTotalRows;
1319: private javax.swing.JComboBox jComboBoxDetailField;
1320: private javax.swing.JComboBox jComboBoxDetailFieldFunction;
1321: private javax.swing.JComboBox jComboBoxSubdataset;
1322: private javax.swing.JLabel jLabel1;
1323: private javax.swing.JLabel jLabel2;
1324: private javax.swing.JLabel jLabel3;
1325: private javax.swing.JLabel jLabel4;
1326: private javax.swing.JLabel jLabel5;
1327: private javax.swing.JLabel jLabel6;
1328: private javax.swing.JLabel jLabel7;
1329: private javax.swing.JLabel jLabelDetailField;
1330: private javax.swing.JLabel jLabelDetailField1;
1331: private javax.swing.JLabel jLabelResult;
1332: private javax.swing.JLabel jLabelStep1;
1333: private javax.swing.JLabel jLabelStep2;
1334: private javax.swing.JLabel jLabelStep3;
1335: private javax.swing.JLabel jLabelStep4;
1336: private javax.swing.JLabel jLabelStep5;
1337: private javax.swing.JLabel jLabelStep6;
1338: private javax.swing.JLabel jLabelStepDescription;
1339: private javax.swing.JPanel jPanel1;
1340: private javax.swing.JPanel jPanel2;
1341: private javax.swing.JPanel jPanel3;
1342: private javax.swing.JPanel jPanel4;
1343: private javax.swing.JPanel jPanel5;
1344: private javax.swing.JPanel jPanel6;
1345: private javax.swing.JPanel jPanelBase;
1346: private javax.swing.JPanel jPanelContent;
1347: private javax.swing.JPanel jPanelContentButtons;
1348: private javax.swing.JPanel jPanelStep0;
1349: private javax.swing.JPanel jPanelStep1;
1350: private javax.swing.JPanel jPanelStep2;
1351: private javax.swing.JPanel jPanelStep3;
1352: private javax.swing.JPanel jPanelStep4;
1353: private javax.swing.JPanel jPanelStep5;
1354: private javax.swing.JPanel jPanelStepContainer;
1355: private javax.swing.JPanel jPanelSteps;
1356: private javax.swing.JSeparator jSeparator2;
1357: private javax.swing.JSeparator jSeparator3;
1358: private javax.swing.JSeparator jSeparator4;
1359:
1360: // End of variables declaration//GEN-END:variables
1361:
1362: public void applyI18n() {
1363: // Start autogenerated code ----------------------
1364: jCheckBoxPrintGrid.setText(I18n.getString(
1365: "crosstabWizardDialog.checkBoxPrintGrid",
1366: "Show grid lines"));
1367: jCheckBoxTotalColumns.setText(I18n.getString(
1368: "crosstabWizardDialog.checkBoxTotalColumns",
1369: "Add column group totals"));
1370: jCheckBoxTotalRows.setText(I18n.getString(
1371: "crosstabWizardDialog.checkBoxTotalRows",
1372: "Add row group totals"));
1373: // End autogenerated code ----------------------
1374: // Start autogenerated code ----------------------
1375: jButtonCancel.setText(I18n.getString(
1376: "crosstabWizardDialog.buttonCancel", "Cancel"));
1377: jButtonFinish.setText(I18n.getString(
1378: "crosstabWizardDialog.buttonFinish", "Finish"));
1379: jButtonNewSubDataset.setText(I18n.getString(
1380: "crosstabWizardDialog.buttonNewSubDataset",
1381: "Create new subdataset"));
1382: jButtonNext.setText(I18n.getString(
1383: "crosstabWizardDialog.buttonNext", "Next >"));
1384: jButtonPrev.setText(I18n.getString(
1385: "crosstabWizardDialog.buttonPrev", "< Prev"));
1386: jLabel1.setText(I18n.getString("crosstabWizardDialog.label1",
1387: "Steps"));
1388: jLabel2.setText(I18n.getString("crosstabWizardDialog.label2",
1389: "Available subdataset"));
1390: jLabelDetailField.setText(I18n
1391: .getString("crosstabWizardDialog.labelDetailField",
1392: "Detail field"));
1393: jLabelDetailField1.setText(I18n.getString(
1394: "crosstabWizardDialog.labelDetailField1", "Function"));
1395: jLabelStep1.setText(I18n.getString(
1396: "crosstabWizardDialog.labelStep1",
1397: "1. SubDataset selection"));
1398: jLabelStep2.setText(I18n.getString(
1399: "crosstabWizardDialog.labelStep2", "2. Rows"));
1400: jLabelStep3.setText(I18n.getString(
1401: "crosstabWizardDialog.labelStep3", "3. Columns"));
1402: jLabelStep4.setText(I18n.getString(
1403: "crosstabWizardDialog.labelStep4", "4. Detail"));
1404: jLabelStep5.setText(I18n.getString(
1405: "crosstabWizardDialog.labelStep5", "5. Layout"));
1406: jLabelStep6.setText(I18n.getString(
1407: "crosstabWizardDialog.labelStep6", "6. Finish"));
1408: jLabelStepDescription.setText(I18n.getString(
1409: "crosstabWizardDialog.labelStepDescription", "Steps"));
1410: // End autogenerated code ----------------------
1411:
1412: jLabelResult
1413: .setText("<html>"
1414: + I18n
1415: .getString(
1416: "crosstabWizardDialog.textArea1",
1417: "You have successfully entered all the required information to\ncreate a crosstab.\n\nTo save this settings, click Finish"));
1418:
1419: java.awt.Font f = jLabelResult.getFont();
1420: jLabelResult.setFont(new java.awt.Font(f.getName(), f
1421: .getStyle(), f.getSize() + 2));
1422:
1423: groupByFieldPanel1.setTitle(I18n.getString(
1424: "crosstabWizardDialog.groupByFieldPanel1.title",
1425: "Row group 1"));
1426: groupByFieldPanel2.setTitle(I18n.getString(
1427: "crosstabWizardDialog.groupByFieldPanel2.title",
1428: "Row group 2"));
1429: groupByFieldPanel3.setTitle(I18n.getString(
1430: "crosstabWizardDialog.groupByFieldPanel3.title",
1431: "Column group 1"));
1432: groupByFieldPanel4.setTitle(I18n.getString(
1433: "crosstabWizardDialog.groupByFieldPanel4.title",
1434: "Column group 2"));
1435: }
1436: }
|