Source Code Cross Referenced for BasicFileView.java in  » 6.0-JDK-Modules » java-3d » com » db » utils » 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 » 6.0 JDK Modules » java 3d » com.db.utils 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2000 Silvere Martin-Michiellot All Rights Reserved.
003:         *
004:         * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
005:         * royalty free, license to use, modify and redistribute this
006:         * software in source and binary code form,
007:         * provided that i) this copyright notice and license appear on all copies of
008:         * the software; and ii) Licensee does not utilize the software in a manner
009:         * which is disparaging to Silvere Martin-Michiellot.
010:         *
011:         * This software is provided "AS IS," without a warranty of any kind. ALL
012:         * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
013:         * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
014:         * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
015:         * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
016:         * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
017:         * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
018:         * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
019:         * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
020:         * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
021:         * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
022:         * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
023:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
024:         *
025:         * This software is not designed or intended for use in on-line control of
026:         * aircraft, air traffic, aircraft navigation or aircraft communications; or in
027:         * the design, construction, operation or maintenance of any nuclear
028:         * facility. Licensee represents and warrants that it will not use or
029:         * redistribute the Software for such purposes.
030:         *
031:         */
032:
033:        //	This code is repackaged after the demo from Sun Microsystems (in the Java3D demo packages) /demo/jfc/FileChooserDemo/ExampleFileView.java
034:        //	Site http://java.sun.com/
035:        //	Email
036:        package com.db.utils;
037:
038:        /*
039:         * @(#)BasicFileView.java	1.11 01/12/03
040:         *
041:         * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
042:         * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
043:         */
044:
045:        import javax.swing.*;
046:        import javax.swing.filechooser.*;
047:
048:        import java.io.File;
049:        import java.util.Hashtable;
050:
051:        /**
052:         * A convenience implementation of the FileView interface that
053:         * manages name, icon, traversable, and file type information.
054:         *
055:         * This this implemention will work well with file systems that use
056:         * "dot" extensions to indicate file type. For example: "picture.gif"
057:         * as a gif image.
058:         *
059:         * If the java.io.File ever contains some of this information, such as
060:         * file type, icon, and hidden file inforation, this implementation may
061:         * become obsolete. At minimum, it should be rewritten at that time to
062:         * use any new type information provided by java.io.File
063:         *
064:         * Example:
065:         *    JFileChooser chooser = new JFileChooser();
066:         *    fileView = new BasicFileView();
067:         *    fileView.putIcon("jpg", new ImageIcon("images/jpgIcon.jpg"));
068:         *    fileView.putIcon("gif", new ImageIcon("images/gifIcon.gif"));
069:         *    chooser.setFileView(fileView);
070:         *
071:         * @version 1.11 12/03/01
072:         * @author Jeff Dinkins
073:         */
074:        public class BasicFileView extends FileView {
075:            private Hashtable icons = new Hashtable(5);
076:            private Hashtable fileDescriptions = new Hashtable(5);
077:            private Hashtable typeDescriptions = new Hashtable(5);
078:
079:            /**
080:             * The name of the file.  Do nothing special here. Let
081:             * the system file view handle this.
082:             * @see #setName
083:             * @see FileView#getName
084:             */
085:            public String getName(File f) {
086:                return null;
087:            }
088:
089:            /**
090:             * Adds a human readable description of the file.
091:             */
092:            public void putDescription(File f, String fileDescription) {
093:                fileDescriptions.put(fileDescription, f);
094:            }
095:
096:            /**
097:             * A human readable description of the file.
098:             *
099:             * @see FileView#getDescription
100:             */
101:            public String getDescription(File f) {
102:                return (String) fileDescriptions.get(f);
103:            };
104:
105:            /**
106:             * Adds a human readable type description for files. Based on "dot"
107:             * extension strings, e.g: ".gif". Case is ignored.
108:             */
109:            public void putTypeDescription(String extension,
110:                    String typeDescription) {
111:                typeDescriptions.put(typeDescription, extension);
112:            }
113:
114:            /**
115:             * Adds a human readable type description for files of the type of
116:             * the passed in file. Based on "dot" extension strings, e.g: ".gif".
117:             * Case is ignored.
118:             */
119:            public void putTypeDescription(File f, String typeDescription) {
120:                putTypeDescription(getExtension(f), typeDescription);
121:            }
122:
123:            /**
124:             * A human readable description of the type of the file.
125:             *
126:             * @see FileView#getTypeDescription
127:             */
128:            public String getTypeDescription(File f) {
129:                return (String) typeDescriptions.get(getExtension(f));
130:            }
131:
132:            /**
133:             * Conveinience method that returnsa the "dot" extension for the
134:             * given file.
135:             */
136:            public String getExtension(File f) {
137:                String name = f.getName();
138:                if (name != null) {
139:                    int extensionIndex = name.lastIndexOf('.');
140:                    if (extensionIndex < 0) {
141:                        return null;
142:                    }
143:                    return name.substring(extensionIndex + 1).toLowerCase();
144:                }
145:                return null;
146:            }
147:
148:            /**
149:             * Adds an icon based on the file type "dot" extension
150:             * string, e.g: ".gif". Case is ignored.
151:             */
152:            public void putIcon(String extension, Icon icon) {
153:                icons.put(extension, icon);
154:            }
155:
156:            /**
157:             * Icon that reperesents this file. Default implementation returns
158:             * null. You might want to override this to return something more
159:             * interesting.
160:             *
161:             * @see FileView#getIcon
162:             */
163:            public Icon getIcon(File f) {
164:                Icon icon = null;
165:                String extension = getExtension(f);
166:                if (extension != null) {
167:                    icon = (Icon) icons.get(extension);
168:                }
169:                return icon;
170:            }
171:
172:            /**
173:             * Whether the file is hidden or not. This implementation returns
174:             * true if the filename starts with a "."
175:             *
176:             * @see FileView#isHidden
177:             */
178:            public Boolean isHidden(File f) {
179:                String name = f.getName();
180:                if (name != null && !name.equals("") && name.charAt(0) == '.') {
181:                    return Boolean.TRUE;
182:                } else {
183:                    return Boolean.FALSE;
184:                }
185:            };
186:
187:            /**
188:             * Whether the directory is traversable or not. Generic implementation
189:             * returns true for all directories and special folders.
190:             *
191:             * You might want to subtype BasicFileView to do somethimg more interesting,
192:             * such as recognize compound documents directories; in such a case you might
193:             * return a special icon for the diretory that makes it look like a regular
194:             * document, and return false for isTraversable to not allow users to
195:             * descend into the directory.
196:             *
197:             * @see FileView#isTraversable
198:             */
199:            public Boolean isTraversable(File f) {
200:                // if (some_reason) {
201:                //    return Boolean.FALSE;
202:                // }
203:                return null; // Use default from FileSystemView
204:            };
205:
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.