63aed3bb9a11dc3a70d29ae1e825754370ed415d
[app.Builder.js] / src / Builder4 / WindowState.vala
1 /**
2  * as state management is a bit too complicated inside the builder
3  * it's better to seperate this into this class
4  * 
5  * This class has references to all the Class instances that make up the window..
6  * 
7  */
8 public class WindowState : Object 
9 {
10         public Xcls_MainWindow win;
11
12         public enum State {
13                 NONE,
14                 PREVIEW,
15                 OBJECT,
16                 PROP,
17                 LISTENER,
18                 CODE,
19                 FILES,
20                 PROJECT // project settings..
21         }
22
23         public State state = State.NONE;
24
25         public bool children_loaded = false;
26
27         
28         public Xcls_WindowLeftTree  left_tree;
29         public Xcls_WindowAddProp   add_props;
30         public Xcls_LeftProps       left_props;
31         public Xcls_ProjectSettings projectsettings;
32         public ValaProjectSettings  vala_projectsettings;
33         public Xcls_RightPalete     rightpalete;
34         public Editor               code_editor;    
35         public Xcls_WindowRooView   window_rooview;
36         public Xcls_GtkView         window_gladeview;
37         
38         public Xcls_ClutterFiles     clutterfiles;
39
40         public Xcls_WindowLeftProjects left_projects; // can not see where this is initialized.. 
41         
42         public DialogTemplateSelect template_select; 
43         
44         public Xcls_DialogNewComponent new_file_dialog;
45         public Xcls_PopoverFileDetails file_details;
46         
47         
48         // dialogs??
49         public Xcls_DialogPluginWebkit webkit_plugin;
50         
51         // ctor 
52         public WindowState(Xcls_MainWindow win)
53         {
54                 this.win = win;
55                 // initialize
56
57                 // left elements..
58                 this.leftTreeInit();
59                 this.propsListInit();
60
61                 // on clutter space...
62                 this.projectEditInit();
63                 this.codeEditInit();
64                 this.projectListInit();
65                 this.fileViewInit();
66
67                 // adding stuff
68                 this.objectAddInit();
69                 this.propsAddInit();
70
71
72                 // previews...
73                 this.gtkViewInit();
74                 this.webkitViewInit();
75
76                 // dialogs
77
78                 this.fileNewInit(); // depricated...
79                 this.fileDetailsInit();
80
81                 this.webkit_plugin = new Xcls_DialogPluginWebkit();
82                 this.template_select = new DialogTemplateSelect();
83                 this.children_loaded = true;
84         }
85
86
87         // left tree
88
89         public void leftTreeInit()
90         {
91          
92                 this.left_tree = new Xcls_WindowLeftTree();
93                 this.left_tree.ref();
94                 this.left_tree.main_window = this.win;
95         
96                 this.win.tree.el.pack_start(this.left_tree.el,true, true,0);
97                 this.left_tree.el.show_all();
98                    
99                 this.left_tree.before_node_change.connect(() => {
100                         return this.leftTreeBeforeChange();
101
102                 });
103
104                 this.left_tree.node_selected.connect((sel) => {
105                         this.leftTreeNodeSelected(sel);
106                 });
107          
108                 this.left_tree.changed.connect(() => {
109                         this.window_rooview.requestRedraw();
110                         this.left_tree.model.file.save();
111                 });
112                  
113         }
114
115         public bool leftTreeBeforeChange()
116         {
117                 if (this.state != State.CODE) {
118                         this.left_props.finish_editing();
119                         return true;
120                 }
121                 if (!this.code_editor.saveContents()) {
122                         return false;
123                 }
124                 return false;
125         }
126         
127         public void leftTreeNodeSelected(JsRender.Node? sel)
128         {
129
130                 print("node_selected called %s\n", (sel == null) ? "NULL" : "a value");
131
132                 if (sel == null) {
133                         this.left_props.el.hide();
134                 } 
135                 this.left_props.el.show();
136                 this.left_props.load(this.left_tree.getActiveFile(), sel);
137                 switch (this.state) {
138                         
139                         case State.OBJECT: 
140                                   
141                                  if (sel == null) {
142                                         this.rightpalete.clear();
143                                         break;
144                                 }
145                                 this.rightpalete.load(this.left_tree.getActiveFile().palete(), sel.fqn());
146                                 break;
147                                  
148                 
149                    case State.PROP:
150                                 if (sel == null) {
151                                         this.add_props.clear();
152                                         break;
153                                 }
154                                 this.add_props.show(this.left_tree.getActiveFile().palete(), "props", sel.fqn());
155                                 break;
156
157                         case State.LISTENER:
158                            
159                                 if (sel == null) {
160                                         this.add_props.clear();
161                                         break;
162                                 }
163                                 this.add_props.show(this.left_tree.getActiveFile().palete(), "signals", sel.fqn());
164                                 break;
165                                 
166                         case State.CODE:
167                                  this.switchState(State.PREVIEW);
168                          
169                                 break;
170                            
171                                                         
172                 }
173                  
174
175         }
176
177
178
179
180         public void propsListInit()
181         {
182         
183                 this.left_props =new Xcls_LeftProps();
184                 this.left_props.ref();
185                 this.left_props.main_window = this.win;
186                 this.win.props.el.pack_start(this.left_props.el,true, true,0);
187                 this.left_props.el.show_all();
188         
189                 this.left_props.show_editor.connect( (file, node, type,  key) => {
190                         this.switchState(State.CODE);
191                         this.code_editor.show(
192                                 file,
193                                 node,
194                                 type,
195                                 key
196                         );
197                         
198                         
199                 });
200
201    
202                 this.left_props.stop_editor.connect( () => {
203                         if (this.state != State.CODE) {
204                                 return true;
205                         }
206         
207                         var ret =  this.code_editor.saveContents();
208                         if (!ret) {
209                                 return false;
210                         }
211                         this.switchState(State.PREVIEW);
212                         return ret;
213                 });
214         
215                 this.left_props.changed.connect(() => {
216                           if (this.left_tree.getActiveFile().xtype == "Roo" ) {
217                                    this.window_rooview.requestRedraw();
218                                    
219                            } else {
220                                   this.window_gladeview.loadFile(this.left_tree.getActiveFile());
221                           }
222                           this.left_tree.model.updateSelected();
223                           this.left_tree.model.file.save();
224                 });
225         
226
227
228         }
229
230         //-------------  projects edit
231
232         public void projectEditInit()
233         {
234                 this.projectsettings  =new Xcls_ProjectSettings();
235                 this.projectsettings.ref();  /// really?
236         
237                 this.vala_projectsettings  =new ValaProjectSettings();
238                 this.vala_projectsettings.ref();
239                 this.vala_projectsettings.window = this.win;
240         
241                 ((Gtk.Container)(this.win.projecteditview.el.get_widget())).add(this.projectsettings.el);
242                 //this.projectsettings.el.show_all();
243
244                 var stage = this.win.projecteditview.el.get_stage();
245                 stage.set_background_color(  Clutter.Color.from_string("#000"));
246         
247                 this.projectsettings.buttonPressed.connect((btn) => {
248                          if (this.left_tree.getActiveFile().xtype == "Roo" ) {
249                                 if (btn == "save") {
250                                         this.window_rooview.view.renderJS(true);
251                                 }
252                                 if (btn == "apply") {
253                                         this.window_rooview.view.renderJS(true);
254                                         return;
255                                 }
256                         } else {
257                                 // do nothing for gtk..
258                         }
259                         if (btn == "save" || btn == "apply") {
260                                 this.win.project.save();
261                  
262                         }
263                         this.switchState (State.PREVIEW); 
264                          
265                  });
266
267         }
268         // ----------- object adding
269         public void objectAddInit()
270         {
271
272                 this.rightpalete  = new Xcls_RightPalete();
273                 this.rightpalete.ref();  /// really?
274                 ((Gtk.Container)(this.win.objectview.el.get_widget())).add(this.rightpalete.el);
275                 //this.projectsettings.el.show_all();
276
277                 var stage = this.win.objectview.el.get_stage();
278                 stage.set_background_color(  Clutter.Color.from_string("#000"));
279                    
280         }
281         
282         // -----------  properties adding list...
283         // listener uses the properties 
284         public void propsAddInit()
285         {
286         // Add properties
287                 this.add_props  = new Xcls_WindowAddProp();
288                 this.add_props.ref();  /// really?
289                 ((Gtk.Container)(this.win.addpropsview.el.get_widget())).add(this.add_props.el);
290                 //this.projectsettings.el.show_all();
291
292                 var  stage = this.win.addpropsview.el.get_stage();
293                 stage.set_background_color(  Clutter.Color.from_string("#000"));
294
295
296                 this.add_props.select.connect( (key,type,skel, etype) => {
297                         this.left_props.addProp(etype, key, skel, type);
298                 });
299
300         }
301         public void propsAddShow()
302         {
303
304         }
305         public void propsAddHide()
306         {
307         
308         }
309
310
311
312         
313         // ----------- Add / Edit listener
314         // listener uses the properties 
315         //public void listenerInit()     { }
316         public void listenerShow()
317         {
318
319         }
320         public void listenerHide()
321         {
322         
323         }
324
325         // -------------- codeEditor
326
327         public void codeEditInit()
328         {
329                 this.code_editor  = new  Editor();
330                 this.code_editor.ref();  /// really?
331                 ((Gtk.Container)(this.win.codeeditview.el.get_widget())).add(this.code_editor.el);
332                 //this.projectsettings.el.show_all();
333
334                 var stage = this.win.codeeditview.el.get_stage();
335                 stage.set_background_color(  Clutter.Color.from_string("#000"));
336                 // editor.save...
337
338                 this.code_editor.save.connect( () => {
339                          this.left_tree.model.file.save();
340                          this.left_tree.model.updateSelected();
341                 });
342                 
343         }
344
345         // ----------- list of projects on left
346         public void  projectListInit() 
347         {
348
349                 this.left_projects = new Xcls_WindowLeftProjects();
350                  this.left_projects.ref();
351                  this.win.leftpane.el.pack_start(this.left_projects.el,true, true,0);
352                  this.left_projects.el.show_all();
353                  this.left_projects.project_selected.connect((proj) => {
354                         proj.scanDirs();
355                         this.clutterfiles.loadProject(proj);
356                 
357                  });
358
359         }
360         // ----------- file view
361
362         public void fileViewInit()
363         {
364                 var stage = this.win.rooview.el.get_stage(); // seems odd... 
365                 this.clutterfiles = new Xcls_ClutterFiles();
366                 this.clutterfiles.ref();
367                 stage.add_child(this.clutterfiles.el);
368                 this.clutterfiles.el.show_all();
369
370
371                 this.clutterfiles.open.connect((file) => { 
372                         this.fileViewOpen(file);
373                 });
374                 this.clutterfiles.el.transitions_completed.connect(() => {
375                         if (this.state == State.FILES) {
376                                 this.win.rooview.el.hide();
377                         } else {
378                                 this.clutterfiles.el.hide();
379                         }
380                         
381                         
382                 });
383
384         }
385  
386         public void fileDetailsInit()
387         {
388                 this.file_details = new Xcls_PopoverFileDetails();
389                 this.file_details.mainwindow = this.win;
390                 // force it modal to the main window..
391                 
392                 this.file_details.success.connect((project,file) =>
393                 {
394                         this.fileViewOpen(file);
395                 });
396
397         }
398         
399         public void fileViewOpen(JsRender.JsRender file)
400         {
401                 this.win.project = file.project;
402                 this.switchState (State.PREVIEW); 
403         
404                 this.left_tree.model.loadFile(file);
405         
406                 var ctr= ((Gtk.Container)(this.win.rooview.el.get_widget()));
407                 var ctr_p= ((Gtk.Container)(this.win.projecteditview.el.get_widget()));
408         
409                 if (file.xtype == "Roo" ) { 
410                         ctr.foreach( (w) => { ctr.remove(w); });
411                         ctr_p.foreach( (w) => { ctr_p.remove(w); });
412                         ctr.add(this.window_rooview.el);
413                         ctr_p.add(this.projectsettings.el);            
414                         this.window_rooview.loadFile(file);
415                         this.window_rooview.el.show_all();
416                         this.projectsettings.el.show_all();            
417
418                 } else {
419                         ctr.foreach( (w) => { ctr.remove(w); });
420                         ctr_p.foreach( (w) => { ctr_p.remove(w); });            
421                         ctr.add(this.window_gladeview.el);
422                         ctr_p.add(this.vala_projectsettings.el);
423                         this.window_gladeview.loadFile(file);
424                         this.window_gladeview.el.show_all();
425                         this.vala_projectsettings.el.show_all();
426                 }
427                 print("OPEN : " + file.name);
428                 this.win.editpane.el.set_position(this.win.editpane.el.max_position);
429                 this.win.setTitle(file.project.name + " : " +file.name);
430                          
431
432                 }
433
434         
435         // ---------  webkit view
436         public void webkitViewInit()
437         {
438                 this.window_rooview  =new Xcls_WindowRooView();
439                 this.window_rooview.ref();
440                 ((Gtk.Container)(this.win.rooview.el.get_widget())).add(this.window_rooview.el);
441                 this.window_rooview.el.show_all();
442
443                 var stage = this.win.rooview.el.get_stage();
444                 stage.set_background_color(  Clutter.Color.from_string("#000"));
445         }
446
447         // ------ Gtk  - view
448
449         public void gtkViewInit()
450         {
451                 this.window_gladeview  =new Xcls_GtkView();
452                 this.window_gladeview.ref();
453                 this.window_gladeview.main_window = this.win;
454         }
455         
456         public void easingSaveAll()
457         {
458                 this.win.addpropsview.el.save_easing_state();
459                 this.win.codeeditview.el.save_easing_state();
460                 this.win.objectview.el.save_easing_state();
461                 this.win.projecteditview.el.save_easing_state();
462                 this.win.rooview.el.save_easing_state();
463                 this.clutterfiles.el.save_easing_state();
464                  
465         }
466         public void easingRestoreAll()
467         {
468                 this.win.addpropsview.el.restore_easing_state();
469                 this.win.codeeditview.el.restore_easing_state();
470                 this.win.objectview.el.restore_easing_state();
471                 this.win.projecteditview.el.restore_easing_state();
472                 this.win.rooview.el.restore_easing_state();
473                 this.clutterfiles.el.restore_easing_state();
474                 
475         }
476         public void switchState(State new_state)
477         {
478                 
479                 // save the easing state of everything..
480                 this.easingSaveAll();
481                 
482                 switch (this.state) {
483
484                         case State.PREVIEW:
485                                 if (this.left_tree.getActiveFile() != null) {
486                                          if (this.left_tree.getActiveFile().xtype == "Roo" ) {
487                                                  this.window_rooview.createThumb();
488                                          } else {
489                                                   this.window_gladeview.createThumb();
490                                           }
491                                 }
492                                 // normally we are going from preview to another state.
493                                 // and different windows hide the preview in differnt ways..
494                                 
495                                 break;
496                         
497                    case State.LISTENER:
498                    case State.PROP:
499                                 
500                                 this.win.addpropsview.el.set_scale(0.0f,0.0f);
501                                  break;
502                                 
503                         case State.CODE:
504
505
506                                 this.code_editor.saveContents();
507                           
508                                 this.win.codeeditview.el.set_scale(0.0f,0.0f);
509                                  break;
510
511
512                          case State.OBJECT:
513                            
514                                 this.win.objectview.el.set_scale(0.0f,0.0f);
515                                  break;
516
517                    case State.PROJECT:
518                                 if (this.win.project.xtype == "Gtk") {
519                                         this.vala_projectsettings.save();
520                                 } 
521                                 
522                                 this.win.projecteditview.el.set_scale(0.0f,0.0f);
523                                  break;
524
525                   case State.FILES:
526                                 // hide files...
527                                 
528                                 this.win.rooview.el.show_all();
529                                 this.win.rooview.el.set_easing_duration(1000);
530                                 this.win.rooview.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f);
531                                 this.win.rooview.el.set_scale(1.0f,1.0f);
532                                 this.win.rooview.el.set_pivot_point(0.5f,0.5f);
533                                 this.win.rooview.el.set_opacity(0xff);
534                            
535                                 
536                            
537                                  this.clutterfiles.el.set_easing_duration(1000);
538                                 this.clutterfiles.el.set_pivot_point(0.5f,0.5f);
539                                 this.clutterfiles.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, -180.0f);
540                                 this.clutterfiles.el.set_opacity(0);
541  
542                                 //this.clutterfiles.el.hide();
543                                  
544
545                                 break;
546
547                                 
548                 }
549            
550                 var oldstate  =this.state;
551                 this.state = new_state;
552                 
553                 
554                                 
555                 this.buttonsShowHide();
556                 
557                 
558                 switch (this.state) {
559                         
560                         case State.PREVIEW:  // this is the default state when working...
561                                  this.win.editpane.el.show(); // holder for tree and properties..
562                                  
563                          
564                                  this.left_projects.el.hide(); 
565                                  if (oldstate != State.FILES) {
566                                         // it's handled above..
567                                         print ("changing state to preview from NOT files..");
568                                          
569  
570                                         this.win.rooview.el.set_scale(1.0f,1.0f);
571                                  }
572                            
573                                 break;
574
575
576                         case State.LISTENER:
577                 // same as prop?
578                         case State.PROP:
579                                 var ae =      this.left_tree.getActiveElement();
580                                 if (ae == null) {
581                                         this.state = oldstate;
582                                         this.buttonsShowHide();
583                                         this.resizeCanvasElements();
584                                         this.easingRestoreAll();
585                                         return;
586                                 }
587                                 this.add_props.el.show_all();
588                                 this.add_props.show(
589                                         Palete.factory(this.win.project.xtype), 
590                                         this.state == State.LISTENER ? "signals" : "props",
591                                         ae.fqn()
592                                 );
593  
594                                         
595  
596                                 
597                                 // -- FIXME? this needs to be State aware?
598                  
599                                 this.win.rooview.el.set_pivot_point(1.0f,0.5f);
600                                   
601                                 this.win.addpropsview.el.set_scale(1.0f,1.0f);
602                                  break;
603                    
604                         case State.OBJECT:
605                                  var n = this.left_tree.getActiveElement();
606
607                                 if (this.left_tree.model.file == null) {
608                                         this.state =oldstate;
609                                         this.buttonsShowHide();
610                                         this.resizeCanvasElements();
611                                         this.easingRestoreAll();
612                                         return;
613                                 }
614                                 
615                                 if (n == null && this.left_tree.model.file.tree != null) {
616                                         this.state = oldstate;
617                                         this.buttonsShowHide();
618                                         this.resizeCanvasElements();
619                                         this.easingRestoreAll();
620                                         return;
621                                 }
622
623                                 this.rightpalete.el.show_all();
624                                 this.rightpalete.load(this.left_tree.getActiveFile().palete(), n == null ? "*top" : n.fqn());
625
626                                 
627                           
628                         
629                                 this.win.objectview.el.set_scale(1.0f,1.0f);
630                                  
631                                 break;
632                    
633                    
634                         case State.CODE:
635
636                                 this.code_editor.el.show_all();
637                                 
638                                 // caller needs to call editor - show....
639                                   
640  
641                                  this.win.codeeditview.el.set_scale(1.0f,1.0f);
642                                  break;
643
644
645
646                    case State.PROJECT:
647
648                            if (this.win.project.xtype == "Roo") {
649                                         this.projectsettings.el.show_all();
650                                         this.projectsettings.show(this.win.project);
651                                 } else {
652                                         this.vala_projectsettings.el.show_all();
653                                         this.vala_projectsettings.show((Project.Gtk)this.win.project);
654                                 }
655
656                                 this.win.rooview.el.set_pivot_point(1.0f,1.0f); // bottom right..
657                                 
658                                 this.win.projecteditview.el.set_scale(1.0f,1.0f);
659                                 
660                            
661                                 break;
662                                 
663                    case State.FILES:  // can only get here from PREVIEW state.. in theory..
664                                 
665    
666                                 this.win.editpane.el.hide(); // holder for tree and properties..
667                          
668                                 this.left_projects.el.show(); 
669                         
670                                  this.win.rooview.el.set_easing_duration(1000);
671                                 this.win.rooview.el.set_pivot_point(0.5f,0.5f);
672                                 this.win.rooview.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 180.0f);
673                                 this.win.rooview.el.set_opacity(0);
674                                 //el.set_scale(0.0f,0.0f);
675
676  
677                                 if (this.win.project != null) {
678                                         this.left_projects.selectProject(this.win.project);
679                                 }
680                          
681                                 
682                                 this.clutterfiles.el.show_all();
683                                  
684                                 this.clutterfiles.el.set_easing_duration(1000);
685                                 this.clutterfiles.el.set_pivot_point(0.5f,0.5f);
686                                 this.clutterfiles.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f);
687                                 this.clutterfiles.el.set_opacity(0xff);
688                                 
689                                 
690                                 
691                                 break;
692
693
694                 }
695                 this.resizeCanvasElements();
696                 this.easingRestoreAll();
697                 
698                         
699         }
700         
701         public int redraw_count = 0;
702         public void resizeCanvas() // called by window resize .. delays redraw
703         {
704                 var rc = this.redraw_count;        
705                 this.redraw_count = 2;
706                 if (rc == 0) {
707                         GLib.Timeout.add(100,  ()  =>{
708                                  return this.resizeCanvasQueue();
709                         });
710                 }
711         }
712         public bool  resizeCanvasQueue()
713         {
714                 //print("WindowState.resizeCanvasQueue %d\n", this.redraw_count);        
715
716                 if (this.redraw_count < 1) {
717                         return false; // should not really happen...
718                 }
719
720
721                 this.redraw_count--;
722
723                 if (this.redraw_count > 0) {
724                         return true; // do it again in 1 second...
725                 }
726                 // got down to 0 or -1....
727                 this.redraw_count = 0;
728                 this.resizeCanvasElements();
729                 return false;
730
731         }
732         public void resizeCanvasElements()
733         {
734                 Gtk.Allocation alloc;
735                 this.win.clutterembed.el.get_allocation(out alloc);
736
737            // print("WindowState.resizeCanvasElements\n");
738                 if (!this.children_loaded || this.win.clutterembed == null) {
739                         print("WindowState.resizeCanvasElements = ingnore not loaded or no clutterfiles\n");
740                         return; 
741                 }
742                 
743                 var avail = alloc.width < 50.0f ? 0 :  alloc.width - 50.0f;
744                 var palsize = avail < 300.0f ? avail : 300.0f;
745                    
746  
747                 // -------- code edit min 600
748                 
749                 var codesize = avail < 800.0f ? avail : 800.0f;
750                 
751                 
752                 //print("set code size %f\n", codesize);
753
754                         
755                 
756                 switch ( this.state) {
757                         case State.PREVIEW:
758                                 this.win.rooview.el.set_size(alloc.width-50, alloc.height);
759                                 break;
760         
761                         case State.FILES: 
762                                 this.clutterfiles.set_size(alloc.width-50, alloc.height);
763                                 break;
764
765                         case State.PROJECT:
766                  
767                                 this.win.projecteditview.el.set_size(alloc.width-50, alloc.height / 2.0f);
768                 
769                            // this.win.rooview.el.save_easing_state();
770                                 //this.win.rooview.el.set_size(alloc.width / 2.0f, alloc.height / 2.0f);
771                                 this.win.rooview.el.set_scale(0.5f, 0.5f);
772                                 //this.win.rooview.el.restore_easing_state();
773                                 break;
774
775                         case State.CODE: 
776                                 this.win.codeeditview.el.set_size(codesize, alloc.height);
777                                 var scale = avail > 0.0f ? (avail - codesize -10 ) / avail : 0.0f;
778                                 //this.win.rooview.el.save_easing_state();
779                                  
780                                 this.win.rooview.el.set_scale(scale,scale);
781                            // this.win.rooview.el.restore_easing_state();
782                                 break;
783                                 
784                         case State.PROP:
785                         case State.LISTENER:
786                                  this.win.addpropsview.el.set_size(palsize, alloc.height);
787                                 var scale = avail > 0.0f ? (avail - palsize -10 ) / avail : 0.0f;
788                                 this.win.rooview.el.set_scale(scale,scale);
789                                 break;
790                                 
791                         case State.OBJECT:  
792                                 this.win.objectview.el.set_size(palsize, alloc.height);    
793                                 var scale = avail > 0.0f ? (avail - palsize -10 ) / avail : 0.0f;
794                                 //this.win.rooview.el.save_easing_state();
795                                 this.win.rooview.el.set_scale(scale,scale);
796                            // this.win.rooview.el.restore_easing_state();
797                                 break;
798                 }
799         }
800
801         // -- buttons show hide.....
802
803         public void buttonsShowHide()
804         {
805                 // basically hide everything, then show the relivant..
806
807                  this.win.backbutton.el.hide();
808         
809                 this.win.projectbutton.el.hide(); // show file nav...
810                 this.win.editfilebutton.el.hide();
811                 this.win.projecteditbutton.el.hide();
812                  
813                 
814                 this.win.objectshowbutton.el.hide(); // add objects
815                 this.win.addpropbutton.el.hide();  
816                 this.win.addlistenerbutton.el.hide(); 
817
818         
819         
820                 this.win.addprojectbutton.el.hide();
821                 this.win.addfilebutton.el.hide();
822                 this.win.delprojectbutton.el.hide();
823                   
824                 
825                 switch (this.state) {
826                         
827                         case State.PREVIEW:  // this is the default state when working...
828                            
829                                 this.win.projectbutton.el.show(); // show file nav...
830                                 this.win.editfilebutton.el.show();
831                                 this.win.projecteditbutton.el.show();
832                                  
833                                 
834                                 this.win.objectshowbutton.el.show(); // add objects
835                                 this.win.addpropbutton.el.show();  
836                                 this.win.addlistenerbutton.el.show(); 
837                                 break;
838                         
839                    
840                         case State.CODE: 
841                         case State.PROP:
842                         case State.LISTENER:
843                         case State.OBJECT:
844                                 
845                                 this.win.backbutton.el.show();
846                                 this.win.objectshowbutton.el.show(); // add objects
847                                 this.win.addpropbutton.el.show();  
848                                 this.win.addlistenerbutton.el.show(); 
849                                 break;
850                         
851                         case State.PROJECT: 
852                                 // anything else?
853                                 this.win.backbutton.el.show();
854                                 break;
855                         
856         
857                         case State.FILES:
858                                 if (this.left_projects.getSelectedProject() != null ) {
859                                         if (this.left_tree.getActiveFile() != null) {
860                                                 this.win.backbutton.el.show();
861                                         }
862                                         this.win.addfilebutton.el.show();
863                                 }
864                                          
865                                 this.win.addprojectbutton.el.show();
866                                 this.win.delprojectbutton.el.show();
867                                 
868                                 break;
869                 }
870
871         }
872
873         
874 }
875
876