KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > localfilesystem > LocalFileSystemView


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.localfilesystem;
20
21 import javax.swing.Icon JavaDoc;
22
23 import org.openharmonise.commons.xml.namespace.NamespaceType;
24 import org.openharmonise.vfs.*;
25 import org.openharmonise.vfs.gui.*;
26 import org.openharmonise.vfs.metadata.*;
27
28
29 /**
30  * @author Matthew Large
31  *
32  */

33 public class LocalFileSystemView implements VirtualFileSystemView {
34
35     /**
36      * Default constructor.
37      */

38     public LocalFileSystemView() {
39         super();
40     }
41
42     /* (non-Javadoc)
43      * @see com.simulacramedia.vfs.VirtualFileView#getIcon(com.simulacramedia.vfs.VirtualFile)
44      */

45     public Icon JavaDoc getIcon(VirtualFile vfFile) {
46         if(vfFile.isDirectory()) {
47             if(vfFile.getFullPath().startsWith("/webdav/Metadata/Properties")) {
48                 return IconManager.getInstance().getIcon("16-property-container.gif");
49             } else if(vfFile.getFullPath().startsWith("/webdav/Metadata/Values")) {
50                 return IconManager.getInstance().getIcon("16-value-container.gif");
51             } else if(vfFile.getFullPath().startsWith("/webdav/Reports")) {
52                 return IconManager.getInstance().getIcon("16-report-folder.gif");
53             } else if(vfFile.getFullPath().startsWith("/webdav/Templates")) {
54                 return IconManager.getInstance().getIcon("16-folder.gif");
55             } else if(vfFile.getFullPath().startsWith("/webdav/Newsletter/draft")) {
56                 return IconManager.getInstance().getIcon("16-newsletter-draft.gif");
57             } else if(vfFile.getFullPath().startsWith("/webdav/Newsletter/sent")) {
58                 return IconManager.getInstance().getIcon("16-newsletter-sent.gif");
59             } else if(vfFile.getFullPath().startsWith("/webdav/Newsletter/outbox")) {
60                 return IconManager.getInstance().getIcon("16-newsletter-outbox.gif");
61             } else if(vfFile.getFullPath().startsWith("/webdav/Users")) {
62                 return IconManager.getInstance().getIcon("16-user-container.gif");
63             } else {
64                 return IconManager.getInstance().getIcon("16-section.gif");
65             }
66         } else {
67             if(vfFile.getFullPath().startsWith("/webdav/Users")) {
68                 return IconManager.getInstance().getIcon("16-user.gif");
69             } else if(vfFile.getFullPath().startsWith("/webdav/Assets/Flash")) {
70                 return IconManager.getInstance().getIcon("16-movie.gif");
71             } else if(vfFile.getFullPath().startsWith("/webdav/Assets/Link")) {
72                 return IconManager.getInstance().getIcon("16-link.gif");
73             } else if(vfFile.getFullPath().startsWith("/webdav/Assets/Web Resources")) {
74                 return IconManager.getInstance().getIcon("16-link.gif");
75             } else if(vfFile.getFullPath().startsWith("/webdav/Assets/Email")) {
76                 return IconManager.getInstance().getIcon("16-email.gif");
77             } else if(vfFile.getFullPath().startsWith("/webdav/Assets/Image")) {
78                 return IconManager.getInstance().getIcon("16-image.gif");
79             } else if(vfFile.getFullPath().startsWith("/webdav/Metadata/Properties")) {
80                 return IconManager.getInstance().getIcon("16-property.gif");
81             } else if(vfFile.getFullPath().startsWith("/webdav/Metadata/Values")) {
82                 return IconManager.getInstance().getIcon("16-value.gif");
83             } else if(vfFile.getFullPath().startsWith("/webdav/Newsletter")) {
84                 return IconManager.getInstance().getIcon("16-newsletter.gif");
85             } else if(vfFile.getFullPath().startsWith("/webdav/Reports")) {
86                 return IconManager.getInstance().getIcon("16-report.gif");
87             } else if(vfFile.getFullPath().startsWith("/webdav/Templates")) {
88                 return IconManager.getInstance().getIcon("16-template.gif");
89             } else {
90                 return IconManager.getInstance().getIcon("16-document.gif");
91             }
92         }
93     }
94
95     /* (non-Javadoc)
96      * @see com.simulacramedia.vfs.VirtualFileView#getIcon(com.simulacramedia.vfs.VirtualFile, boolean)
97      */

98     public Icon JavaDoc getIcon(VirtualFile vfFile, boolean bIsDirectoryOpen) {
99         if(vfFile.getFullPath().startsWith("/webdav/Metadata/Properties")) {
100             return IconManager.getInstance().getIcon("16-property-container.gif");
101         } else if(vfFile.getFullPath().startsWith("/webdav/Metadata/Values")) {
102             return IconManager.getInstance().getIcon("16-value-container.gif");
103         } else if(vfFile.getFullPath().startsWith("/webdav/Templates")) {
104             if( bIsDirectoryOpen ) {
105                 return IconManager.getInstance().getIcon("16-folder-open.gif");
106             } else {
107                 return IconManager.getInstance().getIcon("16-folder.gif");
108             }
109         } else if(vfFile.getFullPath().startsWith("/webdav/Reports")) {
110             if( bIsDirectoryOpen ) {
111                 return IconManager.getInstance().getIcon("16-report-folder-open.gif");
112             } else {
113                 return IconManager.getInstance().getIcon("16-report-folder.gif");
114             }
115         } else if(vfFile.getFullPath().startsWith("/webdav/Newsletter/draft")) {
116             return IconManager.getInstance().getIcon("16-newsletter-draft.gif");
117         } else if(vfFile.getFullPath().startsWith("/webdav/Newsletter/sent")) {
118             return IconManager.getInstance().getIcon("16-newsletter-sent.gif");
119         } else if(vfFile.getFullPath().startsWith("/webdav/Newsletter/outbox")) {
120             return IconManager.getInstance().getIcon("16-newsletter-outbox.gif");
121         } else if(vfFile.getFullPath().startsWith("/webdav/Users")) {
122             return IconManager.getInstance().getIcon("16-user-container.gif");
123         } else if(bIsDirectoryOpen) {
124             return IconManager.getInstance().getIcon("16-section-open.gif");
125         } else {
126             return IconManager.getInstance().getIcon("16-section.gif");
127         }
128     }
129
130     /* (non-Javadoc)
131      * @see com.simulacramedia.vfs.VirtualFileView#getDisplayName(com.simulacramedia.vfs.VirtualFile)
132      */

133     public String JavaDoc getDisplayName(VirtualFile vfFile) {
134         return vfFile.getFileName();
135     }
136
137     /* (non-Javadoc)
138      * @see com.simulacramedia.vfs.VirtualFileSystemView#getFileSystemIcon()
139      */

140     public Icon JavaDoc getFileSystemIcon() {
141         return null;
142     }
143
144     /* (non-Javadoc)
145      * @see com.simulacramedia.vfs.VirtualFileSystemView#getFileSystemDisplayName()
146      */

147     public String JavaDoc getFileSystemDisplayName() {
148         return null;
149     }
150
151     /* (non-Javadoc)
152      * @see com.simulacramedia.vfs.VirtualFileSystemView#getVFSIndependantProperty(java.lang.String)
153      */

154     public PropertyInstance getVFSIndependantProperty(String JavaDoc sIndependantPropName) {
155         return null;
156     }
157
158     /* (non-Javadoc)
159      * @see com.simulacramedia.vfs.VirtualFileSystemView#getModificationDate()
160      */

161     public String JavaDoc getModificationDate(VirtualFile vfFile) {
162         PropertyInstance propInst = vfFile.getProperty( NamespaceType.OHRM.getURI(), "datemodified" );
163         if(propInst.getValues().size()>0) {
164             return (String JavaDoc)propInst.getValues().get(0);
165         } else {
166             return "none";
167         }
168     }
169
170     /* (non-Javadoc)
171      * @see com.simulacramedia.vfs.VirtualFileSystemView#getContentType(com.simulacramedia.vfs.VirtualFile)
172      */

173     public String JavaDoc getContentType(VirtualFile vfFile) {
174         return "text/xml";
175     }
176
177     /* (non-Javadoc)
178      * @see com.simulacramedia.vfs.VirtualFileSystemView#setContentType(com.simulacramedia.vfs.VirtualFile, java.lang.String)
179      */

180     public void setContentType(VirtualFile vfFile, String JavaDoc sContentType) {
181     }
182
183     /* (non-Javadoc)
184      * @see com.simulacramedia.vfs.VirtualFileSystemView#getSummary(com.simulacramedia.vfs.VirtualFile)
185      */

186     public String JavaDoc getSummary(VirtualFile vfFile) {
187         return null;
188     }
189
190     /* (non-Javadoc)
191      * @see com.simulacramedia.vfs.VirtualFileSystemView#getLogicalFileName(com.simulacramedia.vfs.VirtualFile)
192      */

193     public String JavaDoc getLogicalFileName(VirtualFile vfFile) {
194         return null;
195     }
196
197     /* (non-Javadoc)
198      * @see com.simulacramedia.vfs.VirtualFileSystemView#getPublicationDate(com.simulacramedia.vfs.VirtualFile)
199      */

200     public String JavaDoc getPublicationDate(VirtualFile vfFile) {
201         return "none";
202     }
203
204     /* (non-Javadoc)
205      * @see com.simulacramedia.vfs.VirtualFileSystemView#getArchiveDate(com.simulacramedia.vfs.VirtualFile)
206      */

207     public String JavaDoc getArchiveDate(VirtualFile vfFile) {
208         return "none";
209     }
210
211 }
212
Popular Tags