001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.localfilesystem;
020:
021: import javax.swing.Icon;
022:
023: import org.openharmonise.commons.xml.namespace.NamespaceType;
024: import org.openharmonise.vfs.*;
025: import org.openharmonise.vfs.gui.*;
026: import org.openharmonise.vfs.metadata.*;
027:
028: /**
029: * @author Matthew Large
030: *
031: */
032: public class LocalFileSystemView implements VirtualFileSystemView {
033:
034: /**
035: * Default constructor.
036: */
037: public LocalFileSystemView() {
038: super ();
039: }
040:
041: /* (non-Javadoc)
042: * @see com.simulacramedia.vfs.VirtualFileView#getIcon(com.simulacramedia.vfs.VirtualFile)
043: */
044: public Icon getIcon(VirtualFile vfFile) {
045: if (vfFile.isDirectory()) {
046: if (vfFile.getFullPath().startsWith(
047: "/webdav/Metadata/Properties")) {
048: return IconManager.getInstance().getIcon(
049: "16-property-container.gif");
050: } else if (vfFile.getFullPath().startsWith(
051: "/webdav/Metadata/Values")) {
052: return IconManager.getInstance().getIcon(
053: "16-value-container.gif");
054: } else if (vfFile.getFullPath().startsWith(
055: "/webdav/Reports")) {
056: return IconManager.getInstance().getIcon(
057: "16-report-folder.gif");
058: } else if (vfFile.getFullPath().startsWith(
059: "/webdav/Templates")) {
060: return IconManager.getInstance().getIcon(
061: "16-folder.gif");
062: } else if (vfFile.getFullPath().startsWith(
063: "/webdav/Newsletter/draft")) {
064: return IconManager.getInstance().getIcon(
065: "16-newsletter-draft.gif");
066: } else if (vfFile.getFullPath().startsWith(
067: "/webdav/Newsletter/sent")) {
068: return IconManager.getInstance().getIcon(
069: "16-newsletter-sent.gif");
070: } else if (vfFile.getFullPath().startsWith(
071: "/webdav/Newsletter/outbox")) {
072: return IconManager.getInstance().getIcon(
073: "16-newsletter-outbox.gif");
074: } else if (vfFile.getFullPath().startsWith("/webdav/Users")) {
075: return IconManager.getInstance().getIcon(
076: "16-user-container.gif");
077: } else {
078: return IconManager.getInstance().getIcon(
079: "16-section.gif");
080: }
081: } else {
082: if (vfFile.getFullPath().startsWith("/webdav/Users")) {
083: return IconManager.getInstance().getIcon("16-user.gif");
084: } else if (vfFile.getFullPath().startsWith(
085: "/webdav/Assets/Flash")) {
086: return IconManager.getInstance()
087: .getIcon("16-movie.gif");
088: } else if (vfFile.getFullPath().startsWith(
089: "/webdav/Assets/Link")) {
090: return IconManager.getInstance().getIcon("16-link.gif");
091: } else if (vfFile.getFullPath().startsWith(
092: "/webdav/Assets/Web Resources")) {
093: return IconManager.getInstance().getIcon("16-link.gif");
094: } else if (vfFile.getFullPath().startsWith(
095: "/webdav/Assets/Email")) {
096: return IconManager.getInstance()
097: .getIcon("16-email.gif");
098: } else if (vfFile.getFullPath().startsWith(
099: "/webdav/Assets/Image")) {
100: return IconManager.getInstance()
101: .getIcon("16-image.gif");
102: } else if (vfFile.getFullPath().startsWith(
103: "/webdav/Metadata/Properties")) {
104: return IconManager.getInstance().getIcon(
105: "16-property.gif");
106: } else if (vfFile.getFullPath().startsWith(
107: "/webdav/Metadata/Values")) {
108: return IconManager.getInstance()
109: .getIcon("16-value.gif");
110: } else if (vfFile.getFullPath().startsWith(
111: "/webdav/Newsletter")) {
112: return IconManager.getInstance().getIcon(
113: "16-newsletter.gif");
114: } else if (vfFile.getFullPath().startsWith(
115: "/webdav/Reports")) {
116: return IconManager.getInstance().getIcon(
117: "16-report.gif");
118: } else if (vfFile.getFullPath().startsWith(
119: "/webdav/Templates")) {
120: return IconManager.getInstance().getIcon(
121: "16-template.gif");
122: } else {
123: return IconManager.getInstance().getIcon(
124: "16-document.gif");
125: }
126: }
127: }
128:
129: /* (non-Javadoc)
130: * @see com.simulacramedia.vfs.VirtualFileView#getIcon(com.simulacramedia.vfs.VirtualFile, boolean)
131: */
132: public Icon getIcon(VirtualFile vfFile, boolean bIsDirectoryOpen) {
133: if (vfFile.getFullPath().startsWith(
134: "/webdav/Metadata/Properties")) {
135: return IconManager.getInstance().getIcon(
136: "16-property-container.gif");
137: } else if (vfFile.getFullPath().startsWith(
138: "/webdav/Metadata/Values")) {
139: return IconManager.getInstance().getIcon(
140: "16-value-container.gif");
141: } else if (vfFile.getFullPath().startsWith("/webdav/Templates")) {
142: if (bIsDirectoryOpen) {
143: return IconManager.getInstance().getIcon(
144: "16-folder-open.gif");
145: } else {
146: return IconManager.getInstance().getIcon(
147: "16-folder.gif");
148: }
149: } else if (vfFile.getFullPath().startsWith("/webdav/Reports")) {
150: if (bIsDirectoryOpen) {
151: return IconManager.getInstance().getIcon(
152: "16-report-folder-open.gif");
153: } else {
154: return IconManager.getInstance().getIcon(
155: "16-report-folder.gif");
156: }
157: } else if (vfFile.getFullPath().startsWith(
158: "/webdav/Newsletter/draft")) {
159: return IconManager.getInstance().getIcon(
160: "16-newsletter-draft.gif");
161: } else if (vfFile.getFullPath().startsWith(
162: "/webdav/Newsletter/sent")) {
163: return IconManager.getInstance().getIcon(
164: "16-newsletter-sent.gif");
165: } else if (vfFile.getFullPath().startsWith(
166: "/webdav/Newsletter/outbox")) {
167: return IconManager.getInstance().getIcon(
168: "16-newsletter-outbox.gif");
169: } else if (vfFile.getFullPath().startsWith("/webdav/Users")) {
170: return IconManager.getInstance().getIcon(
171: "16-user-container.gif");
172: } else if (bIsDirectoryOpen) {
173: return IconManager.getInstance().getIcon(
174: "16-section-open.gif");
175: } else {
176: return IconManager.getInstance().getIcon("16-section.gif");
177: }
178: }
179:
180: /* (non-Javadoc)
181: * @see com.simulacramedia.vfs.VirtualFileView#getDisplayName(com.simulacramedia.vfs.VirtualFile)
182: */
183: public String getDisplayName(VirtualFile vfFile) {
184: return vfFile.getFileName();
185: }
186:
187: /* (non-Javadoc)
188: * @see com.simulacramedia.vfs.VirtualFileSystemView#getFileSystemIcon()
189: */
190: public Icon getFileSystemIcon() {
191: return null;
192: }
193:
194: /* (non-Javadoc)
195: * @see com.simulacramedia.vfs.VirtualFileSystemView#getFileSystemDisplayName()
196: */
197: public String getFileSystemDisplayName() {
198: return null;
199: }
200:
201: /* (non-Javadoc)
202: * @see com.simulacramedia.vfs.VirtualFileSystemView#getVFSIndependantProperty(java.lang.String)
203: */
204: public PropertyInstance getVFSIndependantProperty(
205: String sIndependantPropName) {
206: return null;
207: }
208:
209: /* (non-Javadoc)
210: * @see com.simulacramedia.vfs.VirtualFileSystemView#getModificationDate()
211: */
212: public String getModificationDate(VirtualFile vfFile) {
213: PropertyInstance propInst = vfFile.getProperty(
214: NamespaceType.OHRM.getURI(), "datemodified");
215: if (propInst.getValues().size() > 0) {
216: return (String) propInst.getValues().get(0);
217: } else {
218: return "none";
219: }
220: }
221:
222: /* (non-Javadoc)
223: * @see com.simulacramedia.vfs.VirtualFileSystemView#getContentType(com.simulacramedia.vfs.VirtualFile)
224: */
225: public String getContentType(VirtualFile vfFile) {
226: return "text/xml";
227: }
228:
229: /* (non-Javadoc)
230: * @see com.simulacramedia.vfs.VirtualFileSystemView#setContentType(com.simulacramedia.vfs.VirtualFile, java.lang.String)
231: */
232: public void setContentType(VirtualFile vfFile, String sContentType) {
233: }
234:
235: /* (non-Javadoc)
236: * @see com.simulacramedia.vfs.VirtualFileSystemView#getSummary(com.simulacramedia.vfs.VirtualFile)
237: */
238: public String getSummary(VirtualFile vfFile) {
239: return null;
240: }
241:
242: /* (non-Javadoc)
243: * @see com.simulacramedia.vfs.VirtualFileSystemView#getLogicalFileName(com.simulacramedia.vfs.VirtualFile)
244: */
245: public String getLogicalFileName(VirtualFile vfFile) {
246: return null;
247: }
248:
249: /* (non-Javadoc)
250: * @see com.simulacramedia.vfs.VirtualFileSystemView#getPublicationDate(com.simulacramedia.vfs.VirtualFile)
251: */
252: public String getPublicationDate(VirtualFile vfFile) {
253: return "none";
254: }
255:
256: /* (non-Javadoc)
257: * @see com.simulacramedia.vfs.VirtualFileSystemView#getArchiveDate(com.simulacramedia.vfs.VirtualFile)
258: */
259: public String getArchiveDate(VirtualFile vfFile) {
260: return "none";
261: }
262:
263: }
|