]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/BatchView.js
New icons for the tree
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / src / argeo-ria-lib / slc / class / org / argeo / slc / ria / BatchView.js
index 18deeaf49dd30f6ee719bf40d41c80a1a7dde175..03f27df4399aa9aa81f40f6eb696b1782fb8ab17 100644 (file)
@@ -5,7 +5,16 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
 {\r
        extend : qx.ui.container.Composite,\r
        implement : [org.argeo.ria.components.IView], \r
-\r
+       include : [org.argeo.ria.session.MPrefHolder],\r
+       statics : {\r
+               riaPreferences : {\r
+                       "slc.batch.delete.confirm" : {\r
+                               label : "Confirm on batch deletion",\r
+                               type  : "boolean",\r
+                               defaultValue  : true\r
+                       }\r
+               }\r
+       },\r
        properties : \r
        {\r
                /**\r
@@ -16,7 +25,7 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
                        init : {\r
                                "submitform" : {\r
                                        label : "Execute Batch",\r
-                                       icon : "resource/slc/media-playback-start.png",\r
+                                       icon : "org.argeo.slc.ria/media-playback-start.png",\r
                                        shortcut : null,\r
                                        enabled : false,\r
                                        menu : "Launcher",\r
@@ -31,7 +40,7 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
                                /*\r
                                "toggleopenonadd" : {\r
                                        label : "Auto edit on Add",\r
-                                       icon : "resource/slc/document-open.png",\r
+                                       icon : "org.argeo.slc.ria/document-open.png",\r
                                        shortcut : null,\r
                                        enabled : true,\r
                                        toggle : true,\r
@@ -46,7 +55,7 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
                                },\r
                                "editexecutionspecs" : {\r
                                        label : "Edit Execution Specs",\r
-                                       icon : "resource/slc/document-open.png",\r
+                                       icon : "org.argeo.slc.ria/document-open.png",\r
                                        shortcut : null,\r
                                        enabled : false,\r
                                        menu : "Launcher",\r
@@ -75,26 +84,34 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
                                */\r
                                "removefrombatch" : {\r
                                        label : "Remove from batch",\r
-                                       icon : "resource/slc/edit-delete.png",\r
+                                       icon : "org.argeo.slc.ria/edit-delete.png",\r
                                        shortcut : null,\r
                                        enabled : false,\r
                                        menu : "Launcher",\r
                                        toolbar : "batch",\r
                                        callback : function(e) {\r
                                                var sel = this.list.getSortedSelection();\r
-                                               var modal = new org.argeo.ria.components.Modal("Confirm", null);\r
-                                               modal.addConfirm("Are you sure you want to remove<br> the selected test"\r
-                                                                               + (sel.length > 1 ? "s" : "")\r
-                                                                               + " from the Batch?");\r
-                                               modal.addListener("ok", function() {\r
-                                                                       for (var i = 0; i < sel.length; i++) {\r
-                                                                               this.list.remove(sel[i]);\r
-                                                                       }\r
-                                                                       if (!this.list.hasChildren()) {\r
-                                                                               this.setBatchAgentId(null);\r
-                                                                       }\r
-                                                               }, this);\r
-                                               modal.attachAndShow();\r
+                                               var confirmPref = this.getRiaPreferenceValue("slc.batch.delete.confirm");\r
+                                               this.debug(confirmPref);\r
+                                               var execution = function() {\r
+                                                       for (var i = 0; i < sel.length; i++) {\r
+                                                               this.list.remove(sel[i]);\r
+                                                       }\r
+                                                       if (!this.list.hasChildren()) {\r
+                                                               this.setBatchAgentId(null);\r
+                                                       }\r
+                                               }\r
+                                               if(confirmPref){\r
+                                                       var modal = new org.argeo.ria.components.Modal("Confirm", null);\r
+                                                       modal.addConfirm("Are you sure you want to remove<br> the selected test"\r
+                                                                                       + (sel.length > 1 ? "s" : "")\r
+                                                                                       + " from the Batch?");\r
+                                                       modal.addListener("ok", execution, this);\r
+                                                       modal.attachAndShow();\r
+                                               }else{\r
+                                                       execution = qx.lang.Function.bind(execution, this);\r
+                                                       execution();\r
+                                               }\r
                                        },\r
                                        selectionChange : function(viewId, selection) {\r
                                                if (viewId != "batch:list")\r
@@ -104,7 +121,23 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
                                                        this.setEnabled(true);\r
                                        },\r
                                        command : null\r
-                               }                               \r
+                               },\r
+                               "clearbatch" : {\r
+                                       label : "Clear batch",\r
+                                       icon : "org.argeo.slc.ria/user-trash-full.png",\r
+                                       shortcut : null,\r
+                                       enabled : true,\r
+                                       menu : "Launcher",\r
+                                       toolbar : "batch",\r
+                                       callback : function(e) {\r
+                                               if(!this.list.hasChildren()) return;\r
+                                               this.list.selectAll();\r
+                                               this.getCommands()["removefrombatch"].command.execute();\r
+                                       },\r
+                                       selectionChange : function(viewId, selection) {\r
+                                       },\r
+                                       command : null\r
+                               }                                                               \r
                        }\r
                },\r
                view : {\r
@@ -251,15 +284,27 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
                                                }\r
                                        }, this);\r
 \r
+                       this.dropDecorator = new qx.ui.decoration.Background();                 \r
+                       this.dropDecorator.set({\r
+                               backgroundImage : "org.argeo.slc.ria/drophere.gif",\r
+                               backgroundRepeat : "no-repeat"\r
+                       });\r
+\r
+                                       \r
                        listChangeListener = function() {\r
                                var command = org.argeo.ria.event.CommandsManager.getInstance()\r
                                                .getCommandById("submitform");\r
                                command.setEnabled(this.list.hasChildren());\r
+                               var command2 = org.argeo.ria.event.CommandsManager.getInstance()\r
+                                               .getCommandById("clearbatch");\r
+                               command2.setEnabled(this.list.hasChildren());\r
+                               this.list.setDecorator((this.list.hasChildren()?null:this.dropDecorator));\r
                        };\r
                        this.list.addListener("addItem", listChangeListener, this);\r
                        this.list.addListener("removeItem", listChangeListener, this);\r
-\r
-                       \r
+                               \r
+                       this.list.setDecorator(this.dropDecorator);\r
+                                               \r
                        this.add(this.listPane);\r
                },              \r
                \r
@@ -318,7 +363,7 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
                        var batchEntry = new org.argeo.slc.ria.execution.BatchEntrySpec(\r
                                        executionModule, executionFlow);\r
                        var label = batchEntry.getLabel();\r
-                       var icon = target.getIcon() || "resource/slc/office-document.png";\r
+                       var icon = target.getIcon() || "org.argeo.slc.ria/office-document.png";\r
                        var item = new qx.ui.form.ListItem(label, icon);\r
                        /*\r
                        item.addListener("dblclick", function(e) {\r