Source Code Cross Referenced for AbstractWizard.java in  » Swing-Library » jwizard » wizard » ui » 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 » Swing Library » jwizard » wizard.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Created on Dec 2, 2004
003:         * 
004:         * @author karthikeyanr
005:         *  
006:         */package wizard.ui;
007:
008:        import java.awt.*;
009:        import java.awt.event.*;
010:        import java.util.List;
011:
012:        import javax.swing.*;
013:        import javax.swing.tree.DefaultMutableTreeNode;
014:
015:        import wizard.action.*;
016:        import wizard.helper.*;
017:        import wizard.interfaces.Pollable;
018:        import wizard.layout.*;
019:        import wizard.model.MagicCardHelper;
020:
021:        public abstract class AbstractWizard extends JDialog implements 
022:                CardFlipListenerIf, Pollable {
023:            MagicPanelReference currentPanelReference;
024:
025:            ResourceBundleManager instance = ResourceBundleManager
026:                    .getInstance();
027:
028:            NextNavigationAction nextAction;
029:
030:            private BackNavigationAction backAction;
031:
032:            private int cardCount;
033:
034:            private CardManagerLayout layout;
035:
036:            private JLabel lblTitle;
037:
038:            private JPanel magicPanel;
039:
040:            private JTree navigationTree;
041:
042:            public abstract boolean wizardComplete();
043:
044:            public AbstractWizard(Frame owner, String title)
045:                    throws HeadlessException {
046:                super (owner, title, true);
047:                setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
048:                addWindowListener(new DilaogWindowListner());
049:                initComponents();
050:            }
051:
052:            public void addCards(List cardList) {
053:                DefaultMutableTreeNode overviewNode = (DefaultMutableTreeNode) navigationTree
054:                        .getModel().getRoot();
055:                overviewNode.removeAllChildren();
056:                magicPanel.removeAll();
057:                cardCount = cardList.size();
058:                for (int i = 0; i < cardCount; i++) {
059:                    AbstractMagicPanel panel = (AbstractMagicPanel) cardList
060:                            .get(i);
061:                    decoratePanel(panel);
062:                    MagicCardHelper.getInstance().addCard(panel);
063:                    magicPanel.add(panel, panel.getID());
064:                    overviewNode.add(new DefaultMutableTreeNode((i + 1) + ". "
065:                            + panel.getTitle()));
066:                }
067:                navigationTree.expandRow(0);
068:                gotoCard(((AbstractMagicPanel) cardList.get(0)).getID());
069:                pack();
070:                MagicPanelListener.install(this );
071:                determineNextActionState();
072:            }
073:
074:            public void cardHasFlipped(int index) {
075:                backAction.setEnabled(index != 0);
076:                nextAction.becomeFinish(index == (cardCount - 1));
077:                navigationTree.scrollRowToVisible(index + 1);
078:                navigationTree.setSelectionRow(index + 1);
079:            }
080:
081:            public void dispose() {
082:                MagicCardHelper.getInstance().reset();
083:                MagicPanelListener.uninstall();
084:                super .dispose();
085:            }
086:
087:            public void poll() {
088:                determineNextActionState();
089:            }
090:
091:            void determineNextActionState() {
092:                nextAction.setEnabled(currentPanelReference.panel()
093:                        .validateEarly());
094:            }
095:
096:            void gotoCard(String nextCardID) {
097:                layout.gotoCard(nextCardID);
098:                currentPanelReference = layout.getCurrentCardReference();
099:                lblTitle
100:                        .setText(currentPanelReference.panel().getDescription());
101:            }
102:
103:            private JPanel createButtonPanel() {
104:                JPanel buttonPanel = new JPanel(
105:                        new FlowLayout(FlowLayout.RIGHT));
106:                backAction = new BackNavigationAction();
107:                buttonPanel.add(new JButton(backAction));
108:
109:                nextAction = new NextNavigationAction();
110:                buttonPanel.add(new JButton(nextAction));
111:
112:                CancelWizardAction cancelWizardAction = new CancelWizardAction(
113:                        this );
114:                buttonPanel.add(new JButton(cancelWizardAction));
115:                setDisposer(cancelWizardAction);
116:                return buttonPanel;
117:            }
118:
119:            private void decoratePanel(AbstractMagicPanel panel) {
120:                panel.setBorder(BorderFactory.createCompoundBorder(
121:                        BorderFactory.createCompoundBorder(BorderFactory
122:                                .createEmptyBorder(0, 0, 0, 5), BorderFactory
123:                                .createLineBorder(Color.LIGHT_GRAY)),
124:                        BorderFactory.createEmptyBorder(5, 5, 5, 5)));
125:            }
126:
127:            private void initComponents() {
128:                magicPanel = new JPanel();
129:                layout = new CardManagerLayout(magicPanel);
130:                layout.addCardFlipListener(this );
131:                magicPanel.setLayout(layout);
132:
133:                JPanel descriptionPanel = new JPanel(new FlowLayout(
134:                        FlowLayout.LEFT));
135:                lblTitle = new JLabel();
136:                descriptionPanel.add(lblTitle);
137:
138:                JPanel buttonPanel = createButtonPanel();
139:
140:                JPanel contentPane = new JPanel(new BorderLayout(5, 5));
141:                contentPane.add(createNavigationPanel(), BorderLayout.WEST);
142:
143:                JPanel centerPanel = new JPanel(new BorderLayout(5, 5));
144:                centerPanel.add(descriptionPanel, BorderLayout.NORTH);
145:                centerPanel.add(magicPanel, BorderLayout.CENTER);
146:
147:                contentPane.add(centerPanel, BorderLayout.CENTER);
148:                contentPane.add(buttonPanel, BorderLayout.SOUTH);
149:                setContentPane(contentPane);
150:            }
151:
152:            private JComponent createNavigationPanel() {
153:                DefaultMutableTreeNode overviewNode = new DefaultMutableTreeNode(
154:                        ResourceBundleManager.getInstance().getString(
155:                                "overview.label"));
156:                navigationTree = new NavigationTree(overviewNode);
157:                navigationTree.setOpaque(false);
158:                navigationTree.setEnabled(false);
159:                navigationTree.putClientProperty("JTree.lineStyle", "None");
160:                navigationTree.setCellRenderer(new NavigationRenderer());
161:                return navigationTree;
162:            }
163:
164:            private void setDisposer(Action disposer) {
165:                JRootPane rootPane = SwingUtilities.getRootPane(this );
166:                KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE");
167:
168:                InputMap inputMap = rootPane
169:                        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
170:                inputMap.put(stroke, "EscapeAction");
171:                rootPane.getActionMap().put("EscapeAction", disposer);
172:            }
173:
174:            public class BackNavigationAction extends AbstractAction {
175:                public BackNavigationAction() {
176:                    super (instance.getString("back.label"));
177:                }
178:
179:                public void actionPerformed(ActionEvent e) {
180:                    gotoCard(currentPanelReference.panel().getPreviousCardID());
181:                    nextAction.setEnabled(true);
182:                }
183:            }
184:
185:            public class DilaogWindowListner extends WindowAdapter {
186:                public void windowClosing(WindowEvent windowEvent) {
187:                    dispose();
188:                }
189:            }
190:
191:            public class NextNavigationAction extends AbstractAction {
192:                private boolean isFinish;
193:
194:                public NextNavigationAction() {
195:                    super (instance.getString("next.label"));
196:                }
197:
198:                public void actionPerformed(ActionEvent e) {
199:                    if (currentPanelReference.panel().validatePanel()) {
200:                        if (isFinish) {
201:                            if (wizardComplete())
202:                                AbstractWizard.this .dispose();
203:                            else
204:                                gotoCard(MagicCardHelper.getInstance()
205:                                        .getCardIDByIndex(0));
206:                        } else {
207:                            gotoCard(currentPanelReference.panel().getNextID());
208:                            determineNextActionState();
209:                        }
210:                    }
211:                }
212:
213:                public void becomeFinish(boolean isFinish) {
214:                    this .isFinish = isFinish;
215:
216:                    if (isFinish)
217:                        putValue(Action.NAME, instance
218:                                .getString("finish.label"));
219:                    else
220:                        putValue(Action.NAME, instance.getString("next.label"));
221:                }
222:            }
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.