Source Code Cross Referenced for PreviewDialog.java in  » Report » pentaho-report » org » jfree » report » modules » gui » base » 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 » pentaho report » org.jfree.report.modules.gui.base 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * ===========================================
003:         * JFreeReport : a free Java reporting library
004:         * ===========================================
005:         *
006:         * Project Info:  http://reporting.pentaho.org/
007:         *
008:         * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009:         *
010:         * This library is free software; you can redistribute it and/or modify it under the terms
011:         * of the GNU Lesser General Public License as published by the Free Software Foundation;
012:         * either version 2.1 of the License, or (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015:         * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016:         * See the GNU Lesser General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU Lesser General Public License along with this
019:         * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020:         * Boston, MA 02111-1307, USA.
021:         *
022:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023:         * in the United States and other countries.]
024:         *
025:         * ------------
026:         * PreviewDialog.java
027:         * ------------
028:         * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029:         */package org.jfree.report.modules.gui.base;
030:
031:        import java.awt.BorderLayout;
032:        import java.awt.Dialog;
033:        import java.awt.Frame;
034:        import java.awt.event.ComponentAdapter;
035:        import java.awt.event.ComponentEvent;
036:        import java.beans.PropertyChangeEvent;
037:        import java.beans.PropertyChangeListener;
038:        import javax.swing.BoxLayout;
039:        import javax.swing.JComponent;
040:        import javax.swing.JDialog;
041:        import javax.swing.JLabel;
042:        import javax.swing.JMenu;
043:        import javax.swing.JMenuBar;
044:        import javax.swing.JPanel;
045:
046:        import org.jfree.report.JFreeReport;
047:        import org.jfree.report.JFreeReportBoot;
048:        import org.jfree.report.modules.gui.common.IconTheme;
049:        import org.jfree.report.modules.gui.commonswing.JStatusBar;
050:        import org.jfree.report.modules.gui.commonswing.ReportProgressBar;
051:        import org.jfree.report.modules.gui.commonswing.ReportProgressDialog;
052:        import org.jfree.report.modules.gui.commonswing.RequestFocusHandler;
053:        import org.jfree.report.modules.gui.commonswing.StatusType;
054:        import org.jfree.report.util.i18n.Messages;
055:        import org.jfree.ui.RefineryUtilities;
056:        import org.jfree.util.Configuration;
057:
058:        /**
059:         * Creation-Date: 11.11.2006, 19:35:16
060:         *
061:         * @author Thomas Morgner
062:         */
063:        public class PreviewDialog extends JDialog {
064:            private class PreviewPanePropertyChangeHandler implements 
065:                    PropertyChangeListener {
066:                protected PreviewPanePropertyChangeHandler() {
067:                }
068:
069:                /**
070:                 * This method gets called when a bound property is changed.
071:                 *
072:                 * @param evt A PropertyChangeEvent object describing the event source and the property that has changed.
073:                 */
074:
075:                public void propertyChange(final PropertyChangeEvent evt) {
076:                    final String propertyName = evt.getPropertyName();
077:                    if (PreviewPane.MENU_PROPERTY.equals(propertyName)) {
078:                        // Update the menu
079:                        final JMenu[] menus = previewPane.getMenu();
080:                        updateMenu(menus);
081:                        return;
082:                    }
083:
084:                    if (PreviewPane.TITLE_PROPERTY.equals(propertyName)) {
085:                        setTitle(previewPane.getTitle());
086:                        return;
087:                    }
088:
089:                    if (PreviewPane.STATUS_TEXT_PROPERTY.equals(propertyName)
090:                            || PreviewPane.STATUS_TYPE_PROPERTY
091:                                    .equals(propertyName)) {
092:                        statusBar.setStatus(previewPane.getStatusType(),
093:                                previewPane.getStatusText());
094:                        return;
095:                    }
096:
097:                    if (PreviewPane.ICON_THEME_PROPERTY.equals(propertyName)) {
098:                        statusBar.setIconTheme(previewPane.getIconTheme());
099:                        return;
100:                    }
101:
102:                    if (PreviewPane.PAGINATING_PROPERTY.equals(propertyName)) {
103:                        if (Boolean.TRUE.equals(evt.getNewValue())) {
104:                            pageLabel.setVisible(false);
105:                            statusBar
106:                                    .setStatus(
107:                                            StatusType.INFORMATION,
108:                                            messages
109:                                                    .getString("PreviewDialog.USER_PAGINATING")); //$NON-NLS-1$
110:                            if (progressBar != null) {
111:                                previewPane
112:                                        .addReportProgressListener(progressBar);
113:                                progressBar.setOnlyPagination(true);
114:                                progressBar.setVisible(true);
115:                                progressBar.revalidate();
116:                            }
117:                            if (progressDialog != null) {
118:                                progressDialog.setOnlyPagination(true);
119:                                progressDialog.setVisible(true);
120:                                previewPane
121:                                        .addReportProgressListener(progressDialog);
122:                                RefineryUtilities
123:                                        .centerDialogInParent(progressDialog);
124:                            }
125:                        } else {
126:                            pageLabel.setVisible(true);
127:                            statusBar.setStatus(StatusType.NONE, ""); //$NON-NLS-1$
128:                            if (progressBar != null) {
129:                                progressBar.setOnlyPagination(false);
130:                                progressBar.setVisible(false);
131:                                previewPane
132:                                        .removeReportProgressListener(progressBar);
133:                                progressBar.revalidate();
134:                            }
135:                            if (progressDialog != null) {
136:                                previewPane
137:                                        .removeReportProgressListener(progressDialog);
138:                                progressDialog.setOnlyPagination(false);
139:                                progressDialog.setVisible(false);
140:                            }
141:                        }
142:                        return;
143:                    }
144:
145:                    if (PreviewPane.PAGE_NUMBER_PROPERTY.equals(propertyName)
146:                            || PreviewPane.NUMBER_OF_PAGES_PROPERTY
147:                                    .equals(propertyName)) {
148:                        pageLabel.setText(previewPane.getPageNumber()
149:                                + "/" + previewPane.getNumberOfPages()); //$NON-NLS-1$
150:                        return;
151:                    }
152:
153:                    if (PreviewPane.CLOSED_PROPERTY.equals(propertyName)) {
154:                        if (previewPane.isClosed()) {
155:                            setVisible(false);
156:                            dispose();
157:                        } else {
158:                            setVisible(true);
159:                        }
160:                    }
161:                }
162:            }
163:
164:            private static class TriggerPaginationListener extends
165:                    ComponentAdapter {
166:                private PreviewPane pane;
167:
168:                public TriggerPaginationListener(final PreviewPane pane) {
169:                    this .pane = pane;
170:                }
171:
172:                /**
173:                 * Invoked when the component has been made visible.
174:                 */
175:                public void componentShown(final ComponentEvent e) {
176:                    if (pane.isDeferredRepagination()) {
177:                        pane.startPagination();
178:                    }
179:                }
180:            }
181:
182:            private PreviewPane previewPane;
183:
184:            private JStatusBar statusBar;
185:
186:            private ReportProgressBar progressBar;
187:
188:            private ReportProgressDialog progressDialog;
189:
190:            private JLabel pageLabel;
191:            private Messages messages;
192:
193:            /**
194:             * Creates a non-modal dialog without a title and without a specified <code>Frame</code> owner.  A shared, hidden
195:             * frame will be set as the owner of the dialog.
196:             * <p/>
197:             * This constructor sets the component's locale property to the value returned by
198:             * <code>JComponent.getDefaultLocale</code>.
199:             *
200:             * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless() returns true.
201:             * @see java.awt.GraphicsEnvironment#isHeadless
202:             * @see javax.swing.JComponent#getDefaultLocale
203:             */
204:            public PreviewDialog() {
205:                init();
206:            }
207:
208:            /**
209:             * Creates a non-modal dialog without a title with the specified <code>Frame</code> as its owner.  If
210:             * <code>owner</code> is <code>null</code>, a shared, hidden frame will be set as the owner of the dialog.
211:             * <p/>
212:             * This constructor sets the component's locale property to the value returned by
213:             * <code>JComponent.getDefaultLocale</code>.
214:             *
215:             * @param owner the <code>Frame</code> from which the dialog is displayed
216:             * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless() returns true.
217:             * @see java.awt.GraphicsEnvironment#isHeadless
218:             * @see javax.swing.JComponent#getDefaultLocale
219:             */
220:            public PreviewDialog(final Frame owner) {
221:                super (owner);
222:                init();
223:            }
224:
225:            /**
226:             * Creates a modal or non-modal dialog without a title and with the specified owner <code>Frame</code>.  If
227:             * <code>owner</code> is <code>null</code>, a shared, hidden frame will be set as the owner of the dialog.
228:             * <p/>
229:             * This constructor sets the component's locale property to the value returned by
230:             * <code>JComponent.getDefaultLocale</code>.
231:             *
232:             * @param owner the <code>Frame</code> from which the dialog is displayed
233:             * @param modal true for a modal dialog, false for one that allows others windows to be active at the same time
234:             * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless() returns true.
235:             * @see java.awt.GraphicsEnvironment#isHeadless
236:             * @see javax.swing.JComponent#getDefaultLocale
237:             */
238:            public PreviewDialog(final Frame owner, final boolean modal) {
239:                super (owner, modal);
240:                init();
241:            }
242:
243:            /**
244:             * Creates a non-modal dialog without a title with the specified <code>Dialog</code> as its owner.
245:             * <p/>
246:             * This constructor sets the component's locale property to the value returned by
247:             * <code>JComponent.getDefaultLocale</code>.
248:             *
249:             * @param owner the non-null <code>Dialog</code> from which the dialog is displayed
250:             * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless() returns true.
251:             * @see java.awt.GraphicsEnvironment#isHeadless
252:             * @see javax.swing.JComponent#getDefaultLocale
253:             */
254:            public PreviewDialog(final Dialog owner) {
255:                super (owner);
256:                init();
257:            }
258:
259:            /**
260:             * Creates a modal or non-modal dialog without a title and with the specified owner dialog.
261:             * <p/>
262:             * This constructor sets the component's locale property to the value returned by
263:             * <code>JComponent.getDefaultLocale</code>.
264:             *
265:             * @param owner the non-null <code>Dialog</code> from which the dialog is displayed
266:             * @param modal true for a modal dialog, false for one that allows other windows to be active at the same time
267:             * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless() returns true.
268:             * @see java.awt.GraphicsEnvironment#isHeadless
269:             * @see javax.swing.JComponent#getDefaultLocale
270:             */
271:            public PreviewDialog(final Dialog owner, final boolean modal) {
272:                super (owner, modal);
273:                init();
274:            }
275:
276:            /**
277:             * Creates a non-modal dialog without a title and without a specified <code>Frame</code> owner.  A shared, hidden
278:             * frame will be set as the owner of the dialog.
279:             * <p/>
280:             * This constructor sets the component's locale property to the value returned by
281:             * <code>JComponent.getDefaultLocale</code>.
282:             *
283:             * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless() returns true.
284:             * @see java.awt.GraphicsEnvironment#isHeadless
285:             * @see javax.swing.JComponent#getDefaultLocale
286:             */
287:            public PreviewDialog(final JFreeReport report) {
288:                init();
289:                setReportJob(report);
290:            }
291:
292:            /**
293:             * Creates a non-modal dialog without a title with the specified <code>Frame</code> as its owner.  If
294:             * <code>owner</code> is <code>null</code>, a shared, hidden frame will be set as the owner of the dialog.
295:             * <p/>
296:             * This constructor sets the component's locale property to the value returned by
297:             * <code>JComponent.getDefaultLocale</code>.
298:             *
299:             * @param owner the <code>Frame</code> from which the dialog is displayed
300:             * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless() returns true.
301:             * @see java.awt.GraphicsEnvironment#isHeadless
302:             * @see javax.swing.JComponent#getDefaultLocale
303:             */
304:            public PreviewDialog(final JFreeReport report, final Frame owner) {
305:                super (owner);
306:                init();
307:                setReportJob(report);
308:            }
309:
310:            /**
311:             * Creates a modal or non-modal dialog without a title and with the specified owner <code>Frame</code>.  If
312:             * <code>owner</code> is <code>null</code>, a shared, hidden frame will be set as the owner of the dialog.
313:             * <p/>
314:             * This constructor sets the component's locale property to the value returned by
315:             * <code>JComponent.getDefaultLocale</code>.
316:             *
317:             * @param owner the <code>Frame</code> from which the dialog is displayed
318:             * @param modal true for a modal dialog, false for one that allows others windows to be active at the same time
319:             * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless() returns true.
320:             * @see java.awt.GraphicsEnvironment#isHeadless
321:             * @see javax.swing.JComponent#getDefaultLocale
322:             */
323:            public PreviewDialog(final JFreeReport report, final Frame owner,
324:                    final boolean modal) {
325:                super (owner, modal);
326:                init();
327:                setReportJob(report);
328:            }
329:
330:            /**
331:             * Creates a non-modal dialog without a title with the specified <code>Dialog</code> as its owner.
332:             * <p/>
333:             * This constructor sets the component's locale property to the value returned by
334:             * <code>JComponent.getDefaultLocale</code>.
335:             *
336:             * @param owner the non-null <code>Dialog</code> from which the dialog is displayed
337:             * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless() returns true.
338:             * @see java.awt.GraphicsEnvironment#isHeadless
339:             * @see javax.swing.JComponent#getDefaultLocale
340:             */
341:            public PreviewDialog(final JFreeReport report, final Dialog owner) {
342:                super (owner);
343:                init();
344:                setReportJob(report);
345:            }
346:
347:            /**
348:             * Creates a modal or non-modal dialog without a title and with the specified owner dialog.
349:             * <p/>
350:             * This constructor sets the component's locale property to the value returned by
351:             * <code>JComponent.getDefaultLocale</code>.
352:             *
353:             * @param owner the non-null <code>Dialog</code> from which the dialog is displayed
354:             * @param modal true for a modal dialog, false for one that allows other windows to be active at the same time
355:             * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless() returns true.
356:             * @see java.awt.GraphicsEnvironment#isHeadless
357:             * @see javax.swing.JComponent#getDefaultLocale
358:             */
359:            public PreviewDialog(final JFreeReport report, final Dialog owner,
360:                    final boolean modal) {
361:                super (owner, modal);
362:                init();
363:                setReportJob(report);
364:            }
365:
366:            protected void init() {
367:                addComponentListener(new RequestFocusHandler());
368:                messages = new Messages(getLocale(),
369:                        SwingPreviewModule.BUNDLE_NAME);
370:
371:                previewPane = new PreviewPane();
372:                previewPane.setDeferredRepagination(true);
373:                addComponentListener(new TriggerPaginationListener(previewPane));
374:
375:                statusBar = new JStatusBar(previewPane.getIconTheme());
376:
377:                pageLabel = new JLabel();
378:
379:                final Configuration configuration = JFreeReportBoot
380:                        .getInstance().getGlobalConfig();
381:                final boolean progressBarEnabled = "true".equals(configuration //$NON-NLS-1$
382:                                .getConfigProperty("org.jfree.report.modules.gui.base.ProgressBarEnabled")); //$NON-NLS-1$
383:                final boolean progressDialogEnabled = "true".equals(configuration //$NON-NLS-1$
384:                                .getConfigProperty("org.jfree.report.modules.gui.base.ProgressDialogEnabled")); //$NON-NLS-1$
385:
386:                if (progressBarEnabled) {
387:                    progressBar = new ReportProgressBar();
388:                    progressBar.setVisible(false);
389:                    previewPane.addReportProgressListener(progressBar);
390:                    previewPane
391:                            .addPropertyChangeListener(new PreviewPanePropertyChangeHandler());
392:                } else {
393:                    progressBar = null;
394:                }
395:
396:                if (progressDialogEnabled) {
397:                    progressDialog = new ReportProgressDialog(this );
398:                    final JFreeReport reportJob = previewPane.getReportJob();
399:                    if (reportJob == null || reportJob.getName() == null) {
400:                        progressDialog.setTitle(messages
401:                                .getString("ProgressDialog.EMPTY_TITLE"));
402:                        progressDialog.setMessage(messages
403:                                .getString("ProgressDialog.EMPTY_TITLE"));
404:                    } else {
405:                        progressDialog.setTitle(messages.getString(
406:                                "ProgressDialog.TITLE", reportJob.getName()));
407:                        progressDialog.setMessage(messages.getString(
408:                                "ProgressDialog.TITLE", reportJob.getName()));
409:                    }
410:                    progressDialog.pack();
411:                } else {
412:                    progressDialog = null;
413:                }
414:
415:                final JComponent extensionArea = statusBar.getExtensionArea();
416:                extensionArea.setLayout(new BoxLayout(extensionArea,
417:                        BoxLayout.X_AXIS));
418:                if (progressBar != null) {
419:                    extensionArea.add(progressBar);
420:                }
421:                extensionArea.add(pageLabel);
422:
423:                final JComponent contentPane = new JPanel();
424:                contentPane.setLayout(new BorderLayout());
425:                contentPane.add(previewPane, BorderLayout.CENTER);
426:                contentPane.add(statusBar, BorderLayout.SOUTH);
427:                setContentPane(contentPane);
428:
429:                updateMenu(previewPane.getMenu());
430:                setTitle(previewPane.getTitle());
431:                statusBar.setIconTheme(previewPane.getIconTheme());
432:                statusBar.setStatus(previewPane.getStatusType(), previewPane
433:                        .getStatusText());
434:            }
435:
436:            private void updateMenu(final JMenu[] menus) {
437:                if (menus != null && menus.length > 0) {
438:                    final JMenuBar menuBar = new JMenuBar();
439:                    for (int i = 0; i < menus.length; i++) {
440:                        final JMenu menu = menus[i];
441:                        menuBar.add(menu);
442:                    }
443:                    setJMenuBar(menuBar);
444:                } else {
445:                    setJMenuBar(null);
446:                }
447:            }
448:
449:            public ReportController getReportController() {
450:                return previewPane.getReportController();
451:            }
452:
453:            public void setReportController(
454:                    final ReportController reportController) {
455:                previewPane.setReportController(reportController);
456:            }
457:
458:            public IconTheme getIconTheme() {
459:                return previewPane.getIconTheme();
460:            }
461:
462:            public void setIconTheme(final IconTheme theme) {
463:                previewPane.setIconTheme(theme);
464:            }
465:
466:            public JFreeReport getReportJob() {
467:                return previewPane.getReportJob();
468:            }
469:
470:            public void setReportJob(final JFreeReport reportJob) {
471:                previewPane.setReportJob(reportJob);
472:            }
473:
474:            public void dispose() {
475:                super .dispose();
476:                previewPane.setClosed(true);
477:            }
478:
479:            protected PreviewPane getPreviewPane() {
480:                return previewPane;
481:            }
482:
483:            public boolean isToolbarFloatable() {
484:                return previewPane.isToolbarFloatable();
485:            }
486:
487:            public void setToolbarFloatable(final boolean toolbarFloatable) {
488:                previewPane.setToolbarFloatable(toolbarFloatable);
489:            }
490:
491:            public double getZoom() {
492:                return previewPane.getZoom();
493:            }
494:
495:            public void setZoom(final double zoom) {
496:                previewPane.setZoom(zoom);
497:            }
498:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.