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.him.editors;
020:
021: import org.openharmonise.vfs.*;
022: import org.openharmonise.vfs.status.*;
023:
024: /**
025: * Editor that does nothing. Editors that wish to safely implement only
026: * part of the editor interface can extend this class.
027: *
028: * @author Matthew Large
029: * @version $Revision: 1.1 $
030: *
031: */
032: public class BlankEditor implements Editor {
033:
034: private boolean m_bResourceCreated = false;
035:
036: /**
037: *
038: */
039: public BlankEditor() {
040: super ();
041: }
042:
043: /* (non-Javadoc)
044: * @see com.simulacramedia.contentmanager.editors.Editor#open(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
045: */
046: public PathStatusWrapper open(String sPath,
047: AbstractVirtualFileSystem vfs) {
048: return new PathStatusWrapper(null, new VFSStatus());
049: }
050:
051: /* (non-Javadoc)
052: * @see com.simulacramedia.contentmanager.editors.Editor#createNew(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
053: */
054: public PathStatusWrapper createNew(String sPath,
055: AbstractVirtualFileSystem vfs) {
056: ResourceStatusWrapper statusWrapper = new ResourceStatusWrapper(
057: null, new VFSStatus());
058:
059: try {
060: VirtualFile vfFile = new VirtualFile(sPath);
061: vfFile.setContent(null);
062: statusWrapper = vfs.addVirtualFile(sPath, vfFile);
063: if (statusWrapper.getStatus().isOK()) {
064: this .m_bResourceCreated = true;
065: }
066: } catch (Exception e) {
067: e.printStackTrace();
068: }
069: return new PathStatusWrapper(null, statusWrapper.getStatus());
070: }
071:
072: /* (non-Javadoc)
073: * @see com.simulacramedia.contentmanager.editors.Editor#discardChanges(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
074: */
075: public StatusData discardChanges(String sPath,
076: AbstractVirtualFileSystem vfs) {
077: return new VFSStatus();
078: }
079:
080: /* (non-Javadoc)
081: * @see com.simulacramedia.contentmanager.editors.Editor#export(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
082: */
083: public StatusData export(String sPath, AbstractVirtualFileSystem vfs) {
084: return new VFSStatus();
085: }
086:
087: /* (non-Javadoc)
088: * @see com.simulacramedia.contentmanager.editors.Editor#createNew(java.lang.String, byte[], com.simulacramedia.vfs.AbstractVirtualFileSystem)
089: */
090: public PathStatusWrapper createNew(String sPath, byte[] content,
091: AbstractVirtualFileSystem vfs) {
092: ResourceStatusWrapper statusWrapper = new ResourceStatusWrapper(
093: null, new VFSStatus());
094:
095: try {
096: VirtualFile vfFile = new VirtualFile(sPath);
097: vfFile.setContent(content);
098: statusWrapper = vfs.addVirtualFile(sPath, vfFile);
099: if (statusWrapper.getStatus().isOK()) {
100: this .m_bResourceCreated = true;
101: }
102: } catch (Exception e) {
103: e.printStackTrace();
104: }
105:
106: return new PathStatusWrapper(null, statusWrapper.getStatus());
107: }
108:
109: /* (non-Javadoc)
110: * @see com.simulacramedia.contentmanager.editors.Editor#hasResourceBeenCreated()
111: */
112: public boolean hasResourceBeenCreated() {
113: return this .m_bResourceCreated;
114: }
115:
116: /* (non-Javadoc)
117: * @see com.simulacramedia.contentmanager.editors.Editor#preview(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
118: */
119: public PathStatusWrapper preview(String sPath,
120: AbstractVirtualFileSystem vfs) {
121: return new PathStatusWrapper(null, new VFSStatus());
122: }
123:
124: /* (non-Javadoc)
125: * @see com.simulacramedia.contentmanager.editors.Editor#upload(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
126: */
127: public PathStatusWrapper upload(String path,
128: AbstractVirtualFileSystem vfs) {
129: return new PathStatusWrapper(null, new VFSStatus());
130: }
131:
132: }
|