Source Code Cross Referenced for BandsDialog.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:         * BandsDialog.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.gui.event.ReportBandChangedEvent;
036:        import it.businesslogic.ireport.gui.event.ReportBandsSelectionEvent;
037:        import it.businesslogic.ireport.gui.event.ReportElementChangedEvent;
038:        import it.businesslogic.ireport.gui.event.ReportElementsSelectionEvent;
039:        import it.businesslogic.ireport.gui.event.ReportListener;
040:        import javax.swing.table.*;
041:        import javax.swing.*;
042:        import javax.swing.event.*;
043:        import it.businesslogic.ireport.*;
044:        import it.businesslogic.ireport.gui.event.ReportObjectsSelectionEvent;
045:        import it.businesslogic.ireport.util.*;
046:
047:        import java.util.*;
048:
049:        /**
050:         *
051:         * @author  Administrator
052:         */
053:        public class BandsDialog extends javax.swing.JDialog implements 
054:                ReportListener {
055:
056:            private JReportFrame jReportFrame = null;
057:
058:            private Band selectedBand = null;
059:
060:            /** Creates new form BandsDialog */
061:            public BandsDialog(java.awt.Frame parent, boolean modal) {
062:                super (parent, modal);
063:                initComponents();
064:                applyI18n();
065:                this .pack();
066:                Misc.centerFrame(this );
067:                jListBands.setModel(new DefaultListModel());
068:                /* 
069:                 
070:                 this.jRTextExpressionArea.getDocument().addDocumentListener( new javax.swing.event.DocumentListener() {
071:                    public void changedUpdate(javax.swing.event.DocumentEvent evt)
072:                    {
073:                        jRTextExpressionAreaTextChanged();
074:                    }
075:                    public void insertUpdate(javax.swing.event.DocumentEvent evt) {
076:                        jRTextExpressionAreaTextChanged();
077:                    }
078:                    public void removeUpdate(javax.swing.event.DocumentEvent evt) {
079:                        jRTextExpressionAreaTextChanged();
080:                    }
081:                });
082:                 *
083:                 */
084:
085:                javax.swing.KeyStroke escape = javax.swing.KeyStroke
086:                        .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
087:                                false);
088:                javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
089:                    public void actionPerformed(java.awt.event.ActionEvent e) {
090:                        setVisible(false);
091:                    }
092:                };
093:
094:                getRootPane().getInputMap(
095:                        javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
096:                        escape, "ESCAPE");
097:                getRootPane().getActionMap().put("ESCAPE", escapeAction);
098:
099:                //to make the default button ...
100:                this .getRootPane().setDefaultButton(this .jButton1);
101:
102:                MainFrame.getMainInstance().addReportListener(this );
103:
104:            }
105:
106:            private void jRTextExpressionAreaTextChanged() {
107:
108:            }
109:
110:            public void jTableBandsListSelectionValueChanged(
111:                    javax.swing.event.ListSelectionEvent e) {
112:
113:            }
114:
115:            public void updateBands() {
116:
117:                Object selected = getSelectedBand();
118:                boolean isSelected = false;
119:
120:                ((DefaultListModel) jListBands.getModel()).removeAllElements();
121:
122:                if (jReportFrame == null)
123:                    return;
124:                Enumeration e = jReportFrame.getReport().getBands().elements();
125:                while (e.hasMoreElements()) {
126:                    it.businesslogic.ireport.Band band = (it.businesslogic.ireport.Band) e
127:                            .nextElement();
128:                    ((DefaultListModel) jListBands.getModel()).addElement(band);
129:                    if (selected == band) {
130:                        jListBands.setSelectedValue(selected, true);
131:                        isSelected = true;
132:                    }
133:                }
134:
135:                if (!isSelected
136:                        && jReportFrame.getReport().getBands().size() > 0) {
137:                    jListBands.setSelectedIndex(0);
138:                }
139:            }
140:
141:            /** This method is called from within the constructor to
142:             * initialize the form.
143:             * WARNING: Do NOT modify this code. The content of this method is
144:             * always regenerated by the Form Editor.
145:             */
146:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
147:            private void initComponents() {
148:                java.awt.GridBagConstraints gridBagConstraints;
149:
150:                jPanelFields = new javax.swing.JPanel();
151:                jPanelButtons = new javax.swing.JPanel();
152:                jPanel2 = new javax.swing.JPanel();
153:                jPanel3 = new javax.swing.JPanel();
154:                jLabel1 = new javax.swing.JLabel();
155:                jLabel2 = new javax.swing.JLabel();
156:                jNumberFieldHeight = new it.businesslogic.ireport.gui.JNumberField();
157:                jCheckBoxSplitAllowed = new javax.swing.JCheckBox();
158:                jRTextExpressionArea = new it.businesslogic.ireport.gui.JRTextExpressionArea();
159:                jButton1 = new javax.swing.JButton();
160:                jScrollPane1 = new javax.swing.JScrollPane();
161:                jListBands = new javax.swing.JList();
162:
163:                addWindowListener(new java.awt.event.WindowAdapter() {
164:                    public void windowClosing(java.awt.event.WindowEvent evt) {
165:                        closeDialog(evt);
166:                    }
167:                });
168:
169:                jPanelFields.setLayout(new java.awt.BorderLayout(4, 4));
170:
171:                jPanelButtons.setLayout(new java.awt.BorderLayout());
172:
173:                jPanelButtons.setBorder(javax.swing.BorderFactory
174:                        .createTitledBorder(javax.swing.BorderFactory
175:                                .createEtchedBorder(), "Band properties"));
176:                jPanelButtons.setMinimumSize(new java.awt.Dimension(100, 10));
177:                jPanelButtons
178:                        .setPreferredSize(new java.awt.Dimension(300, 250));
179:                jPanel2.setLayout(new java.awt.BorderLayout());
180:
181:                jPanel3.setLayout(new java.awt.GridBagLayout());
182:
183:                jPanel3.setPreferredSize(new java.awt.Dimension(10, 55));
184:                jLabel1.setText("Print When Expression");
185:                gridBagConstraints = new java.awt.GridBagConstraints();
186:                gridBagConstraints.gridx = 0;
187:                gridBagConstraints.gridy = 2;
188:                gridBagConstraints.gridwidth = 2;
189:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
190:                gridBagConstraints.insets = new java.awt.Insets(3, 3, 0, 3);
191:                jPanel3.add(jLabel1, gridBagConstraints);
192:
193:                jLabel2.setText("Band height");
194:                gridBagConstraints = new java.awt.GridBagConstraints();
195:                gridBagConstraints.gridx = 0;
196:                gridBagConstraints.gridy = 0;
197:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
198:                gridBagConstraints.insets = new java.awt.Insets(3, 3, 0, 3);
199:                jPanel3.add(jLabel2, gridBagConstraints);
200:
201:                jNumberFieldHeight
202:                        .setHorizontalAlignment(javax.swing.JTextField.RIGHT);
203:                jNumberFieldHeight.setText("0");
204:                try {
205:                    jNumberFieldHeight.setDecimals(0);
206:                } catch (java.beans.PropertyVetoException e1) {
207:                    e1.printStackTrace();
208:                }
209:                jNumberFieldHeight
210:                        .setMinimumSize(new java.awt.Dimension(80, 19));
211:                jNumberFieldHeight.setPreferredSize(new java.awt.Dimension(80,
212:                        19));
213:                jNumberFieldHeight
214:                        .addActionListener(new java.awt.event.ActionListener() {
215:                            public void actionPerformed(
216:                                    java.awt.event.ActionEvent evt) {
217:                                jNumberFieldHeightActionPerformed(evt);
218:                            }
219:                        });
220:
221:                gridBagConstraints = new java.awt.GridBagConstraints();
222:                gridBagConstraints.gridx = 0;
223:                gridBagConstraints.gridy = 1;
224:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
225:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
226:                gridBagConstraints.insets = new java.awt.Insets(0, 3, 3, 3);
227:                jPanel3.add(jNumberFieldHeight, gridBagConstraints);
228:
229:                jCheckBoxSplitAllowed.setSelected(true);
230:                jCheckBoxSplitAllowed.setText("Split allowed");
231:                jCheckBoxSplitAllowed
232:                        .addActionListener(new java.awt.event.ActionListener() {
233:                            public void actionPerformed(
234:                                    java.awt.event.ActionEvent evt) {
235:                                jCheckBoxSplitAllowedActionPerformed(evt);
236:                            }
237:                        });
238:
239:                gridBagConstraints = new java.awt.GridBagConstraints();
240:                gridBagConstraints.gridx = 1;
241:                gridBagConstraints.gridy = 0;
242:                gridBagConstraints.gridheight = 2;
243:                gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
244:                gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
245:                jPanel3.add(jCheckBoxSplitAllowed, gridBagConstraints);
246:
247:                jRTextExpressionArea.setBorder(javax.swing.BorderFactory
248:                        .createEtchedBorder());
249:                jRTextExpressionArea.setElectricScroll(0);
250:                jRTextExpressionArea
251:                        .setMinimumSize(new java.awt.Dimension(0, 0));
252:                gridBagConstraints = new java.awt.GridBagConstraints();
253:                gridBagConstraints.gridx = 0;
254:                gridBagConstraints.gridy = 3;
255:                gridBagConstraints.gridwidth = 2;
256:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
257:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
258:                gridBagConstraints.weightx = 1.0;
259:                gridBagConstraints.weighty = 1.0;
260:                gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
261:                jPanel3.add(jRTextExpressionArea, gridBagConstraints);
262:
263:                jButton1.setText("Apply");
264:                jButton1.addActionListener(new java.awt.event.ActionListener() {
265:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
266:                        jButton1ActionPerformed(evt);
267:                    }
268:                });
269:
270:                gridBagConstraints = new java.awt.GridBagConstraints();
271:                gridBagConstraints.gridx = 0;
272:                gridBagConstraints.gridwidth = 2;
273:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
274:                gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
275:                jPanel3.add(jButton1, gridBagConstraints);
276:
277:                jPanel2.add(jPanel3, java.awt.BorderLayout.CENTER);
278:
279:                jPanelButtons.add(jPanel2, java.awt.BorderLayout.CENTER);
280:
281:                jPanelFields.add(jPanelButtons, java.awt.BorderLayout.CENTER);
282:
283:                getContentPane()
284:                        .add(jPanelFields, java.awt.BorderLayout.CENTER);
285:
286:                jScrollPane1.setToolTipText("");
287:                jScrollPane1
288:                        .setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
289:                jScrollPane1.setPreferredSize(new java.awt.Dimension(150, 300));
290:                jListBands.setBorder(javax.swing.BorderFactory
291:                        .createEtchedBorder());
292:                jListBands
293:                        .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
294:                jListBands.setToolTipText("List of bands");
295:                jListBands.setMaximumSize(new java.awt.Dimension(32767, 32767));
296:                jListBands
297:                        .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
298:                            public void valueChanged(
299:                                    javax.swing.event.ListSelectionEvent evt) {
300:                                jListBandsValueChanged(evt);
301:                            }
302:                        });
303:
304:                jScrollPane1.setViewportView(jListBands);
305:
306:                getContentPane().add(jScrollPane1, java.awt.BorderLayout.WEST);
307:
308:                pack();
309:            }// </editor-fold>//GEN-END:initComponents
310:
311:            private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
312:
313:                boolean changed = false;
314:
315:                Band b = getSelectedBand();
316:                if (b == null)
317:                    return;
318:                int okHeight = b.getHeight();
319:
320:                int newHeight = updateBandHeight(getJReportFrame().getReport(),
321:                        b, (int) jNumberFieldHeight.getValue());
322:
323:                if (newHeight >= 0 && okHeight != newHeight) {
324:                    try {
325:                        jNumberFieldHeight.setValue(newHeight);
326:                    } catch (Exception ex) {
327:                    }
328:
329:                    getJReportFrame().setIsDocDirty(true);
330:                    getJReportFrame().updateScrollBars();
331:                    getJReportFrame().getReportPanel().repaint();
332:
333:                    changed = true;
334:                }
335:
336:                // Setting the new jCheckBoxSplitAllowed...
337:                b = getSelectedBand();
338:                if (b != null) {
339:                    b.setSplitAllowed(jCheckBoxSplitAllowed.isSelected());
340:                    changed = true;
341:                }
342:
343:                if (!b.getPrintWhenExpression().equals(
344:                        jRTextExpressionArea.getText())) {
345:                    getSelectedBand().setPrintWhenExpression(
346:                            jRTextExpressionArea.getText());
347:                    changed = true;
348:                }
349:
350:                if (changed) {
351:                    getJReportFrame().fireReportListenerReportBandChanged(
352:                            new ReportBandChangedEvent(getJReportFrame(),
353:                                    getSelectedBand(),
354:                                    ReportBandChangedEvent.CHANGED));
355:                }
356:
357:            }//GEN-LAST:event_jButton1ActionPerformed
358:
359:            private void jCheckBoxSplitAllowedActionPerformed(
360:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxSplitAllowedActionPerformed
361:
362:            }//GEN-LAST:event_jCheckBoxSplitAllowedActionPerformed
363:
364:            private void jNumberFieldHeightActionPerformed(
365:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNumberFieldHeightActionPerformed
366:
367:            }//GEN-LAST:event_jNumberFieldHeightActionPerformed
368:
369:            private void jListBandsValueChanged(
370:                    javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListBandsValueChanged
371:                //
372:
373:                updateSelection();
374:            }//GEN-LAST:event_jListBandsValueChanged
375:
376:            public void updateSelection() {
377:                // This solve a bug with the not reached focus event...
378:                jNumberFieldHeightActionPerformed(null);
379:
380:                if (jListBands.getModel().getSize() == 0) {
381:                    try {
382:                        this .jNumberFieldHeight.setValue(0);
383:                    } catch (Exception ex) {
384:                    }
385:                    this .jRTextExpressionArea.setText("");
386:                    jCheckBoxSplitAllowed.setSelected(false);
387:                    return;
388:                }
389:
390:                if (jListBands.getSelectedIndex() < 0) {
391:                    jListBands.setSelectedIndex(0);
392:                    return;
393:                }
394:
395:                selectedBand = (Band) jListBands.getSelectedValue();
396:                try {
397:                    this .jNumberFieldHeight.setValue(selectedBand.getHeight());
398:                } catch (Exception ex) {
399:                }
400:                this .jRTextExpressionArea.setText(selectedBand
401:                        .getPrintWhenExpression());
402:                this .jCheckBoxSplitAllowed.setSelected(selectedBand
403:                        .isSplitAllowed());
404:            }
405:
406:            /** Closes the dialog */
407:            private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
408:                setVisible(false);
409:                dispose();
410:            }//GEN-LAST:event_closeDialog
411:
412:            /**
413:             * @param args the command line arguments
414:             */
415:            public static void main(String args[]) {
416:                new BandsDialog(new javax.swing.JFrame(), true)
417:                        .setVisible(true);
418:            }
419:
420:            /** Getter for property jReportFrame.
421:             * @return Value of property jReportFrame.
422:             *
423:             */
424:            public it.businesslogic.ireport.gui.JReportFrame getJReportFrame() {
425:                return jReportFrame;
426:            }
427:
428:            /** Setter for property jReportFrame.
429:             * @param jReportFrame New value of property jReportFrame.
430:             *
431:             */
432:            public void setJReportFrame(
433:                    it.businesslogic.ireport.gui.JReportFrame jReportFrame) {
434:                this .jReportFrame = jReportFrame;
435:
436:                // Update all...
437:                if (jReportFrame == null) {
438:                    setVisible(false);
439:                    return;
440:                }
441:
442:                this .setTitle(jReportFrame.getReport().getName() + " "
443:                        + I18n.getString("bandsDialog.bands", " bands..."));
444:                if (isVisible()) {
445:                    updateBands();
446:                }
447:            }
448:
449:            // Variables declaration - do not modify//GEN-BEGIN:variables
450:            private javax.swing.JButton jButton1;
451:            private javax.swing.JCheckBox jCheckBoxSplitAllowed;
452:            private javax.swing.JLabel jLabel1;
453:            private javax.swing.JLabel jLabel2;
454:            private javax.swing.JList jListBands;
455:            private it.businesslogic.ireport.gui.JNumberField jNumberFieldHeight;
456:            private javax.swing.JPanel jPanel2;
457:            private javax.swing.JPanel jPanel3;
458:            private javax.swing.JPanel jPanelButtons;
459:            private javax.swing.JPanel jPanelFields;
460:            private it.businesslogic.ireport.gui.JRTextExpressionArea jRTextExpressionArea;
461:            private javax.swing.JScrollPane jScrollPane1;
462:
463:            // End of variables declaration//GEN-END:variables
464:
465:            public void setVisible(boolean visible) {
466:                if (visible == isVisible())
467:                    return;
468:                super .setVisible(visible);
469:                if (visible == true) {
470:                    this .setJReportFrame(jReportFrame);
471:                }
472:            }
473:
474:            public void setSelectedBand(String bandName) {
475:                for (int i = 0; i < jListBands.getModel().getSize(); ++i) {
476:                    Band b = (Band) jListBands.getModel().getElementAt(i);
477:                    if (b.getName().equals(bandName)) {
478:                        jListBands.setSelectedIndex(i);
479:                        return;
480:                    }
481:                }
482:            }
483:
484:            public Band getSelectedBand() {
485:                return selectedBand;
486:            }
487:
488:            public void setSelectedBand(Band selectedBand) {
489:                this .selectedBand = selectedBand;
490:            }
491:
492:            public void applyI18n() {
493:                // Start autogenerated code ----------------------
494:                jCheckBoxSplitAllowed.setText(I18n.getString(
495:                        "bandsDialog.checkBoxSplitAllowed", "Split allowed"));
496:                // End autogenerated code ----------------------
497:                // Start autogenerated code ----------------------
498:                jButton1
499:                        .setText(I18n.getString("bandsDialog.button1", "Apply"));
500:                jLabel1.setText(I18n.getString("bandsDialog.label1",
501:                        "Print When Expression"));
502:                jLabel2.setText(I18n.getString("bandsDialog.label2",
503:                        "Band height"));
504:                // End autogenerated code ----------------------
505:
506:                ((javax.swing.border.TitledBorder) jPanelButtons.getBorder())
507:                        .setTitle(I18n.getString(
508:                                "bandsDialog.panelBorder.BandProperties",
509:                                "Band properties"));
510:
511:                jListBands.setToolTipText(I18n.getString(
512:                        "bandsDialog.listBands", "List of bands"));
513:
514:            }
515:
516:            /**
517:             * Return the new height or -1 if an exception occurred
518:             */
519:            public static int updateBandHeight(Report report, Band b,
520:                    int newHeight) {
521:                if (b == null || report == null)
522:                    return -1;
523:                int okHeight = b.getHeight();
524:                boolean changed = false;
525:
526:                // 1. we set band height, but first we adjust elements position
527:                int delta = newHeight - b.getHeight();
528:                if (delta != 0) {
529:                    changed = true;
530:                    // Available space...
531:                    int available_height = Misc.getMaxBandHeight(report, b);
532:
533:                    if (available_height < newHeight) {
534:                        final int available_height_f = available_height;
535:                        final int newHeight_f = newHeight;
536:                        SwingUtilities.invokeLater(new Runnable() {
537:                            public void run() {
538:                                JOptionPane
539:                                        .showMessageDialog(
540:                                                MainFrame.getMainInstance(),
541:                                                "The band height has beed adjusted to fit the report requirements\n(max hight allowed for this band: "
542:                                                        + available_height_f
543:                                                        + ", requested: "
544:                                                        + newHeight_f + ").",
545:                                                "Alert",
546:                                                JOptionPane.WARNING_MESSAGE);
547:                            }
548:                        });
549:                    }
550:                    okHeight = Math.max(0, Math
551:                            .min(available_height, newHeight));
552:
553:                    delta = okHeight - b.getHeight();
554:                    // Redraw all under the min height...
555:                    int band_h = report.getBandYLocation(b);
556:                    b.setHeight(b.getHeight() + delta);
557:                    int edge_y = Math.min(report.getBandYLocation(b)
558:                            + b.getHeight(), report.getBandYLocation(b)
559:                            + b.getHeight() - delta);
560:                    Enumeration e = report.getElements().elements();
561:                    while (e.hasMoreElements()) {
562:                        ReportElement re = (ReportElement) e.nextElement();
563:                        if (re.position.y >= edge_y + 10) {
564:                            // I should add the distance form the base of resized band, and my element... 
565:                            int space_before_band = band_h - re.position.y
566:                                    - re.height;
567:                            if (band_h <= report.getBandYLocation(re.getBand()) + 10)
568:                                space_before_band = 0;
569:                            re.setPosition(new java.awt.Point(
570:                                    re.getPosition().x, re.getPosition().y
571:                                            + delta));
572:                        }
573:                    }
574:
575:                    if (report.getReportFrame() != null) {
576:                        report.getReportFrame().setIsDocDirty(true);
577:                        report.getReportFrame().updateScrollBars();
578:                        report.getReportFrame().getReportPanel().repaint();
579:                    }
580:                }
581:
582:                return okHeight;
583:
584:            }
585:
586:            public void reportElementsSelectionChanged(
587:                    ReportElementsSelectionEvent evt) {
588:            }
589:
590:            public void reportElementsChanged(ReportElementChangedEvent evt) {
591:
592:            }
593:
594:            public void reportBandChanged(ReportBandChangedEvent evt) {
595:                updateSelection();
596:            }
597:
598:            public void reportBandsSelectionChanged(
599:                    ReportBandsSelectionEvent evt) {
600:            }
601:
602:            public void reportObjectsSelectionChanged(
603:                    ReportObjectsSelectionEvent evt) {
604:            }
605:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.