df56d0715ba9e6f579131c663b4ba897d2d3c590
[roobuilder] / src / Builder4 / DialogSaveModule.bjs
1 {
2  "build_module" : "builder",
3  "items" : [
4   {
5    "# JsRender.Node data" : "",
6    "# Project.Project project" : "",
7    "$ modal" : true,
8    "$ xns" : "Gtk",
9    "default_height" : 200,
10    "default_width" : 400,
11    "items" : [
12     {
13      "$ pack" : [
14       " get_content_area().add",
15       "",
16       ""
17      ],
18      "$ xns" : "Gtk",
19      "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
20      "items" : [
21       {
22        "$ xns" : "Gtk",
23        "* pack" : "add",
24        "label" : "Name",
25        "xtype" : "Label"
26       },
27       {
28        "$ xns" : "Gtk",
29        "* pack" : "add",
30        "id" : "name",
31        "xtype" : "Entry"
32       }
33      ],
34      "xtype" : "Box"
35     },
36     {
37      "$ xns" : "Gtk",
38      "* pack" : "add_action_widget,0",
39      "label" : "Cancel",
40      "xtype" : "Button"
41     },
42     {
43      "$ xns" : "Gtk",
44      "* pack" : "add_action_widget,1",
45      "label" : "OK",
46      "xtype" : "Button"
47     }
48    ],
49    "listeners" : {
50     "delete_event" : [
51      " (self, event) => {",
52      "    this.el.response(Gtk.ResponseType.CANCEL);",
53      "    return true;",
54      "} "
55     ]
56    },
57    "xtype" : "Dialog",
58    "|   string show" : [
59     " (Gtk.Window parent, Project.Project project, JsRender.Node data) {",
60     " ",
61     "     ",
62     "    this.el.set_transient_for(parent);",
63     "    this.el.modal = true;",
64     "    ",
65     "    this.data = data;",
66     "    this.project = project;",
67     "    this.name.el.set_text(\"\");",
68     "    this.el.show_all();",
69     "     var   name = \"\";",
70     "    while (true) {",
71     "        var response_id = this.el.run();",
72     "        if (response_id < 1) {",
73     "            this.el.hide();",
74     "             return \"\";",
75     "        }",
76     "        ",
77     "        name = _this.name.el.get_text();",
78     "        if (name.length < 1) {",
79     "            Xcls_StandardErrorDialog.singleton().show(",
80     "                 _this.el,",
81     "                \"You must give the template a name. \"",
82     "            );",
83     "            continue;",
84     "        }",
85     "        if (!Regex.match_simple (\"^[A-Za-z][A-Za-z0-9.]+$\", name) )",
86     "        {",
87     "            Xcls_StandardErrorDialog.singleton().show(",
88     "                 _this.el,",
89     "                \"Template Name must contain only letters dots\"",
90     "            );",
91     "            continue;",
92     "        }",
93     "        break;",
94     "    }",
95     "    var f = project.newFile(name);",
96     "    f.tree =  _this.data.deepClone();",
97     "    f.save();",
98     "    ",
99     "    // now we save it..",
100     "    this.el.hide();",
101     "    ",
102     "    return name;",
103     "    ",
104     "    ",
105     "    ",
106     "}",
107     ""
108    ]
109   }
110  ],
111  "modOrder" : "",
112  "name" : "DialogSaveModule",
113  "parent" : "",
114  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/DialogSaveModule.bjs",
115  "permname" : "",
116  "title" : ""
117 }