php7 fixes
[Pman.Builder] / Pman.Tab.BuilderProps.bjs
1 {
2     "id": "roo-file-197",
3     "name": "Pman.Tab.BuilderProps",
4     "parent": "Pman.Tab.BuilderTree",
5     "title": "Pman.Tab.BuilderProps",
6     "path": "/home/edward/gitlive/Pman.Builder/Pman.Tab.BuilderProps.bjs",
7     "items": [
8         {
9             "region": "south",
10             "xtype": "GridPanel",
11             "|xns": "Roo",
12             "items": [
13                 {
14                     "listeners": {
15                         "render": "function (grid)\n{\n    _this.grid = grid;\n}",
16                         "afteredit": "function (e)\n{\n   // change this..\n   //this.currentNode.elConfig\n   \n   \n}",
17                         "cellclick": "function (_self, rowIndex, ci, e)\n{\n     if (ci != 0) {\n        return;\n    }\n    //console.log(e);\n    // click on left col..\n    // show menu..\n    // make sure it's initialized..\n    _this.panel.menu = Roo.factory(_this.panel.menu);\n    \n    _this.panel.menu.show(e.getTarget(), 'tr');\n}",
18                         "beforeedit": "function (e)\n{\n   Roo.log('beforeedit');\n   Roo.log(e.record.data);\n   var key = e.record.data.name;\n   var val = e.record.data.value;\n   // source code edit..\n   if (key.match(/^\\|/) || key.match(/^\\!/)) {\n        Pman.Dialog.BuilderSourceEdit.show( { value :  val }, function(d) {\n            // perhaps we should eval it..\n        \n            _this.grid.currentNode.elConfig[key] = d.value;\n            _this.grid.setSourceFromNode(_this.grid.currentNode.elConfig);\n            _this.grid.fireEvent('propertychange', \n                Pman.Tab.BuilderProps.grid, key, d.value, false\n            );\n        });\n        e.cancel = true;\n        return;\n   }\n}",
19                         "propertychange": "function (grid, id, v, oldval)\n{\n    if (v == 'false') {\n        v = false;\n    }\n    if (v == 'true') {\n        v = true;\n    }\n    var ec = _this.grid.currentNode.elConfig;\n    \n    if (id[0] == '!') {\n        ec.listeners = ec.listeners || {};\n        ec.listeners[id.substring(1)] = v;\n        if (typeof(ec[id]) != 'undefined') {\n            delete ec[id];\n        }\n    } else { \n       ec[id] = v;\n    }\n\n    _this.grid.setSourceFromNode(ec);\n    \n    var bp = Pman.Tab.BuilderView.panel;\n    bp.redraw.defer(100,bp, [true]);\n    _this.grid.currentNode.setText(\n        Pman.Builder.Tree.configToText(ec)\n    );\n}",
20                         "contextmenu": "function (e)\n{\n    // should we check e..??\n    _this.panel.menu2 = Roo.factory(_this.panel.menu2);\n    \n    _this.panel.menu2.show(e.getTarget());\n    e.stopEvent()\n\n}"
21                     },
22                     "*prop": "grid",
23                     "xtype": "PropertyGrid",
24                     "|setCurrrentNode": "function(node) {\n   \n    \n    this.view.el.unmask();\n    \n    if (!node || !node.elConfig) {\n        this.currentNode = false;\n        this.setSourceFromNode({});\n        this.view.el.mask('select a node');\n    } else {\n        this.currentNode = node;\n        this.setSourceFromNode(this.currentNode.elConfig);\n        \n    }\n    \n}\n",
25                     "|setSourceFromNode": "function(config) {\n   \n        \n    var cfg = {};\n    for (var k in config) {\n        //if (k.charAt(0) == '*') {\n        //    continue; // dont show props..\n        //}\n        \n        if (k  == 'listeners') {\n            for (var kk in config[k]) {\n                cfg['!' + kk ] = config[k][kk];\n            }\n            \n            continue;\n        }\n        if (k  == 'items') {\n            continue;\n        }\n        \n        if (typeof config[k] == 'object') {\n            \n            try {\n                var ec = Roo.encode(config[k]);\n                cfg[k] = ec;\n            } catch(e) {}\n            continue;\n        }\n        cfg[k] = config[k];\n    }\n    \n    if (!cfg.xtype) {\n        return;\n    }\n\n    this.setSource(cfg);\n\n    \n      \n}\n",
26                     "|xns": "Roo.grid"
27                 },
28                 {
29                     "|xns": "Roo.menu",
30                     "xtype": "Menu",
31                     "*prop": "menu",
32                     "items": [
33                         {
34                             "listeners": {
35                                 "click": "function (_self, e)\n{\n \n     var rc = _this.grid.getSelectionModel().getSelectedCell();\n     var n = _this.grid.getDataSource().getAt(rc[0]).data.name;\n     if (n == 'xtype') {\n        return;\n     }\n      if (n[0] == '!') {\n        Roo.MesssageBox.alert(\"Error\", \"Error, you can not do this to listeners\");\n        return;\n    }\n     if (n[0] == '|') {\n        var val =  _this.grid.currentNode.elConfig[n];\n        delete _this.grid.currentNode.elConfig[n];\n        _this.grid.currentNode.elConfig[ n.substring(1)] = val;\n         \n     } else {\n        var val =  _this.grid.currentNode.elConfig[n];\n        delete _this.grid.currentNode.elConfig[n];\n        _this.grid.currentNode.elConfig['|'+ n] = val;\n     }\n    // reloads      \n    _this.grid.setCurrrentNode(_this.grid.currentNode);\n    var bp = Pman.Tab.BuilderView.panel;\n    bp.redraw.defer(100,bp, [true]);\n    // update the tree's  text\n    _this.grid.currentNode.setText(\n        Pman.Builder.Tree.configToText(_this.grid.currentNode.elConfig)\n    );\n}"
36                             },
37                             "text": "Toggle property as Javascript",
38                             "xtype": "Item",
39                             "|xns": "Roo.menu"
40                         },
41                         {
42                             "|xns": "Roo.menu",
43                             "xtype": "Separator"
44                         },
45                         {
46                             "listeners": {
47                                 "click": "function (_self, e)\n{\n \n     var rc = _this.grid.getSelectionModel().getSelectedCell();\n     var n = _this.grid.getDataSource().getAt(rc[0]).data.name;\n     if (n == 'xtype') {\n        return;\n    }\n    if (n[0] == '!') {\n        try{\n            delete _this.grid.currentNode.elConfig.listeners[n.substring(1)]; \n        }catch(err){\n            delete _this.grid.currentNode.elConfig[n];\n            Roo.log(err);\n        }\n        \n    } else {\n        delete _this.grid.currentNode.elConfig[n];\n    }\n    // reloads      \n    _this.grid.setCurrrentNode(_this.grid.currentNode);\n    var bp = Pman.Tab.BuilderView.panel;\n    bp.redraw.defer(100,bp, [true]);\n    // update the tree's  text\n    _this.grid.currentNode.setText(\n        Pman.Builder.Tree.configToText(_this.grid.currentNode.elConfig)\n    );\n}"
48                             },
49                             "text": "Delete Property / Event",
50                             "xtype": "Item",
51                             "|xns": "Roo.menu"
52                         }
53                     ]
54                 },
55                 {
56                     "*prop": "menu2",
57                     "xtype": "Menu",
58                     "|xns": "Roo.menu",
59                     "items": [
60                         {
61                             "listeners": {
62                                 "click": "function (_self, e)\n{\n \n    // show a dialog to select property??\n    // or should we add a line and get clever with pulldowns..\n    var ec = _this.grid.currentNode.elConfig;\n\n    Pman.Dialog.BuilderProp.show({\n            xtype : ec.xtype  || '',\n            xns: ec['|xns'] || '',\n            list: 'props'\n    }, function (n,val) {\n        ec[n] = val || '';\n        _this.grid.setCurrrentNode(_this.grid.currentNode);\n        var bp = Pman.Tab.BuilderView.panel;\n        bp.redraw.defer(100,bp, [true]);\n        // update the tree's  text\n        _this.grid.currentNode.setText(\n            Pman.Builder.Tree.configToText(_this.grid.currentNode.elConfig)\n        );\n    });\n}"
63                             },
64                             "text": "Add Property",
65                             "xtype": "Item",
66                             "|xns": "Roo.menu"
67                         },
68                         {
69                             "listeners": {
70                                 "click": "function (_self, e)\n{\n \n    // show a dialog to select property??\n    // or should we add a line and get clever with pulldowns..\n    var ec = _this.grid.currentNode.elConfig;\n    Pman.Dialog.BuilderProp.show({\n            xtype : ec.xtype  || '',\n            xns: ec['|xns'] || '',\n            list: 'events'\n    }, function (n,val) {\n        n = '!|' + n;\n        ec[n] = val || \"function () {\\n\\n}\";\n        _this.grid.setCurrrentNode(_this.grid.currentNode);\n        var bp = Pman.Tab.BuilderView.panel;\n        bp.redraw.defer(100,bp, [true]);\n        // update the tree's  text\n        _this.grid.currentNode.setText(\n            Pman.Builder.Tree.configToText(_this.grid.currentNode.elConfig)\n        );\n    });\n}"
71                             },
72                             "text": "Add Event Handler",
73                             "xtype": "Item",
74                             "|xns": "Roo.menu"
75                         },
76                         {
77                             "|xns": "Roo.menu",
78                             "xtype": "Separator"
79                         },
80                         {
81                             "listeners": {
82                                 "click": "function (_self, e)\n{\n \n    // show a dialog to select property??\n    // or should we add a line and get clever with pulldowns..\n}"
83                             },
84                             "text": "Add User Defined Property",
85                             "xtype": "Item",
86                             "|xns": "Roo.menu"
87                         }
88                     ]
89                 }
90             ]
91         }
92     ],
93     "permname": "",
94     "modOrder": "001"
95 }