Source Code Cross Referenced for ReportBandSheetPanel.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » gui » sheet » 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.sheet 
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:         * ReportElementSheetPanel.java
028:         * 
029:         * Created on 16 febbraio 2005, 6.57
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.gui.sheet;
034:
035:        import it.businesslogic.ireport.*;
036:        import it.businesslogic.ireport.gui.*;
037:        import it.businesslogic.ireport.gui.JNumberField;
038:        import it.businesslogic.ireport.gui.event.*;
039:        import it.businesslogic.ireport.refactoring.ReportRefactor;
040:        import it.businesslogic.ireport.util.*;
041:        import it.businesslogic.ireport.util.LanguageChangedEvent;
042:        import it.businesslogic.ireport.util.LanguageChangedListener;
043:        import java.awt.Color;
044:        import java.util.*;
045:        import javax.swing.JCheckBox;
046:        import javax.swing.JComponent;
047:
048:        /**
049:         *
050:         * @author  Administrator
051:         */
052:        public class ReportBandSheetPanel extends CategorySheetPanel implements 
053:                ReportListener, LanguageChangedListener,
054:                ReportFrameActivatedListener {
055:
056:            // Sheet properties
057:            private SheetProperty spHeight;
058:            private SheetProperty spSplitAllowed;
059:            private ExpressionSheetProperty spPrintWhenExpression;
060:
061:            // Group related property sheets
062:            private SheetProperty spGroupName;
063:            private ExpressionSheetProperty spGroupExpression;
064:            private SheetProperty spGroupOnNewPage;
065:            private SheetProperty spGroupOnNewColumn;
066:            private SheetProperty spGroupResetPageNumber;
067:            private SheetProperty spGroupPrintHeaderOnEachPage;
068:            private SheetProperty spGroupMinHeightToStartOnNewPage;
069:
070:            public static java.awt.Color sharedDifferentValueLabelColor = java.awt.Color.red
071:                    .darker().darker();
072:            public static java.awt.Color mandatoryPropertiesLabelColor = java.awt.Color.blue;
073:            public static java.awt.Color notMandatoryPropertiesLabelColor = java.awt.Color.black;
074:
075:            private JReportFrame jrf = null;
076:
077:            private boolean init = false;
078:
079:            private Vector bandSelection = new Vector();
080:
081:            /** Creates a new instance of ReportElementSheetPanel */
082:            public ReportBandSheetPanel() {
083:                super ();
084:                this .setBackground(Color.BLUE);
085:                initSheetProperties();
086:                // We have to register for element changes...
087:                MainFrame mf = MainFrame.getMainInstance();
088:                mf.addReportListener(this );
089:                mf.addReportFrameActivatedListener(this );
090:                I18n.addOnLanguageChangedListener(this );
091:            }
092:
093:            public void reportFrameActivated(ReportFrameActivatedEvent evt) {
094:
095:                if (MainFrame.getMainInstance().getActiveReportFrame() == this 
096:                        .getJrf())
097:                    return;
098:                updateSelection(MainFrame.getMainInstance()
099:                        .getActiveReportFrame());
100:
101:            }
102:
103:            public void languageChanged(LanguageChangedEvent evt) {
104:                this .removeAllProperties();
105:                initSheetProperties();
106:                updateSelection();
107:            }
108:
109:            public void updateSelection() {
110:                JReportFrame newJrf = MainFrame.getMainInstance()
111:                        .getActiveReportFrame();
112:                updateSelection(newJrf);
113:            }
114:
115:            /**
116:             * Numbers do not change when the focus is lost due to a selection change.
117:             * This apply the value....
118:             */
119:            public void applyValueForNumbers() {
120:                Enumeration e = getProperties().elements();
121:                while (e.hasMoreElements()) {
122:                    SheetProperty sp = (SheetProperty) e.nextElement();
123:
124:                    //if (sp instanceof NumberComboBoxSheetProperty)
125:                    //{
126:                    //    JNumberComboBox c = (JNumberComboBox)sp.getEditor();
127:                    //    System.out.println("NNNN");
128:                    //    if (c.hasFocus())
129:                    //    {
130:                    //       FocusManager.getCurrentManager().clearGlobalFocusOwner();
131:                    //       System.out.println(FocusManager.getCurrentManager().getFocusOwner());
132:                    //       return; // Only a component can be focused at time...
133:                    //    }
134:                    //}
135:                    if (sp.getType() == sp.INTEGER || sp.getType() == sp.NUMBER) {
136:                        JComponent c = sp.getEditor();
137:                        if (c.hasFocus() && c instanceof  JNumberField) {
138:                            ((JNumberField) c).focusLost(null);
139:                            return; // Only a component can be focused at time...
140:                        }
141:                    }
142:
143:                }
144:            }
145:
146:            /**
147:             * Update all the element properties...
148:             * 
149:             */
150:            public void updateSelection(JReportFrame newJrf) {
151:                // Improving speed...
152:                // Do nothing if there are elements selected...
153:                if (newJrf != null && newJrf.getSelectedElements().size() > 0)
154:                    return;
155:
156:                // Fix for numbers focus losing...
157:                applyValueForNumbers();
158:                if (newJrf == null) {
159:                    this .setBandSelection(new Vector());
160:                } else {
161:                    this .setBandSelection(newJrf.getSelectedBands());
162:                }
163:
164:                setInit(true);
165:
166:                this .removeAllProperties();
167:
168:                this .jrf = newJrf;
169:
170:                if (jrf == null || getBandSelection().size() == 0) {
171:                    this .recreateSheet();
172:                    return;
173:                }
174:
175:                try {
176:                    Vector selectedElements = getBandSelection();
177:
178:                    boolean sameHeight = true;
179:                    boolean sameSplitAllowed = true;
180:                    boolean samePrintWhenExpression = true;
181:
182:                    boolean isTheFirstElement = true;
183:
184:                    boolean sameIsGroup = true;
185:                    boolean sameGroupName = true;
186:                    boolean sameGroupExpression = true;
187:                    boolean sameGroupOnNewPage = true;
188:                    boolean sameGroupOnNewColumn = true;
189:                    boolean sameGroupResetPageNumber = true;
190:                    boolean sameGroupPrintHeaderOnEachPage = true;
191:                    boolean sameGroupMinHeightToStartOnNewPage = true;
192:
193:                    for (int i = 0; i < selectedElements.size(); ++i) {
194:                        Band band = (Band) selectedElements.elementAt(i);
195:
196:                        //if (sameName)  sameName = this.setGenericSheetProperty(isTheFirstElement, band.getName(), false);
197:                        if (sameHeight)
198:                            sameHeight = this .setElementNumber(
199:                                    isTheFirstElement, band.getHeight(),
200:                                    (JNumberField) spHeight.getEditor());
201:                        if (sameSplitAllowed)
202:                            sameSplitAllowed = this .setCheckBox(
203:                                    isTheFirstElement, band.isSplitAllowed(),
204:                                    false, spSplitAllowed);
205:                        if (samePrintWhenExpression)
206:                            samePrintWhenExpression = setTextArea(
207:                                    isTheFirstElement, band
208:                                            .getPrintWhenExpression(),
209:                                    spPrintWhenExpression);
210:
211:                        if (sameIsGroup) {
212:
213:                            sameIsGroup = sameIsGroup & band.getGroup() != null;
214:
215:                            if (sameIsGroup) {
216:                                Group group = band.getGroup();
217:
218:                                if (sameGroupExpression)
219:                                    sameGroupExpression = setTextArea(
220:                                            isTheFirstElement, group
221:                                                    .getGroupExpression(),
222:                                            spGroupExpression);
223:                                if (sameGroupName)
224:                                    sameGroupName = setTextArea(
225:                                            isTheFirstElement, group.getName(),
226:                                            spGroupName);
227:                                if (sameGroupOnNewPage)
228:                                    sameGroupOnNewPage = this .setCheckBox(
229:                                            isTheFirstElement, group
230:                                                    .isIsStartNewPage(), false,
231:                                            spGroupOnNewPage);
232:                                if (sameGroupOnNewColumn)
233:                                    sameGroupOnNewColumn = this .setCheckBox(
234:                                            isTheFirstElement, group
235:                                                    .isIsStartNewColumn(),
236:                                            false, spGroupOnNewColumn);
237:                                if (sameGroupResetPageNumber)
238:                                    sameGroupResetPageNumber = this 
239:                                            .setCheckBox(
240:                                                    isTheFirstElement,
241:                                                    group.isIsResetPageNumber(),
242:                                                    false,
243:                                                    spGroupResetPageNumber);
244:                                if (sameGroupPrintHeaderOnEachPage)
245:                                    sameGroupPrintHeaderOnEachPage = this 
246:                                            .setCheckBox(
247:                                                    isTheFirstElement,
248:                                                    group
249:                                                            .isIsReprintHeaderOnEachPage(),
250:                                                    false,
251:                                                    spGroupPrintHeaderOnEachPage);
252:                                if (sameGroupMinHeightToStartOnNewPage)
253:                                    sameGroupMinHeightToStartOnNewPage = this 
254:                                            .setElementNumber(
255:                                                    isTheFirstElement,
256:                                                    group
257:                                                            .getMinHeightToStartNewPage(),
258:                                                    (JNumberField) spGroupMinHeightToStartOnNewPage
259:                                                            .getEditor());
260:                            }
261:                        }
262:
263:                        isTheFirstElement = false;
264:                    }
265:
266:                    spHeight
267:                            .setLabelColor((sameHeight) ? notMandatoryPropertiesLabelColor
268:                                    : sharedDifferentValueLabelColor);
269:                    //spSplitAllowed.setLabelColor( (sameSplitAllowed) ? mandatoryPropertiesLabelColor : sharedDifferentValueLabelColor );
270:                    //spPrintWhenExpression.setLabelColor( (samePrintWhenExpression) ? mandatoryPropertiesLabelColor : sharedDifferentValueLabelColor );
271:
272:                    ExpressionContext ec = new ExpressionContext();
273:                    ec.setSubDataset(jrf.getReport());
274:
275:                    spPrintWhenExpression.setExpressionContext(ec);
276:
277:                    spPrintWhenExpression.setLabelError(null);
278:                    spPrintWhenExpression.updateLabel();
279:
280:                    String commonStr = it.businesslogic.ireport.util.I18n
281:                            .getString("bandProperties", "Band Properties");
282:                    this .addSheetProperty(commonStr, spHeight);
283:                    this .addSheetProperty(commonStr, spSplitAllowed);
284:                    this .addSheetProperty(commonStr, spPrintWhenExpression);
285:
286:                    if (sameIsGroup) {
287:                        String groupStr = it.businesslogic.ireport.util.I18n
288:                                .getString("groupProperties",
289:                                        "Group Properties");
290:                        this .addSheetProperty(groupStr, spGroupName);
291:                        this .addSheetProperty(groupStr, spGroupExpression);
292:                        this .addSheetProperty(groupStr, spGroupOnNewPage);
293:                        this .addSheetProperty(groupStr, spGroupOnNewColumn);
294:                        this .addSheetProperty(groupStr, spGroupResetPageNumber);
295:                        this .addSheetProperty(groupStr,
296:                                spGroupPrintHeaderOnEachPage);
297:                        this .addSheetProperty(groupStr,
298:                                spGroupMinHeightToStartOnNewPage);
299:
300:                        spGroupExpression.setLabelError(null);
301:                        spGroupExpression.updateLabel();
302:                    }
303:
304:                    spSplitAllowed.setDefaultValue(new Boolean(true));
305:
306:                    this .recreateSheet();
307:
308:                } catch (Exception ex) {
309:                    ex.printStackTrace();
310:                } finally {
311:
312:                }
313:
314:                setInit(false);
315:            }
316:
317:            /**
318:             * This methos is called when a property changes...
319:             */
320:            public void sheetPropertyValueChanged(
321:                    SheetPropertyValueChangedEvent evt) {
322:                if (isInit())
323:                    return;
324:
325:                //System.out.println("Changed: " + evt.getPropertyName());
326:                //if (isNullItem((SheetProperty)evt.getSource())) return;
327:
328:                //removeNullItem( (SheetProperty)evt.getSource() );
329:
330:                Vector selectedElements = getBandSelection();
331:
332:                Vector modified_groups = new Vector();
333:                Vector modified_bands = new Vector();
334:                for (int i = 0; i < selectedElements.size(); ++i) {
335:
336:                    Band band = (Band) selectedElements.elementAt(i);
337:                    if (applyNewBandProperty(band, evt.getPropertyName(), evt
338:                            .getOldValue(), evt.getNewValue())) {
339:                        modified_bands.add(band);
340:                    }
341:
342:                    if (band.getGroup() != null) {
343:                        Group g = band.getGroup();
344:                        if (!modified_groups.contains(g)) {
345:                            modified_groups.add(g);
346:                            if (applyNewGroupProperty(band, g, evt
347:                                    .getPropertyName(), evt.getOldValue(), evt
348:                                    .getNewValue())) {
349:                                if (!modified_bands
350:                                        .contains(g.getGroupFooter()))
351:                                    modified_bands.add(g.getGroupFooter());
352:                                if (!modified_bands
353:                                        .contains(g.getGroupHeader()))
354:                                    modified_bands.add(g.getGroupHeader());
355:                            }
356:                        }
357:                    }
358:
359:                }
360:
361:                for (int i = 0; i < modified_bands.size(); ++i) {
362:                    Band band = (Band) modified_bands.elementAt(i);
363:                    getJrf().fireReportListenerReportBandChanged(
364:                            new ReportBandChangedEvent(getJrf(), band,
365:                                    ReportBandChangedEvent.CHANGED, this ));
366:                }
367:
368:                repaintEditor();
369:                getJrf().getReport().incrementReportChanges();
370:
371:                /*
372:                ReportElementChangedEvent changedEvent = new ReportElementChangedEvent(jrf , selectedElements , ReportElementChangedEvent.CHANGED);
373:                changedEvent.setEventSource( this );
374:                if (evt.getPropertyName().equals("textfieldEvaluationTime"))
375:                {
376:                   changedEvent.setPropertyChanged( evt.getPropertyName() );
377:                   changedEvent.setNewValue( evt.getNewValue() );
378:                }
379:                jrf.fireReportListenerReportElementsChanged(changedEvent);
380:                MainFrame.getMainInstance().getElementPropertiesDialog().updateSelection();
381:                 */
382:            }
383:
384:            /*
385:             * This method apply the new value for the specified property
386:             * The oldValue can be wrong or null if a multiselection was performed
387:             */
388:            private boolean applyNewBandProperty(Band b, String propertyName,
389:                    Object oldValue, Object newValue) {
390:                if (propertyName == null)
391:                    return false;
392:                if (isInit())
393:                    return false;
394:
395:                boolean fireEvent = true;
396:                if (propertyName.equals("height")) {
397:                    if (newValue != null && !newValue.equals("")) {
398:                        int val = Integer.parseInt("" + newValue);
399:
400:                        BandsDialog.updateBandHeight(getJrf().getReport(), b,
401:                                val);
402:                        int newHeight = b.getHeight();
403:                        if (newHeight != val) {
404:                            boolean oldInit = isInit();
405:                            setInit(true);
406:                            spHeight.setValue("" + newHeight);
407:                            setInit(oldInit);
408:                        }
409:                    }
410:                } else if (propertyName.equals("splitAllowed")) {
411:                    b.setSplitAllowed(((Boolean) newValue).booleanValue());
412:                } else if (propertyName.equals("printWhenExpression")) {
413:                    if (newValue != null) {
414:                        b.setPrintWhenExpression("" + newValue);
415:                    }
416:                    ((SheetProperty) this .getSheetProperty(propertyName))
417:                            .setLabelError(null);
418:                    ((SheetProperty) this .getSheetProperty(propertyName))
419:                            .updateLabel();
420:                    //MainFrame.getMainInstance().getBandsDialog().updateBands();
421:                    //fireEvent = false;
422:                }
423:
424:                // Groups...
425:
426:                return fireEvent;
427:            }
428:
429:            public void changeGroupName(Report report, SubDataset subDataset,
430:                    Group group, String oldName) {
431:                if (group.getName().equals(oldName))
432:                    return;
433:
434:                group.getGroupHeader().setName(group.getName() + "Header");
435:                group.getGroupFooter().setName(group.getName() + "Footer");
436:
437:                for (int k = subDataset.getVariables().size() - 1; k >= 0; --k) {
438:                    JRVariable var = (JRVariable) subDataset.getVariables()
439:                            .elementAt(k);
440:                    if (var.isBuiltin()
441:                            && var.getName().equalsIgnoreCase(
442:                                    oldName + "_COUNT")) {
443:                        JRVariable oldVar = var.cloneMe();
444:                        var.setName(group.getName() + "_COUNT");
445:                        // Notify the variable change...
446:                        subDataset
447:                                .fireSubDatasetObjectChangedListenerSubDatasetObjectChanged(new SubDatasetObjectChangedEvent(
448:                                        subDataset,
449:                                        SubDatasetObjectChangedEvent.VARIABLE,
450:                                        SubDatasetObjectChangedEvent.MODIFIED,
451:                                        oldVar, var));
452:                        break;
453:                    }
454:                }
455:
456:                // Update All variables...
457:                Enumeration e = subDataset.getVariables().elements();
458:                while (e.hasMoreElements()) {
459:                    JRVariable var = (JRVariable) e.nextElement();
460:                    if (var.getResetGroup() != null
461:                            && var.getResetGroup().equals(oldName)) {
462:                        var.setResetGroup(group.getName());
463:
464:                        // Does not make sense notify this change...
465:                    }
466:                }
467:
468:                // Adjust elements
469:                if (subDataset instanceof  Report) {
470:                    e = ((Report) subDataset).getElements().elements();
471:                    while (e.hasMoreElements()) {
472:                        ReportElement re = (ReportElement) e.nextElement();
473:                        if (re.printWhenGroupChanges.equals(oldName))
474:                            re.printWhenGroupChanges = group.getName();
475:
476:                        if (re instanceof  TextFieldReportElement
477:                                && ((TextFieldReportElement) re).getGroup()
478:                                        .equals(oldName))
479:                            ((TextFieldReportElement) re).setGroup(group
480:                                    .getName());
481:
482:                        if (re instanceof  ImageReportElement
483:                                && ((ImageReportElement) re)
484:                                        .getEvaluationGroup().equals(oldName))
485:                            ((ImageReportElement) re).setEvaluationGroup(group
486:                                    .getName());
487:
488:                        if (re instanceof  ChartReportElement
489:                                && ((ChartReportElement) re)
490:                                        .getEvaluationGroup().equals(oldName))
491:                            ((ChartReportElement) re).setEvaluationGroup(group
492:                                    .getName());
493:                    }
494:                }
495:
496:                ReportRefactor.replaceInReportExpressions("$V{" + oldName
497:                        + "_COUNT}", "$V{" + group.getName() + "_COUNT}",
498:                        subDataset, report);
499:
500:            }
501:
502:            /**
503:             *  Check if the new group name is ok for the current report.
504:             *  
505:             * @param report The group's report.
506:             * @param group The group to change, or null if the group does not yet exists
507:             * @param newName The candidate new name of the group. Must be Not null.
508:             * @return returns true if the new name is valid
509:             */
510:            public static boolean isValidGroupName(SubDataset report,
511:                    Group group, String newName) {
512:                if (newName.equals("page"))
513:                    return false;
514:                else if (newName.equals("column"))
515:                    return false;
516:                else if (newName.equals("lastPage"))
517:                    return false;
518:
519:                for (int i = 0; i < report.getGroups().size(); ++i) {
520:                    Group tmpGroup = (Group) report.getGroups().get(i);
521:                    if (tmpGroup != group && tmpGroup.getName().equals(newName)) {
522:                        return false;
523:                    }
524:                }
525:
526:                return true;
527:            }
528:
529:            /*
530:             * This method apply the new value for the specified property
531:             * The oldValue can be wrong or null if a multiselection was performed
532:             * 
533:             * If a change was made, the report is set as modified...
534:             * 
535:             * @return The method return true if a band changed event is required
536:             */
537:            private boolean applyNewGroupProperty(Band band, Group group,
538:                    String propertyName, Object oldValue, Object newValue) {
539:                if (propertyName == null)
540:                    return false;
541:                if (isInit())
542:                    return false;
543:
544:                boolean needBandChangedEvent = false;
545:
546:                if (propertyName.equals("groupName")) {
547:                    String oldName = group.getName();
548:
549:                    if (newValue == null
550:                            || !isValidGroupName(getJrf().getReport(), group,
551:                                    "" + newValue)) {
552:                        ((SheetProperty) this .getSheetProperty(propertyName))
553:                                .setLabelError(I18n.getString(
554:                                        "messages.invalidGroupName",
555:                                        "Invalid group name!"));
556:                        ((SheetProperty) this .getSheetProperty(propertyName))
557:                                .updateLabel();
558:
559:                    } else {
560:                        ((SheetProperty) this .getSheetProperty(propertyName))
561:                                .setLabelError(null);
562:                        ((SheetProperty) this .getSheetProperty(propertyName))
563:                                .updateLabel();
564:
565:                        String newName = ("" + newValue).trim();
566:                        group.setName(newName);
567:                        changeGroupName(getJrf().getReport(), getJrf()
568:                                .getReport(), group, oldName);
569:                        needBandChangedEvent = true;
570:                        // update expression fields...
571:                        boolean oldInit = isInit();
572:
573:                        setInit(true);
574:                        spPrintWhenExpression.setValue(""
575:                                + band.getPrintWhenExpression());
576:                        spGroupExpression.setValue(""
577:                                + group.getGroupExpression());
578:                        setInit(oldInit);
579:                    }
580:                } else if (propertyName.equals("groupExpression")) {
581:                    if (newValue != null) {
582:                        group.setGroupExpression("" + newValue);
583:                    }
584:                    ((SheetProperty) this .getSheetProperty(propertyName))
585:                            .setLabelError(null);
586:                    ((SheetProperty) this .getSheetProperty(propertyName))
587:                            .updateLabel();
588:                } else if (propertyName.equals("groupStartOnNewPage")) {
589:                    group
590:                            .setIsStartNewPage(((Boolean) newValue)
591:                                    .booleanValue());
592:                } else if (propertyName.equals("groupStartOnNewColumn")) {
593:                    group.setIsStartNewColumn(((Boolean) newValue)
594:                            .booleanValue());
595:                } else if (propertyName.equals("groupResetPageNumber")) {
596:                    group.setIsResetPageNumber(((Boolean) newValue)
597:                            .booleanValue());
598:                } else if (propertyName.equals("groupPrintHeaderOnEachPage")) {
599:                    group.setIsReprintHeaderOnEachPage(((Boolean) newValue)
600:                            .booleanValue());
601:                } else if (propertyName
602:                        .equals("groupMinHeightToStartOnNewPage")) {
603:                    if (newValue != null && !newValue.equals("")) {
604:                        int val = 0;
605:
606:                        try {
607:                            val = Integer.parseInt("" + newValue);
608:                            int newHeight = val;
609:                            if (val < 0)
610:                                newHeight = 0;
611:                            int maxH = getJrf().getReport().getHeight()
612:                                    - getJrf().getReport().getTopMargin()
613:                                    + getJrf().getReport().getBottomMargin();
614:                            maxH -= getJrf().getReport().getBandByName(
615:                                    "pageHeader").getHeight();
616:                            maxH -= getJrf().getReport().getBandByName(
617:                                    "pageFooter").getHeight();
618:                            if (val > maxH)
619:                                newHeight = maxH;
620:
621:                            //group.setMinHeightToStartNewPage(newHeight);
622:                            if (newHeight != val) {
623:                                boolean oldInit = isInit();
624:                                setInit(true);
625:                                spGroupMinHeightToStartOnNewPage.setValue(""
626:                                        + newHeight);
627:                                setInit(oldInit);
628:                            }
629:                        } catch (Exception ex) {
630:                            ex.printStackTrace();
631:                        }
632:                    }
633:                }
634:                return needBandChangedEvent;
635:            }
636:
637:            /*
638:             *     This method is called when a band is removed, changed or added.
639:             */
640:            public void reportBandChanged(ReportBandChangedEvent evt) {
641:                if (evt.getSource() != null && evt.getSource() == this )
642:                    return;
643:                updateSelection();
644:            }
645:
646:            protected void initSheetProperties() {
647:                spHeight = new SheetProperty("height",
648:                        it.businesslogic.ireport.util.I18n.getString(
649:                                "gui.elementpropertiessheet.height", "Height"),
650:                        SheetProperty.INTEGER);
651:                spHeight.setShowResetButton(false);
652:
653:                spSplitAllowed = new SheetProperty("splitAllowed",
654:                        it.businesslogic.ireport.util.I18n.getString(
655:                                "gui.bandpropertiessheet.splitAllowed",
656:                                "Is split allowed"), SheetProperty.BOOLEAN);
657:                spSplitAllowed.setShowResetButton(false);
658:                spPrintWhenExpression = new ExpressionSheetProperty(
659:                        "printWhenExpression",
660:                        it.businesslogic.ireport.util.I18n
661:                                .getString(
662:                                        "gui.elementpropertiessheet.printWhenExpression",
663:                                        "Print When Expression"));
664:                spPrintWhenExpression.setShowResetButton(false);
665:
666:                // GROUP SECTION:
667:
668:                spGroupExpression = new ExpressionSheetProperty(
669:                        "groupExpression", I18n.getString(
670:                                "jRGroupDialog.label3", "Group expression"));
671:                spGroupExpression.setShowResetButton(false);
672:
673:                spGroupName = new SheetProperty("groupName", I18n.getString(
674:                        "jRGroupDialog.label1", "Group name"),
675:                        SheetProperty.TEXT);
676:                spGroupName.setShowResetButton(false);
677:
678:                spGroupOnNewPage = new SheetProperty("groupStartOnNewPage",
679:                        it.businesslogic.ireport.util.I18n.getString(
680:                                "jRGroupDialog.checkBoxStartNewPage",
681:                                "Start on a new page"), SheetProperty.BOOLEAN);
682:                spGroupOnNewPage.setShowResetButton(false);
683:
684:                spGroupOnNewColumn = new SheetProperty("groupStartOnNewColumn",
685:                        it.businesslogic.ireport.util.I18n.getString(
686:                                "jRGroupDialog.checkBoxStartNewColumn",
687:                                "Start on a new column"), SheetProperty.BOOLEAN);
688:                spGroupOnNewColumn.setShowResetButton(false);
689:
690:                spGroupResetPageNumber = new SheetProperty(
691:                        "groupResetPageNumber",
692:                        it.businesslogic.ireport.util.I18n.getString(
693:                                "jRGroupDialog.checkBoxResetPageNumber",
694:                                "Reset page number"), SheetProperty.BOOLEAN);
695:                spGroupResetPageNumber.setShowResetButton(false);
696:
697:                spGroupPrintHeaderOnEachPage = new SheetProperty(
698:                        "groupPrintHeaderOnEachPage",
699:                        it.businesslogic.ireport.util.I18n.getString(
700:                                "jRGroupDialog.checkBoxPrintHeaderEachPage",
701:                                "Print header on each page"),
702:                        SheetProperty.BOOLEAN);
703:                spGroupPrintHeaderOnEachPage.setShowResetButton(false);
704:
705:                spGroupMinHeightToStartOnNewPage = new SheetProperty(
706:                        "groupMinHeightToStartOnNewPage",
707:                        it.businesslogic.ireport.util.I18n.getString(
708:                                "jRGroupDialog.label5",
709:                                "Min height to start new page"),
710:                        SheetProperty.INTEGER);
711:                spGroupMinHeightToStartOnNewPage.setShowResetButton(false);
712:
713:            }
714:
715:            public boolean isInit() {
716:                return init;
717:            }
718:
719:            public void setInit(boolean init) {
720:                this .init = init;
721:            }
722:
723:            public JReportFrame getJrf() {
724:                return jrf;
725:            }
726:
727:            public void setJrf(JReportFrame jrf) {
728:                this .jrf = jrf;
729:            }
730:
731:            /**
732:             * Redraw the correct editor panel (JReportPanel or the active CrosstabPanel)
733:             *
734:             */
735:            public void repaintEditor() {
736:                if (jrf == null)
737:                    return;
738:                jrf.getJPanelReport().repaint();
739:            }
740:
741:            public Vector getBandSelection() {
742:                return bandSelection;
743:            }
744:
745:            public void setBandSelection(Vector newBandSelection) {
746:                this .bandSelection.removeAllElements();
747:                if (newBandSelection == null)
748:                    return;
749:                this .bandSelection.addAll(newBandSelection);
750:            }
751:
752:            public void reportElementsSelectionChanged(
753:                    ReportElementsSelectionEvent evt) {
754:            }
755:
756:            public void reportElementsChanged(ReportElementChangedEvent evt) {
757:            }
758:
759:            public void reportBandsSelectionChanged(
760:                    ReportBandsSelectionEvent evt) {
761:                updateSelection();
762:            }
763:
764:            public void reportObjectsSelectionChanged(
765:                    ReportObjectsSelectionEvent evt) {
766:            }
767:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.