Source Code Cross Referenced for HelpWin.java in  » Report » datavision-1.1.0 » jimm » datavision » gui » 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 » datavision 1.1.0 » jimm.datavision.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jimm.datavision.gui;
002:
003:        import jimm.datavision.ErrorHandler;
004:        import jimm.util.I18N;
005:        import java.awt.Dimension;
006:        import java.awt.BorderLayout;
007:        import java.awt.event.ActionListener;
008:        import java.awt.event.ActionEvent;
009:        import java.net.URL;
010:        import javax.swing.*;
011:        import javax.swing.text.html.HTMLDocument;
012:        import javax.swing.text.html.HTMLFrameHyperlinkEvent;
013:        import javax.swing.event.HyperlinkListener;
014:        import javax.swing.event.HyperlinkEvent;
015:
016:        /**
017:         * A help window. Opens on docs/DataVision/DataVision.html.
018:         *
019:         * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
020:         */
021:        public class HelpWin extends JFrame implements  HyperlinkListener {
022:
023:            protected static final int START_WIDTH = 400;
024:            protected static final int START_HEIGHT = 500;
025:            protected static final String DOCS_DIR = "docs";
026:            protected static final String HTML_DIR = "DataVision";
027:            protected static final String START_CONTENT_FILE = "DataVision.html";
028:
029:            protected static final String HOME_ICON = "images/Home16.gif";
030:            protected static final String PREV_ICON = "images/Back16.gif";
031:            protected static final String NEXT_ICON = "images/Forward16.gif";
032:
033:            protected static HelpWin helpWin;
034:
035:            protected JEditorPane contentEditorPane;
036:            protected HelpURLStack pages;
037:            protected Action goHomeAction;
038:            protected Action goPrevAction;
039:            protected Action goNextAction;
040:            protected JTextField urlField;
041:
042:            public static synchronized HelpWin instance() {
043:                if (helpWin == null)
044:                    helpWin = new HelpWin();
045:                return helpWin;
046:            }
047:
048:            protected HelpWin() {
049:                super (I18N.get("HelpWin.title"));
050:                buildWindow();
051:                pages = new HelpURLStack(contentEditorPane, urlField);
052:                pack();
053:                setVisible(true);
054:
055:                new Thread(new Runnable() {
056:                    public void run() {
057:                        loadHelp();
058:                    }
059:                }).start();
060:            }
061:
062:            protected void buildWindow() {
063:                makeActions();
064:
065:                getContentPane().setLayout(new BorderLayout());
066:                getContentPane().add(makeToolbar(), BorderLayout.NORTH);
067:                getContentPane().add(buildContentPane(), BorderLayout.CENTER);
068:            }
069:
070:            protected JComponent buildContentPane() {
071:                contentEditorPane = new JEditorPane();
072:                contentEditorPane.setEditable(false);
073:
074:                // Scroll pane.
075:                JScrollPane scrollPane = new JScrollPane(contentEditorPane);
076:                scrollPane
077:                        .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
078:                scrollPane.setPreferredSize(new Dimension(START_WIDTH,
079:                        START_HEIGHT));
080:
081:                // Start listening to hyperlink events.
082:                contentEditorPane.addHyperlinkListener(this );
083:
084:                return scrollPane;
085:            }
086:
087:            /**
088:             * Creates the actions used by menu items and toolbar widgets.
089:             */
090:            protected void makeActions() {
091:                URL url = getClass().getClassLoader().getResource(HOME_ICON);
092:                String str = I18N.get("HelpWin.cmd_home");
093:                goHomeAction = new AbstractAction(str, new ImageIcon(url, str)) {
094:                    public void actionPerformed(ActionEvent e) {
095:                        pages.goToHomePage();
096:                        updateNavActions();
097:                    }
098:                };
099:                goHomeAction.putValue(Action.SHORT_DESCRIPTION, str);
100:                goHomeAction.setEnabled(true);
101:
102:                url = getClass().getClassLoader().getResource(PREV_ICON);
103:                str = I18N.get("HelpWin.cmd_prev");
104:                goPrevAction = new AbstractAction(str, new ImageIcon(url, str)) {
105:                    public void actionPerformed(ActionEvent e) {
106:                        pages.goToPreviousPage();
107:                        updateNavActions();
108:                    }
109:                };
110:                goPrevAction.putValue(Action.SHORT_DESCRIPTION, str);
111:                goPrevAction.setEnabled(false);
112:
113:                url = getClass().getClassLoader().getResource(NEXT_ICON);
114:                str = I18N.get("HelpWin.cmd_next");
115:                goNextAction = new AbstractAction(str, new ImageIcon(url, str)) {
116:                    public void actionPerformed(ActionEvent e) {
117:                        pages.goToNextPage();
118:                        updateNavActions();
119:                    }
120:                };
121:                goNextAction.putValue(Action.SHORT_DESCRIPTION, str);
122:                goNextAction.setEnabled(false);
123:            }
124:
125:            /**
126:             * Creates and returns a new tool bar.
127:             */
128:            protected JToolBar makeToolbar() {
129:                JToolBar bar = new JToolBar(
130:                        javax.swing.SwingConstants.HORIZONTAL);
131:                bar.add(goHomeAction);
132:                bar.add(goPrevAction);
133:                bar.add(goNextAction);
134:
135:                urlField = new JTextField(40);
136:                urlField.addActionListener(new ActionListener() {
137:                    public void actionPerformed(ActionEvent e) {
138:                        pages.goTo(urlField.getText());
139:                    }
140:                });
141:                bar.add(urlField);
142:
143:                return bar;
144:            }
145:
146:            /**
147:             * Updates navigation buttons based on number of pages and current
148:             * display page.
149:             */
150:            protected void updateNavActions() {
151:                goPrevAction.setEnabled(pages.hasPrevious());
152:                goNextAction.setEnabled(pages.hasNext());
153:            }
154:
155:            protected void loadHelp() {
156:                // Create a URL object for the file docs/DataVision/DataVision.html.
157:                String s = null;
158:                URL helpURL = null;
159:                try {
160:                    String sep = System.getProperty("file.separator");
161:                    s = "file:" + System.getProperty("user.dir") + sep
162:                            + DOCS_DIR + sep + HTML_DIR + sep
163:                            + START_CONTENT_FILE;
164:                    helpURL = new URL(s);
165:                } catch (Exception e) {
166:                    ErrorHandler.error(I18N.get("HelpWin.error") + ' ' + s, e);
167:                }
168:
169:                // Load the URL.
170:                if (helpURL != null) {
171:                    pages.goTo(helpURL);
172:                    updateNavActions();
173:                }
174:            }
175:
176:            public void hyperlinkUpdate(HyperlinkEvent e) {
177:                if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
178:                    return;
179:
180:                if (e instanceof  HTMLFrameHyperlinkEvent) {
181:                    HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
182:                    HTMLDocument doc = (HTMLDocument) contentEditorPane
183:                            .getDocument();
184:                    doc.processHTMLFrameHyperlinkEvent(evt);
185:                } else {
186:                    try {
187:                        pages.goTo(e.getURL());
188:                        updateNavActions();
189:                    } catch (Throwable t) {
190:                        ErrorHandler.error(t);
191:                    }
192:                }
193:            }
194:
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.