Source Code Cross Referenced for GroupsDialog.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » gui » 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 
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;
034:
035:        import it.businesslogic.ireport.SubDataset;
036:        import javax.swing.event.ListSelectionEvent;
037:        import javax.swing.table.*;
038:        import javax.swing.*;
039:        import it.businesslogic.ireport.*;
040:        import it.businesslogic.ireport.util.*;
041:        import it.businesslogic.ireport.gui.event.*;
042:        import java.awt.Point;
043:
044:        import java.util.*;
045:
046:        /**
047:         *
048:         * @author  Administrator
049:         */
050:        public class GroupsDialog extends javax.swing.JDialog {
051:
052:            private JReportFrame jReportFrame = null;
053:            private SubDataset subDataset = null;
054:
055:            // Variables declaration - do not modify//GEN-BEGIN:variables
056:            private javax.swing.JButton jButtonDeleteGroup;
057:            private javax.swing.JButton jButtonModifyGroup;
058:            private javax.swing.JButton jButtonMoveDownGroup;
059:            private javax.swing.JButton jButtonMoveUpGroup;
060:            private javax.swing.JButton jButtonNewGroup;
061:            private javax.swing.JPanel jPanelButtons;
062:            private javax.swing.JPanel jPanelFields;
063:            private javax.swing.JScrollPane jScrollPane3;
064:            private javax.swing.JTable jTableGroups;
065:
066:            // End of variables declaration//GEN-END:variables
067:
068:            /**
069:             * Creates new form GroupsDialog
070:             */
071:            public GroupsDialog(java.awt.Frame parent, boolean modal) {
072:                super (parent, modal);
073:                initComponents();
074:                this .setSize(420, 250);
075:                applyI18n();
076:                I18n
077:                        .addOnLanguageChangedListener(new LanguageChangedListener() {
078:                            public void languageChanged(LanguageChangedEvent evt) {
079:                                applyI18n();
080:                            }
081:                        });
082:                Misc.centerFrame(this );
083:
084:                DefaultListSelectionModel dlsm = (DefaultListSelectionModel) this .jTableGroups
085:                        .getSelectionModel();
086:                dlsm
087:                        .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
088:                            public void valueChanged(ListSelectionEvent e) {
089:                                jTableGroupsListSelectionValueChanged(e);
090:                            }
091:                        });
092:
093:                javax.swing.KeyStroke escape = javax.swing.KeyStroke
094:                        .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
095:                                false);
096:                javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
097:                    public void actionPerformed(java.awt.event.ActionEvent e) {
098:                        setVisible(false);
099:                    }
100:                };
101:
102:                getRootPane().getInputMap(
103:                        javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
104:                        escape, "ESCAPE");
105:                getRootPane().getActionMap().put("ESCAPE", escapeAction);
106:
107:            }
108:
109:            public void jTableGroupsListSelectionValueChanged(
110:                    javax.swing.event.ListSelectionEvent e) {
111:
112:                /* Buttons Move Up and Move Down */
113:                if (this .jTableGroups.getSelectedRowCount() == 1
114:                        && this .jTableGroups.getRowCount() > 1) {
115:                    int row = jTableGroups.getSelectedRows()[0];
116:                    this .jButtonMoveDownGroup
117:                            .setEnabled(row != this .jTableGroups.getRowCount() - 1);
118:                    this .jButtonMoveUpGroup.setEnabled(row != 0);
119:                } else {
120:                    // Moving of multiple groups not allowed
121:                    this .jButtonMoveDownGroup.setEnabled(false);
122:                    this .jButtonMoveUpGroup.setEnabled(false);
123:                }
124:
125:                /* Other buttons*/
126:                if (this .jTableGroups.getSelectedRowCount() > 0) {
127:                    this .jButtonModifyGroup.setEnabled(true);
128:                    this .jButtonDeleteGroup.setEnabled(true);
129:                } else {
130:                    this .jButtonModifyGroup.setEnabled(false);
131:                    this .jButtonDeleteGroup.setEnabled(false);
132:                }
133:            }
134:
135:            public void updateGroups() {
136:
137:                if (getSubDataset() == null) {
138:                    return;
139:                }
140:
141:                DefaultTableModel dtm = (DefaultTableModel) jTableGroups
142:                        .getModel();
143:                dtm.setRowCount(0);
144:
145:                for (Iterator i = getSubDataset().getGroups().iterator(); i
146:                        .hasNext();) {
147:                    it.businesslogic.ireport.Group group = (it.businesslogic.ireport.Group) i
148:                            .next();
149:                    Vector row = new Vector();
150:                    row.addElement(group);
151:
152:                    dtm.addRow(row);
153:                }
154:            }
155:
156:            /** This method is called from within the constructor to
157:             * initialize the form.
158:             * WARNING: Do NOT modify this code. The content of this method is
159:             * always regenerated by the Form Editor.
160:             */
161:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
162:            private void initComponents() {
163:                java.awt.GridBagConstraints gridBagConstraints;
164:
165:                jPanelFields = new javax.swing.JPanel();
166:                jScrollPane3 = new javax.swing.JScrollPane();
167:                jTableGroups = new javax.swing.JTable();
168:                jPanelButtons = new javax.swing.JPanel();
169:                jButtonNewGroup = new javax.swing.JButton();
170:                jButtonModifyGroup = new javax.swing.JButton();
171:                jButtonMoveUpGroup = new javax.swing.JButton();
172:                jButtonMoveDownGroup = new javax.swing.JButton();
173:                jButtonDeleteGroup = new javax.swing.JButton();
174:
175:                addWindowListener(new java.awt.event.WindowAdapter() {
176:                    public void windowClosing(java.awt.event.WindowEvent evt) {
177:                        closeDialog(evt);
178:                    }
179:                });
180:
181:                jPanelFields.setLayout(new java.awt.BorderLayout());
182:
183:                jScrollPane3.setBackground(new java.awt.Color(255, 255, 255));
184:                jTableGroups.setModel(new javax.swing.table.DefaultTableModel(
185:                        new Object[][] {
186:
187:                        }, new String[] { "Group name" }) {
188:                    boolean[] canEdit = new boolean[] { false };
189:
190:                    public boolean isCellEditable(int rowIndex, int columnIndex) {
191:                        return canEdit[columnIndex];
192:                    }
193:                });
194:                jTableGroups
195:                        .addMouseListener(new java.awt.event.MouseAdapter() {
196:                            public void mouseClicked(
197:                                    java.awt.event.MouseEvent evt) {
198:                                jTableGroupsMouseClicked(evt);
199:                            }
200:                        });
201:
202:                jScrollPane3.setViewportView(jTableGroups);
203:
204:                jPanelFields.add(jScrollPane3, java.awt.BorderLayout.CENTER);
205:
206:                jPanelButtons.setLayout(new java.awt.GridBagLayout());
207:
208:                jPanelButtons.setPreferredSize(new java.awt.Dimension(100, 10));
209:                jPanelButtons.setMinimumSize(new java.awt.Dimension(100, 10));
210:                jButtonNewGroup.setText("New");
211:                jButtonNewGroup
212:                        .addActionListener(new java.awt.event.ActionListener() {
213:                            public void actionPerformed(
214:                                    java.awt.event.ActionEvent evt) {
215:                                jButtonNewGroupActionPerformed(evt);
216:                            }
217:                        });
218:
219:                gridBagConstraints = new java.awt.GridBagConstraints();
220:                gridBagConstraints.gridx = 0;
221:                gridBagConstraints.gridy = 0;
222:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
223:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
224:                gridBagConstraints.insets = new java.awt.Insets(3, 3, 5, 3);
225:                jPanelButtons.add(jButtonNewGroup, gridBagConstraints);
226:
227:                jButtonModifyGroup.setText("Modify");
228:                jButtonModifyGroup.setEnabled(false);
229:                jButtonModifyGroup
230:                        .addActionListener(new java.awt.event.ActionListener() {
231:                            public void actionPerformed(
232:                                    java.awt.event.ActionEvent evt) {
233:                                jButtonModifyGroupActionPerformed(evt);
234:                            }
235:                        });
236:
237:                gridBagConstraints = new java.awt.GridBagConstraints();
238:                gridBagConstraints.gridx = 0;
239:                gridBagConstraints.gridy = 1;
240:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
241:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
242:                gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
243:                jPanelButtons.add(jButtonModifyGroup, gridBagConstraints);
244:
245:                jButtonMoveUpGroup.setText("Move Up");
246:                jButtonMoveUpGroup.setEnabled(false);
247:                jButtonMoveUpGroup
248:                        .addActionListener(new java.awt.event.ActionListener() {
249:                            public void actionPerformed(
250:                                    java.awt.event.ActionEvent evt) {
251:                                jButtonMoveUpGroupActionPerformed(evt);
252:                            }
253:                        });
254:
255:                gridBagConstraints = new java.awt.GridBagConstraints();
256:                gridBagConstraints.gridx = 0;
257:                gridBagConstraints.gridy = 2;
258:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
259:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
260:                gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
261:                jPanelButtons.add(jButtonMoveUpGroup, gridBagConstraints);
262:
263:                jButtonMoveDownGroup.setText("Move Down");
264:                jButtonMoveDownGroup.setEnabled(false);
265:                jButtonMoveDownGroup
266:                        .addActionListener(new java.awt.event.ActionListener() {
267:                            public void actionPerformed(
268:                                    java.awt.event.ActionEvent evt) {
269:                                jButtonMoveDownGroupActionPerformed(evt);
270:                            }
271:                        });
272:
273:                gridBagConstraints = new java.awt.GridBagConstraints();
274:                gridBagConstraints.gridx = 0;
275:                gridBagConstraints.gridy = 3;
276:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
277:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
278:                gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
279:                jPanelButtons.add(jButtonMoveDownGroup, gridBagConstraints);
280:
281:                jButtonDeleteGroup.setText("Delete");
282:                jButtonDeleteGroup.setEnabled(false);
283:                jButtonDeleteGroup
284:                        .addActionListener(new java.awt.event.ActionListener() {
285:                            public void actionPerformed(
286:                                    java.awt.event.ActionEvent evt) {
287:                                jButtonDeleteGroupActionPerformed(evt);
288:                            }
289:                        });
290:
291:                gridBagConstraints = new java.awt.GridBagConstraints();
292:                gridBagConstraints.gridx = 0;
293:                gridBagConstraints.gridy = 4;
294:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
295:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
296:                gridBagConstraints.weightx = 1.0;
297:                gridBagConstraints.weighty = 1.0;
298:                gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
299:                jPanelButtons.add(jButtonDeleteGroup, gridBagConstraints);
300:
301:                jPanelFields.add(jPanelButtons, java.awt.BorderLayout.EAST);
302:
303:                getContentPane()
304:                        .add(jPanelFields, java.awt.BorderLayout.CENTER);
305:
306:                pack();
307:            }// </editor-fold>//GEN-END:initComponents
308:
309:            private void jTableGroupsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableGroupsMouseClicked
310:
311:                if (evt.getClickCount() == 2 && evt.getButton() == evt.BUTTON1
312:                        && jTableGroups.getSelectedRow() >= 0) {
313:                    jButtonModifyGroupActionPerformed(new java.awt.event.ActionEvent(
314:                            jButtonModifyGroup, 0, ""));
315:                }
316:
317:            }//GEN-LAST:event_jTableGroupsMouseClicked
318:
319:            private void jButtonMoveDownGroupActionPerformed(
320:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMoveDownGroupActionPerformed
321:                if (jTableGroups.getSelectedRows().length == 1) {
322:                    int[] rows = jTableGroups.getSelectedRows();
323:                    Group grp = (Group) jTableGroups.getValueAt(rows[0], 0);
324:
325:                    if (this .getSubDataset() instanceof  Report) {
326:                        ((Report) getSubDataset()).moveGroup(grp, 1); // 1: Forward
327:
328:                        // do some administration
329:                        MainFrame.getMainInstance().getBandsDialog()
330:                                .updateBands();
331:                        MainFrame.getMainInstance()
332:                                .getElementPropertiesDialog().updateSelection();
333:                        this .getJReportFrame().repaint();
334:                        MainFrame.getMainInstance().reportBandChanged(
335:                                new ReportBandChangedEvent(this 
336:                                        .getJReportFrame(), null,
337:                                        ReportBandChangedEvent.CHANGED));
338:                    }
339:                    this .getJReportFrame().setIsDocDirty(true);
340:
341:                    updateGroups();
342:                    // find position of moved group in the updated list and set focus
343:                    for (int i = 0; i <= jTableGroups.getRowCount() - 1; i++) {
344:                        if (grp == (Group) jTableGroups.getValueAt(i, 0)) {
345:                            jTableGroups.changeSelection(i, 0, true, false);
346:                            break;
347:                        }
348:                    }
349:                }
350:            }//GEN-LAST:event_jButtonMoveDownGroupActionPerformed
351:
352:            private void jButtonMoveUpGroupActionPerformed(
353:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMoveUpGroupActionPerformed
354:
355:                if (jTableGroups.getSelectedRows().length == 1) {
356:                    int[] rows = jTableGroups.getSelectedRows();
357:                    Group grp = (Group) jTableGroups.getValueAt(rows[0], 0);
358:
359:                    if (this .getSubDataset() instanceof  Report) {
360:                        ((Report) getSubDataset()).moveGroup(grp, -1); // -1: Backward
361:
362:                        // do some administration
363:                        MainFrame.getMainInstance().getBandsDialog()
364:                                .updateBands();
365:                        MainFrame.getMainInstance()
366:                                .getElementPropertiesDialog().updateSelection();
367:                        this .getJReportFrame().setIsDocDirty(true);
368:                        this .getJReportFrame().repaint();
369:                        MainFrame.getMainInstance().reportBandChanged(
370:                                new ReportBandChangedEvent(this 
371:                                        .getJReportFrame(), null,
372:                                        ReportBandChangedEvent.CHANGED));
373:
374:                    }
375:                    updateGroups();
376:
377:                    // find position of moved group in the updated list and set focus
378:                    for (int i = 0; i <= jTableGroups.getRowCount() - 1; i++) {
379:                        if (grp == (Group) jTableGroups.getValueAt(i, 0)) {
380:                            jTableGroups.changeSelection(i, 0, true, false);
381:                            break;
382:                        }
383:                    }
384:
385:                }
386:
387:            }//GEN-LAST:event_jButtonMoveUpGroupActionPerformed
388:
389:            private void jButtonDeleteGroupActionPerformed(
390:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeleteGroupActionPerformed
391:                // jTableGroups.getSelectedRows();  disabled by Robert, July 31, 2004
392:
393:                int[] rows = jTableGroups.getSelectedRows();
394:                for (int i = rows.length - 1; i >= 0; --i) {
395:
396:                    // Adjust elements
397:                    if (getSubDataset() instanceof  Report) {
398:                        Enumeration e = ((Report) getSubDataset())
399:                                .getElements().elements();
400:                        while (e.hasMoreElements()) {
401:                            ReportElement re = (ReportElement) e.nextElement();
402:                            if (re.printWhenGroupChanges
403:                                    .equals(""
404:                                            + (it.businesslogic.ireport.Group) jTableGroups
405:                                                    .getValueAt(rows[i], 0))) {
406:                                re.printWhenGroupChanges = "";
407:                            }
408:                        }
409:                    }
410:
411:                    // Adjust variables...
412:                    Enumeration e = getSubDataset().getVariables().elements();
413:                    while (e.hasMoreElements()) {
414:                        JRVariable var = (JRVariable) e.nextElement();
415:                        if (var.getResetType().equals("Group")
416:                                && var
417:                                        .getResetGroup()
418:                                        .equals(
419:                                                ""
420:                                                        + (it.businesslogic.ireport.Group) jTableGroups
421:                                                                .getValueAt(
422:                                                                        rows[i],
423:                                                                        0))) {
424:                            var.setResetType("Report");
425:                            var.setResetGroup("");
426:                        }
427:                    }
428:
429:                    if (getSubDataset() instanceof  Report) {
430:                        ((Report) getSubDataset())
431:                                .delGroup((it.businesslogic.ireport.Group) jTableGroups
432:                                        .getValueAt(rows[i], 0));
433:                    } else {
434:                        getSubDataset().getGroups().remove(
435:                                jTableGroups.getValueAt(rows[i], 0));
436:                    }
437:                }
438:                updateGroups();
439:
440:                if (getSubDataset() instanceof  Report) {
441:                    this .getJReportFrame().checkSelection(false);
442:                    MainFrame.getMainInstance().getBandsDialog().updateBands();
443:                    MainFrame.getMainInstance().getElementPropertiesDialog()
444:                            .updateSelection();
445:                    this .getJReportFrame().repaint();
446:                    MainFrame.getMainInstance().reportBandChanged(
447:                            new ReportBandChangedEvent(this .getJReportFrame(),
448:                                    null, ReportBandChangedEvent.REMOVED));
449:                }
450:                this .getJReportFrame().setIsDocDirty(true);
451:            }//GEN-LAST:event_jButtonDeleteGroupActionPerformed
452:
453:            private void jButtonModifyGroupActionPerformed(
454:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonModifyGroupActionPerformed
455:                it.businesslogic.ireport.Group group = (it.businesslogic.ireport.Group) jTableGroups
456:                        .getValueAt(jTableGroups.getSelectedRow(), 0);
457:
458:                JRGroupDialog jrpd = new JRGroupDialog(this , true);
459:                jrpd.setGroup(group);
460:                jrpd.setSubdataset(getSubDataset());
461:                jrpd.setVisible(true);
462:
463:                if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
464:
465:                    String oldName = group.getName();
466:
467:                    group.setName(jrpd.getGroupName());
468:                    group.setGroupExpression(jrpd.getExpression());
469:                    group.setIsReprintHeaderOnEachPage(jrpd
470:                            .isPrintHeaderEachPage());
471:                    group.setIsResetPageNumber(jrpd.isResetPageNumber());
472:                    group.setIsStartNewColumn(jrpd.isStartNewColumn());
473:                    group.setIsStartNewPage(jrpd.isStartNewPage());
474:                    group.setMinHeightToStartNewPage(jrpd
475:                            .getMinHeightStartNewPage());
476:
477:                    group.getGroupHeader().setName(group.getName() + "Header");
478:                    group.getGroupFooter().setName(group.getName() + "Footer");
479:
480:                    if (getSubDataset() instanceof  Report) {
481:                        int deltaHeader = jrpd.getHeaderBandHeight()
482:                                - group.getGroupHeader().getHeight();
483:                        int deltaFooter = jrpd.getFooterBandHeight()
484:                                - group.getGroupFooter().getHeight();
485:
486:                        int positionFooterBottom = ((Report) getSubDataset())
487:                                .getBandYLocation(group.getGroupFooter())
488:                                + group.getGroupFooter().getHeight();
489:                        int positionHeaderBottom = ((Report) getSubDataset())
490:                                .getBandYLocation(group.getGroupHeader())
491:                                + group.getGroupHeader().getHeight();
492:
493:                        // move down / up all modified bands...
494:                        Enumeration enumElements = ((Report) getSubDataset())
495:                                .getElements().elements();
496:                        while (enumElements.hasMoreElements()) {
497:                            ReportElement re = (ReportElement) enumElements
498:                                    .nextElement();
499:
500:                            if (re.getPosition().getY() >= positionFooterBottom) {
501:                                re.trasform(new Point(0, deltaHeader
502:                                        + deltaFooter),
503:                                        TransformationType.TRANSFORMATION_MOVE);
504:                            } else if (re.getPosition().getY() >= positionHeaderBottom) {
505:                                re.trasform(new Point(0, deltaHeader),
506:                                        TransformationType.TRANSFORMATION_MOVE);
507:                            }
508:                        }
509:                    }
510:                    group.getGroupHeader()
511:                            .setHeight(jrpd.getHeaderBandHeight());
512:                    group.getGroupFooter()
513:                            .setHeight(jrpd.getFooterBandHeight());
514:
515:                    for (int k = getSubDataset().getVariables().size() - 1; k >= 0; --k) {
516:                        JRVariable var = (JRVariable) getSubDataset()
517:                                .getVariables().elementAt(k);
518:                        if (var.isBuiltin()
519:                                && var.getName().equalsIgnoreCase(
520:                                        oldName + "_COUNT")) {
521:                            getSubDataset().removeVariable(var);
522:                            break;
523:                        }
524:                    }
525:                    getSubDataset().addVariable(
526:                            new it.businesslogic.ireport.JRVariable(group
527:                                    .getName()
528:                                    + "_COUNT", "java.lang.Integer", true));
529:
530:                    // Update All variables...
531:                    Enumeration e = getSubDataset().getVariables().elements();
532:                    while (e.hasMoreElements()) {
533:                        JRVariable var = (JRVariable) e.nextElement();
534:                        if (var.getResetGroup() != null
535:                                && var.getResetGroup().equals(oldName)) {
536:                            var.setResetGroup(group.getName());
537:                        }
538:                    }
539:
540:                    // Adjust elements
541:                    if (getSubDataset() instanceof  Report) {
542:                        e = ((Report) getSubDataset()).getElements().elements();
543:                        while (e.hasMoreElements()) {
544:                            ReportElement re = (ReportElement) e.nextElement();
545:                            if (re.printWhenGroupChanges.equals(oldName))
546:                                re.printWhenGroupChanges = group.getName();
547:
548:                            if (re instanceof  TextFieldReportElement
549:                                    && ((TextFieldReportElement) re).getGroup()
550:                                            .equals(oldName))
551:                                ((TextFieldReportElement) re).setGroup(group
552:                                        .getName());
553:                        }
554:                        this .getJReportFrame().repaint();
555:                    }
556:
557:                    // refersh bands frame.... really required ?!
558:                    MainFrame.getMainInstance().getBandsDialog().updateBands();
559:                    MainFrame.getMainInstance().getElementPropertiesDialog()
560:                            .updateSelection();
561:                    this .getJReportFrame().setIsDocDirty(true);
562:                    this .updateGroups();
563:                    MainFrame.getMainInstance().reportBandChanged(
564:                            new ReportBandChangedEvent(this .getJReportFrame(),
565:                                    null, ReportBandChangedEvent.CHANGED));
566:                }
567:
568:            }//GEN-LAST:event_jButtonModifyGroupActionPerformed
569:
570:            private void jButtonNewGroupActionPerformed(
571:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNewGroupActionPerformed
572:                JRGroupDialog jrpd = new JRGroupDialog(this , true);
573:                jrpd.setVisible(true);
574:
575:                if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
576:                    Group g = new it.businesslogic.ireport.Group(this 
577:                            .getSubDataset(), jrpd.getGroupName());
578:                    g.setGroupExpression(jrpd.getExpression());
579:                    g
580:                            .setIsReprintHeaderOnEachPage(jrpd
581:                                    .isPrintHeaderEachPage());
582:                    g.setIsResetPageNumber(jrpd.isResetPageNumber());
583:                    g.setIsStartNewColumn(jrpd.isStartNewColumn());
584:                    g.setIsStartNewPage(jrpd.isStartNewPage());
585:                    g.setMinHeightToStartNewPage(jrpd
586:                            .getMinHeightStartNewPage());
587:
588:                    g.getGroupHeader().setHeight(jrpd.getHeaderBandHeight());
589:                    g.getGroupFooter().setHeight(jrpd.getFooterBandHeight());
590:
591:                    this .getJReportFrame().setIsDocDirty(true);
592:                    if (getSubDataset() instanceof  Report) {
593:                        ((Report) getSubDataset()).addGroup(g);
594:                        this .getJReportFrame().repaint();
595:                        MainFrame.getMainInstance().reportBandChanged(
596:                                new ReportBandChangedEvent(this 
597:                                        .getJReportFrame(), null,
598:                                        ReportBandChangedEvent.ADDED));
599:                    } else {
600:                        getSubDataset().getGroups().add(g);
601:                    }
602:                    this .updateGroups();
603:
604:                    // refersh bands frame.... (ridicolous, never required :-)
605:                    //((MainFrame)this.getParent()).getBandsDialog().updateBands();
606:                    //((MainFrame)this.getParent()).getElementPropertiesDialog().updateBands();
607:                    //((MainFrame)this.getParent()).getElementPropertiesDialog().updateGroups();
608:                }
609:            }//GEN-LAST:event_jButtonNewGroupActionPerformed
610:
611:            /** Closes the dialog */
612:            private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
613:                setVisible(false);
614:                dispose();
615:            }//GEN-LAST:event_closeDialog
616:
617:            /**
618:             * @param args the command line arguments
619:             */
620:            public static void main(String args[]) {
621:                new GroupsDialog(new javax.swing.JFrame(), true)
622:                        .setVisible(true);
623:            }
624:
625:            /** Getter for property jReportFrame.
626:             * @return Value of property jReportFrame.
627:             *
628:             */
629:            public it.businesslogic.ireport.gui.JReportFrame getJReportFrame() {
630:                return jReportFrame;
631:            }
632:
633:            /** Setter for property jReportFrame.
634:             * @param jReportFrame New value of property jReportFrame.
635:             *
636:             */
637:            public void setJReportFrame(
638:                    it.businesslogic.ireport.gui.JReportFrame jReportFrame) {
639:                this .jReportFrame = jReportFrame;
640:
641:                // Update all...
642:                if (jReportFrame == null) {
643:                    setVisible(false);
644:                    return;
645:                }
646:
647:                setSubDataset(jReportFrame.getReport());
648:
649:                //this.setTitle(jReportFrame.getReport().getName()+" groups...");
650:                this .setTitle(jReportFrame.getReport().getName() + " "
651:                        + I18n.getString("groupsDialog.groups", " groups..."));
652:
653:                if (isVisible()) {
654:                    updateGroups();
655:                }
656:            }
657:
658:            public void setVisible(boolean visible) {
659:                if (visible == isVisible())
660:                    return;
661:                super .setVisible(visible);
662:                if (visible == true) {
663:                    this .setJReportFrame(jReportFrame);
664:                }
665:            }
666:
667:            public void applyI18n() {
668:                // Start autogenerated code ----------------------
669:                jButtonDeleteGroup.setText(I18n.getString(
670:                        "groupsDialog.buttonDeleteGroup", "Delete"));
671:                jButtonModifyGroup.setText(I18n.getString(
672:                        "groupsDialog.buttonModifyGroup", "Modify"));
673:                jButtonMoveDownGroup.setText(I18n.getString(
674:                        "groupsDialog.buttonMoveDownGroup", "Move Down"));
675:                jButtonMoveUpGroup.setText(I18n.getString(
676:                        "groupsDialog.buttonMoveUpGroup", "Move Up"));
677:                jButtonNewGroup.setText(I18n.getString(
678:                        "groupsDialog.buttonNewGroup", "New"));
679:                // End autogenerated code ----------------------
680:
681:                jTableGroups.getColumnModel().getColumn(0).setHeaderValue(
682:                        I18n.getString("groupsDialog.tablecolumn.groupName",
683:                                "Group name"));
684:
685:            }
686:
687:            public SubDataset getSubDataset() {
688:                return subDataset;
689:            }
690:
691:            public void setSubDataset(SubDataset subDataset) {
692:                this.subDataset = subDataset;
693:                updateGroups();
694:            }
695:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.