Source Code Cross Referenced for ReportSheetPanel.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.BarcodeReportElement;
037:        import it.businesslogic.ireport.FontListLoader;
038:        import it.businesslogic.ireport.GraphicReportElement;
039:        import it.businesslogic.ireport.IReportFont;
040:        import it.businesslogic.ireport.LineReportElement;
041:        import it.businesslogic.ireport.RectangleReportElement;
042:        import it.businesslogic.ireport.TextFieldReportElement;
043:        import it.businesslogic.ireport.TextReportElement;
044:        import it.businesslogic.ireport.crosstab.CrosstabCell;
045:        import it.businesslogic.ireport.gui.*;
046:        import it.businesslogic.ireport.gui.JNumberComboBox;
047:        import it.businesslogic.ireport.gui.JNumberField;
048:        import it.businesslogic.ireport.gui.event.*;
049:        import it.businesslogic.ireport.gui.sheet.SheetProperty;
050:        import it.businesslogic.ireport.util.*;
051:        import it.businesslogic.ireport.util.LanguageChangedEvent;
052:        import it.businesslogic.ireport.util.LanguageChangedListener;
053:        import java.awt.Color;
054:        import java.awt.Point;
055:        import java.util.*;
056:        import javax.swing.FocusManager;
057:        import javax.swing.JCheckBox;
058:        import javax.swing.JComboBox;
059:        import javax.swing.JComponent;
060:        import javax.swing.JOptionPane;
061:        import javax.swing.SwingUtilities;
062:
063:        /**
064:         *
065:         * @author  Administrator
066:         */
067:        public class ReportSheetPanel extends CategorySheetPanel implements 
068:                ReportListener, LanguageChangedListener,
069:                ReportFrameActivatedListener {
070:
071:            // Sheet properties
072:            private SheetProperty spName;
073:
074:            private SheetProperty spHeight;
075:            private SheetProperty spWidth;
076:            private SheetProperty spOrientation;
077:
078:            private SheetProperty spMarginTop;
079:            private SheetProperty spMarginLeft;
080:            private SheetProperty spMarginRight;
081:            private SheetProperty spMarginBottom;
082:
083:            private SheetProperty spColumns;
084:            private SheetProperty spColumnWidth;
085:            private SheetProperty spColumnSpacing;
086:            private SheetProperty spScriptletMode;
087:            private SheetProperty spScriptletClass;
088:            private SheetProperty spLanguage;
089:
090:            private SheetProperty spTitleOnNewPage;
091:            private SheetProperty spSummaryOnNewPage;
092:            private SheetProperty spFloatingColumnFooter;
093:            private SheetProperty spIgnorePagination;
094:
095:            private SheetProperty spPrintOrder;
096:            private SheetProperty spWhenNoData;
097:
098:            private SheetProperty spFormatFactoryClass;
099:            private SheetProperty spResourceBundleBaseName;
100:            private SheetProperty spWhenResourceMissingType;
101:
102:            public static java.awt.Color mandatoryPropertiesLabelColor = java.awt.Color.blue;
103:            public static java.awt.Color notMandatoryPropertiesLabelColor = java.awt.Color.black;
104:
105:            private JReportFrame jrf = null;
106:            private boolean init = false;
107:
108:            /** Creates a new instance of ReportElementSheetPanel */
109:            public ReportSheetPanel() {
110:                super ();
111:
112:                initSheetProperties();
113:                // We have to register for element changes...
114:                MainFrame mf = MainFrame.getMainInstance();
115:                mf.addReportListener(this );
116:                mf.addReportFrameActivatedListener(this );
117:
118:                I18n.addOnLanguageChangedListener(this );
119:
120:                MainFrame.getMainInstance().addFontsListChangedListener(
121:                        new FontsListChangedListener() {
122:                            public void fontsListChanged(
123:                                    FontsListChangedEvent evt) {
124:
125:                                boolean localinit = isInit();
126:                                setInit(true);
127:                                setInit(localinit);
128:                            }
129:                        });
130:            }
131:
132:            public void reportFrameActivated(ReportFrameActivatedEvent evt) {
133:                updateSelection(evt.getReportFrame());
134:            }
135:
136:            public void languageChanged(LanguageChangedEvent evt) {
137:                this .removeAllProperties();
138:                initSheetProperties();
139:                updateSelection();
140:            }
141:
142:            public void updateSelection() {
143:
144:                JReportFrame newJrf = MainFrame.getMainInstance()
145:                        .getActiveReportFrame();
146:                updateSelection(newJrf);
147:            }
148:
149:            /**
150:             * Numbers do not change when the focus is lost due to a selection change.
151:             * This apply the value....
152:             */
153:            public void applyValueForNumbers() {
154:                Enumeration e = getProperties().elements();
155:                while (e.hasMoreElements()) {
156:                    SheetProperty sp = (SheetProperty) e.nextElement();
157:
158:                    //if (sp instanceof NumberComboBoxSheetProperty)
159:                    //{
160:                    //    JNumberComboBox c = (JNumberComboBox)sp.getEditor();
161:                    //    System.out.println("NNNN");
162:                    //    if (c.hasFocus())
163:                    //    {
164:                    //       FocusManager.getCurrentManager().clearGlobalFocusOwner();
165:                    //       System.out.println(FocusManager.getCurrentManager().getFocusOwner());
166:                    //       return; // Only a component can be focused at time...
167:                    //    }
168:                    //}
169:                    if (sp.getType() == sp.INTEGER || sp.getType() == sp.NUMBER) {
170:                        JComponent c = sp.getEditor();
171:                        if (c.hasFocus() && c instanceof  JNumberField) {
172:                            ((JNumberField) c).focusLost(null);
173:                            return; // Only a component can be focused at time...
174:                        }
175:                    }
176:
177:                }
178:            }
179:
180:            /**
181:             * Update all the element properties...
182:             * 
183:             */
184:            public void updateSelection(JReportFrame newJrf) {
185:                // Improving speed...
186:                // Do nothing if there are elements selected...
187:                if (newJrf != null && newJrf.getSelectedElements().size() > 0)
188:                    return;
189:
190:                // Fix for numbers focus losing...
191:                applyValueForNumbers();
192:
193:                setInit(true);
194:
195:                this .removeAllProperties();
196:
197:                this .jrf = newJrf;
198:
199:                if (jrf == null) {
200:                    this .recreateSheet();
201:                    return;
202:                }
203:
204:                try {
205:
206:                    Report report = jrf.getReport();
207:
208:                    setGenericSheetProperty(true, report.getName(), spName);
209:
210:                    setTagComboBox(true, report.getOrientation(), spOrientation);
211:                    setElementNumber(true, (double) report.getWidth(),
212:                            (JNumberField) spWidth.getEditor());
213:                    setElementNumber(true, (double) report.getHeight(),
214:                            (JNumberField) spHeight.getEditor());
215:
216:                    setElementNumber(true, (double) report.getLeftMargin(),
217:                            (JNumberField) spMarginLeft.getEditor());
218:                    setElementNumber(true, (double) report.getRightMargin(),
219:                            (JNumberField) spMarginRight.getEditor());
220:                    setElementNumber(true, (double) report.getTopMargin(),
221:                            (JNumberField) spMarginTop.getEditor());
222:                    setElementNumber(true, (double) report.getBottomMargin(),
223:                            (JNumberField) spMarginBottom.getEditor());
224:
225:                    setElementNumber(true, (double) report.getColumnCount(),
226:                            (JNumberField) spColumns.getEditor());
227:                    setElementNumber(true, (double) report.getColumnWidth(),
228:                            (JNumberField) spColumnWidth.getEditor());
229:                    setElementNumber(true, (double) report.getColumnSpacing(),
230:                            (JNumberField) spColumnSpacing.getEditor());
231:
232:                    setTagComboBox(true, report.getScriptletHandling() + "",
233:                            spScriptletMode);
234:                    setGenericSheetProperty(true, report.getScriptletClass(),
235:                            spScriptletClass);
236:
237:                    if (report.getScriptletHandling() != Report.SCRIPTLET_CLASSIC_HANDLING) {
238:                        spScriptletClass.setReadOnly(true);
239:                        spScriptletClass.setValue("");
240:                    } else {
241:                        spScriptletClass.setReadOnly(false);
242:                    }
243:                    spScriptletClass.updateLabel();
244:
245:                    setTagComboBox(true, report.getLanguage(), spLanguage);
246:
247:                    setCheckBox(true, report.isIsTitleNewPage(), false,
248:                            spTitleOnNewPage);
249:                    setCheckBox(true, report.isIsSummaryNewPage(), false,
250:                            spSummaryOnNewPage);
251:                    setCheckBox(true, report.isFloatColumnFooter(), false,
252:                            spFloatingColumnFooter);
253:                    setCheckBox(true, report.isIgnorePagination(), false,
254:                            spIgnorePagination);
255:
256:                    setTagComboBox(true, report.getPrintOrder(), spPrintOrder);
257:                    setTagComboBox(true, report.getWhenNoDataType(),
258:                            spWhenNoData);
259:
260:                    setTagComboBox(true, report.getFormatFactoryClass(),
261:                            spFormatFactoryClass);
262:                    setTagComboBox(true, report.getResourceBundleBaseName(),
263:                            spResourceBundleBaseName);
264:                    setTagComboBox(true, report.getWhenResourceMissingType(),
265:                            spWhenResourceMissingType);
266:
267:                    spName.setLabelError(validateProperty("name", spName
268:                            .getValue()));
269:                    //spOrientation.setLabelColor( mandatoryPropertiesLabelColor );
270:                    //spWidth.setLabelColor( mandatoryPropertiesLabelColor );
271:                    //spHeight.setLabelColor( mandatoryPropertiesLabelColor );
272:
273:                    String commonStr = it.businesslogic.ireport.util.I18n
274:                            .getString("reportPropertiesFrame.title",
275:                                    "Report properties");
276:                    this .addSheetProperty(commonStr, spName);
277:
278:                    String pageStr = it.businesslogic.ireport.util.I18n
279:                            .getString(
280:                                    "reportPropertiesFrame.panelBorder.PageSize",
281:                                    "Page size");
282:                    this .addSheetProperty(pageStr, spOrientation);
283:                    this .addSheetProperty(pageStr, spWidth);
284:                    this .addSheetProperty(pageStr, spHeight);
285:
286:                    String marginsStr = it.businesslogic.ireport.util.I18n
287:                            .getString(
288:                                    "reportPropertiesFrame.panelBorder.PageMargin",
289:                                    "Page margin");
290:                    this .addSheetProperty(marginsStr, spMarginLeft);
291:                    this .addSheetProperty(marginsStr, spMarginRight);
292:                    this .addSheetProperty(marginsStr, spMarginTop);
293:                    this .addSheetProperty(marginsStr, spMarginBottom);
294:
295:                    String columnsStr = it.businesslogic.ireport.util.I18n
296:                            .getString(
297:                                    "reportPropertiesFrame.panelBorder.ReportColumns",
298:                                    "Report columns");
299:                    this .addSheetProperty(columnsStr, spColumns);
300:                    this .addSheetProperty(columnsStr, spColumnWidth);
301:                    this .addSheetProperty(columnsStr, spColumnSpacing);
302:
303:                    commonStr = it.businesslogic.ireport.util.I18n.getString(
304:                            "more", "More...");
305:                    this .addSheetProperty(commonStr, spScriptletMode);
306:                    this .addSheetProperty(commonStr, spScriptletClass);
307:                    this .addSheetProperty(commonStr, spLanguage);
308:                    this .addSheetProperty(commonStr, spTitleOnNewPage);
309:                    this .addSheetProperty(commonStr, spSummaryOnNewPage);
310:                    this .addSheetProperty(commonStr, spFloatingColumnFooter);
311:                    this .addSheetProperty(commonStr, spIgnorePagination);
312:                    this .addSheetProperty(commonStr, spPrintOrder);
313:                    this .addSheetProperty(commonStr, spWhenNoData);
314:                    this .addSheetProperty(commonStr, spFormatFactoryClass);
315:                    this .addSheetProperty(commonStr, spResourceBundleBaseName);
316:                    this .addSheetProperty(commonStr, spWhenResourceMissingType);
317:
318:                    this .recreateSheet();
319:
320:                } catch (Exception ex) {
321:                    ex.printStackTrace();
322:                } finally {
323:
324:                }
325:
326:                setInit(false);
327:            }
328:
329:            /*
330:             * This method remove the first entry in comboboxes if the first entry
331:             * is something like "<Different values>"....
332:             *
333:             */
334:            public void removeNullItem(SheetProperty comboProperty) {
335:                if (comboProperty == null)
336:                    return;
337:                if (comboProperty.getEditor() instanceof  JComboBox) {
338:                    JComboBox combobox = (JComboBox) comboProperty.getEditor();
339:                    if (combobox.getSelectedIndex() > 0) {
340:                        Object obj = combobox.getItemAt(0);
341:                        if ((obj + "")
342:                                .equals(it.businesslogic.ireport.util.I18n
343:                                        .getString(
344:                                                "gui.elementpropertiessheet.differentValues",
345:                                                "<different values>"))) {
346:                            combobox.removeItemAt(0);
347:                        }
348:                    }
349:                }
350:            }
351:
352:            /*
353:             * This method says if the selected value is actually something like "<Different values>"....
354:             *
355:             */
356:            public boolean isNullItem(SheetProperty comboProperty) {
357:                if (comboProperty == null)
358:                    return false;
359:                if (comboProperty.getEditor() instanceof  JComboBox) {
360:                    JComboBox combobox = (JComboBox) comboProperty.getEditor();
361:                    if (combobox.getSelectedIndex() == 0) {
362:                        Object obj = combobox.getItemAt(0);
363:                        if ((obj + "")
364:                                .equals(it.businesslogic.ireport.util.I18n
365:                                        .getString(
366:                                                "gui.elementpropertiessheet.differentValues",
367:                                                "<different values>"))) {
368:                            return true;
369:                        }
370:                    }
371:                }
372:                return false;
373:            }
374:
375:            /**
376:             * This methos is called when a property changes...
377:             */
378:            public void sheetPropertyValueChanged(
379:                    SheetPropertyValueChangedEvent evt) {
380:                if (isInit())
381:                    return;
382:
383:                applyNewProperty(getJrf().getReport(), evt.getPropertyName(),
384:                        evt.getOldValue(), evt.getNewValue());
385:
386:                repaintEditor();
387:
388:                /*
389:                ReportElementChangedEvent changedEvent = new ReportElementChangedEvent(jrf , selectedElements , ReportElementChangedEvent.CHANGED);
390:                changedEvent.setEventSource( this );
391:                if (evt.getPropertyName().equals("textfieldEvaluationTime"))
392:                {
393:                   changedEvent.setPropertyChanged( evt.getPropertyName() );
394:                   changedEvent.setNewValue( evt.getNewValue() );
395:                }
396:                jrf.fireReportListenerReportElementsChanged(changedEvent);
397:                MainFrame.getMainInstance().getElementPropertiesDialog().updateSelection();
398:                 */
399:            }
400:
401:            /*
402:             * This method apply the new value for the specified property
403:             * The oldValue can be wrong or null if a multiselection was performed
404:             */
405:            private void applyNewProperty(Report report, String propertyName,
406:                    Object oldValue, Object newValue) {
407:                if (propertyName == null)
408:                    return;
409:                if (isInit())
410:                    return;
411:
412:                boolean fireEvent = true;
413:                if (propertyName.equals("name")) {
414:                    String s = (String) newValue;
415:                    spName.setLabelError(validateProperty(propertyName,
416:                            newValue));
417:                    spName.updateLabel();
418:
419:                    report.setName("" + newValue);
420:                    MainFrame.getMainInstance().setTitle(
421:                            MainFrame.getRebrandedTitle()
422:                                    + " ["
423:                                    + report.getName()
424:                                    + " "
425:                                    + report.getWidth()
426:                                    + "x"
427:                                    + report.getHeight()
428:                                    + " "
429:                                    + report.getFilename()
430:                                    + " "
431:                                    + (report.isReadOnly() ? "(READ ONLY) "
432:                                            : "") + "]");
433:                } else if (propertyName.equals("orientation")) {
434:                    adjustSizes("" + newValue, report);
435:                    report.setOrientation("" + newValue);
436:                    recalcColumnWidth(report);
437:                    updateSizeMeasures(report);
438:
439:                    //this.updateSelection(getJrf());
440:                    getJrf().updateScrollBars();
441:                    getJrf().getJPanelReport().repaint();
442:                } else if (propertyName.equals("width")) {
443:                    if (newValue != null && !newValue.equals("")) {
444:                        int val = Integer.parseInt("" + newValue);
445:                        report.setWidth(val);
446:                        recalcColumnWidth(report);
447:                        adjustOrientation(report);
448:                        updateSizeMeasures(report);
449:                    } else
450:                        fireEvent = false;
451:                } else if (propertyName.equals("height")) {
452:                    if (newValue != null && !newValue.equals("")) {
453:                        int val = Integer.parseInt("" + newValue);
454:                        report.setHeight(val);
455:                        adjustOrientation(report);
456:                        updateSizeMeasures(report);
457:                    } else
458:                        fireEvent = false;
459:                } else if (propertyName.equals("marginTop")) {
460:                    if (newValue != null && !newValue.equals("")) {
461:                        int val = Integer.parseInt("" + newValue);
462:                        int delta = val - report.getTopMargin();
463:                        report.setTopMargin(val);
464:                        adjustElementPositions(report, delta, 0);
465:                        getJrf().updateScrollBars();
466:                        getJrf().getJPanelReport().repaint();
467:                    } else
468:                        fireEvent = false;
469:                } else if (propertyName.equals("marginLeft")) {
470:                    if (newValue != null && !newValue.equals("")) {
471:                        int val = Integer.parseInt("" + newValue);
472:                        int delta = val - report.getLeftMargin();
473:                        report.setLeftMargin(val);
474:                        adjustElementPositions(report, 0, delta);
475:                        getJrf().updateScrollBars();
476:                        getJrf().getJPanelReport().repaint();
477:                    } else
478:                        fireEvent = false;
479:                } else if (propertyName.equals("marginRight")) {
480:                    if (newValue != null && !newValue.equals("")) {
481:                        int val = Integer.parseInt("" + newValue);
482:                        int delta = val - report.getRightMargin();
483:                        report.setRightMargin(val);
484:                        getJrf().updateScrollBars();
485:                        getJrf().getJPanelReport().repaint();
486:                    } else
487:                        fireEvent = false;
488:                } else if (propertyName.equals("marginBottom")) {
489:                    if (newValue != null && !newValue.equals("")) {
490:                        int val = Integer.parseInt("" + newValue);
491:                        int delta = val - report.getBottomMargin();
492:                        report.setBottomMargin(val);
493:                        getJrf().updateScrollBars();
494:                        getJrf().getJPanelReport().repaint();
495:                    } else
496:                        fireEvent = false;
497:                } else if (propertyName.equals("columns")) {
498:                    if (newValue != null && !newValue.equals("")) {
499:                        int val = Integer.parseInt("" + newValue);
500:                        report.setColumnCount(val);
501:                        recalcColumnWidth(report);
502:                        updateSizeMeasures(report);
503:                        getJrf().updateScrollBars();
504:                        getJrf().getJPanelReport().repaint();
505:                    } else
506:                        fireEvent = false;
507:                } else if (propertyName.equals("columnWidth")) {
508:                    if (newValue != null && !newValue.equals("")) {
509:                        int val = Integer.parseInt("" + newValue);
510:                        report.setColumnWidth(val);
511:                        recalcColumnWidth(report);
512:                        updateSizeMeasures(report);
513:                        getJrf().updateScrollBars();
514:                        getJrf().getJPanelReport().repaint();
515:                    } else
516:                        fireEvent = false;
517:                } else if (propertyName.equals("columnSpacing")) {
518:                    if (newValue != null && !newValue.equals("")) {
519:                        int val = Integer.parseInt("" + newValue);
520:                        report.setColumnSpacing(val);
521:                        recalcColumnWidth(report);
522:                        updateSizeMeasures(report);
523:                        getJrf().updateScrollBars();
524:                        getJrf().getJPanelReport().repaint();
525:                    } else
526:                        fireEvent = false;
527:                } else if (propertyName.equals("scriptletMode")) {
528:                    if (newValue != null && !newValue.equals("")) {
529:                        int val = Integer.parseInt("" + newValue);
530:                        report.setScriptletHandling(val);
531:
532:                        if (val != Report.SCRIPTLET_CLASSIC_HANDLING) {
533:                            spScriptletClass.setReadOnly(true);
534:                            spScriptletClass.setValue("");
535:                            report.setScriptletClass("");
536:                        } else {
537:                            spScriptletClass.setReadOnly(false);
538:                        }
539:                        spScriptletClass.updateLabel();
540:
541:                    } else
542:                        fireEvent = false;
543:                } else if (propertyName.equals("scriptletClass")) {
544:                    if (newValue != null) {
545:                        report.setScriptletClass("" + newValue);
546:                    }
547:                } else if (propertyName.equals("language")) {
548:                    if (newValue != null) {
549:                        report.setLanguage("" + newValue);
550:                    }
551:                } else if (propertyName.equals("titleOnNewPage")) {
552:                    try {
553:                        report.setIsTitleNewPage(Boolean.valueOf(newValue + "")
554:                                .booleanValue());
555:                    } catch (Exception ex) {
556:                    }
557:                } else if (propertyName.equals("titleOnNewPage")) {
558:                    try {
559:                        report.setIsTitleNewPage(Boolean.valueOf(newValue + "")
560:                                .booleanValue());
561:                    } catch (Exception ex) {
562:                    }
563:                } else if (propertyName.equals("summaryOnNewPage")) {
564:                    try {
565:                        report.setIsSummaryNewPage(Boolean.valueOf(
566:                                newValue + "").booleanValue());
567:                    } catch (Exception ex) {
568:                    }
569:                } else if (propertyName.equals("floatingColumnFooter")) {
570:                    try {
571:                        report.setFloatColumnFooter(Boolean.valueOf(
572:                                newValue + "").booleanValue());
573:                    } catch (Exception ex) {
574:                    }
575:                } else if (propertyName.equals("ignorePagination")) {
576:                    try {
577:                        report.setIgnorePagination(Boolean.valueOf(
578:                                newValue + "").booleanValue());
579:                    } catch (Exception ex) {
580:                    }
581:                }
582:
583:                else if (propertyName.equals("printOrder")) {
584:                    if (newValue != null) {
585:                        report.setPrintOrder("" + newValue);
586:                    }
587:                } else if (propertyName.equals("whenNoData")) {
588:                    if (newValue != null) {
589:                        report.setWhenNoDataType("" + newValue);
590:                    }
591:                } else if (propertyName.equals("formatClass")) {
592:                    if (newValue != null) {
593:                        report.setFormatFactoryClass("" + newValue);
594:                    }
595:                } else if (propertyName.equals("resourceBundleBaseName")) {
596:                    if (newValue != null) {
597:                        report.setResourceBundleBaseName("" + newValue);
598:                    }
599:                } else if (propertyName.equals("whenResourceMissingType")) {
600:                    if (newValue != null) {
601:                        report.setWhenResourceMissingType("" + newValue);
602:                    }
603:                }
604:
605:                if (fireEvent) {
606:                    report.incrementReportChanges();
607:                }
608:
609:            }
610:
611:            /** 
612:             * The method return null if the value for the property is ok, or a localized not null String with
613:             * the error description otherwise.
614:             */
615:            public String validateProperty(String propertyName, Object newValue) {
616:
617:                if (propertyName.equals("name")) {
618:                    String s = (String) newValue;
619:                    if (s.trim().length() > 0) {
620:                        return null;
621:                    } else {
622:                        return I18n.getString("error.reportNameNull",
623:                                "The report name can not be a blank string");
624:                    }
625:                }
626:
627:                return null;
628:            }
629:
630:            /**
631:             *     This method is called when a new element is selected,
632:             *     or deselected.
633:             */
634:            public void reportElementsSelectionChanged(
635:                    ReportElementsSelectionEvent evt) {
636:
637:            }
638:
639:            /*
640:             *     This method is called when an element is removed, changed or added.
641:             */
642:            public void reportElementsChanged(ReportElementChangedEvent evt) {
643:
644:            }
645:
646:            /*
647:             *     This method is called when a band is removed, changed or added.
648:             */
649:            public void reportBandChanged(ReportBandChangedEvent evt) {
650:
651:            }
652:
653:            protected void initSheetProperties() {
654:                spOrientation = new SheetProperty("orientation",
655:                        it.businesslogic.ireport.util.I18n.getString(
656:                                "orientation", "Orientation"),
657:                        SheetProperty.COMBOBOX);
658:                spOrientation.setTags(new Tag[] {
659:                        new Tag("Portrait", it.businesslogic.ireport.util.I18n
660:                                .getString("pageOrientation.Portrait",
661:                                        "Portrait")),
662:                        new Tag("Landscape", it.businesslogic.ireport.util.I18n
663:                                .getString("pageOrientation.Landscape",
664:                                        "Landscape")) });
665:
666:                spOrientation.setShowResetButton(false);
667:
668:                spWidth = new SheetProperty("width",
669:                        it.businesslogic.ireport.util.I18n.getString(
670:                                "gui.elementpropertiessheet.width", "Width"),
671:                        SheetProperty.INTEGER);
672:                spWidth.setShowResetButton(false);
673:
674:                spHeight = new SheetProperty("height",
675:                        it.businesslogic.ireport.util.I18n.getString(
676:                                "gui.elementpropertiessheet.height", "Height"),
677:                        SheetProperty.INTEGER);
678:                spHeight.setShowResetButton(false);
679:
680:                spName = new SheetProperty("name",
681:                        it.businesslogic.ireport.util.I18n.getString(
682:                                "reportName", "Report name"),
683:                        SheetProperty.STRING);
684:                spName.setShowResetButton(false);
685:
686:                spMarginTop = new SheetProperty("marginTop",
687:                        it.businesslogic.ireport.util.I18n.getString("top",
688:                                "Top"), SheetProperty.INTEGER);
689:                spMarginTop.setShowResetButton(false);
690:                spMarginLeft = new SheetProperty("marginLeft",
691:                        it.businesslogic.ireport.util.I18n.getString("left",
692:                                "Left"), SheetProperty.INTEGER);
693:                spMarginLeft.setShowResetButton(false);
694:                spMarginRight = new SheetProperty("marginRight",
695:                        it.businesslogic.ireport.util.I18n.getString("right",
696:                                "Right"), SheetProperty.INTEGER);
697:                spMarginRight.setShowResetButton(false);
698:                spMarginBottom = new SheetProperty("marginBottom",
699:                        it.businesslogic.ireport.util.I18n.getString("bottom",
700:                                "Bottom"), SheetProperty.INTEGER);
701:                spMarginBottom.setShowResetButton(false);
702:
703:                spColumns = new SheetProperty("columns",
704:                        it.businesslogic.ireport.util.I18n.getString("columns",
705:                                "Columns"), SheetProperty.INTEGER);
706:                spColumns.setShowResetButton(false);
707:                spColumnWidth = new SheetProperty("columnWidth",
708:                        it.businesslogic.ireport.util.I18n.getString("width",
709:                                "Width"), SheetProperty.INTEGER);
710:                spColumnWidth.setShowResetButton(false);
711:                spColumnSpacing = new SheetProperty("columnSpacing",
712:                        it.businesslogic.ireport.util.I18n.getString("spacing",
713:                                "Spacing"), SheetProperty.INTEGER);
714:                spColumnSpacing.setShowResetButton(false);
715:
716:                spScriptletMode = new SheetProperty("scriptletMode",
717:                        it.businesslogic.ireport.util.I18n.getString(
718:                                "scriptletMode", "Scriptlet"),
719:                        SheetProperty.COMBOBOX);
720:                spScriptletMode
721:                        .setTags(new Tag[] {
722:                                new Tag("0", it.businesslogic.ireport.util.I18n
723:                                        .getString("noScriptlet",
724:                                                "Don't use scriptlet")),
725:                                new Tag(
726:                                        "1",
727:                                        it.businesslogic.ireport.util.I18n
728:                                                .getString("iReportScriptlet",
729:                                                        "Use iReport internal scriptlet support")),
730:                                new Tag("2", it.businesslogic.ireport.util.I18n
731:                                        .getString("customScriptlet",
732:                                                "Use this scriptlet class...")) });
733:                spScriptletMode.setShowResetButton(false);
734:
735:                spScriptletClass = new SheetProperty("scriptletClass",
736:                        it.businesslogic.ireport.util.I18n.getString(
737:                                "scriptlet", "Scriptlet class"),
738:                        SheetProperty.STRING);
739:                spScriptletClass.setShowResetButton(false);
740:
741:                spLanguage = new SheetProperty("language",
742:                        it.businesslogic.ireport.util.I18n.getString(
743:                                "reportPropertiesFrame.label18", "Language"),
744:                        SheetProperty.COMBOBOX);
745:                spLanguage.setTags(new Tag[] { new Tag("java", "Java"),
746:                        new Tag("groovy", "Groovy") });
747:                spLanguage.setShowResetButton(false);
748:
749:                spTitleOnNewPage = new SheetProperty("titleOnNewPage",
750:                        it.businesslogic.ireport.util.I18n.getString(
751:                                "titleOnANewPage", "Title on a new page"),
752:                        SheetProperty.BOOLEAN);
753:                spTitleOnNewPage.setShowResetButton(false);
754:                spSummaryOnNewPage = new SheetProperty("summaryOnNewPage",
755:                        it.businesslogic.ireport.util.I18n.getString(
756:                                "summaryInANewPage", "Summary on a new page"),
757:                        SheetProperty.BOOLEAN);
758:                spSummaryOnNewPage.setShowResetButton(false);
759:                spFloatingColumnFooter = new SheetProperty(
760:                        "floatingColumnFooter",
761:                        it.businesslogic.ireport.util.I18n
762:                                .getString(
763:                                        "reportPropertiesFrame.checkBoxFloatColumnFooter",
764:                                        "Floating column footer"),
765:                        SheetProperty.BOOLEAN);
766:                spFloatingColumnFooter.setShowResetButton(false);
767:                spIgnorePagination = new SheetProperty("ignorePagination",
768:                        it.businesslogic.ireport.util.I18n.getString(
769:                                "ignorePagination", "Ignore pagination"),
770:                        SheetProperty.BOOLEAN);
771:                spIgnorePagination.setShowResetButton(false);
772:
773:                spPrintOrder = new SheetProperty("printOrder",
774:                        it.businesslogic.ireport.util.I18n.getString(
775:                                "printOrder", "Print order"),
776:                        SheetProperty.COMBOBOX);
777:                spPrintOrder
778:                        .setTags(new Tag[] {
779:                                new Tag("Vertical",
780:                                        it.businesslogic.ireport.util.I18n
781:                                                .getString(
782:                                                        "printOrder.Vertical",
783:                                                        "Vertical")),
784:                                new Tag(
785:                                        "Horizontal",
786:                                        it.businesslogic.ireport.util.I18n
787:                                                .getString(
788:                                                        "printOrder.Horizontal",
789:                                                        "Horizontal")) });
790:                spPrintOrder.setShowResetButton(false);
791:
792:                spWhenNoData = new SheetProperty("whenNoData",
793:                        it.businesslogic.ireport.util.I18n.getString(
794:                                "whenNoData", "When no data"),
795:                        SheetProperty.COMBOBOX);
796:                spWhenNoData.setTags(new Tag[] {
797:                        new Tag("NoPages", it.businesslogic.ireport.util.I18n
798:                                .getString("whenNoData.NoPages", "No pages")),
799:                        new Tag("BlankPage",
800:                                it.businesslogic.ireport.util.I18n.getString(
801:                                        "whenNoData.BlankPage", "Blank page")),
802:                        new Tag("AllSectionsNoDetail",
803:                                it.businesslogic.ireport.util.I18n.getString(
804:                                        "whenNoData.AllSectionsNoDetail",
805:                                        "All sections, no detail")),
806:                        new Tag("NoDataSection",
807:                                it.businesslogic.ireport.util.I18n.getString(
808:                                        "whenNoData.NoDataSection",
809:                                        "No-data section")) });
810:
811:                spWhenNoData.setShowResetButton(false);
812:
813:                spFormatFactoryClass = new SheetProperty("formatClass",
814:                        it.businesslogic.ireport.util.I18n.getString(
815:                                "formatFactoryClass", "Format factory class"),
816:                        SheetProperty.STRING);
817:                spFormatFactoryClass.setShowResetButton(false);
818:
819:                spResourceBundleBaseName = new SheetProperty(
820:                        "resourceBundleBaseName",
821:                        it.businesslogic.ireport.util.I18n.getString(
822:                                "resourceBundleBaseName",
823:                                "Resource bundle base name"),
824:                        SheetProperty.STRING);
825:                spResourceBundleBaseName.setShowResetButton(false);
826:
827:                spWhenResourceMissingType = new SheetProperty(
828:                        "whenResourceMissingType",
829:                        it.businesslogic.ireport.util.I18n.getString(
830:                                "whenResourceMissingType",
831:                                "When resource missing type"),
832:                        SheetProperty.COMBOBOX);
833:                spWhenResourceMissingType.setTags(new Tag[] {
834:                        new Tag("Null", it.businesslogic.ireport.util.I18n
835:                                .getString("whenResourceMissingType.Null",
836:                                        "Null")),
837:                        new Tag("Empty", it.businesslogic.ireport.util.I18n
838:                                .getString("whenResourceMissingType.Empty",
839:                                        "Empty")),
840:                        new Tag("Key",
841:                                it.businesslogic.ireport.util.I18n.getString(
842:                                        "whenResourceMissingType.Key", "Key")),
843:                        new Tag("Error", it.businesslogic.ireport.util.I18n
844:                                .getString("whenResourceMissingType.Error",
845:                                        "Error")) });
846:                spWhenResourceMissingType.setShowResetButton(false);
847:
848:            }
849:
850:            public boolean isInit() {
851:                return init;
852:            }
853:
854:            public void setInit(boolean init) {
855:                this .init = init;
856:            }
857:
858:            public JReportFrame getJrf() {
859:                return jrf;
860:            }
861:
862:            public void setJrf(JReportFrame jrf) {
863:                this .jrf = jrf;
864:            }
865:
866:            /**
867:             * Redraw the correct editor panel (JReportPanel or the active CrosstabPanel)
868:             *
869:             */
870:            public void repaintEditor() {
871:                if (jrf == null)
872:                    return;
873:                if (jrf.getSelectedCrosstabEditorPanel() == null) {
874:                    jrf.getJPanelReport().repaint();
875:                } else {
876:                    jrf.getSelectedCrosstabEditorPanel().repaint();
877:                }
878:            }
879:
880:            public void reportBandsSelectionChanged(
881:                    ReportBandsSelectionEvent evt) {
882:            }
883:
884:            public void reportObjectsSelectionChanged(
885:                    ReportObjectsSelectionEvent evt) {
886:            }
887:
888:            /**
889:             * This method sets height and width according to the orientation.
890:             * @return Void
891:             * @since July 3, 2004
892:             * @author Robert Lamping
893:             */
894:            public void adjustSizes(String orientation, Report report) {
895:                int reportSwitch = 0;
896:                if (orientation.equals("Landscape")) {
897:                    // set Width to largest value of ReportWidth, ReportHeight
898:                    if (report.getWidth() < report.getHeight()) {
899:                        reportSwitch = report.getHeight();
900:                        report.setHeight(report.getWidth());
901:                        report.setWidth(reportSwitch);
902:                    }
903:                } else {
904:                    // Orientation = Portrait
905:                    if (report.getWidth() > report.getHeight()) {
906:                        reportSwitch = report.getHeight();
907:                        report.setHeight(report.getWidth());
908:                        report.setWidth(reportSwitch);
909:                    }
910:                }
911:            }
912:
913:            /**
914:             * This method recalcs the column width accordly to the available report width
915:             *
916:             */
917:            void recalcColumnWidth(Report report) {
918:
919:                int columns = report.getColumnCount();
920:                // calculate space...
921:                int avail = report.getWidth() - report.getLeftMargin()
922:                        - report.getRightMargin()
923:                        - (report.getColumnCount() - 1)
924:                        * report.getColumnSpacing();
925:                int dim = avail;
926:                dim = (int) ((double) dim / (double) columns);
927:
928:                while ((dim * columns) > avail) {
929:                    dim--;
930:                }
931:                report.setColumnWidth(dim);
932:            }
933:
934:            void updateSizeMeasures(Report report) {
935:                boolean oldInit = isInit();
936:                setInit(true);
937:
938:                setTagComboBox(true, report.getOrientation(), spOrientation);
939:                setElementNumber(true, (double) report.getWidth(),
940:                        (JNumberField) spWidth.getEditor());
941:                setElementNumber(true, (double) report.getHeight(),
942:                        (JNumberField) spHeight.getEditor());
943:
944:                setElementNumber(true, (double) report.getLeftMargin(),
945:                        (JNumberField) spMarginLeft.getEditor());
946:                setElementNumber(true, (double) report.getRightMargin(),
947:                        (JNumberField) spMarginRight.getEditor());
948:                setElementNumber(true, (double) report.getTopMargin(),
949:                        (JNumberField) spMarginTop.getEditor());
950:                setElementNumber(true, (double) report.getBottomMargin(),
951:                        (JNumberField) spMarginBottom.getEditor());
952:
953:                setElementNumber(true, (double) report.getColumnCount(),
954:                        (JNumberField) spColumns.getEditor());
955:                setElementNumber(true, (double) report.getColumnWidth(),
956:                        (JNumberField) spColumnWidth.getEditor());
957:                setElementNumber(true, (double) report.getColumnSpacing(),
958:                        (JNumberField) spColumnSpacing.getEditor());
959:                MainFrame.getMainInstance().setTitle(
960:                        MainFrame.getRebrandedTitle() + " [" + report.getName()
961:                                + " " + report.getWidth() + "x"
962:                                + report.getHeight() + " "
963:                                + report.getFilename() + " "
964:                                + (report.isReadOnly() ? "(READ ONLY) " : "")
965:                                + "]");
966:                setInit(oldInit);
967:            }
968:
969:            public void adjustOrientation(Report report) {
970:                if (report.getWidth() <= report.getHeight()) {
971:                    report.setOrientation("Portrait");
972:                } else {
973:                    report.setOrientation("Landscape");
974:                }
975:            }
976:
977:            public void adjustElementPositions(Report report, int differenceY,
978:                    int differenceX) {
979:                if (differenceX != 0 || differenceY != 0) {
980:                    Enumeration e = report.getElements().elements();
981:                    while (e.hasMoreElements()) {
982:                        ReportElement re = (ReportElement) e.nextElement();
983:                        re.trasform(
984:                                new java.awt.Point(differenceX, differenceY),
985:                                TransformationType.TRANSFORMATION_MOVE);
986:                    }
987:                }
988:            }
989:
990:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.