Source Code Cross Referenced for WizardDialog.java in  » Report » pentaho-report » org » pentaho » reportdesigner » crm » report » wizard » 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.pentaho.reportdesigner.crm.report.wizard 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006-2007 Pentaho Corporation.  All rights reserved.
003:         * This software was developed by Pentaho Corporation and is provided under the terms
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005:         * this file except in compliance with the license. If you need a copy of the license,
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007:         *
008:         * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to
010:         * the license for the specific language governing your rights and limitations.
011:         *
012:         * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013:         */
014:        package org.pentaho.reportdesigner.crm.report.wizard;
015:
016:        import com.jgoodies.forms.builder.ButtonBarBuilder;
017:        import com.jgoodies.forms.layout.CellConstraints;
018:        import com.jgoodies.forms.layout.FormLayout;
019:        import org.jetbrains.annotations.NonNls;
020:        import org.jetbrains.annotations.NotNull;
021:        import org.pentaho.reportdesigner.crm.report.IconLoader;
022:        import org.pentaho.reportdesigner.crm.report.ReportDialog;
023:        import org.pentaho.reportdesigner.lib.client.components.CenterPanelDialog;
024:        import org.pentaho.reportdesigner.lib.client.components.ComponentFactory;
025:        import org.pentaho.reportdesigner.lib.client.i18n.TranslationManager;
026:
027:        import javax.swing.*;
028:        import java.awt.*;
029:        import java.awt.event.ActionEvent;
030:        import java.awt.event.ActionListener;
031:        import java.util.HashMap;
032:
033:        /**
034:         * User: Martin
035:         * Date: 20.01.2006
036:         * Time: 09:26:50
037:         */
038:        public class WizardDialog extends CenterPanelDialog implements 
039:                WizardPageListener {
040:            @NotNull
041:            private WizardPage currentPage;
042:            @NotNull
043:            private JComponent currentPageCenterPanel;
044:
045:            @NotNull
046:            private JPanel centerPanel;
047:
048:            @NotNull
049:            private JButton previousButton;
050:            @NotNull
051:            private JButton nextButton;
052:            @NotNull
053:            private JButton cancelButton;
054:            @NotNull
055:            private JButton finishButton;
056:
057:            @NotNull
058:            private HashMap<String, WizardData> wizardDatas;
059:
060:            private boolean ok;
061:
062:            @NotNull
063:            private WizardHeaderComponent wizardHeaderComponent;
064:            @NotNull
065:            private ReportDialog reportDialog;
066:
067:            public WizardDialog(@NotNull
068:            final ReportDialog reportDialog, @NotNull
069:            String title, @NotNull
070:            ModalityType modalityType, @NotNull
071:            @NonNls
072:            final String key, @NotNull
073:            WizardPage firstPage) {
074:                super (reportDialog, title, modalityType);
075:                //noinspection ConstantConditions
076:                if (reportDialog == null) {
077:                    throw new IllegalArgumentException(
078:                            "reportDialog must not be null");
079:                }
080:                this .reportDialog = reportDialog;
081:                //noinspection ConstantConditions
082:                if (firstPage == null) {
083:                    throw new IllegalArgumentException(
084:                            "firstPage must not be null");
085:                }
086:
087:                wizardDatas = new HashMap<String, WizardData>();
088:
089:                currentPage = firstPage;
090:
091:                @NonNls
092:                FormLayout formLayout = new FormLayout(
093:                        "4dlu, fill:pref:grow, 4dlu", "0dlu, " + "pref, "
094:                                + "0dlu, " + "pref," + "4dlu, "
095:                                + "fill:pref:grow, " + "4dlu");
096:
097:                centerPanel = new JPanel(formLayout);
098:                setCenterPanel(centerPanel);
099:
100:                wizardHeaderComponent = new WizardHeaderComponent();
101:                getContentPane().add(wizardHeaderComponent, BorderLayout.NORTH);
102:
103:                currentPage.setWizardDialog(this );
104:
105:                previousButton = ComponentFactory.createButton("R",
106:                        "WizardDialog.Previous");
107:                nextButton = ComponentFactory.createButton("R",
108:                        "WizardDialog.Next");
109:
110:                cancelButton = new JButton(TranslationManager.getInstance()
111:                        .getTranslation("R", "Button.cancel"));
112:                finishButton = new JButton(TranslationManager.getInstance()
113:                        .getTranslation("R", "Button.finish"));
114:
115:                JPanel buttonPanel = new JPanel();
116:                ButtonBarBuilder buttonBarBuilder = new ButtonBarBuilder(
117:                        buttonPanel);
118:                buttonBarBuilder.addGlue();
119:                buttonBarBuilder.addGridded(cancelButton);
120:                buttonBarBuilder.addUnrelatedGap();
121:                buttonBarBuilder.addGriddedButtons(new JButton[] {
122:                        previousButton, nextButton });
123:                buttonBarBuilder.addUnrelatedGap();
124:                buttonBarBuilder.addGridded(finishButton);
125:                setButtonPanel(nextButton, cancelButton, buttonPanel);
126:
127:                previousButton.addActionListener(new ActionListener() {
128:                    public void actionPerformed(@NotNull
129:                    ActionEvent e) {
130:                        readData();
131:
132:                        WizardPage wizardPage = currentPage.getPrevious();
133:                        if (wizardPage != null) {
134:                            uninstallCurrentPage();
135:                            currentPage = wizardPage;
136:                            installCurrentPage();
137:                        }
138:                    }
139:                });
140:
141:                nextButton.addActionListener(new ActionListener() {
142:                    public void actionPerformed(@NotNull
143:                    ActionEvent e) {
144:                        readData();
145:
146:                        WizardPage next = currentPage.getNext();
147:                        if (next != null) {
148:                            uninstallCurrentPage();
149:                            currentPage = next;
150:                            installCurrentPage();
151:                        }
152:                    }
153:                });
154:
155:                cancelButton.addActionListener(new ActionListener() {
156:                    public void actionPerformed(@NotNull
157:                    ActionEvent e) {
158:                        uninstallCurrentPage();
159:                        ok = false;
160:                        reportDialog.getWorkspaceSettings().storeDialogBounds(
161:                                WizardDialog.this , key);
162:                        dispose();
163:                    }
164:                });
165:
166:                finishButton.addActionListener(new ActionListener() {
167:                    public void actionPerformed(@NotNull
168:                    ActionEvent e) {
169:                        readData();
170:                        uninstallCurrentPage();
171:                        ok = true;
172:                        reportDialog.getWorkspaceSettings().storeDialogBounds(
173:                                WizardDialog.this , key);
174:                        dispose();
175:                    }
176:                });
177:
178:                installCurrentPage();
179:            }
180:
181:            @NotNull
182:            public ReportDialog getReportDialog() {
183:                return reportDialog;
184:            }
185:
186:            private void readData() {
187:                WizardData[] wd = currentPage.getWizardDatas();
188:                for (WizardData wizardData : wd) {
189:                    wizardDatas.put(wizardData.getKey(), wizardData);
190:                }
191:            }
192:
193:            @NotNull
194:            public HashMap<String, WizardData> getWizardDatas() {
195:                return wizardDatas;
196:            }
197:
198:            public boolean isOk() {
199:                return ok;
200:            }
201:
202:            private void uninstallCurrentPage() {
203:                centerPanel.remove(currentPageCenterPanel);
204:                currentPage.removeWizardPageListener(this );
205:            }
206:
207:            private void installCurrentPage() {
208:                CellConstraints cc = new CellConstraints();
209:                currentPage.setWizardDialog(this );
210:                currentPageCenterPanel = currentPage.getCenterPanel();
211:                this .centerPanel.add(currentPageCenterPanel, cc.xy(2, 6));
212:                currentPage.addWizardPageListener(this );
213:                stateChanged();
214:
215:                this .centerPanel.revalidate();
216:                this .centerPanel.repaint();
217:            }
218:
219:            public void stateChanged() {
220:                previousButton.setEnabled(currentPage.hasPrevious()
221:                        && currentPage.canPrevious());
222:                nextButton.setEnabled(currentPage.hasNext()
223:                        && currentPage.canNext());
224:                cancelButton.setEnabled(currentPage.canCancel());
225:
226:                finishButton.setEnabled(canAllPagesFinish());
227:
228:                if (currentPage.getIcon() != null) {
229:                    wizardHeaderComponent.setIcon(currentPage.getIcon());
230:                } else {
231:                    wizardHeaderComponent.setIcon(IconLoader.getInstance()
232:                            .getReportWizardIcon());
233:                }
234:                wizardHeaderComponent.setTitle(currentPage.getTitle());
235:                wizardHeaderComponent.setDescription(currentPage
236:                        .getDescription());
237:            }
238:
239:            private boolean canAllPagesFinish() {
240:                if (!currentPage.canFinish()) {
241:                    return false;
242:                }
243:
244:                WizardPage previous = currentPage;
245:                while ((previous = previous.getPrevious()) != null) {
246:                    if (!previous.canFinish()) {
247:                        return false;
248:                    }
249:                }
250:
251:                WizardPage next = currentPage;
252:                while ((next = next.getNext()) != null) {
253:                    if (!next.canFinish()) {
254:                        return false;
255:                    }
256:                }
257:
258:                return true;
259:            }
260:
261:            public void dispose() {
262:                super .dispose();
263:
264:                currentPage.dispose();
265:
266:                WizardPage previous = currentPage;
267:                while ((previous = previous.getPrevious()) != null) {
268:                    previous.dispose();
269:                }
270:
271:                WizardPage next = currentPage;
272:                while ((next = next.getNext()) != null) {
273:                    next.dispose();
274:                }
275:            }
276:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.