php7 fixes
[Pman.Builder] / Pman.Tab.BuilderProps.js
index 47dceb0..ceb9282 100644 (file)
@@ -2,35 +2,19 @@
 
 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
 
-
-
-// register the module first
-Pman.on('beforeload', function()
-{
-    Pman.register({
-        modKey : '001-Pman.Tab.BuilderProps',
-        module : Pman.Tab.BuilderProps,
-        region : 'center',
-        parent : Pman.Tab.BuilderTree,
-        name : "Pman.Tab.BuilderProps",
-        disabled : false, 
-        permname: '' 
-    });
-});
-
-Pman.Tab.BuilderProps = new Roo.util.Observable({
-
-    panel : false,
-    disabled : false,
-    parentLayout:  false,
-
-    add : function(parentLayout, region)
+Pman.Tab.BuilderProps = new Roo.XComponent({
+    part     :  ["Builder","Props"],
+    order    : '001-Pman.Tab.BuilderProps',
+    region   : 'center',
+    parent   : 'Pman.Tab.BuilderTree',
+    name     : "Pman.Tab.BuilderProps",
+    disabled : false, 
+    permname : '', 
+    _tree : function()
     {
-
         var _this = this;
-        this.parentLayout = parentLayout;
-
-        this.panel = parentLayout.addxtype({
+        var MODULE = this;
+        return {
             xtype: 'GridPanel',
             xns: Roo,
             region : 'south',
@@ -91,12 +75,34 @@ Pman.Tab.BuilderProps = new Roo.util.Observable({
                         if (v == 'true') {
                             v = true;
                         }
-                        _this.grid.currentNode.elConfig[id] = v;
+                        var ec = _this.grid.currentNode.elConfig;
+                        
+                        if (id[0] == '!') {
+                            ec.listeners = ec.listeners || {};
+                            ec.listeners[id.substring(1)] = v;
+                            if (typeof(ec[id]) != 'undefined') {
+                                delete ec[id];
+                            }
+                        } else { 
+                           ec[id] = v;
+                        }
+                    
+                        _this.grid.setSourceFromNode(ec);
+                        
                         var bp = Pman.Tab.BuilderView.panel;
                         bp.redraw.defer(100,bp, [true]);
                         _this.grid.currentNode.setText(
-                            Pman.Tab.BuilderTree.tree.configToText(_this.grid.currentNode.elConfig)
+                            Pman.Builder.Tree.configToText(ec)
                         );
+                    },
+                    contextmenu : function (e)
+                    {
+                        // should we check e..??
+                        _this.panel.menu2 = Roo.factory(_this.panel.menu2);
+                        
+                        _this.panel.menu2.show(e.getTarget());
+                        e.stopEvent()
+                    
                     }
                 },
                 setCurrrentNode : function(node) {
@@ -164,38 +170,162 @@ Pman.Tab.BuilderProps = new Roo.util.Observable({
                         xtype: 'Item',
                         xns: Roo.menu,
                         listeners : {
-                            activate : function (_self)
+                            click : function (_self, e)
                             {
-                            
+                             
+                                 var rc = _this.grid.getSelectionModel().getSelectedCell();
+                                 var n = _this.grid.getDataSource().getAt(rc[0]).data.name;
+                                 if (n == 'xtype') {
+                                    return;
+                                 }
+                                  if (n[0] == '!') {
+                                    Roo.MesssageBox.alert("Error", "Error, you can not do this to listeners");
+                                    return;
+                                }
+                                 if (n[0] == '|') {
+                                    var val =  _this.grid.currentNode.elConfig[n];
+                                    delete _this.grid.currentNode.elConfig[n];
+                                    _this.grid.currentNode.elConfig[ n.substring(1)] = val;
+                                     
+                                 } else {
+                                    var val =  _this.grid.currentNode.elConfig[n];
+                                    delete _this.grid.currentNode.elConfig[n];
+                                    _this.grid.currentNode.elConfig['|'+ n] = val;
+                                 }
+                                // reloads      
+                                _this.grid.setCurrrentNode(_this.grid.currentNode);
+                                var bp = Pman.Tab.BuilderView.panel;
+                                bp.redraw.defer(100,bp, [true]);
+                                // update the tree's  text
+                                _this.grid.currentNode.setText(
+                                    Pman.Builder.Tree.configToText(_this.grid.currentNode.elConfig)
+                                );
+                            }
+                        },
+                        text : "Toggle property as Javascript"
+                    },
+                    {
+                        xtype: 'Separator',
+                        xns: Roo.menu
+                    },
+                    {
+                        xtype: 'Item',
+                        xns: Roo.menu,
+                        listeners : {
+                            click : function (_self, e)
+                            {
+                             
+                                 var rc = _this.grid.getSelectionModel().getSelectedCell();
+                                 var n = _this.grid.getDataSource().getAt(rc[0]).data.name;
+                                 if (n == 'xtype') {
+                                    return;
+                                }
+                                if (n[0] == '!') {
+                                    try{
+                                        delete _this.grid.currentNode.elConfig.listeners[n.substring(1)]; 
+                                    }catch(err){
+                                        delete _this.grid.currentNode.elConfig[n];
+                                        Roo.log(err);
+                                    }
+                                    
+                                } else {
+                                    delete _this.grid.currentNode.elConfig[n];
+                                }
+                                // reloads      
+                                _this.grid.setCurrrentNode(_this.grid.currentNode);
+                                var bp = Pman.Tab.BuilderView.panel;
+                                bp.redraw.defer(100,bp, [true]);
+                                // update the tree's  text
+                                _this.grid.currentNode.setText(
+                                    Pman.Builder.Tree.configToText(_this.grid.currentNode.elConfig)
+                                );
                             }
                         },
-                        activate : 'function (_self, e)
-{
-     var rc = _this.grid.getSelectionModel().getSelectedCell();
-     var n = _this.grid.getDataSource().getAt(rc[0]).data.name;
-     if (n == \'xtype\') {
-        return;
-    }
-    if (n[0] == \'!\') {
-        delete _this.grid.currentNode.elConfig.listeners[n.substring(1)];
-    } else {
-        delete _this.grid.currentNode.elConfig[n];
-    }
-    // reloads      
-    _this.grid.setCurrrentNode(_this.grid.currentNode);
-    var bp = Pman.Tab.BuilderView.panel;
-    bp.redraw.defer(100,bp, [true]);
-    // update the tree\'s  text
-    _this.currentNode.setText(
-        Pman.Tab.BuilderTree.tree.configToText(_this.currentNode.elConfig)
-    );
-}',
                         text : "Delete Property / Event"
                     }
                 ]
+            },
+            'menu2' : {
+                xtype: 'Menu',
+                xns: Roo.menu,
+                items : [
+                    {
+                        xtype: 'Item',
+                        xns: Roo.menu,
+                        listeners : {
+                            click : function (_self, e)
+                            {
+                             
+                                // show a dialog to select property??
+                                // or should we add a line and get clever with pulldowns..
+                                var ec = _this.grid.currentNode.elConfig;
+                            
+                                Pman.Dialog.BuilderProp.show({
+                                        xtype : ec.xtype  || '',
+                                        xns: ec['|xns'] || '',
+                                        list: 'props'
+                                }, function (n,val) {
+                                    ec[n] = val || '';
+                                    _this.grid.setCurrrentNode(_this.grid.currentNode);
+                                    var bp = Pman.Tab.BuilderView.panel;
+                                    bp.redraw.defer(100,bp, [true]);
+                                    // update the tree's  text
+                                    _this.grid.currentNode.setText(
+                                        Pman.Builder.Tree.configToText(_this.grid.currentNode.elConfig)
+                                    );
+                                });
+                            }
+                        },
+                        text : "Add Property"
+                    },
+                    {
+                        xtype: 'Item',
+                        xns: Roo.menu,
+                        listeners : {
+                            click : function (_self, e)
+                            {
+                             
+                                // show a dialog to select property??
+                                // or should we add a line and get clever with pulldowns..
+                                var ec = _this.grid.currentNode.elConfig;
+                                Pman.Dialog.BuilderProp.show({
+                                        xtype : ec.xtype  || '',
+                                        xns: ec['|xns'] || '',
+                                        list: 'events'
+                                }, function (n,val) {
+                                    n = '!|' + n;
+                                    ec[n] = val || "function () {\n\n}";
+                                    _this.grid.setCurrrentNode(_this.grid.currentNode);
+                                    var bp = Pman.Tab.BuilderView.panel;
+                                    bp.redraw.defer(100,bp, [true]);
+                                    // update the tree's  text
+                                    _this.grid.currentNode.setText(
+                                        Pman.Builder.Tree.configToText(_this.grid.currentNode.elConfig)
+                                    );
+                                });
+                            }
+                        },
+                        text : "Add Event Handler"
+                    },
+                    {
+                        xtype: 'Separator',
+                        xns: Roo.menu
+                    },
+                    {
+                        xtype: 'Item',
+                        xns: Roo.menu,
+                        listeners : {
+                            click : function (_self, e)
+                            {
+                             
+                                // show a dialog to select property??
+                                // or should we add a line and get clever with pulldowns..
+                            }
+                        },
+                        text : "Add User Defined Property"
+                    }
+                ]
             }
-        });
-        this.layout = this.panel.layout;
-
+        };
     }
 });