Pman.Tab.BuilderTree.bjs
[Pman.Builder] / Pman.Tab.BuilderTree.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5
6
7 // register the module first
8 Pman.on('beforeload', function()
9 {
10     Pman.register({
11         part :  ["Builder","Tree"],
12         modKey : '001-Pman.Tab.BuilderTree',
13         module : Pman.Tab.BuilderTree,
14         region : 'center',
15         parent : Pman.Tab.BuilderTab,
16         name : "Pman.Tab.BuilderTree",
17         disabled : false, 
18         permname: '' 
19     });
20 });
21
22 Pman.Tab.BuilderTree = new Roo.util.Observable({
23
24     panel : false,
25     disabled : false,
26     parentLayout:  false,
27
28     add : function(parentLayout, region)
29     {
30
31         var _this = this;
32         this.parentLayout = parentLayout;
33
34         this.panel = parentLayout.addxtype({
35             xtype: 'NestedLayoutPanel',
36             xns: Roo,
37             region : 'west',
38             layout : {
39                 xtype: 'BorderLayout',
40                 xns: Roo,
41                 items : [
42                     {
43                         xtype: 'TreePanel',
44                         xns: Roo,
45                         listeners : {
46                             activate : function (_self)
47                             {
48                                 
49                                 _this.tree = _self.tree;
50                                 _this.menu = _self.menu;
51                             
52                                 if (_this.hasMouseEvent) {
53                                     return;
54                                 }
55                                 
56                                 _this.hasMouseEvent = true;
57                                  this.el.on('mouseover', function() { _this.isMouseOver= true; });
58                                 this.el.on('mouseout', function() { _this.isMouseOver = false; });
59                             
60                             }
61                         },
62                         region : 'center',
63                         tree : {
64                             xtype: 'TreePanel',
65                             xns: Roo.tree,
66                             listeners : {
67                                 beforenodedrop : function (e)
68                                 {
69                                     
70                                     return Pman.Builder.Tree.handleDropNode(e);      
71                                 
72                                 },
73                                 click : function (node, e)
74                                 {
75                                       e.preventDefault();
76                                                        // console.log(e.button);
77                                         Pman.Builder.Tree.setCurrentNode(node);
78                                         
79                                     
80                                         
81                                 
82                                 },
83                                 contextmenu : function (node, e)
84                                 {
85                                     e.stopEvent();
86                                         
87                                     this.getSelectionModel().select(node);
88                                      Pman.Builder.Tree.setCurrentNode(node);
89                                      
90                                           _this.menu = Roo.factory(_this.menu);
91                                 
92                                         _this.menu.show(node.ui.textNode, 'tr');
93                                      return;
94                                      
95                                      /*
96                                     var xt = node.elConfig.xtype;
97                                     var altx= false;
98                                     if (typeof(node.elConfig['*prop']) != 'undefined') {
99                                         altx = node.parentNode.elConfig.xtype +'.' + node.elConfig['*prop'];
100                                     }
101                                     var mn = Pman.Tab.BuilderPalete.getMenu(xt,altx);
102                                     
103                                     
104                                     if (mn) {
105                                         mn.show(e.getTarget());
106                                     }
107                                     
108                                  */
109                                 
110                                 },
111                                 nodedragover : function (e)
112                                 {
113                                     
114                                         return Pman.Builder.Tree.handleDragOver(e);      
115                                  
116                                      
117                                    
118                                 }
119                             },
120                             animate : false,
121                             containerScroll : true,
122                             ddGroup : 'component',
123                             enableDD : true,
124                             rootVisible : true,
125                             renderer : function(n) { return n.text; },
126                             sm : {
127                                 xtype: 'DefaultSelectionModel',
128                                 xns: Roo.tree
129                             },
130                             root : {
131                                 xtype: 'TreeNode',
132                                 xns: Roo.tree,
133                                 text : "Part",
134                                 elConfig : function() {
135                                     return  {
136                                          xtype : '*top',
137                                             
138                                             app : 'TestApp',
139                                             // perm
140                                             // permtype
141                                             modkey : 0,
142                                             '|module' :  '',
143                                             region : 'center',
144                                             '|parent' : 'Pman',
145                                             name : "Module Name",
146                                             items: [] 
147                                 
148                                     
149                                     }
150                                 }
151                             }
152                         },
153                         menu : {
154                             xtype: 'Menu',
155                             xns: Roo.menu,
156                             items : [
157                                 {
158                                     xtype: 'Item',
159                                     xns: Roo.menu,
160                                     listeners : {
161                                         click : function (_self)
162                                         {
163                                             
164                                             var str = Pman.Builder.Tree.currentNodeType();
165                                             if (typeof(Pman.Builder.Wizard[str]) == 'undefined') {
166                                                 Roo.MessageBox.alert("Sorry", "No wizard exists for " + str);
167                                                 return;
168                                             }
169                                             var cn = Pman.Builder.Tree.currentNode;
170                                             if (typeof(cn.elConfig['.builderCfg']) == 'undefined') {
171                                                 Roo.MessageBox.alert("Sorry", "No configuration exists for " + str);
172                                                 return;
173                                             }
174                                             
175                                             
176                                             var cfg = Roo.decode(cn.elConfig['.builderCfg']);
177                                             Roo.log(cfg);
178                                             Pman.Dialog.BuilderAddTable.show( 
179                                                 cfg,       
180                                                 function(data) {
181                                         
182                                                     var cls = data['|xns'] + '.' + data['xtype'];
183                                                     
184                                                     var res = Pman.Builder.Wizard[cls](data); // with old..
185                                                      Pman.Builder.Tree.replaceCurrentNode( res );
186                                         
187                                          
188                                                }
189                                             );
190                                         
191                                            
192                                             // otherwise, call back with template??
193                                             
194                                            
195                                            
196                                                 
197                                         }
198                                     },
199                                     text : "Edit Using Wizard"
200                                 },
201                                 {
202                                     xtype: 'Separator',
203                                     xns: Roo.menu
204                                 },
205                                 {
206                                     xtype: 'Item',
207                                     xns: Roo.menu,
208                                     listeners : {
209                                         click : function (_self)
210                                         {
211                                             Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that node?",
212                                                 function(r) {
213                                                     if (r!='yes') {
214                                                         return;
215                                                     }
216                                                    Pman.Builder.Tree.deleteCurrent();
217                                                 }
218                                             );
219                                                 
220                                         }
221                                     },
222                                     text : "Delete Node"
223                                 },
224                                 {
225                                     xtype: 'Item',
226                                     xns: Roo.menu,
227                                     text : "Save as template"
228                                 }
229                             ]
230                         }
231                     }
232                 ],
233                 center : {
234                     xtype: 'LayoutRegion',
235                     xns: Roo
236                 },
237                 south : {
238                     xtype: 'LayoutRegion',
239                     xns: Roo,
240                     height : 300,
241                     split : true
242                 }
243             }
244         });
245         this.layout = this.panel.layout;
246
247     }
248 });