Source Code Cross Referenced for GroupsDialog.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » gui » subdataset » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » iReport 2.0.5 » it.businesslogic.ireport.gui.subdataset 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:         * GroupsDialog.java
028:         * 
029:         * Created on 10 maggio 2003, 9.51
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.gui.subdataset;
034:
035:        import java.awt.Component;
036:        import java.awt.Dialog;
037:        import java.awt.Frame;
038:        import javax.swing.table.*;
039:        import javax.swing.*;
040:        import javax.swing.event.*;
041:        import it.businesslogic.ireport.*;
042:        import it.businesslogic.ireport.util.*;
043:
044:        import java.util.*;
045:
046:        /**
047:         *
048:         * @author  Administrator
049:         */
050:        public class GroupsDialog extends javax.swing.JDialog {
051:
052:            private SubDataset subDataset = null;
053:
054:            // Variables declaration - do not modify//GEN-BEGIN:variables
055:            private javax.swing.JButton jButtonDeleteGroup;
056:            private javax.swing.JButton jButtonModifyGroup;
057:            private javax.swing.JButton jButtonMoveDownGroup;
058:            private javax.swing.JButton jButtonMoveUpGroup;
059:            private javax.swing.JButton jButtonNewGroup;
060:            private javax.swing.JPanel jPanelButtons;
061:            private javax.swing.JPanel jPanelFields;
062:            private javax.swing.JScrollPane jScrollPane3;
063:            private javax.swing.JTable jTableGroups;
064:
065:            // End of variables declaration//GEN-END:variables
066:
067:            /**
068:             * Creates new form GroupsDialog
069:             */
070:            public GroupsDialog(java.awt.Dialog parent, boolean modal) {
071:                super (parent, modal);
072:                initComponents();
073:                applyI18n();
074:                this .setSize(420, 250);
075:                Misc.centerFrame(this );
076:
077:                DefaultListSelectionModel dlsm = (DefaultListSelectionModel) this .jTableGroups
078:                        .getSelectionModel();
079:                dlsm
080:                        .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
081:                            public void valueChanged(ListSelectionEvent e) {
082:                                jTableGroupsListSelectionValueChanged(e);
083:                            }
084:                        });
085:
086:                javax.swing.KeyStroke escape = javax.swing.KeyStroke
087:                        .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
088:                                false);
089:                javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
090:                    public void actionPerformed(java.awt.event.ActionEvent e) {
091:                        setVisible(false);
092:                    }
093:                };
094:
095:                getRootPane().getInputMap(
096:                        javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
097:                        escape, "ESCAPE");
098:                getRootPane().getActionMap().put("ESCAPE", escapeAction);
099:
100:            }
101:
102:            public void jTableGroupsListSelectionValueChanged(
103:                    javax.swing.event.ListSelectionEvent e) {
104:
105:                /* Buttons Move Up and Move Down */
106:                if (this .jTableGroups.getSelectedRowCount() == 1
107:                        && this .jTableGroups.getRowCount() > 1) {
108:                    int row = jTableGroups.getSelectedRows()[0];
109:                    this .jButtonMoveDownGroup
110:                            .setEnabled(row != this .jTableGroups.getRowCount() - 1);
111:                    this .jButtonMoveUpGroup.setEnabled(row != 0);
112:                } else {
113:                    // Moving of multiple groups not allowed
114:                    this .jButtonMoveDownGroup.setEnabled(false);
115:                    this .jButtonMoveUpGroup.setEnabled(false);
116:                }
117:
118:                /* Other buttons*/
119:                if (this .jTableGroups.getSelectedRowCount() > 0) {
120:                    this .jButtonModifyGroup.setEnabled(true);
121:                    this .jButtonDeleteGroup.setEnabled(true);
122:                } else {
123:                    this .jButtonModifyGroup.setEnabled(false);
124:                    this .jButtonDeleteGroup.setEnabled(false);
125:                }
126:            }
127:
128:            public void updateGroups() {
129:
130:                if (getSubDataset() == null) {
131:                    return;
132:                }
133:
134:                int[] selectedRows = jTableGroups.getSelectedRows();
135:                List selectedObjects = new ArrayList();
136:                for (int i = 0; i < selectedRows.length; ++i) {
137:                    selectedObjects.add(jTableGroups.getValueAt(
138:                            selectedRows[i], 0));
139:                }
140:
141:                DefaultTableModel dtm = (DefaultTableModel) jTableGroups
142:                        .getModel();
143:                dtm.setRowCount(0);
144:
145:                int k = 0;
146:                for (Iterator i = getSubDataset().getGroups().iterator(); i
147:                        .hasNext();) {
148:                    it.businesslogic.ireport.Group group = (it.businesslogic.ireport.Group) i
149:                            .next();
150:                    Vector row = new Vector();
151:                    row.addElement(group);
152:
153:                    dtm.addRow(row);
154:                    if (selectedObjects.contains(group)) {
155:                        jTableGroups.getSelectionModel().addSelectionInterval(
156:                                k, k);
157:                    }
158:                    k++;
159:                }
160:            }
161:
162:            /** This method is called from within the constructor to
163:             * initialize the form.
164:             * WARNING: Do NOT modify this code. The content of this method is
165:             * always regenerated by the Form Editor.
166:             */
167:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
168:            private void initComponents() {
169:                java.awt.GridBagConstraints gridBagConstraints;
170:
171:                jPanelFields = new javax.swing.JPanel();
172:                jScrollPane3 = new javax.swing.JScrollPane();
173:                jTableGroups = new javax.swing.JTable();
174:                jPanelButtons = new javax.swing.JPanel();
175:                jButtonNewGroup = new javax.swing.JButton();
176:                jButtonModifyGroup = new javax.swing.JButton();
177:                jButtonMoveUpGroup = new javax.swing.JButton();
178:                jButtonMoveDownGroup = new javax.swing.JButton();
179:                jButtonDeleteGroup = new javax.swing.JButton();
180:
181:                addWindowListener(new java.awt.event.WindowAdapter() {
182:                    public void windowClosing(java.awt.event.WindowEvent evt) {
183:                        closeDialog(evt);
184:                    }
185:                });
186:
187:                jPanelFields.setLayout(new java.awt.BorderLayout());
188:
189:                jScrollPane3.setBackground(new java.awt.Color(255, 255, 255));
190:                jTableGroups.setModel(new javax.swing.table.DefaultTableModel(
191:                        new Object[][] {
192:
193:                        }, new String[] { "Group name" }) {
194:                    boolean[] canEdit = new boolean[] { false };
195:
196:                    public boolean isCellEditable(int rowIndex, int columnIndex) {
197:                        return canEdit[columnIndex];
198:                    }
199:                });
200:                jTableGroups
201:                        .addMouseListener(new java.awt.event.MouseAdapter() {
202:                            public void mouseClicked(
203:                                    java.awt.event.MouseEvent evt) {
204:                                jTableGroupsMouseClicked(evt);
205:                            }
206:                        });
207:
208:                jScrollPane3.setViewportView(jTableGroups);
209:
210:                jPanelFields.add(jScrollPane3, java.awt.BorderLayout.CENTER);
211:
212:                jPanelButtons.setLayout(new java.awt.GridBagLayout());
213:
214:                jPanelButtons.setPreferredSize(new java.awt.Dimension(100, 10));
215:                jPanelButtons.setMinimumSize(new java.awt.Dimension(100, 10));
216:                jButtonNewGroup.setText("New");
217:                jButtonNewGroup
218:                        .addActionListener(new java.awt.event.ActionListener() {
219:                            public void actionPerformed(
220:                                    java.awt.event.ActionEvent evt) {
221:                                jButtonNewGroupActionPerformed(evt);
222:                            }
223:                        });
224:
225:                gridBagConstraints = new java.awt.GridBagConstraints();
226:                gridBagConstraints.gridx = 0;
227:                gridBagConstraints.gridy = 0;
228:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
229:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
230:                gridBagConstraints.insets = new java.awt.Insets(3, 3, 5, 3);
231:                jPanelButtons.add(jButtonNewGroup, gridBagConstraints);
232:
233:                jButtonModifyGroup.setText("Modify");
234:                jButtonModifyGroup.setEnabled(false);
235:                jButtonModifyGroup
236:                        .addActionListener(new java.awt.event.ActionListener() {
237:                            public void actionPerformed(
238:                                    java.awt.event.ActionEvent evt) {
239:                                jButtonModifyGroupActionPerformed(evt);
240:                            }
241:                        });
242:
243:                gridBagConstraints = new java.awt.GridBagConstraints();
244:                gridBagConstraints.gridx = 0;
245:                gridBagConstraints.gridy = 1;
246:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
247:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
248:                gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
249:                jPanelButtons.add(jButtonModifyGroup, gridBagConstraints);
250:
251:                jButtonMoveUpGroup.setText("Move Up");
252:                jButtonMoveUpGroup.setEnabled(false);
253:                jButtonMoveUpGroup
254:                        .addActionListener(new java.awt.event.ActionListener() {
255:                            public void actionPerformed(
256:                                    java.awt.event.ActionEvent evt) {
257:                                jButtonMoveUpGroupActionPerformed(evt);
258:                            }
259:                        });
260:
261:                gridBagConstraints = new java.awt.GridBagConstraints();
262:                gridBagConstraints.gridx = 0;
263:                gridBagConstraints.gridy = 2;
264:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
265:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
266:                gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
267:                jPanelButtons.add(jButtonMoveUpGroup, gridBagConstraints);
268:
269:                jButtonMoveDownGroup.setText("Move Down");
270:                jButtonMoveDownGroup.setEnabled(false);
271:                jButtonMoveDownGroup
272:                        .addActionListener(new java.awt.event.ActionListener() {
273:                            public void actionPerformed(
274:                                    java.awt.event.ActionEvent evt) {
275:                                jButtonMoveDownGroupActionPerformed(evt);
276:                            }
277:                        });
278:
279:                gridBagConstraints = new java.awt.GridBagConstraints();
280:                gridBagConstraints.gridx = 0;
281:                gridBagConstraints.gridy = 3;
282:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
283:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
284:                gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
285:                jPanelButtons.add(jButtonMoveDownGroup, gridBagConstraints);
286:
287:                jButtonDeleteGroup.setText("Delete");
288:                jButtonDeleteGroup.setEnabled(false);
289:                jButtonDeleteGroup
290:                        .addActionListener(new java.awt.event.ActionListener() {
291:                            public void actionPerformed(
292:                                    java.awt.event.ActionEvent evt) {
293:                                jButtonDeleteGroupActionPerformed(evt);
294:                            }
295:                        });
296:
297:                gridBagConstraints = new java.awt.GridBagConstraints();
298:                gridBagConstraints.gridx = 0;
299:                gridBagConstraints.gridy = 4;
300:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
301:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
302:                gridBagConstraints.weightx = 1.0;
303:                gridBagConstraints.weighty = 1.0;
304:                gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
305:                jPanelButtons.add(jButtonDeleteGroup, gridBagConstraints);
306:
307:                jPanelFields.add(jPanelButtons, java.awt.BorderLayout.EAST);
308:
309:                getContentPane()
310:                        .add(jPanelFields, java.awt.BorderLayout.CENTER);
311:
312:                pack();
313:            }// </editor-fold>//GEN-END:initComponents
314:
315:            private void jTableGroupsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableGroupsMouseClicked
316:
317:                if (evt.getClickCount() == 2 && evt.getButton() == evt.BUTTON1) {
318:                    jButtonModifyGroupActionPerformed(null);
319:                }
320:
321:            }//GEN-LAST:event_jTableGroupsMouseClicked
322:
323:            private void jButtonMoveDownGroupActionPerformed(
324:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMoveDownGroupActionPerformed
325:                if (jTableGroups.getSelectedRows().length == 1) {
326:                    int[] rows = jTableGroups.getSelectedRows();
327:                    Group grp = (Group) jTableGroups.getValueAt(rows[0], 0);
328:
329:                    // Now move the groups within the group array
330:                    int groupPos = getSubDataset().getGroups().indexOf(grp);
331:                    // groupTwo is always after grpOne
332:                    if (groupPos < getSubDataset().getGroups().size() - 1) {
333:                        getSubDataset().getGroups().remove(groupPos);
334:                        getSubDataset().getGroups().insertElementAt(grp,
335:                                groupPos + 1);
336:                        updateGroups();
337:                        jTableGroupsListSelectionValueChanged(null);
338:                    }
339:
340:                    //((MainFrame)this.getParent()).reportBandChanged( new ReportBandChangedEvent(this.getJReportFrame(), null, ReportBandChangedEvent.CHANGED ));
341:                }
342:            }//GEN-LAST:event_jButtonMoveDownGroupActionPerformed
343:
344:            private void jButtonMoveUpGroupActionPerformed(
345:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMoveUpGroupActionPerformed
346:
347:                if (jTableGroups.getSelectedRows().length == 1) {
348:                    int[] rows = jTableGroups.getSelectedRows();
349:                    Group grp = (Group) jTableGroups.getValueAt(rows[0], 0);
350:                    // Now move the groups within the group array
351:                    int groupPos = getSubDataset().getGroups().indexOf(grp);
352:                    // groupTwo is always after grpOne
353:                    if (groupPos > 0) {
354:                        getSubDataset().getGroups().remove(groupPos);
355:                        getSubDataset().getGroups().insertElementAt(grp,
356:                                groupPos - 1);
357:                        updateGroups();
358:                        jTableGroupsListSelectionValueChanged(null);
359:                    }
360:
361:                    // ((MainFrame)this.getParent()).reportBandChanged( new ReportBandChangedEvent(this.getJReportFrame(), null, ReportBandChangedEvent.CHANGED ));
362:                }
363:
364:            }//GEN-LAST:event_jButtonMoveUpGroupActionPerformed
365:
366:            private void jButtonDeleteGroupActionPerformed(
367:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeleteGroupActionPerformed
368:                // jTableGroups.getSelectedRows();  disabled by Robert, July 31, 2004
369:
370:                int[] rows = jTableGroups.getSelectedRows();
371:                for (int i = rows.length - 1; i >= 0; --i) {
372:
373:                    getSubDataset().getGroups().remove(
374:                            jTableGroups.getValueAt(rows[i], 0));
375:                }
376:                updateGroups();
377:                //((MainFrame)this.getParent()).reportBandChanged( new ReportBandChangedEvent(this.getJReportFrame(), null, ReportBandChangedEvent.REMOVED ));
378:            }//GEN-LAST:event_jButtonDeleteGroupActionPerformed
379:
380:            private void jButtonModifyGroupActionPerformed(
381:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonModifyGroupActionPerformed
382:                it.businesslogic.ireport.Group group = (it.businesslogic.ireport.Group) jTableGroups
383:                        .getValueAt(jTableGroups.getSelectedRow(), 0);
384:
385:                group = modifyGroup(getSubDataset(), group, this );
386:
387:                if (group != null) {
388:                    jTableGroups.setValueAt(group, jTableGroups
389:                            .getSelectedRow(), 0);
390:                }
391:            }//GEN-LAST:event_jButtonModifyGroupActionPerformed
392:
393:            private void jButtonNewGroupActionPerformed(
394:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNewGroupActionPerformed
395:                GroupDialog jrpd = new GroupDialog(this , true);
396:                jrpd.setSubDataset(getSubDataset());
397:                jrpd.setVisible(true);
398:
399:                if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
400:                    Group g = new it.businesslogic.ireport.Group(
401:                            getSubDataset(), jrpd.getGroupName());
402:                    g.setGroupExpression(jrpd.getExpression());
403:                    //g.setIsReprintHeaderOnEachPage(jrpd.isPrintHeaderEachPage() );
404:                    //g.setIsResetPageNumber( jrpd.isResetPageNumber()  );
405:                    //g.setIsStartNewColumn( jrpd.isStartNewColumn());
406:                    //g.setIsStartNewPage( jrpd.isStartNewPage());
407:                    //g.setMinHeightToStartNewPage( jrpd.getMinHeightStartNewPage() );
408:
409:                    //g.getGroupHeader().setHeight(  jrpd.getHeaderBandHeight());
410:                    //g.getGroupFooter().setHeight(  jrpd.getFooterBandHeight());
411:
412:                    getSubDataset().getGroups().add(g);
413:                    this .updateGroups();
414:
415:                    // refersh bands frame....
416:                    //((MainFrame)this.getParent()).reportBandChanged( new ReportBandChangedEvent(this.getJReportFrame(), null, ReportBandChangedEvent.ADDED ));
417:                }
418:            }//GEN-LAST:event_jButtonNewGroupActionPerformed
419:
420:            /** Closes the dialog */
421:            private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
422:                setVisible(false);
423:                dispose();
424:            }//GEN-LAST:event_closeDialog
425:
426:            /** Setter for property jReportFrame.
427:             * @param jReportFrame New value of property jReportFrame.
428:             *
429:             */
430:            public void setSubDataset(
431:                    it.businesslogic.ireport.SubDataset subDataset) {
432:                this .subDataset = subDataset;
433:                if (subDataset == null)
434:                    return;
435:                //
436:                this .setTitle(subDataset.getName() + " "
437:                        + I18n.getString("groupsDialog.groups", " groups..."));
438:                //this.setTitle(subDataset.getName()+" groups...");
439:                //
440:                updateGroups();
441:            }
442:
443:            public SubDataset getSubDataset() {
444:                return subDataset;
445:            }
446:
447:            public void applyI18n() {
448:                // Start autogenerated code ----------------------
449:                jButtonDeleteGroup.setText(I18n.getString(
450:                        "groupsDialog.buttonDeleteGroup", "Delete"));
451:                jButtonModifyGroup.setText(I18n.getString(
452:                        "groupsDialog.buttonModifyGroup", "Modify"));
453:                jButtonMoveDownGroup.setText(I18n.getString(
454:                        "groupsDialog.buttonMoveDownGroup", "Move Down"));
455:                jButtonMoveUpGroup.setText(I18n.getString(
456:                        "groupsDialog.buttonMoveUpGroup", "Move Up"));
457:                jButtonNewGroup.setText(I18n.getString(
458:                        "groupsDialog.buttonNewGroup", "New"));
459:                // End autogenerated code ----------------------
460:                jTableGroups.getColumnModel().getColumn(0).setHeaderValue(
461:                        I18n.getString("groupsDialog.tablecolumn.groupName",
462:                                "Group name"));
463:
464:            }
465:
466:            public static Group modifyGroup(SubDataset subDataset, Group group,
467:                    Component parent) {
468:                return modifyGroup(subDataset, group, parent,
469:                        GroupDialog.COMPONENT_NONE);
470:
471:            }
472:
473:            public static Group modifyGroup(SubDataset subDataset, Group group,
474:                    Component parent, int focusComponent) {
475:                Object obj = null;
476:                if (parent != null) {
477:                    obj = SwingUtilities.getWindowAncestor(parent);
478:                }
479:                GroupDialog jrpd = null;
480:
481:                if (obj != null && obj instanceof  Dialog) {
482:                    jrpd = new GroupDialog((Dialog) obj, true);
483:                } else {
484:                    jrpd = new GroupDialog((Frame) obj, true);
485:                }
486:                jrpd.setGroup(group);
487:                jrpd.setSubDataset(subDataset);
488:                jrpd.setFocusedExpression(focusComponent);
489:                jrpd.setVisible(true);
490:
491:                if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
492:
493:                    String oldName = group.getName();
494:
495:                    group.setName(jrpd.getGroupName());
496:                    group.setGroupExpression(jrpd.getExpression());
497:                    //group.setIsReprintHeaderOnEachPage(jrpd.isPrintHeaderEachPage() );
498:                    //group.setIsResetPageNumber( jrpd.isResetPageNumber()  );
499:                    //group.setIsStartNewColumn( jrpd.isStartNewColumn());
500:                    //group.setIsStartNewPage( jrpd.isStartNewPage());
501:                    //group.setMinHeightToStartNewPage( jrpd.getMinHeightStartNewPage() );
502:
503:                    //group.getGroupHeader().setName( group.getName()+"Header");
504:                    //group.getGroupFooter().setName( group.getName()+"Footer");
505:                    //group.getGroupHeader().setHeight(  jrpd.getHeaderBandHeight());
506:                    //group.getGroupFooter().setHeight(  jrpd.getFooterBandHeight());
507:
508:                    for (int k = subDataset.getVariables().size() - 1; k >= 0; --k) {
509:                        JRVariable var = (JRVariable) subDataset.getVariables()
510:                                .elementAt(k);
511:                        if (var.isBuiltin()
512:                                && var.getName().equalsIgnoreCase(
513:                                        oldName + "_COUNT")) {
514:                            subDataset.removeVariable(var);
515:                            break;
516:                        }
517:                    }
518:                    subDataset
519:                            .addVariable(new it.businesslogic.ireport.JRVariable(
520:                                    group.getName() + "_COUNT",
521:                                    "java.lang.Integer", true));
522:
523:                    // Update All variables...
524:                    Enumeration e = subDataset.getVariables().elements();
525:                    while (e.hasMoreElements()) {
526:                        JRVariable var = (JRVariable) e.nextElement();
527:                        if (var.getResetGroup() != null
528:                                && var.getResetGroup().equals(oldName)) {
529:                            var.setResetGroup(group.getName());
530:                        }
531:                    }
532:
533:                    //this.updateGroups();
534:                    //((MainFrame)this.getParent()).reportBandChanged( new ReportBandChangedEvent(this.getJReportFrame(), null, ReportBandChangedEvent.CHANGED ));
535:                }
536:
537:                return group;
538:            }
539:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.