KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > editors > BlankEditor


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.him.editors;
20
21 import org.openharmonise.vfs.*;
22 import org.openharmonise.vfs.status.*;
23
24
25 /**
26  * Editor that does nothing. Editors that wish to safely implement only
27  * part of the editor interface can extend this class.
28  *
29  * @author Matthew Large
30  * @version $Revision: 1.1 $
31  *
32  */

33 public class BlankEditor implements Editor {
34
35     private boolean m_bResourceCreated = false;
36
37     /**
38      *
39      */

40     public BlankEditor() {
41         super();
42     }
43
44     /* (non-Javadoc)
45      * @see com.simulacramedia.contentmanager.editors.Editor#open(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
46      */

47     public PathStatusWrapper open(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
48         return new PathStatusWrapper(null, new VFSStatus());
49     }
50
51     /* (non-Javadoc)
52      * @see com.simulacramedia.contentmanager.editors.Editor#createNew(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
53      */

54     public PathStatusWrapper createNew(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
55         ResourceStatusWrapper statusWrapper = new ResourceStatusWrapper(null, new VFSStatus());
56         
57         try {
58             VirtualFile vfFile = new VirtualFile(sPath);
59             vfFile.setContent(null);
60             statusWrapper = vfs.addVirtualFile(sPath, vfFile);
61             if(statusWrapper.getStatus().isOK()) {
62                 this.m_bResourceCreated = true;
63             }
64         } catch(Exception JavaDoc e) {
65             e.printStackTrace();
66         }
67         return new PathStatusWrapper(null, statusWrapper.getStatus());
68     }
69
70     /* (non-Javadoc)
71      * @see com.simulacramedia.contentmanager.editors.Editor#discardChanges(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
72      */

73     public StatusData discardChanges(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
74         return new VFSStatus();
75     }
76
77     /* (non-Javadoc)
78      * @see com.simulacramedia.contentmanager.editors.Editor#export(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
79      */

80     public StatusData export(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
81         return new VFSStatus();
82     }
83
84     /* (non-Javadoc)
85      * @see com.simulacramedia.contentmanager.editors.Editor#createNew(java.lang.String, byte[], com.simulacramedia.vfs.AbstractVirtualFileSystem)
86      */

87     public PathStatusWrapper createNew(String JavaDoc sPath, byte[] content, AbstractVirtualFileSystem vfs) {
88         ResourceStatusWrapper statusWrapper = new ResourceStatusWrapper(null, new VFSStatus());
89         
90         try {
91             VirtualFile vfFile = new VirtualFile(sPath);
92             vfFile.setContent(content);
93             statusWrapper = vfs.addVirtualFile(sPath, vfFile);
94             if(statusWrapper.getStatus().isOK()) {
95                 this.m_bResourceCreated = true;
96             }
97         } catch(Exception JavaDoc e) {
98             e.printStackTrace();
99         }
100         
101         return new PathStatusWrapper(null, statusWrapper.getStatus());
102     }
103
104     /* (non-Javadoc)
105      * @see com.simulacramedia.contentmanager.editors.Editor#hasResourceBeenCreated()
106      */

107     public boolean hasResourceBeenCreated() {
108         return this.m_bResourceCreated;
109     }
110
111     /* (non-Javadoc)
112      * @see com.simulacramedia.contentmanager.editors.Editor#preview(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
113      */

114     public PathStatusWrapper preview(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
115         return new PathStatusWrapper(null, new VFSStatus());
116     }
117
118     /* (non-Javadoc)
119      * @see com.simulacramedia.contentmanager.editors.Editor#upload(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
120      */

121     public PathStatusWrapper upload(String JavaDoc path, AbstractVirtualFileSystem vfs) {
122         return new PathStatusWrapper(null, new VFSStatus());
123     }
124
125 }
126
Popular Tags