dbgenerate.js
[app.Builder.js] / Builder / DialogNewComponent.bjs
1 {
2     "id": "file-gtk-2",
3     "name": "DialogNewComponent",
4     "parent": "",
5     "title": false,
6     "path": "/home/alan/gitlive/app.Builder.js/Sample/DialogNewComponent.bjs",
7     "items": [
8         {
9             "listeners": {
10                 "delete_event": "function (self, event) {\n    this.el.hide();\n    return true;\n}",
11                 "response": "function (self, response_id) {\n\tif (response_id < 1) { // cancel!\n            this.el.hide();\n            return;\n        }\n\n        if (!this.get('name').el.get_text().length ) {\n            this.get('/StandardErrorDialog').show(\n                \"You have to set Project name \"\n            );\n             \n            return;\n        }\n        var isNew = this.file.name.length ? false : true;\n        \n        if (this.file.name.length && this.file.name != this.get('name').el.get_text()) {\n            this.get('/StandardErrorDialog').show(\n                \"Sorry changing names does not work yet. \"\n            );\n             \n            return;\n        }\n        for (var i in this.def) {\n            this.file[i] =  this.get(i).el.get_text();\n        }\n       \n        if (!isNew) {\n            this.file.save();\n            this.el.hide();\n            return;\n        }\n       \n    \n\tvar dir ='';\n        for (var i in this.project.paths) {\n \t\tdir = i;\n\t\tbreak;\n\t}\n\n \n        \n        // what about .js ?\n         if (GLib.file_test (GLib.dir + '/' + this.file.name + '.bjs', GLib.FileTest.EXISTS)) {\n            StandardErrorDialog.show(\n                \"That file already exists\"\n            ); \n            return;\n        }\n        this.el.hide();\n        \n        \n        //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());\n        \n        var _this = this;\n        var nf = _this.project.create(dir + '/' + this.file.name + '.bjs');\n        for (var i in this.file) {\n            nf[i] = this.file[i];\n        }\n        if (this.get('/DialogNewComponent').success) {\n            this.get('/DialogNewComponent').success(_this.project, nf);\n        }\n}",
12                 "show": "function (self) {\n  this.el.show_all();\n}"
13             },
14             "default_height": 200,
15             "default_width": 500,
16             "id": "DialogNewComponent",
17             "title": "New Component",
18             "xtype": "Dialog",
19             "|deletable": false,
20             "|modal": true,
21             "|show": "function (c) \n{\n    this.project = c.project;\n    if (!this.el) {\n        this.init();\n    }\n    this.def =  { \n        name : '' , \n        title : '' ,\n        region : '' ,\n        parent: '',\n      //  disable: '',\n        modOrder : '0',\n        permname : ''\n    };\n    for (var i in this.def) {\n        c[i] = c[i] || this.def[i];\n        this.get(i).el.set_text(c[i]);\n    }\n    if (c.name) {\n        this.el.set_title(\"Edit File Details - \" + c.name);\n    } else {\n        this.el.set_title(\"Create New File\");\n    }\n     \n    this.file = c;\n    console.log('show all');\n    this.el.show_all();\n    this.success = c.success;\n    \n    \n}",
22             "|xns": "Gtk",
23             "items": [
24                 {
25                     "|xns": "Gtk",
26                     "xtype": "VBox",
27                     "|pack": "function(p,e) {\n                    p.el.get_content_area().add(e.el)\n                }\n",
28                     "items": [
29                         {
30                             "n_columns": 2,
31                             "n_rows": 3,
32                             "pack": "pack_start,false,false,0",
33                             "xtype": "Table",
34                             "|homogeneous": false,
35                             "|xns": "Gtk",
36                             "items": [
37                                 {
38                                     "label": "Component Name",
39                                     "pack": "add",
40                                     "x_options": 4,
41                                     "xalign": 0.9,
42                                     "xtype": "Label",
43                                     "|justify": "Gtk.Justification.RIGHT",
44                                     "|xns": "Gtk"
45                                 },
46                                 {
47                                     "id": "name",
48                                     "pack": "add",
49                                     "xtype": "Entry",
50                                     "|visible": true,
51                                     "|xns": "Gtk"
52                                 },
53                                 {
54                                     "label": "Title",
55                                     "pack": "add",
56                                     "x_options": 4,
57                                     "xalign": 0.9,
58                                     "xtype": "Label",
59                                     "|justify": "Gtk.Justification.RIGHT",
60                                     "|visible": true,
61                                     "|xns": "Gtk"
62                                 },
63                                 {
64                                     "id": "title",
65                                     "pack": "add",
66                                     "xtype": "Entry",
67                                     "|visible": true,
68                                     "|xns": "Gtk"
69                                 },
70                                 {
71                                     "label": "Region",
72                                     "pack": "add",
73                                     "tooltip_text": "center, north, south, east, west",
74                                     "x_options": 4,
75                                     "xalign": 0.9,
76                                     "xtype": "Label",
77                                     "|justify": "Gtk.Justification.RIGHT",
78                                     "|visible": true,
79                                     "|xns": "Gtk"
80                                 },
81                                 {
82                                     "id": "region",
83                                     "pack": "add",
84                                     "xtype": "Entry",
85                                     "|visible": true,
86                                     "|xns": "Gtk"
87                                 },
88                                 {
89                                     "label": "Parent Name",
90                                     "pack": "add",
91                                     "x_options": 4,
92                                     "xalign": 0.9,
93                                     "xtype": "Label",
94                                     "|justify": "Gtk.Justification.RIGHT",
95                                     "|visible": true,
96                                     "|xns": "Gtk"
97                                 },
98                                 {
99                                     "id": "parent",
100                                     "pack": "add",
101                                     "xtype": "Entry",
102                                     "|visible": true,
103                                     "|xns": "Gtk"
104                                 },
105                                 {
106                                     "label": "Permission Name",
107                                     "pack": "add",
108                                     "x_options": 4,
109                                     "xalign": 0.9,
110                                     "xtype": "Label",
111                                     "|justify": "Gtk.Justification.RIGHT",
112                                     "|visible": true,
113                                     "|xns": "Gtk"
114                                 },
115                                 {
116                                     "id": "permname",
117                                     "pack": "add",
118                                     "xtype": "Entry",
119                                     "|visible": true,
120                                     "|xns": "Gtk"
121                                 },
122                                 {
123                                     "label": "Order (for tabs)",
124                                     "pack": "add",
125                                     "x_options": 4,
126                                     "xalign": 0.9,
127                                     "xtype": "Label",
128                                     "|justify": "Gtk.Justification.RIGHT",
129                                     "|visible": true,
130                                     "|xns": "Gtk"
131                                 },
132                                 {
133                                     "id": "modOrder",
134                                     "pack": "add",
135                                     "xtype": "Entry",
136                                     "|visible": true,
137                                     "|xns": "Gtk"
138                                 }
139                             ]
140                         }
141                     ]
142                 },
143                 {
144                     "|xns": "Gtk",
145                     "xtype": "Button",
146                     "pack": "add_action_widget,0",
147                     "label": "Cancel"
148                 },
149                 {
150                     "|xns": "Gtk",
151                     "xtype": "Button",
152                     "pack": "add_action_widget,1",
153                     "label": "OK"
154                 }
155             ]
156         }
157     ]
158 }