Fix #5829 - Messing around with flutter API
[roobuilder] / src / JsRender / Flutter.vala
1 /**
2  * 
3  *  this is the code represents a File when using the Gtk view..
4  *   
5  *  It ues NodeToGtk
6  * 
7  * 
8  */
9
10 namespace JsRender {
11
12
13  
14         
15
16   
17         public  class Flutter : JsRender
18         {
19            static int fid = 1;
20
21             public Flutter(Project.Project project, string path) {
22             
23                 base( project, path);
24                 this.xtype = "Flutter";
25                 this.language = "dart";
26                  
27                 this.id = "file-flutter-%d".printf(fid++);
28            
29
30                 
31                 
32             }
33               
34  
35
36                 public   override void   removeFiles() {
37                 /*
38                         var js = GLib.Path.get_dirname(this.path) +"/" +  name + ".js";
39                         if (FileUtils.test(js, FileTest.EXISTS)) {
40                                 GLib.FileUtils.remove(js);
41                         }
42                         var vala = GLib.Path.get_dirname(this.path) +"/" + name + ".vala";
43                         if (FileUtils.test(vala, FileTest.EXISTS)) {
44                                 GLib.FileUtils.remove(vala);
45                         }
46                         */
47                 }
48             
49                 public   override void  loadItems() throws GLib.Error // : function(cb, sync) == original was async.
50                 {
51                   
52                         print("load Items!\n");
53                         if (this.tree != null) {
54                                 this.loaded = true;
55                         
56                                 return;
57                         }
58                         /*
59                         print("load: %s\n" , this.path);
60                         if (!GLib.FileUtils.test(this.path, GLib.FileTest.EXISTS)) {
61                                 // new file?!?
62                                 this.tree = null;
63                                 this.loaded = true;
64                                 return;
65                         }
66                         */
67
68                         var pa = new Json.Parser();
69                         pa.load_from_file(this.path);
70                         var node = pa.get_root();
71                 
72                         if (node.get_node_type () != Json.NodeType.OBJECT) {
73                                 throw new Error.INVALID_FORMAT ("Unexpected element type %s", node.type_name ());
74                         }
75                         var obj = node.get_object ();
76                 
77                         this.name = obj.get_string_member("name");
78                         this.parent = obj.get_string_member("parent");
79                         this.title = obj.get_string_member("title");
80                 
81                          
82                         // load items[0] ??? into tree...
83                         var bjs_version_str = this.jsonHasOrEmpty(obj, "bjs-version");
84                         bjs_version_str = bjs_version_str == "" ? "1" : bjs_version_str;
85
86                         if (obj.has_member("items") 
87                                 && 
88                                 obj.get_member("items").get_node_type() == Json.NodeType.ARRAY
89                                 &&
90                                 obj.get_array_member("items").get_length() > 0
91                         ) {
92                                 var ar = obj.get_array_member("items");
93                                 var tree_base = ar.get_object_element(0);
94                                 this.tree = new Node();
95                                 this.tree.loadFromJson(tree_base, int.parse(bjs_version_str));
96
97                         }
98                         //NodeToVala.mungeFile(this); // force line numbering..
99                         this.loaded = true;
100                 
101                 }
102              
103             
104         
105             public override string toSourcePreview()
106             {
107                         return "";
108                 }
109             public override void setSource(string str) {}
110             
111             public override string toSourceCode() // no seed support currently.
112             {
113                     return  ""; ///NodeToVala.mungeFile(this);
114             }
115             
116             // this is only used by dumping code...
117             public override string toSource() // no seed support currently.
118             {
119                  
120                          
121                 return "";
122                 
123                 
124             }
125         
126             public override void save() {
127                 this.saveBJS();
128                 // this.saveJS(); - disabled at present.. project settings will probably enable this later..
129         
130                 //this.saveVala();
131             }
132                 // ignore these calls.
133             public override void saveHTML ( string html ) {}
134                 
135                         
136             /** 
137              *  saveJS
138              * 
139              * save as a javascript file. - not used currently
140              * why is this not save...???
141              * 
142              
143               
144             void saveJS()
145             {
146                  
147                 var fn = GLib.Path.get_dirname(this.path) + "/" + this.name + ".js";
148                 print("WRITE :%s\n " , fn);
149                 this.writeFile(fn, this.toSource());
150                 
151             }
152             */
153            void  saveVala()
154             {
155                         /*if (this.tree == null) {
156                                 return;
157                         }
158                         var fn = GLib.Path.get_dirname(this.path) + "/" + this.name + ".vala";
159                         print("WRITE :%s\n " , fn);
160                         this.writeFile(fn,  NodeToVala.mungeFile(this));
161                 */
162                 
163             }
164          
165             
166    
167             string getHelpUrl(string cls)
168             {
169                 return "http://devel.akbkhome.com/seed/" + cls + ".html";
170             }
171             public override void  findTransStrings(Node? node )
172                 {
173                         // not yet..
174                 }
175
176             
177           
178
179         
180
181         }
182 }
183
184
185