aboutsummaryrefslogtreecommitdiff
path: root/js/io/system/filesystem.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/system/filesystem.js')
-rw-r--r--js/io/system/filesystem.js723
1 files changed, 0 insertions, 723 deletions
diff --git a/js/io/system/filesystem.js b/js/io/system/filesystem.js
deleted file mode 100644
index 54c16a05..00000000
--- a/js/io/system/filesystem.js
+++ /dev/null
@@ -1,723 +0,0 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7var FileIo = require("js/io/system/fileio").FileIo,
8 ProjectIo = require("js/io/system/projectio").ProjectIo,
9 ShellApi = require("js/io/system/shellapi").ShellApi,
10 ComponentsPanelBase = require("js/panels/Components/ComponentsPanelBase.reel").ComponentsPanelBase;
11////////////////////////////////////////////////////////////////////////
12//Exporting as File System
13exports.FileSystem = (require("montage/core/core").Montage).create(Object.prototype, {
14 ////////////////////////////////////////////////////////////////////
15 //
16 init: {
17 enumerable: false,
18 value: function () {
19 //Called by NinjaMain
20
21
22
23 //Calling Shell API to initialize
24 ShellApi.init();
25 }
26 },
27
28 shellApiHandler :{
29 enumerable:true,
30 writable:false,
31 value:ShellApi
32 },
33
34
35 ////////////////////////////////////////////////////////////////////
36 //
37 cloud: {
38 enumerable: false,
39 value: false
40 },
41 ////////////////////////////////////////////////////////////////////
42 //
43 cloud: {
44 enumerable: false,
45 get: function() {
46 return this._cloud;
47 },
48 set: function(value) {
49 this._cloud = value
50 }
51 },
52
53
54
55
56
57
58 ////////////////////////////////////////////////////////////////////
59 //
60 _documentType: {
61 enumerable: false,
62 value: function () {
63 //return DocumentManagerModule.DocumentManager.activeDocument.documentType; // this._documentType()
64 }
65 },
66
67
68
69 ////////////////////////////////////////////////////////////////////
70 //
71 newFile: {
72 enumerable: false,
73 value: function (template) {
74 //Checking for cloud (to be added later)
75 if (this.cloud) {
76 //TODO: Add cloud integration
77 console.log("[CLOUD] New File");
78 //documentManagerModule.DocumentManager.openDocument({"type": "html"});
79 } else {
80 //
81 var file = {uri: ShellApi.openShellDialog({type: 'file', action: 'new'})}, type;
82 var check = ShellApi.fileExists(file);
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97 //TODO: implement createFile to avoid duplicate funtionality
98 if (check.success) {
99 switch (check.status) {
100 case 204:
101 //TODO: Add logic for already existing file
102 window.alert('Error Code 204: File already exists.');
103 break;
104 case 404:
105 //File does not exists, ready to be created
106
107
108 //TODO: The type (template) should be sent into this routine via the UI of file I/O (not by file extension as now)
109 if (template) {
110 type = template;
111 } else {
112 type = file.uri.split('.');
113 type = type[type.length-1];
114 }
115 //
116
117
118 //TODO: Improve logic
119 //Checking for file to exist in files template folder
120 var templateCheck = ShellApi.fileExists({uri: window.NativeShellApp.GetKnownFolder('appsource')+'\\document-templates\\files\\template.'+type}), content;
121 //
122 if (templateCheck.success) {
123 switch (check.status) {
124 case 204:
125 //Template exists, so opening and getting contents to be used when creating file
126 content = ShellApi.openFile({uri: 'template.'+type});
127 if (content.content) {
128 file.content = content.content;
129 } else {
130 file.content = "";
131 }
132 break;
133 case 404:
134 //No template
135 file.content = "";
136 break;
137 case 500:
138 //Error
139 break;
140 default:
141 //Error
142 break;
143 }
144 } else {
145
146 }
147
148
149 /*
150switch (type.toLowerCase()) {
151 case 'html':
152 break;
153 case 'css':
154 break;
155 case 'js':
156 break;
157 case 'xml':
158 break;
159 case 'json':
160 break;
161 default:
162 break;
163 }
164*/
165
166
167
168
169
170
171
172 var create = ShellApi.createFile(file);
173 if (create.success) {
174 switch (create.status) {
175 case 201:
176 //File was created, opening created file
177 this.openFile(file);
178 break;
179 case 400:
180 //TODO: Add error handling
181 //window.alert('Error Code 400: File already exists.');
182 break;
183 case 500:
184 //TODO: Add error handling
185 //window.alert('Error Code 500: An error occurred while creating a new file.');
186 break;
187 default:
188 //TODO: Add error handling
189 //window.alert('Unknown Error: An error occurred while creating a new file.');
190 break;
191 }
192 } else {
193 //window.alert('Unknown Error: An error occurred while creating a new file.');
194 }
195
196
197
198
199
200
201
202
203
204
205
206
207 break;
208 case 500:
209 //TODO: Add error handling
210 //window.alert('Error Code 500: An error occurred while creating a new file.');
211 break;
212 default:
213 //TODO: Add error handling
214 //window.alert('Unknown Error: An error occurred while creating a new file.');
215 break;
216 }
217 } else {
218 //TODO: Add error handling
219 //window.alert('Unknown Error: An error occurred while creating a new file.');
220 }
221 }
222
223 }
224 },
225
226