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 java.io.*;
022: import java.net.*;
023:
024: import org.openharmonise.vfs.*;
025: import org.openharmonise.vfs.status.*;
026:
027: /**
028: * The generic editor simply creates a local working work and hands
029: * responsibility for choosing and launching an appropriate editor off to
030: * the operating system. Implementor of the {@link org.openharmonise.him.editors.Editor}
031: * interface that only wish to so pre/post processing should extend this
032: * class.
033: *
034: * @author Matthew Large
035: * @version $Revision: 1.1 $
036: *
037: */
038: public abstract class GenericEditor extends AbstractEditor implements
039: Editor {
040:
041: /**
042: * Default constructor.
043: */
044: public GenericEditor() {
045: super ();
046: }
047:
048: /* (non-Javadoc)
049: * @see com.simulacramedia.contentmanager.editors.Editor#open(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
050: */
051: public PathStatusWrapper open(String sPath,
052: AbstractVirtualFileSystem vfs) {
053:
054: VirtualFile vfFile = vfs.getVirtualFile(sPath).getResource();
055:
056: String sWorkingFilePath = super .createWorkingFile(vfFile);
057:
058: File fFile = new File(sWorkingFilePath);
059:
060: try {
061: Process proc5 = Runtime.getRuntime().exec(
062: "rundll32 url.dll,FileProtocolHandler file:/"
063: + fFile.toURI().getPath());
064: } catch (MalformedURLException e1) {
065: e1.printStackTrace();
066: } catch (IOException e1) {
067: e1.printStackTrace();
068: }
069:
070: PathStatusWrapper pathStatus = new PathStatusWrapper(
071: sWorkingFilePath, new VFSStatus());
072: return pathStatus;
073: }
074:
075: /* (non-Javadoc)
076: * @see com.simulacramedia.contentmanager.editors.Editor#createNew(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
077: */
078: public PathStatusWrapper createNew(String sPath,
079: AbstractVirtualFileSystem vfs) {
080: PathStatusWrapper pathStatus = new PathStatusWrapper(null,
081: new VFSStatus());
082: return pathStatus;
083: }
084:
085: /* (non-Javadoc)
086: * @see com.simulacramedia.contentmanager.editors.Editor#export(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
087: */
088: public StatusData export(String sPath, AbstractVirtualFileSystem vfs) {
089: return new VFSStatus();
090: }
091:
092: /* (non-Javadoc)
093: * @see com.simulacramedia.contentmanager.editors.Editor#createNew(java.lang.String, byte[], com.simulacramedia.vfs.AbstractVirtualFileSystem)
094: */
095: public PathStatusWrapper createNew(String sPath, byte[] content,
096: AbstractVirtualFileSystem vfs) {
097: PathStatusWrapper pathStatus = new PathStatusWrapper(null,
098: new VFSStatus());
099: return pathStatus;
100: }
101:
102: /* (non-Javadoc)
103: * @see com.simulacramedia.contentmanager.editors.Editor#preview(java.lang.String, byte[], com.simulacramedia.vfs.AbstractVirtualFileSystem)
104: */
105: public PathStatusWrapper preview(String sPath,
106: AbstractVirtualFileSystem vfs) {
107: VirtualFile vfFile = vfs.getVirtualFile(sPath).getResource();
108: String sFilename = this .getFileName(vfFile);
109: File fFile = super .createPreviewFile(sFilename, vfFile
110: .getContent());
111: try {
112: Process proc5 = Runtime.getRuntime().exec(
113: "rundll32 url.dll,FileProtocolHandler file:/"
114: + fFile.toURI().getPath());
115: } catch (MalformedURLException e1) {
116: e1.printStackTrace();
117: } catch (IOException e1) {
118: e1.printStackTrace();
119: }
120: PathStatusWrapper pathStatus = new PathStatusWrapper(fFile
121: .getAbsolutePath(), new VFSStatus());
122: return pathStatus;
123: }
124:
125: /* (non-Javadoc)
126: * @see com.simulacramedia.contentmanager.editors.Editor#upload(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
127: */
128: public PathStatusWrapper upload(String path,
129: AbstractVirtualFileSystem vfs) {
130: PathStatusWrapper pathStatus = new PathStatusWrapper(null,
131: new VFSStatus());
132: return pathStatus;
133: }
134: }
|