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


001:        /*
002:         * FavoritesVFS.java - Stores frequently-visited directory locations
003:         * :tabSize=8:indentSize=8:noTabs=false:
004:         * :folding=explicit:collapseFolds=1:
005:         *
006:         * Copyright (C) 2000, 2004 Slava Pestov
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.io;
024:
025:        //{{{ Imports
026:        import java.awt.Component;
027:        import java.util.*;
028:        import org.gjt.sp.jedit.msg.DynamicMenuChanged;
029:        import org.gjt.sp.jedit.*;
030:
031:        //}}}
032:
033:        /**
034:         * A VFS used for remembering frequently-visited directories. Listing it
035:         * returns the favorites list. The deletePath of each entry is the
036:         * directory prefixed with "favorites:" so that right-clicking on a
037:         * favorite and clicking 'delete' in the browser just deletes the
038:         * favorite, and not the directory itself.
039:         * @author Slava Pestov
040:         * @version $Id: FavoritesVFS.java 5179 2005-02-05 20:34:41Z spestov $
041:         */
042:        public class FavoritesVFS extends VFS {
043:            public static final String PROTOCOL = "favorites";
044:
045:            //{{{ FavoritesVFS constructor
046:            public FavoritesVFS() {
047:                super ("favorites", DELETE_CAP | LOW_LATENCY_CAP,
048:                        new String[] { EA_TYPE });
049:
050:                /* addToFavorites(), which is a static method
051:                 * (for convinience) needs an instance of the
052:                 * VFS to pass to VFSManager.sendVFSUpdate(),
053:                 * hence this hack. */
054:                instance = this ;
055:            } //}}}
056:
057:            //{{{ getParentOfPath() method
058:            public String getParentOfPath(String path) {
059:                return PROTOCOL + ":";
060:            } //}}}
061:
062:            //{{{ _listFiles() method
063:            public VFSFile[] _listFiles(Object session, String url,
064:                    Component comp) {
065:                return getFavorites();
066:            } //}}}
067:
068:            //{{{ _getFile() method
069:            public VFSFile _getFile(Object session, String path, Component comp) {
070:                // does it matter that this doesn't set the type correctly?
071:                return new Favorite(path, VFSFile.DIRECTORY);
072:            } //}}}
073:
074:            //{{{ _delete() method
075:            public boolean _delete(Object session, String path, Component comp) {
076:                synchronized (lock) {
077:                    path = path.substring(PROTOCOL.length() + 1);
078:
079:                    Iterator iter = favorites.iterator();
080:                    while (iter.hasNext()) {
081:                        if (((Favorite) iter.next()).getPath().equals(path)) {
082:                            iter.remove();
083:                            VFSManager.sendVFSUpdate(this , PROTOCOL + ":",
084:                                    false);
085:                            EditBus.send(new DynamicMenuChanged("favorites"));
086:                            return true;
087:                        }
088:                    }
089:                }
090:
091:                return false;
092:            } //}}}
093:
094:            //{{{ loadFavorites() method
095:            public static void loadFavorites() {
096:                synchronized (lock) {
097:                    favorites = new LinkedList();
098:
099:                    String favorite;
100:                    int i = 0;
101:                    while ((favorite = jEdit.getProperty("vfs.favorite." + i)) != null) {
102:                        favorites.add(new Favorite(favorite, jEdit
103:                                .getIntegerProperty("vfs.favorite." + i
104:                                        + ".type", VFSFile.DIRECTORY)));
105:                        i++;
106:                    }
107:                }
108:            } //}}}
109:
110:            //{{{ addToFavorites() method
111:            public static void addToFavorites(String path, int type) {
112:                synchronized (lock) {
113:                    if (favorites == null)
114:                        loadFavorites();
115:
116:                    Iterator iter = favorites.iterator();
117:                    while (iter.hasNext()) {
118:                        if (((Favorite) iter.next()).getPath().equals(path))
119:                            return;
120:                    }
121:
122:                    favorites.add(new Favorite(path, type));
123:
124:                    VFSManager.sendVFSUpdate(instance, PROTOCOL + ":", false);
125:                    EditBus.send(new DynamicMenuChanged("favorites"));
126:                }
127:            } //}}}
128:
129:            //{{{ saveFavorites() method
130:            public static void saveFavorites() {
131:                synchronized (lock) {
132:                    if (favorites == null)
133:                        return;
134:
135:                    int i = 0;
136:                    Iterator iter = favorites.iterator();
137:                    while (iter.hasNext()) {
138:                        Favorite e = ((Favorite) iter.next());
139:                        jEdit.setProperty("vfs.favorite." + i, e.getPath());
140:                        jEdit.setIntegerProperty("vfs.favorite." + i + ".type",
141:                                e.getType());
142:
143:                        i++;
144:                    }
145:                    jEdit.unsetProperty("vfs.favorite." + favorites.size());
146:                    jEdit.unsetProperty("vfs.favorite." + favorites.size()
147:                            + ".type");
148:                }
149:            } //}}}
150:
151:            //{{{ getFavorites() method
152:            public static VFSFile[] getFavorites() {
153:                synchronized (lock) {
154:                    if (favorites == null)
155:                        loadFavorites();
156:
157:                    return (VFSFile[]) favorites.toArray(new VFSFile[favorites
158:                            .size()]);
159:                }
160:            } //}}}
161:
162:            //{{{ Private members
163:            private static FavoritesVFS instance;
164:            private static Object lock = new Object();
165:            private static List favorites;
166:
167:            //}}}
168:
169:            //{{{ Favorite class
170:            static class Favorite extends VFSFile {
171:                Favorite(String path, int type) {
172:                    super (path, path, PROTOCOL + ":" + path, type, 0, false);
173:                }
174:
175:                public String getExtendedAttribute(String name) {
176:                    if (name.equals(EA_TYPE))
177:                        return super .getExtendedAttribute(name);
178:                    else {
179:                        // don't want it to show "0 bytes" for size,
180:                        // etc.
181:                        return null;
182:                    }
183:                }
184:            } //}}}
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.