]> git.argeo.org Git - gpl/argeo-slc.git/blob - server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/SpecsEditorView.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 / SpecsEditorView.js
1 /**
2 * Applet for the batch manager
3 */
4 qx.Class.define("org.argeo.slc.ria.SpecsEditorView",
5 {
6 extend : qx.ui.container.Composite,
7 implement : [org.argeo.ria.components.IView],
8
9 properties :
10 {
11 /**
12 * The commands definition Map that will be automatically added and wired to the menubar and toolbar.
13 * See {@link org.argeo.ria.event.CommandsManager#definitions} for the keys to use for defining commands.
14 */
15 commands : {
16 init : {
17 "updateData" : {
18 label : "Edit Execution Specs",
19 icon : "org.argeo.slc.riadocument-open.png",
20 shortcut : null,
21 enabled : false,
22 menu : null,
23 toolbar : null,
24 callback : function(e) {},
25 selectionChange : function(viewId, selection) {
26 if (viewId != "batch:list")
27 return;
28 var view = org.argeo.ria.components.ViewsManager.getInstance().getViewPaneById("editor").getContent();
29 if ((selection && selection.length == 1)) {
30 view.setBatchEntrySpec(selection[0].getUserData("batchEntrySpec"));
31 }else{
32 view.setBatchEntrySpec(null);
33 }
34 },
35 command : null
36 }
37 }
38 },
39 view : {
40 init : null
41 },
42 viewSelection : {
43 nullable:false,
44 check:"org.argeo.ria.components.ViewSelection"
45 },
46 instanceId : {init:""},
47 instanceLabel : {init:""},
48 batchEntrySpec : {
49 init : null,
50 nullable:true,
51 event : "changeBatchEntrySpec"
52 }
53
54 },
55
56 construct : function(){
57 this.base(arguments);
58 this.setLayout(new qx.ui.layout.Dock());
59 },
60
61 members : {
62 /**
63 * The implementation should contain the GUI initialisation.
64 * This is the role of the manager to actually add the graphical component to the pane,
65 * so it's not necessary to do it here.
66 * @param viewPane {org.argeo.ria.components.ViewPane} The pane manager
67 * @param data {Mixed} Any object or data passed by the initiator of the view
68 * @return {Boolean}
69 */
70 init : function(viewPane, data){
71 this.setView(viewPane);
72 this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId()));
73
74 this.addListener("changeBatchEntrySpec", this.updateData, this);
75 this._emptyTitleString = "Script Parameters (select a script to edit)";
76 this._editorTitleString = "Script '%1' Parameters";
77 },
78 /**
79 * The implementation should contain the real data loading (i.o. query...)
80 * @return {Boolean}
81 */
82 load : function(){
83 this._createLayout();
84 this.getView().setViewTitle(this._emptyTitleString);
85 },
86
87 /**
88 * Update the table
89 * @param event {qx.event.type.DataEvent}
90 */
91 updateData : function(event){
92 var batchEntry = event.getData();
93 if(batchEntry == null){
94 this.tableModel.setData([]);
95 this.getView().setViewTitle(this._emptyTitleString);
96 return;
97 }
98 this.getView().setViewTitle(qx.lang.String.format(this._editorTitleString, [batchEntry.getFlow().getName()]));
99 var values = batchEntry.getValues();
100 var data = [];
101 for(var key in values){
102 var valueObj = values[key];
103 var hidden = valueObj.getHidden();
104 var type = valueObj.getSpecType();
105 if(type == "primitive" && !hidden){
106 metadata = {
107 key : key,
108 disabled : valueObj.getFrozen(),
109 type : type,
110 subType : valueObj.getSpecSubType()
111 }
112 data.push([key, valueObj.getValue(), metadata]);
113 }
114 }
115 this.tableModel.setData(data);
116 },
117
118 /**
119 * Creates the main applet layout.
120 */
121 _createLayout : function() {
122 this.tableModel = new qx.ui.table.model.Simple();
123 this.tableModel.setColumns(["Attribute Name", "Value"]);
124 this.tableModel.setColumnEditable(1, true);
125 this.table = new qx.ui.table.Table(this.tableModel, {
126 tableColumnModel: function(obj){
127 return new qx.ui.table.columnmodel.Resize(obj)
128 }
129 });
130 this.table.set({
131 decorator : null,
132 statusBarVisible: false,
133 showCellFocusIndicator:true,
134 columnVisibilityButtonVisible : false
135 });
136
137 this.table.addListener("dataEdited", function(e){
138 var data = e.getData();
139 var rowData = this.tableModel.getRowData(data.row);
140 var metaData = rowData[2];
141 var values = this.getBatchEntrySpec().getValues();
142 values[metaData.key].setValue(data.value);
143 }, this);
144
145 var columnModel = this.table.getTableColumnModel();
146 var factory = new org.argeo.slc.ria.execution.CellEditorFactory();
147 columnModel.setCellEditorFactory(1, factory);
148 columnModel.setDataCellRenderer(1, factory);
149 columnModel.getBehavior().setWidth(0, "40%");
150 this.add(this.table, {edge:"center"});
151 },
152
153 /**
154 * Whether this component is already contained in a scroller (return false) or not (return true).
155 * @return {Boolean}
156 */
157 addScroll : function(){return false;},
158 /**
159 * Called at destruction time
160 * Perform all the clean operations (stopping polling queries, etc.)
161 */
162 close : function(){return true;}
163 }
164
165
166 });