Source Code Cross Referenced for HelpHistoryModel.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » help » 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 » jEdit » org.gjt.sp.jedit.help 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * HelpHistoryModel.java - History Model for Help GUI
003:         * :tabSize=8:indentSize=8:noTabs=false:
004:         * :folding=explicit:collapseFolds=1:
005:         *
006:         * Copyright (C) 2005 Nicholas O'Leary
007:         *
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         */
022:
023:        package org.gjt.sp.jedit.help;
024:
025:        import java.net.URL;
026:
027:        /**
028:         * History model used by the help browser 
029:         * @author Nicholas O'Leary
030:         * @version $Id: HelpHistoryModel.java 9197 2007-03-22 14:35:05Z Vampire0 $
031:         */
032:        public class HelpHistoryModel {
033:            //{{{ HelpHistoryModel constructor
034:            public HelpHistoryModel(int size) {
035:                int historyPos = 0;
036:                history = new HistoryEntry[size];
037:                listeners = new java.util.Vector();
038:            } //}}}
039:
040:            //{{{ forward() method
041:            public HistoryEntry forward(HelpViewer helpViewer) {
042:                if (history.length - historyPos <= 1) {
043:                    return null;
044:                }
045:                if (history[historyPos] == null) {
046:                    return null;
047:                }
048:                setCurrentScrollPosition(helpViewer.getCurrentPage(),
049:                        helpViewer.getCurrentScrollPosition());
050:                HistoryEntry result = new HistoryEntry(history[historyPos]);
051:                historyPos++;
052:                fireUpdate();
053:                return result;
054:            } //}}}
055:
056:            //{{{ hasNext() method
057:            public boolean hasNext() {
058:                return !((history.length - historyPos <= 1) || (history[historyPos] == null));
059:            } //}}}
060:
061:            //{{{ back() method
062:            public HistoryEntry back(HelpViewer helpViewer) {
063:                if (historyPos <= 1) {
064:                    return null;
065:                }
066:                setCurrentScrollPosition(helpViewer.getCurrentPage(),
067:                        helpViewer.getCurrentScrollPosition());
068:                HistoryEntry result = new HistoryEntry(
069:                        history[--historyPos - 1]);
070:                fireUpdate();
071:                return result;
072:            } //}}}
073:
074:            //{{{ hasPrevious() method
075:            public boolean hasPrevious() {
076:                return (historyPos > 1);
077:            } //}}}
078:
079:            //{{{ addToHistory() method
080:            public void addToHistory(String url) {
081:                history[historyPos] = new HistoryEntry(url, url, 0);
082:                if (historyPos + 1 == history.length) {
083:                    System
084:                            .arraycopy(history, 1, history, 0,
085:                                    history.length - 1);
086:                    history[historyPos] = null;
087:                } else {
088:                    historyPos++;
089:                    for (int i = historyPos; i < history.length; i++) {
090:                        history[i] = null;
091:                    }
092:                }
093:                fireUpdate();
094:            } //}}}
095:
096:            //{{{ setCurrentScrollPosition() method
097:            public void setCurrentScrollPosition(URL currentPage,
098:                    int scrollPosition) {
099:                if ((null != currentPage)
100:                        && (historyPos >= 1)
101:                        && (currentPage.toString()
102:                                .equals(history[historyPos - 1].url))) {
103:                    history[historyPos - 1].scrollPosition = scrollPosition;
104:                }
105:            } //}}}
106:
107:            //{{{ setCurrentEntry() method
108:            public void setCurrentEntry(HistoryEntry entry) {
109:                for (int i = 0; i < history.length; i++) {
110:                    if ((history[i] != null) && (history[i].equals(entry))) {
111:                        historyPos = i + 1;
112:                        fireUpdate();
113:                        break;
114:                    }
115:                }
116:                // Do nothing?
117:            } //}}}
118:
119:            //{{{ updateTitle() method
120:            public void updateTitle(String url, String title) {
121:                for (int i = 0; i < history.length; i++) {
122:                    if ((history[i] != null) && history[i].url.equals(url)) {
123:                        history[i].title = title;
124:                    }
125:                }
126:                fireUpdate();
127:            }//}}}
128:
129:            //{{{ getPreviousURLs() method
130:            public HistoryEntry[] getPreviousURLs() {
131:                if (historyPos <= 1) {
132:                    return new HelpHistoryModel.HistoryEntry[0];
133:                }
134:                HistoryEntry[] previous = new HistoryEntry[historyPos - 1];
135:                System.arraycopy(history, 0, previous, 0, historyPos - 1);
136:                return previous;
137:            } //}}}
138:
139:            //{{{ getNextURLs() method
140:            public HistoryEntry[] getNextURLs() {
141:                if (history.length - historyPos <= 1) {
142:                    return new HelpHistoryModel.HistoryEntry[0];
143:                }
144:                if (history[historyPos] == null) {
145:                    return new HelpHistoryModel.HistoryEntry[0];
146:                }
147:                HistoryEntry[] next = new HistoryEntry[history.length
148:                        - historyPos];
149:                System.arraycopy(history, historyPos, next, 0, history.length
150:                        - historyPos);
151:                return next;
152:            } //}}}
153:
154:            //{{{ addHelpHistoryModelListener() method
155:            public void addHelpHistoryModelListener(
156:                    HelpHistoryModelListener hhml) {
157:                listeners.add(hhml);
158:            } //}}}
159:
160:            //{{{ removeHelpHistoryModelListener() method
161:            public void removeHelpHistoryModelListener(
162:                    HelpHistoryModelListener hhml) {
163:                listeners.remove(hhml);
164:            } //}}}
165:
166:            //{{{ fireUpdate() method
167:            public void fireUpdate() {
168:                for (int i = 0; i < listeners.size(); i++) {
169:                    ((HelpHistoryModelListener) listeners.elementAt(i))
170:                            .historyUpdated();
171:                }
172:            } //}}}
173:
174:            //{{{ Private members
175:            private int historyPos;
176:            private HistoryEntry[] history;
177:            private java.util.Vector listeners;
178:
179:            //}}}
180:
181:            //{{{ Inner Classes
182:
183:            //{{{ HistoryEntry class
184:            static class HistoryEntry {
185:                String url;
186:                String title;
187:                int scrollPosition;
188:
189:                //{{{ HistoryEntry constructor
190:                HistoryEntry(String url, String title) {
191:                    this (url, title, 0);
192:                } //}}}
193:
194:                //{{{ HistoryEntry constructor
195:                HistoryEntry(HistoryEntry original) {
196:                    this (original.url, original.title, original.scrollPosition);
197:                } //}}}
198:
199:                //{{{ HistoryEntry constructor
200:                HistoryEntry(String url, String title, int scrollPosition) {
201:                    this .url = url;
202:                    this .title = title;
203:                    this .scrollPosition = scrollPosition;
204:                } //}}}
205:
206:                //{{{ equals() method
207:                public boolean equals(HistoryEntry he) {
208:                    return he.url.equals(this .url)
209:                            && he.title.equals(this .title)
210:                            && (he.scrollPosition == scrollPosition);
211:                } //}}}
212:
213:                //{{{ toString() method
214:                public String toString() {
215:                    return getClass().getName() + "[url=" + url + ",title="
216:                            + title + ",scrollPosition=" + scrollPosition + "]";
217:                } //}}}
218:            } //}}}
219:
220:            //}}}
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.