001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: *
025: *
026: *
027: * CrosstabGroupDialog.java
028: *
029: * Created on 9 maggio 2003, 17.25
030: *
031: */
032:
033: package it.businesslogic.ireport.crosstab.gui;
034:
035: import it.businesslogic.ireport.SubDataset;
036: import it.businesslogic.ireport.crosstab.CrosstabColumnGroup;
037: import it.businesslogic.ireport.crosstab.CrosstabGroup;
038: import it.businesslogic.ireport.gui.MainFrame;
039: import it.businesslogic.ireport.gui.sheet.Tag;
040: import it.businesslogic.ireport.util.Misc;
041: import it.businesslogic.ireport.util.I18n;
042:
043: /**
044: * @author Administrator
045: */
046: public class CrosstabGroupDialog extends javax.swing.JDialog {
047: public static final int ROWGROUP = 0;
048: public static final int COLUMNGROUP = 1;
049:
050: private CrosstabGroup tmpGroup = null;
051: private int groupType = 1;
052:
053: /**
054: * Creates a new CrosstabGroupDialog object.
055: *
056: * @param subDataset DOCUMENT ME!
057: * @param parent DOCUMENT ME!
058: * @param modal DOCUMENT ME!
059: */
060: public CrosstabGroupDialog(int groupType, java.awt.Frame parent,
061: boolean modal) {
062: super (parent, modal);
063: initAll(groupType);
064: }
065:
066: public CrosstabGroupDialog(int groupType, java.awt.Dialog parent,
067: boolean modal) {
068: super (parent, modal);
069: initAll(groupType);
070: }
071:
072: public void initAll(int groupType) {
073: initComponents();
074:
075: jComboBoxBucketClass.addItem("java.lang.String");
076: jComboBoxBucketClass.addItem("java.lang.Double");
077: jComboBoxBucketClass.addItem("java.lang.Float");
078: jComboBoxBucketClass.addItem("java.lang.Integer");
079: jComboBoxBucketClass.addItem("java.lang.Long");
080: jComboBoxBucketClass.addItem("java.lang.Short");
081: jComboBoxBucketClass.addItem("java.math.BigDecimal");
082:
083: jComboBoxBucketClass.addItem("java.util.Date");
084: jComboBoxBucketClass.addItem("java.sql.Timestamp");
085: jComboBoxBucketClass.addItem("java.sql.Time");
086:
087: setGroupType(groupType);
088:
089: //this.setSize(400, 400);
090: Misc.centerFrame(this );
091: pack();
092: javax.swing.KeyStroke escape = javax.swing.KeyStroke
093: .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
094: false);
095: javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
096: public void actionPerformed(java.awt.event.ActionEvent e) {
097: jButtonCancelActionPerformed(e);
098: }
099: };
100:
101: getRootPane().getInputMap(
102: javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
103: escape, "ESCAPE");
104: getRootPane().getActionMap().put("ESCAPE", escapeAction);
105:
106: //to make the default button ...
107: this .getRootPane().setDefaultButton(this .jButtonOK);
108: applyI18n();
109:
110: }
111:
112: /**
113: * This method is called from within the constructor to initialize the
114: * form. WARNING: Do NOT modify this code. The content of this method is
115: * always regenerated by the Form Editor.
116: */
117:
118: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
119: private void initComponents() {
120: java.awt.GridBagConstraints gridBagConstraints;
121:
122: jLabel1 = new javax.swing.JLabel();
123: jTextFieldName = new javax.swing.JTextField();
124: jPanel1 = new javax.swing.JPanel();
125: jPanel4 = new javax.swing.JPanel();
126: jButtonOK = new javax.swing.JButton();
127: jButtonCancel = new javax.swing.JButton();
128: jLabelSize = new javax.swing.JLabel();
129: jNumberFieldSize = new it.businesslogic.ireport.gui.JNumberField();
130: jPanel2 = new javax.swing.JPanel();
131: jLabel3 = new javax.swing.JLabel();
132: jRTextExpressionAreaExpression = new it.businesslogic.ireport.gui.JRTextExpressionArea();
133: jLabel4 = new javax.swing.JLabel();
134: jComboBoxOrder = new javax.swing.JComboBox();
135: jLabel5 = new javax.swing.JLabel();
136: jPanel5 = new javax.swing.JPanel();
137: jLabel6 = new javax.swing.JLabel();
138: jComboBoxBucketClass = new javax.swing.JComboBox();
139: jRTextExpressionAreaComparatorExpression = new it.businesslogic.ireport.gui.JRTextExpressionArea();
140: jPanel3 = new javax.swing.JPanel();
141: jComboBoxTotalPosition = new javax.swing.JComboBox();
142: jComboBoxHeaderPosition = new javax.swing.JComboBox();
143: jLabel2 = new javax.swing.JLabel();
144: jLabel7 = new javax.swing.JLabel();
145:
146: getContentPane().setLayout(new java.awt.GridBagLayout());
147:
148: setTitle("Add/modify crosstab group");
149: setModal(true);
150: addWindowListener(new java.awt.event.WindowAdapter() {
151: public void windowClosing(java.awt.event.WindowEvent evt) {
152: closeDialog(evt);
153: }
154: });
155:
156: jLabel1.setText("Group name");
157: gridBagConstraints = new java.awt.GridBagConstraints();
158: gridBagConstraints.gridx = 0;
159: gridBagConstraints.gridy = 0;
160: gridBagConstraints.gridwidth = 3;
161: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
162: gridBagConstraints.insets = new java.awt.Insets(3, 3, 0, 3);
163: getContentPane().add(jLabel1, gridBagConstraints);
164:
165: jTextFieldName
166: .setPreferredSize(new java.awt.Dimension(360, 21));
167: gridBagConstraints = new java.awt.GridBagConstraints();
168: gridBagConstraints.gridx = 0;
169: gridBagConstraints.gridy = 1;
170: gridBagConstraints.gridwidth = 3;
171: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
172: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
173: gridBagConstraints.insets = new java.awt.Insets(0, 3, 3, 3);
174: getContentPane().add(jTextFieldName, gridBagConstraints);
175:
176: jPanel1.setLayout(new java.awt.GridBagLayout());
177:
178: jPanel1.setMinimumSize(new java.awt.Dimension(126, 40));
179: jPanel1.setPreferredSize(new java.awt.Dimension(126, 40));
180: gridBagConstraints = new java.awt.GridBagConstraints();
181: gridBagConstraints.gridx = 0;
182: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
183: gridBagConstraints.weightx = 1.0;
184: gridBagConstraints.weighty = 1.0;
185: jPanel1.add(jPanel4, gridBagConstraints);
186:
187: jButtonOK.setMnemonic('o');
188: jButtonOK.setText("OK");
189: jButtonOK
190: .addActionListener(new java.awt.event.ActionListener() {
191: public void actionPerformed(
192: java.awt.event.ActionEvent evt) {
193: jButtonOKActionPerformed(evt);
194: }
195: });
196:
197: gridBagConstraints = new java.awt.GridBagConstraints();
198: gridBagConstraints.gridx = 1;
199: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
200: jPanel1.add(jButtonOK, gridBagConstraints);
201:
202: jButtonCancel.setMnemonic('c');
203: jButtonCancel.setText("Cancel");
204: jButtonCancel
205: .addActionListener(new java.awt.event.ActionListener() {
206: public void actionPerformed(
207: java.awt.event.ActionEvent evt) {
208: jButtonCancelActionPerformed(evt);
209: }
210: });
211:
212: gridBagConstraints = new java.awt.GridBagConstraints();
213: gridBagConstraints.gridx = 2;
214: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
215: gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 3);
216: jPanel1.add(jButtonCancel, gridBagConstraints);
217:
218: gridBagConstraints = new java.awt.GridBagConstraints();
219: gridBagConstraints.gridx = 0;
220: gridBagConstraints.gridy = 99;
221: gridBagConstraints.gridwidth = 3;
222: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
223: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
224: gridBagConstraints.weightx = 1.0;
225: gridBagConstraints.weighty = 1.0;
226: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
227: getContentPane().add(jPanel1, gridBagConstraints);
228:
229: jLabelSize.setText("Group width / height");
230: gridBagConstraints = new java.awt.GridBagConstraints();
231: gridBagConstraints.gridx = 0;
232: gridBagConstraints.gridy = 2;
233: gridBagConstraints.gridwidth = 2;
234: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
235: getContentPane().add(jLabelSize, gridBagConstraints);
236:
237: jNumberFieldSize.setColumns(4);
238: jNumberFieldSize
239: .setHorizontalAlignment(javax.swing.JTextField.RIGHT);
240: try {
241: jNumberFieldSize.setDecimals(0);
242: } catch (java.beans.PropertyVetoException e1) {
243: e1.printStackTrace();
244: }
245: jNumberFieldSize.setMinimumSize(new java.awt.Dimension(40, 21));
246: jNumberFieldSize
247: .setPreferredSize(new java.awt.Dimension(38, 21));
248: gridBagConstraints = new java.awt.GridBagConstraints();
249: gridBagConstraints.gridx = 2;
250: gridBagConstraints.gridy = 2;
251: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
252: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
253: getContentPane().add(jNumberFieldSize, gridBagConstraints);
254:
255: jPanel2.setLayout(new java.awt.GridBagLayout());
256:
257: jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(
258: javax.swing.BorderFactory.createEtchedBorder(),
259: "Bucket",
260: javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
261: javax.swing.border.TitledBorder.DEFAULT_POSITION,
262: new java.awt.Font("Dialog", 0, 11)));
263: jLabel3.setText("Bucket expression");
264: gridBagConstraints = new java.awt.GridBagConstraints();
265: gridBagConstraints.gridx = 0;
266: gridBagConstraints.gridy = 14;
267: gridBagConstraints.gridwidth = 2;
268: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
269: gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 3);
270: jPanel2.add(jLabel3, gridBagConstraints);
271:
272: jRTextExpressionAreaExpression
273: .setBorder(javax.swing.BorderFactory
274: .createEtchedBorder());
275: jRTextExpressionAreaExpression.setCaretVisible(false);
276: jRTextExpressionAreaExpression.setElectricScroll(0);
277: jRTextExpressionAreaExpression
278: .setMinimumSize(new java.awt.Dimension(657, 90));
279: jRTextExpressionAreaExpression
280: .setPreferredSize(new java.awt.Dimension(325, 100));
281: gridBagConstraints = new java.awt.GridBagConstraints();
282: gridBagConstraints.gridx = 0;
283: gridBagConstraints.gridy = 15;
284: gridBagConstraints.gridwidth = 2;
285: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
286: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
287: gridBagConstraints.weightx = 1.0;
288: gridBagConstraints.weighty = 1.0;
289: gridBagConstraints.insets = new java.awt.Insets(0, 3, 3, 3);
290: jPanel2.add(jRTextExpressionAreaExpression, gridBagConstraints);
291:
292: jLabel4.setText("Order");
293: gridBagConstraints = new java.awt.GridBagConstraints();
294: gridBagConstraints.gridx = 0;
295: gridBagConstraints.gridy = 18;
296: gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
297: gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 3);
298: jPanel2.add(jLabel4, gridBagConstraints);
299:
300: gridBagConstraints = new java.awt.GridBagConstraints();
301: gridBagConstraints.gridx = 1;
302: gridBagConstraints.gridy = 18;
303: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
304: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
305: gridBagConstraints.weightx = 1.0;
306: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
307: jPanel2.add(jComboBoxOrder, gridBagConstraints);
308:
309: jLabel5.setText("Custom comparator expression");
310: gridBagConstraints = new java.awt.GridBagConstraints();
311: gridBagConstraints.gridx = 0;
312: gridBagConstraints.gridy = 20;
313: gridBagConstraints.gridwidth = 2;
314: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
315: gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 3);
316: jPanel2.add(jLabel5, gridBagConstraints);
317:
318: jPanel5.setLayout(new java.awt.GridBagLayout());
319:
320: jLabel6.setText("Class");
321: gridBagConstraints = new java.awt.GridBagConstraints();
322: gridBagConstraints.gridx = 0;
323: gridBagConstraints.gridy = 0;
324: gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
325: gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 3);
326: jPanel5.add(jLabel6, gridBagConstraints);
327:
328: jComboBoxBucketClass.setEditable(true);
329: gridBagConstraints = new java.awt.GridBagConstraints();
330: gridBagConstraints.gridx = 1;
331: gridBagConstraints.gridy = 0;
332: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
333: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
334: gridBagConstraints.weightx = 1.0;
335: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
336: jPanel5.add(jComboBoxBucketClass, gridBagConstraints);
337:
338: gridBagConstraints = new java.awt.GridBagConstraints();
339: gridBagConstraints.gridx = 0;
340: gridBagConstraints.gridy = 1;
341: gridBagConstraints.gridwidth = 2;
342: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
343: gridBagConstraints.weightx = 1.0;
344: jPanel2.add(jPanel5, gridBagConstraints);
345:
346: jRTextExpressionAreaComparatorExpression
347: .setBorder(javax.swing.BorderFactory
348: .createEtchedBorder());
349: jRTextExpressionAreaComparatorExpression.setCaretVisible(false);
350: jRTextExpressionAreaComparatorExpression.setElectricScroll(0);
351: jRTextExpressionAreaComparatorExpression
352: .setMinimumSize(new java.awt.Dimension(657, 45));
353: jRTextExpressionAreaComparatorExpression
354: .setPreferredSize(new java.awt.Dimension(325, 45));
355: gridBagConstraints = new java.awt.GridBagConstraints();
356: gridBagConstraints.gridx = 0;
357: gridBagConstraints.gridy = 21;
358: gridBagConstraints.gridwidth = 2;
359: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
360: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
361: gridBagConstraints.weightx = 1.0;
362: gridBagConstraints.weighty = 1.0;
363: gridBagConstraints.insets = new java.awt.Insets(0, 3, 3, 3);
364: jPanel2.add(jRTextExpressionAreaComparatorExpression,
365: gridBagConstraints);
366:
367: gridBagConstraints = new java.awt.GridBagConstraints();
368: gridBagConstraints.gridx = 0;
369: gridBagConstraints.gridy = 4;
370: gridBagConstraints.gridwidth = 3;
371: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
372: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
373: getContentPane().add(jPanel2, gridBagConstraints);
374:
375: jPanel3.setLayout(new java.awt.GridBagLayout());
376:
377: gridBagConstraints = new java.awt.GridBagConstraints();
378: gridBagConstraints.gridx = 1;
379: gridBagConstraints.gridy = 4;
380: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
381: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
382: gridBagConstraints.weightx = 1.0;
383: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
384: jPanel3.add(jComboBoxTotalPosition, gridBagConstraints);
385:
386: gridBagConstraints = new java.awt.GridBagConstraints();
387: gridBagConstraints.gridx = 1;
388: gridBagConstraints.gridy = 1;
389: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
390: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
391: gridBagConstraints.weightx = 1.0;
392: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
393: jPanel3.add(jComboBoxHeaderPosition, gridBagConstraints);
394:
395: jLabel2
396: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
397: jLabel2.setText("Print the group header on this position: ");
398: gridBagConstraints = new java.awt.GridBagConstraints();
399: gridBagConstraints.gridx = 0;
400: gridBagConstraints.gridy = 1;
401: gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
402: jPanel3.add(jLabel2, gridBagConstraints);
403:
404: jLabel7
405: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
406: jLabel7.setText("Print the group total on this position: ");
407: gridBagConstraints = new java.awt.GridBagConstraints();
408: gridBagConstraints.gridx = 0;
409: gridBagConstraints.gridy = 4;
410: gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
411: jPanel3.add(jLabel7, gridBagConstraints);
412:
413: gridBagConstraints = new java.awt.GridBagConstraints();
414: gridBagConstraints.gridx = 0;
415: gridBagConstraints.gridwidth = 3;
416: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
417: gridBagConstraints.weightx = 1.0;
418: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
419: getContentPane().add(jPanel3, gridBagConstraints);
420:
421: pack();
422: java.awt.Dimension screenSize = java.awt.Toolkit
423: .getDefaultToolkit().getScreenSize();
424: java.awt.Dimension dialogSize = getSize();
425: setLocation((screenSize.width - dialogSize.width) / 2,
426: (screenSize.height - dialogSize.height) / 2);
427: }// </editor-fold>//GEN-END:initComponents
428:
429: private void jButtonCancelActionPerformed(
430: java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonCancelActionPerformed
431: {
432: setVisible(false);
433: this .setDialogResult(javax.swing.JOptionPane.CANCEL_OPTION);
434: dispose();
435: }//GEN-LAST:event_jButtonCancelActionPerformed
436:
437: private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonOKActionPerformed
438: {
439:
440: if (this .jTextFieldName.getText().trim().length() <= 0) {
441: javax.swing.JOptionPane
442: .showMessageDialog(
443: this ,
444: I18n
445: .getString(
446: "messages.crosstabGroupDialog.invalidGroup",
447: "Please insert a valid group name!"),
448: I18n
449: .getString(
450: "messages.crosstabGroupDialog.invalidGroupCaption",
451: "Invalid group!"),
452: javax.swing.JOptionPane.WARNING_MESSAGE);
453:
454: return;
455: }
456:
457: if (("" + this .jComboBoxBucketClass.getSelectedItem()).trim()
458: .length() <= 0) {
459: javax.swing.JOptionPane
460: .showMessageDialog(
461: this ,
462: I18n
463: .getString(
464: "messages.crosstabGroupDialog.invalidClassName",
465: "Please insert a valid class name for the bucket!"),
466: I18n
467: .getString(
468: "messages.crosstabGroupDialog.invalidClassNameCaption",
469: "Invalid class!"),
470: javax.swing.JOptionPane.WARNING_MESSAGE);
471:
472: return;
473: }
474:
475: tmpGroup = new CrosstabGroup();
476:
477: tmpGroup.setName(jTextFieldName.getText().trim());
478:
479: tmpGroup.setBucketExpressionClass(this .jComboBoxBucketClass
480: .getSelectedItem()
481: + "");
482:
483: tmpGroup.setSize((int) jNumberFieldSize.getValue());
484:
485: tmpGroup.setBucketExpression(jRTextExpressionAreaExpression
486: .getText());
487: tmpGroup
488: .setBucketComparatorExpression(jRTextExpressionAreaComparatorExpression
489: .getText());
490: tmpGroup.setBucketOrder(""
491: + ((Tag) jComboBoxOrder.getSelectedItem()).getValue());
492:
493: tmpGroup.setTotalPosition(""
494: + ((Tag) jComboBoxTotalPosition.getSelectedItem())
495: .getValue());
496: tmpGroup.setHasTotal(!tmpGroup.getTotalPosition()
497: .equals("None"));
498: tmpGroup.setHasHeader(true);
499: tmpGroup.setHeaderPosition(""
500: + ((Tag) jComboBoxHeaderPosition.getSelectedItem())
501: .getValue());
502:
503: setVisible(false);
504: this .setDialogResult(javax.swing.JOptionPane.OK_OPTION);
505: dispose();
506: }//GEN-LAST:event_jButtonOKActionPerformed
507:
508: /**
509: * Closes the dialog
510: * @param evt DOCUMENT ME!
511: */
512: private void closeDialog(java.awt.event.WindowEvent evt)//GEN-FIRST:event_closeDialog
513: {
514: setVisible(false);
515: this .setDialogResult(javax.swing.JOptionPane.CLOSED_OPTION);
516: dispose();
517: }//GEN-LAST:event_closeDialog
518:
519: /**
520: * Getter for property dialogResult.
521: *
522: * @return Value of property dialogResult.
523: */
524: public int getDialogResult() {
525:
526: return dialogResult;
527: }
528:
529: /**
530: * Setter for property dialogResult.
531: *
532: * @param dialogResult New value of property dialogResult.
533: */
534: public void setDialogResult(int dialogResult) {
535: this .dialogResult = dialogResult;
536: }
537:
538: public void setExpressionContext(SubDataset sds) {
539: if (sds == null) {
540: sds = MainFrame.getMainInstance().getActiveReportFrame()
541: .getReport();
542: }
543: this .jRTextExpressionAreaComparatorExpression
544: .setSubDataset(sds);
545: this .jRTextExpressionAreaComparatorExpression
546: .getCrosstabElements().removeAllElements();
547: this .jRTextExpressionAreaExpression.setSubDataset(sds);
548: this .jRTextExpressionAreaExpression.getCrosstabElements()
549: .removeAllElements();
550: }
551:
552: // Variables declaration - do not modify//GEN-BEGIN:variables
553: private javax.swing.JButton jButtonCancel;
554: private javax.swing.JButton jButtonOK;
555: private javax.swing.JComboBox jComboBoxBucketClass;
556: private javax.swing.JComboBox jComboBoxHeaderPosition;
557: private javax.swing.JComboBox jComboBoxOrder;
558: private javax.swing.JComboBox jComboBoxTotalPosition;
559: private javax.swing.JLabel jLabel1;
560: private javax.swing.JLabel jLabel2;
561: private javax.swing.JLabel jLabel3;
562: private javax.swing.JLabel jLabel4;
563: private javax.swing.JLabel jLabel5;
564: private javax.swing.JLabel jLabel6;
565: private javax.swing.JLabel jLabel7;
566: private javax.swing.JLabel jLabelSize;
567: private it.businesslogic.ireport.gui.JNumberField jNumberFieldSize;
568: private javax.swing.JPanel jPanel1;
569: private javax.swing.JPanel jPanel2;
570: private javax.swing.JPanel jPanel3;
571: private javax.swing.JPanel jPanel4;
572: private javax.swing.JPanel jPanel5;
573: private it.businesslogic.ireport.gui.JRTextExpressionArea jRTextExpressionAreaComparatorExpression;
574: private it.businesslogic.ireport.gui.JRTextExpressionArea jRTextExpressionAreaExpression;
575: private javax.swing.JTextField jTextFieldName;
576: // End of variables declaration//GEN-END:variables
577: private int dialogResult;
578:
579: public CrosstabGroup getGroup() {
580: return tmpGroup;
581: }
582:
583: public void setGroup(CrosstabGroup group) {
584:
585: if (group instanceof CrosstabColumnGroup) {
586: setGroupType(COLUMNGROUP);
587: } else {
588: setGroupType(ROWGROUP);
589: }
590:
591: jTextFieldName.setText(group.getName());
592: try {
593:
594: jNumberFieldSize.setValue(group.getSize());
595: } catch (Exception ex) {
596: }
597:
598: Misc.setComboboxSelectedTagValue(jComboBoxTotalPosition, group
599: .getTotalPosition());
600:
601: Misc.setComboboxSelectedTagValue(jComboBoxHeaderPosition, group
602: .getHeaderPosition());
603:
604: jRTextExpressionAreaExpression.setText(group
605: .getBucketExpression());
606: Misc.setComboboxSelectedTagValue(jComboBoxOrder, group
607: .getBucketOrder());
608: jRTextExpressionAreaComparatorExpression.setText(group
609: .getBucketComparatorExpression());
610: jComboBoxBucketClass.setSelectedItem(group
611: .getBucketExpressionClass());
612:
613: }
614:
615: public int getGroupType() {
616: return groupType;
617: }
618:
619: public void setGroupType(int groupType) {
620: this .groupType = groupType;
621:
622: this .jComboBoxOrder.removeAllItems();
623: this .jComboBoxOrder.addItem(new Tag("Ascending", I18n
624: .getString("order.Ascending", "Ascending")));
625: this .jComboBoxOrder.addItem(new Tag("Descending", I18n
626: .getString("order.Descending", "Descending")));
627: Misc.setComboboxSelectedTagValue(jComboBoxTotalPosition,
628: "Ascending");
629:
630: this .jComboBoxTotalPosition.removeAllItems();
631: this .jComboBoxTotalPosition.addItem(new Tag("None", I18n
632: .getString("totalPosition.None", "None")));
633: this .jComboBoxTotalPosition.addItem(new Tag("Start", I18n
634: .getString("totalPosition.Start", "Start")));
635: this .jComboBoxTotalPosition.addItem(new Tag("End", I18n
636: .getString("totalPosition.End", "End")));
637: Misc
638: .setComboboxSelectedTagValue(jComboBoxTotalPosition,
639: "None");
640:
641: if (groupType == this .COLUMNGROUP) {
642:
643: try {
644: this .jNumberFieldSize.setValue(30);
645: } catch (Exception ex) {
646: }
647:
648: this .jLabelSize.setText(I18n.getString(
649: "crosstabGroupDialog.labelSize.columnHeight",
650: "Group height"));
651: this .jComboBoxHeaderPosition.removeAllItems();
652: this .jComboBoxHeaderPosition.addItem(new Tag("Left", I18n
653: .getString("headerPosition.Left", "Left")));
654: this .jComboBoxHeaderPosition.addItem(new Tag("Center", I18n
655: .getString("headerPosition.Center", "Center")));
656: this .jComboBoxHeaderPosition.addItem(new Tag("Right", I18n
657: .getString("headerPosition.Right", "Right")));
658: this .jComboBoxHeaderPosition
659: .addItem(new Tag("Stretch", I18n.getString(
660: "headerPosition.Stretch", "Stretch")));
661:
662: Misc.setComboboxSelectedTagValue(jComboBoxHeaderPosition,
663: "Left");
664:
665: } else {
666: try {
667: this .jNumberFieldSize.setValue(100);
668: } catch (Exception ex) {
669: }
670:
671: this .jLabelSize.setText(I18n.getString(
672: "crosstabGroupDialog.labelSize.columnWidth",
673: "Group width"));
674: this .jComboBoxHeaderPosition.removeAllItems();
675: this .jComboBoxHeaderPosition.addItem(new Tag("Top", I18n
676: .getString("headerPosition.Top", "Top")));
677: this .jComboBoxHeaderPosition.addItem(new Tag("Middle", I18n
678: .getString("headerPosition.Middle", "Middle")));
679: this .jComboBoxHeaderPosition.addItem(new Tag("Bottom", I18n
680: .getString("headerPosition.Bottom", "Bottom")));
681: this .jComboBoxHeaderPosition
682: .addItem(new Tag("Stretch", I18n.getString(
683: "headerPosition.Stretch", "Stretch")));
684:
685: Misc.setComboboxSelectedTagValue(jComboBoxHeaderPosition,
686: "Top");
687: }
688:
689: }
690:
691: public void applyI18n() {
692: // Start autogenerated code ----------------------
693: jButtonCancel.setText(I18n.getString(
694: "crosstabGroupDialog.buttonCancel", "Cancel"));
695: jButtonOK.setText(I18n.getString(
696: "crosstabGroupDialog.buttonOK", "OK"));
697: jLabel1.setText(I18n.getString("crosstabGroupDialog.label1",
698: "Group name"));
699: jLabel2.setText(I18n.getString("crosstabGroupDialog.label2",
700: "Print the group header on this position: "));
701: jLabel3.setText(I18n.getString("crosstabGroupDialog.label3",
702: "Bucket expression"));
703: jLabel4.setText(I18n.getString("crosstabGroupDialog.label4",
704: "Order"));
705: jLabel5.setText(I18n.getString("crosstabGroupDialog.label5",
706: "Custom comparator expression"));
707: jLabel6.setText(I18n.getString("crosstabGroupDialog.label6",
708: "Class"));
709: jLabel7.setText(I18n.getString("crosstabGroupDialog.label7",
710: "Print the group total on this position: "));
711: jLabelSize.setText(I18n
712: .getString("crosstabGroupDialog.labelSize",
713: "Group width / height"));
714: // End autogenerated code ----------------------
715: ((javax.swing.border.TitledBorder) jPanel2.getBorder())
716: .setTitle(I18n.getString(
717: "crosstabGroupDialog.panelBorder.Bucket",
718: "Bucket"));
719:
720: this .setTitle(I18n.getString("crosstabGroupDialog.title",
721: "Add/modify crosstab group"));
722: jButtonCancel.setMnemonic(I18n.getString(
723: "crosstabGroupDialog.buttonCancelMnemonic", "c")
724: .charAt(0));
725: jButtonOK.setMnemonic(I18n.getString(
726: "crosstabGroupDialog.buttonOKMnemonic", "o").charAt(0));
727: }
728:
729: public static final int COMPONENT_NONE = 0;
730: public static final int COMPONENT_BUCKET_EXPRESSION = 1;
731: public static final int COMPONENT_COMPARATOR_EXPRESSION = 2;
732:
733: /**
734: * This method set the focus on a specific component.
735: * Valid constants are something like:
736: * FIELD_XXX
737: */
738: public void setFocusedExpression(int expID) {
739: switch (expID) {
740: case COMPONENT_BUCKET_EXPRESSION:
741: Misc.selectTextAndFocusArea(jRTextExpressionAreaExpression);
742: break;
743: case COMPONENT_COMPARATOR_EXPRESSION:
744: Misc
745: .selectTextAndFocusArea(jRTextExpressionAreaComparatorExpression);
746: break;
747:
748: }
749:
750: }
751: }
|