1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
7 // register the module first
8 Pman.on('beforeload', function()
11 part : ["Builder","Tree"],
12 modKey : '001-Pman.Tab.BuilderTree',
13 module : Pman.Tab.BuilderTree,
15 parent : Pman.Tab.BuilderTab,
16 name : "Pman.Tab.BuilderTree",
22 Pman.Tab.BuilderTree = new Roo.util.Observable({
28 add : function(parentLayout, region)
32 this.parentLayout = parentLayout;
34 this.panel = parentLayout.addxtype({
35 xtype: 'NestedLayoutPanel',
39 xtype: 'BorderLayout',
46 activate : function (_self)
49 _this.tree = _self.tree;
50 _this.menu = _self.menu;
52 if (_this.hasMouseEvent) {
56 _this.hasMouseEvent = true;
57 this.el.on('mouseover', function() { _this.isMouseOver= true; });
58 this.el.on('mouseout', function() { _this.isMouseOver = false; });
67 beforenodedrop : function (e)
70 return Pman.Builder.Tree.handleDropNode(e);
73 click : function (node, e)
76 // console.log(e.button);
77 Pman.BuilderTree.setCurrentNode(node);
83 contextmenu : function (node, e)
87 this.getSelectionModel().select(node);
88 Pman.Builder.Tree.setCurrentNode(node);
90 _this.menu = Roo.factory(_this.menu);
92 _this.menu.show(node.ui.textNode, 'tr');
96 var xt = node.elConfig.xtype;
98 if (typeof(node.elConfig['*prop']) != 'undefined') {
99 altx = node.parentNode.elConfig.xtype +'.' + node.elConfig['*prop'];
101 var mn = Pman.Tab.BuilderPalete.getMenu(xt,altx);
105 mn.show(e.getTarget());
111 nodedragover : function (e)
114 return Pman.Builder.Tree.handleDragOver(e);
121 containerScroll : true,
122 ddGroup : 'component',
125 clearAll : function() {
127 if (rt.childNodes.length) {
128 rt.removeChild(rt.childNodes[0]);
131 this.root.elConfig = Roo.apply({ }, this.defaultElConfig());
132 //var btop = Pman.Tab.BuilderTop;
133 //if (btop.modsel && btop.modsel.lastData) {
134 // this.tree.root.elConfig.app = btop.modsel.lastData.app;
137 this.setCurrentNode(this.root,true);
140 cloneConfig : function(config) {
141 if (!config) { return null; }
144 for (var i in config) {
145 if (typeof config[i] == 'object') {
146 newConfig[i] = this.cloneConfig(config[i]);
147 } else if (typeof config[i] != 'function') { // should this happen?
148 newConfig[i] = config[i];
153 configToText : function(c) {
157 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
158 if (sr) txt.push('<s>');
159 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
160 if (c.xtype) { txt.push(c.xtype); }
161 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
162 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
165 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
166 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
167 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
168 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
169 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
170 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
171 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
172 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
173 if (sr) txt.push('</s>');
174 return (txt.length == 0 ? "Element" : txt.join(" "));
178 currentNodeType : function() {
179 return this.nodeXtype(this.currentNode);
182 defaultElConfig : function() {
191 name : 'Module Name',
195 deleteCurrent : function() {
196 if (this.currentNode == this.root) {
199 var cfg = this.currentNode.elConfig;
200 // things that can not be deleted...
203 var pn = this.currentNode.parentNode;
206 var ix = pn.indexOf(this.currentNode);
208 pn.removeChild(this.currentNode);
209 if (pn.childNodes.length) {
210 ix = Math.min(pn.childNodes.length-1, ix);
212 this.setCurrentNode(pn.childNodes.length ? pn.childNodes[ix] : pn ,true);
215 dupeNode : function(node)
217 var cfg = this.cloneConfig(node.elConfig);
219 var newNode = new Roo.tree.TreeNode(
222 text: this.configToText(cfg)
225 newNode.elConfig = cfg;
226 node.eachChild(function(n) {
227 newNode.appendChild(this.dupeNode(n));
233 loadBJS : function(module, part) {
236 url : baseURL + '/Roo/Builder_part.php',
241 success : function(res)
246 if (!res.data.json.length) {
247 var cfg = _t.defaultElConfig();
248 cfg.name = Pman.Tab.BuilderTop.filesel.lastData.name;
249 cfg.part = Pman.Tab.BuilderTop.filesel.lastData.name;
256 _t.loadTree(JSON.parse(res.data.json));
266 loadTree : function(o) {
268 this.root.elConfig = o;
269 this.root.setText(this.configToText(this.root.elConfig));
270 this.appendNode(this.root, o.items[0]);
271 this.root.expand(true);
272 Pman.Tab.BuilderView.panel.redraw();
273 this.setCurrentNode(this.root,true);
275 nodeXtype : function(n) {
276 if (!n) {return ''; }
277 var xt = n.elConfig.xtype || '';
278 var xns= n.elConfig['|xns'] || '';
279 xns += xns.length ? '.' : '';
282 renderer : function(n) { return n.text; },
283 setCurrentNode : function(node,select) {
284 this.currentNode = node || this.root;
286 //Pman.Tab.BuilderView.highlightElement(this.currentNode);
288 var p = Pman.Tab.BuilderProps.grid;
289 if (p) { //may not be ready yet..
290 p.setCurrrentNode(this.currentNode);
294 this.currentNode.setText(this.configToText(this.currentNode.elConfig));
296 if (select) { //&& node !== this.tree.root) {
297 if (this.currentNode !== this.root) {
298 this.currentNode.ensureVisible();
300 this.currentNode.expand(false,false);
301 this.currentNode.select();
304 Pman.Tab.BuilderPalette.grid.getSelectionModel().clearSelections();
305 Pman.Tab.BuilderPalette.grid.view.refresh();
311 return this.toJS(this.root);
314 var ret = this.cloneConfig(n.elConfig);
315 if (n.childNodes.length) {
317 n.eachChild(function(cn) {
318 ret.items.push(_this.toJS(cn));
327 xtype: 'DefaultSelectionModel',
334 elConfig : function() {
345 name : "Module Name",
361 click : function (_self)
363 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that node?",
368 _this.tree.deleteCurrent();
379 text : "Save as template"
386 xtype: 'LayoutRegion',
390 xtype: 'LayoutRegion',
397 this.layout = this.panel.layout;