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.him.harmonise.*;
022: import org.openharmonise.vfs.*;
023: import org.openharmonise.vfs.metadata.*;
024: import org.openharmonise.vfs.status.*;
025: import org.openharmonise.workfloweditor.model.*;
026: import org.openharmonise.workfloweditor.vfs.*;
027:
028: /**
029: * Handles editing of workflows.
030: *
031: * @author Matthew Large
032: * @version $Revision: 1.1 $
033: *
034: */
035: public class WorkflowEditor implements Editor {
036:
037: private boolean m_bResourceCreated = false;
038:
039: /**
040: * Default Constructor.
041: */
042: public WorkflowEditor() {
043: super ();
044: }
045:
046: /* (non-Javadoc)
047: * @see com.simulacramedia.contentmanager.editors.Editor#open(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
048: */
049: public PathStatusWrapper open(String sPath,
050: AbstractVirtualFileSystem vfs) {
051:
052: if (sPath.startsWith(HarmonisePaths.PATH_WORKFLOW_STAGES) == false) {
053: VirtualFile vfFile = vfs.getVirtualFile(sPath)
054: .getResource();
055: String sTitle = vfs.getVirtualFileSystemView()
056: .getDisplayName(vfFile);
057: Property prop = PropertyCache.getInstance()
058: .getPropertyByPath(sPath);
059:
060: org.openharmonise.workfloweditor.WorkflowEditor editor = new org.openharmonise.workfloweditor.WorkflowEditor();
061: WorkflowModel model = new VFSWorkflowModel(sTitle, prop);
062: editor.setModel(model);
063: }
064:
065: return new PathStatusWrapper(null, new VFSStatus());
066: }
067:
068: /* (non-Javadoc)
069: * @see com.simulacramedia.contentmanager.editors.Editor#createNew(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
070: */
071: public PathStatusWrapper createNew(String sPath,
072: AbstractVirtualFileSystem vfs) {
073: ResourceStatusWrapper statusWrapper = new ResourceStatusWrapper(
074: null, new VFSStatus());
075:
076: try {
077: VirtualFile vfFile = new VirtualFile(sPath);
078: vfFile.setContent(null);
079:
080: statusWrapper = vfs.addVirtualFile(sPath, vfFile);
081:
082: if (statusWrapper.getStatus().isOK()) {
083: this .m_bResourceCreated = true;
084: }
085: } catch (Exception e) {
086: e.printStackTrace();
087: }
088: return new PathStatusWrapper(null, statusWrapper.getStatus());
089: }
090:
091: /* (non-Javadoc)
092: * @see com.simulacramedia.contentmanager.editors.Editor#createNew(java.lang.String, byte[], com.simulacramedia.vfs.AbstractVirtualFileSystem)
093: */
094: public PathStatusWrapper createNew(String sPath, byte[] content,
095: AbstractVirtualFileSystem vfs) {
096: ResourceStatusWrapper statusWrapper = new ResourceStatusWrapper(
097: null, new VFSStatus());
098:
099: try {
100: VirtualFile vfFile = new VirtualFile(sPath);
101: vfFile.setContent(content);
102:
103: statusWrapper = vfs.addVirtualFile(sPath, vfFile);
104:
105: if (statusWrapper.getStatus().isOK()) {
106: this .m_bResourceCreated = true;
107: }
108: } catch (Exception e) {
109: e.printStackTrace();
110: }
111:
112: return new PathStatusWrapper(null, statusWrapper.getStatus());
113: }
114:
115: /* (non-Javadoc)
116: * @see com.simulacramedia.contentmanager.editors.Editor#discardChanges(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
117: */
118: public StatusData discardChanges(String sPath,
119: AbstractVirtualFileSystem vfs) {
120: return new VFSStatus();
121: }
122:
123: /* (non-Javadoc)
124: * @see com.simulacramedia.contentmanager.editors.Editor#export(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
125: */
126: public StatusData export(String sPath, AbstractVirtualFileSystem vfs) {
127: return new VFSStatus();
128: }
129:
130: /* (non-Javadoc)
131: * @see com.simulacramedia.contentmanager.editors.Editor#hasResourceBeenCreated()
132: */
133: public boolean hasResourceBeenCreated() {
134: return this .m_bResourceCreated;
135: }
136:
137: /* (non-Javadoc)
138: * @see com.simulacramedia.contentmanager.editors.Editor#preview(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
139: */
140: public PathStatusWrapper preview(String sPath,
141: AbstractVirtualFileSystem vfs) {
142: return new PathStatusWrapper(null, new VFSStatus());
143: }
144:
145: /* (non-Javadoc)
146: * @see com.simulacramedia.contentmanager.editors.Editor#upload(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
147: */
148: public PathStatusWrapper upload(String path,
149: AbstractVirtualFileSystem vfs) {
150: return new PathStatusWrapper(null, new VFSStatus());
151: }
152:
153: }
|