]> git.argeo.org Git - gpl/argeo-slc.git/blob - server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/monitor/UploadView.js
Qooxdoo 0.8.3
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / src / argeo-ria-lib / slc / class / org / argeo / slc / ria / monitor / UploadView.js
1 qx.Class.define("org.argeo.slc.ria.monitor.UploadView", {
2 extend : qx.ui.container.Composite,
3 implement : [org.argeo.ria.components.IView],
4
5 properties : {
6 /**
7 * The commands definition Map that will be automatically added and wired to the menubar and toolbar.
8 * See {@link org.argeo.ria.event.CommandsManager#definitions} for the keys to use for defining commands.
9 */
10 commands : {
11 init : {}
12 },
13 viewSelection : {
14 nullable:false,
15 check:"org.argeo.ria.components.ViewSelection"
16 },
17 view : {
18 init : null
19 },
20 instanceId : {init:""},
21 instanceLabel : {init:""}
22 },
23
24 construct : function(){
25 this.base(arguments);
26 this.setLayout(new qx.ui.layout.Basic);
27 },
28
29 members : {
30 /**
31 * The implementation should contain the GUI initialisation.
32 * This is the role of the manager to actually add the graphical component to the pane,
33 * so it's not necessary to do it here.
34 * @param viewPane {org.argeo.ria.components.ViewPane} The pane manager
35 * @param data {Mixed} Any object or data passed by the initiator of the view
36 * @return {Boolean}
37 */
38 init : function(viewPane, data){
39 this.setView(viewPane);
40 this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId()));
41 this.form = new org.argeo.ria.components.upload.UploadForm("uploadFrm", org.argeo.slc.ria.SlcApi.getInstallModuleService());
42 this.form.setLayout(new qx.ui.layout.HBox(5));
43 this.fileWidget = new org.argeo.ria.components.upload.UploadField("uploadFile", "Choose a file");
44
45 this.form.addListener("completed", function(e){
46 this.fileWidget.setFieldValue("");
47 var response = this.form.getIframeHtmlContent();
48 this.debug(response);
49 this.displayMessage(response, 4000);
50 }, this);
51 this.form.addListener("sending", function(e){
52 this.debug("Sending...");
53 this.displayMessage("Sending...");
54 }, this);
55 this.fileWidget.addListener("changeFieldValue", function(e){
56 if(e.getData()!=""){
57 this.submitButton.setEnabled(true);
58 }
59 }, this);
60
61 this.submitButton = new qx.ui.form.Button("Upload");
62 this.submitButton.setEnabled(false);
63 this.submitButton.addListener("execute", function(e){
64 if(this.fileWidget.getFieldValue()!=""){
65 this.form.send();
66 }
67 }, this);
68
69 this.fileWidget.getTextField().setWidth(200);
70 this.form.add(this.fileWidget);
71 this.form.add(this.submitButton);
72 this.messageLabel = new qx.ui.basic.Label("");
73 this.messageLabel.setRich(true);
74 this.messageLabel.setPadding(4,4,4,20);
75 this.form.add(this.messageLabel);
76 this.add(this.form, {left : 20, top:20});
77 },
78
79 displayMessage : function(message, timer){
80 this.messageLabel.setContent("<i>"+qx.lang.String.stripTags(message)+"</i>");
81 if(timer){
82 qx.event.Timer.once(function(){
83 this.messageLabel.setContent("");
84 }, this, timer);
85 }
86 },
87 /**
88 * The implementation should contain the real data loading (i.o. query...)
89 * @return {Boolean}
90 */
91 load : function(){
92 },
93
94 /**
95 * Whether this component is already contained in a scroller (return false) or not (return true).
96 * @return {Boolean}
97 */
98 addScroll : function(){return true;},
99 /**
100 * Called at destruction time
101 * Perform all the clean operations (stopping polling queries, etc.)
102 */
103 close : function(){return true;}
104 }
105 });