tools
[app.Builder.js] / Sample / DialogSaveTemplate.js
index 84bd4d1..c82c49d 100644 (file)
@@ -17,16 +17,39 @@ DialogSaveTemplate=new XObject({
             return true;
         },
         response : function (self, response_id) {
+        
             if (!response_id) {
+                this.el.hide();
                  return;
             }
-            // now we save it..
+            var name = this.get('name').el.get_text();
+            if (!name.length) {
+                this.get('/StandardErrorDialog').show(
+                    "You must give the template a name. "
+                );
+                return;
+            }
             
+           if (!name.match(/^[A-Z ]+$/i) || !name.match(/[A-Z]/i)) {
+                this.get('/StandardErrorDialog').show(
+                    "Template Nane must contain only letters and spaces. "
+                );
+                 return;
+            }
+            this.get('/Window.LeftTree').getPaleteProvider().saveTemplate(name, this.data);
+            // now we save it..
+                this.el.hide();
             
         }
     },
     default_height : 200,
     default_width : 400,
+    modal : true,
+    show : function(data) {
+        this.data = data;
+        this.get('name').el.set_text('');
+        this.el.show_all();
+    },
     items : [
         {
             xtype: Gtk.HBox,
@@ -41,6 +64,7 @@ DialogSaveTemplate=new XObject({
                 },
                 {
                     xtype: Gtk.Entry,
+                    id : "name",
                     pack : "add"
                 }
             ]
@@ -53,7 +77,7 @@ DialogSaveTemplate=new XObject({
         {
             xtype: Gtk.Button,
             label : "OK",
-            pack : "add_action_widget,0"
+            pack : "add_action_widget,1"
         }
     ]
 });