Fix #7250 - better handling of adding properties
[roobuilder] / src / Builder4 / EditProject.bjs
1 {
2  "build_module" : "builder",
3  "items" : [
4   {
5    "$ deletable" : true,
6    "$ modal" : true,
7    "$ xns" : "Gtk",
8    "border_width" : 3,
9    "default_height" : 500,
10    "default_width" : 600,
11    "items" : [
12     {
13      "$ homogeneous" : false,
14      "$ pack" : [
15       " get_content_area().add ",
16       " ",
17       ""
18      ],
19      "$ xns" : "Gtk",
20      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
21      "bool expand" : true,
22      "items" : [
23       {
24        "$ homogeneous" : false,
25        "$ xns" : "Gtk",
26        "* pack" : "pack_start,false,true,3",
27        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
28        "items" : [
29         {
30          "$ xns" : "Gtk",
31          "* pack" : "pack_start,false,true,3",
32          "label" : "Project type :",
33          "xtype" : "Label"
34         },
35         {
36          "$ xns" : "Gtk",
37          "* init" : [
38           " this.el.add_attribute(_this.cellrender.el , \"markup\", 1 );  ",
39           "  "
40          ],
41          "* pack" : "pack_end,true,true,3",
42          "id" : "xtype",
43          "items" : [
44           {
45            "$ xns" : "Gtk",
46            "* pack" : "pack_start,true",
47            "id" : "cellrender",
48            "xtype" : "CellRendererText"
49           },
50           {
51            "$ columns" : "typeof(string),typeof(string)",
52            "$ xns" : "Gtk",
53            "* pack" : "set_model",
54            "id" : "model",
55            "n_columns" : 2,
56            "xtype" : "ListStore",
57            "| void loadData" : [
58             "  ( ) {",
59             "        this.el.clear();",
60             "                      ",
61             "        Gtk.TreeIter iter;",
62             "                ",
63             "        el.append(out iter);",
64             "        el.set_value(iter, 0, \"Roo\");",
65             "        el.set_value(iter, 1, \"Roo Project\");",
66             "        ",
67             "        el.append(out iter);",
68             "        el.set_value(iter, 0, \"Gtk\");",
69             "        el.set_value(iter, 1, \"Gtk Project\");",
70             "         ",
71             "        el.append(out iter);",
72             "        el.set_value(iter, 0, \"Flutter\");",
73             "        el.set_value(iter, 1, \"Flutter Project\");",
74             "              ",
75             "                                     ",
76             "}",
77             ""
78            ]
79           }
80          ],
81          "xtype" : "ComboBox",
82          "| string getValue" : [
83           " () {",
84           "     var ix = this.el.get_active();",
85           "        if (ix < 0 ) {",
86           "            return \"\";",
87           "        }",
88           "        switch(ix) {",
89           "            case 0:",
90           "                return \"Roo\";",
91           "            case 1:",
92           "                return \"Gtk\";",
93           "           case 2:",
94           "                return \"Flutter\";",
95           "        }",
96           "        return \"\";",
97           "}",
98           ""
99          ]
100         }
101        ],
102        "xtype" : "Box"
103       },
104       {
105        "$ action" : "Gtk.FileChooserAction.SELECT_FOLDER",
106        "$ create_folders" : false,
107        "$ select_multiple" : false,
108        "$ xns" : "Gtk",
109        "* pack" : "pack_end,true,true,5",
110        "bool expand" : true,
111        "id" : "dir",
112        "xtype" : "FileChooserWidget"
113       }
114      ],
115      "xtype" : "Box"
116     },
117     {
118      "$ xns" : "Gtk",
119      "* pack" : "add_action_widget,1",
120      "label" : "OK",
121      "xtype" : "Button"
122     },
123     {
124      "$ xns" : "Gtk",
125      "* pack" : "add_action_widget,0",
126      "label" : "Cancel",
127      "xtype" : "Button"
128     }
129    ],
130    "listeners" : {
131     "destroy_event" : [
132      "(self, event) => {",
133      "\tthis.el.response(0);",
134      "//     this.el.hide();",
135      "    return false;",
136      "}"
137     ]
138    },
139    "name" : "EditProject",
140    "title" : "Project Properties",
141    "xtype" : "Dialog",
142    "| Project.Project? show" : [
143     "() {",
144     "      ",
145     "",
146     "    //[ 'xtype'  ].forEach(function(k) {",
147     "    //    _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);",
148     "    //});",
149     "\t// shouild set path..",
150     "    _this.model.loadData();",
151     "    this.el.show_all();",
152     "    ",
153     "    var err_dialog = Xcls_StandardErrorDialog.singleton();",
154     "",
155     "    var id = -1;",
156     "    while (id < 0) {",
157     "         id =  this.el.run();",
158     "         if (id < 1) {",
159     "                this.el.hide();",
160     "                return null;",
161     "        }",
162     " ",
163     "         ",
164     "      if (_this.xtype.getValue().length < 1) {",
165     "           ",
166     "            err_dialog.show(_this.el,\"You have to set Project type\");             ",
167     "            id = -1;",
168     "            continue;",
169     "        }",
170     "        if (_this.dir.el.get_filename().length < 1) {",
171     "",
172     "            err_dialog.show(_this.el,\"You have to select a folder\");             ",
173     "            id = -1;",
174     "            continue;",
175     "        }",
176     "           ",
177     "    }",
178     "    ",
179     "    this.el.hide();",
180     "    ",
181     "    ",
182     "    ",
183     " ",
184     "    var fn = _this.dir.el.get_filename();",
185     "    print(\"add %s\\n\" , fn);",
186     "    ",
187     "    var project = Project.Project.factory(_this.xtype.getValue(), fn);",
188     "    project.save();",
189     "    Project.projects.set(project.name,project);",
190     "    ",
191     "    //var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project);",
192     "    ",
193     "    return project;",
194     "",
195     "    ",
196     "    //this.success = c.success;",
197     "}",
198     ""
199    ]
200   }
201  ],
202  "modOrder" : "",
203  "name" : "EditProject",
204  "parent" : "",
205  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/EditProject.bjs",
206  "permname" : "",
207  "title" : ""
208 }