KickJava   Java API By Example, From Geeks To Geeks.

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


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.him.harmonise.*;
22 import org.openharmonise.vfs.*;
23 import org.openharmonise.vfs.metadata.*;
24 import org.openharmonise.vfs.status.*;
25 import org.openharmonise.workfloweditor.model.*;
26 import org.openharmonise.workfloweditor.vfs.*;
27
28
29 /**
30  * Handles editing of workflows.
31  *
32  * @author Matthew Large
33  * @version $Revision: 1.1 $
34  *
35  */

36 public class WorkflowEditor implements Editor {
37
38     private boolean m_bResourceCreated = false;
39
40     /**
41      * Default Constructor.
42      */

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

50     public PathStatusWrapper open(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
51         
52         if(sPath.startsWith(HarmonisePaths.PATH_WORKFLOW_STAGES) == false) {
53             VirtualFile vfFile = vfs.getVirtualFile(sPath).getResource();
54             String JavaDoc sTitle = vfs.getVirtualFileSystemView().getDisplayName(vfFile);
55             Property prop = PropertyCache.getInstance().getPropertyByPath(sPath);
56     
57             org.openharmonise.workfloweditor.WorkflowEditor editor = new org.openharmonise.workfloweditor.WorkflowEditor();
58             WorkflowModel model = new VFSWorkflowModel(sTitle, prop);
59             editor.setModel(model);
60         }
61
62         return new PathStatusWrapper(null, new VFSStatus());
63     }
64
65     /* (non-Javadoc)
66      * @see com.simulacramedia.contentmanager.editors.Editor#createNew(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
67      */

68     public PathStatusWrapper createNew(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
69         ResourceStatusWrapper statusWrapper = new ResourceStatusWrapper(null, new VFSStatus());
70         
71         try {
72             VirtualFile vfFile = new VirtualFile(sPath);
73             vfFile.setContent(null);
74             
75             statusWrapper = vfs.addVirtualFile(sPath, vfFile);
76             
77             if(statusWrapper.getStatus().isOK()) {
78                 this.m_bResourceCreated = true;
79             }
80         } catch(Exception JavaDoc e) {
81             e.printStackTrace();
82         }
83         return new PathStatusWrapper(null, statusWrapper.getStatus());
84     }
85
86     /* (non-Javadoc)
87      * @see com.simulacramedia.contentmanager.editors.Editor#createNew(java.lang.String, byte[], com.simulacramedia.vfs.AbstractVirtualFileSystem)
88      */

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

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

121     public StatusData export(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
122         return new VFSStatus();
123     }
124
125     /* (non-Javadoc)
126      * @see com.simulacramedia.contentmanager.editors.Editor#hasResourceBeenCreated()
127      */

128     public boolean hasResourceBeenCreated() {
129         return this.m_bResourceCreated;
130     }
131
132     /* (non-Javadoc)
133      * @see com.simulacramedia.contentmanager.editors.Editor#preview(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
134      */

135     public PathStatusWrapper preview(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
136         return new PathStatusWrapper(null, new VFSStatus());
137     }
138
139     /* (non-Javadoc)
140      * @see com.simulacramedia.contentmanager.editors.Editor#upload(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
141      */

142     public PathStatusWrapper upload(String JavaDoc path, AbstractVirtualFileSystem vfs) {
143         return new PathStatusWrapper(null, new VFSStatus());
144     }
145
146 }
147
Popular Tags