KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.io.*;
22 import java.net.*;
23
24 import org.openharmonise.vfs.*;
25 import org.openharmonise.vfs.status.*;
26
27
28 /**
29  * The generic editor simply creates a local working work and hands
30  * responsibility for choosing and launching an appropriate editor off to
31  * the operating system. Implementor of the {@link org.openharmonise.him.editors.Editor}
32  * interface that only wish to so pre/post processing should extend this
33  * class.
34  *
35  * @author Matthew Large
36  * @version $Revision: 1.1 $
37  *
38  */

39 public abstract class GenericEditor extends AbstractEditor implements Editor {
40
41     /**
42      * Default constructor.
43      */

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

51     public PathStatusWrapper open(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
52         
53         VirtualFile vfFile = vfs.getVirtualFile(sPath).getResource();
54         
55         String JavaDoc sWorkingFilePath = super.createWorkingFile(vfFile);
56
57         File fFile = new File(sWorkingFilePath);
58         
59         try {
60             Process JavaDoc proc5 = Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler file:/" + fFile.toURI().getPath() );
61         } catch (MalformedURLException e1) {
62             e1.printStackTrace();
63         } catch (IOException e1) {
64             e1.printStackTrace();
65         }
66
67         PathStatusWrapper pathStatus = new PathStatusWrapper(sWorkingFilePath, new VFSStatus());
68         return pathStatus;
69     }
70
71     /* (non-Javadoc)
72      * @see com.simulacramedia.contentmanager.editors.Editor#createNew(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
73      */

74     public PathStatusWrapper createNew(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
75         PathStatusWrapper pathStatus = new PathStatusWrapper(null, new VFSStatus());
76         return pathStatus;
77     }
78
79     /* (non-Javadoc)
80      * @see com.simulacramedia.contentmanager.editors.Editor#export(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
81      */

82     public StatusData export(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
83         return new VFSStatus();
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(String JavaDoc sPath, byte[] content, AbstractVirtualFileSystem vfs) {
90         PathStatusWrapper pathStatus = new PathStatusWrapper(null, new VFSStatus());
91         return pathStatus;
92     }
93     
94     /* (non-Javadoc)
95      * @see com.simulacramedia.contentmanager.editors.Editor#preview(java.lang.String, byte[], com.simulacramedia.vfs.AbstractVirtualFileSystem)
96      */

97     public PathStatusWrapper preview(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
98         VirtualFile vfFile = vfs.getVirtualFile(sPath).getResource();
99         String JavaDoc sFilename = this.getFileName(vfFile);
100         File fFile = super.createPreviewFile(sFilename, vfFile.getContent());
101         try {
102             Process JavaDoc proc5 = Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler file:/" + fFile.toURI().getPath() );
103         } catch (MalformedURLException e1) {
104             e1.printStackTrace();
105         } catch (IOException e1) {
106             e1.printStackTrace();
107         }
108         PathStatusWrapper pathStatus = new PathStatusWrapper(fFile.getAbsolutePath(), new VFSStatus());
109         return pathStatus;
110     }
111
112     /* (non-Javadoc)
113      * @see com.simulacramedia.contentmanager.editors.Editor#upload(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
114      */

115     public PathStatusWrapper upload(String JavaDoc path, AbstractVirtualFileSystem vfs) {
116         PathStatusWrapper pathStatus = new PathStatusWrapper(null, new VFSStatus());
117         return pathStatus;
118     }
119 }
120
Popular Tags