]> git.argeo.org Git - gpl/argeo-slc.git/blob - server/org.argeo.slc.ria/src/main/webapp/argeo-ria-lib/sample/class/org/argeo/ria/sample/List.js
Create Argeo SLC RIA project
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / src / main / webapp / argeo-ria-lib / sample / class / org / argeo / ria / sample / List.js
1 /**
2 * A Basic IView implementation displaying a fake list of result and opening
3 * an org.argeo.ria.sample.Applet
4 */
5 qx.Class.define("org.argeo.ria.sample.List",
6 {
7 extend : qx.ui.container.Composite,
8 implement : [org.argeo.ria.components.IView],
9
10 construct : function(){
11 this.base(arguments, new qx.ui.layout.VBox());
12 var model = new qx.ui.table.model.Simple();
13 model.setColumns(["Test Case", "Date"]);
14 this.table = new qx.ui.table.Table(model, {
15 tableColumnModel: function(obj){
16 return new qx.ui.table.columnmodel.Resize(obj)
17 }
18 });
19 },
20
21 properties :
22 {
23 /**
24 * The viewPane containing this applet.
25 */
26 view : {
27 init : null
28 },
29 /**
30 * The applet commands.
31 */
32 commands : {
33 init : {
34 "opentest" : {
35 label : "Open",
36 icon : "resource/slc/media-playback-start.png",
37 shortcut : "Control+o",
38 enabled : false,
39 menu : "Selection",
40 toolbar : "selection",
41 callback : function(e){
42 var viewsManager = org.argeo.ria.components.ViewsManager.getInstance();
43 var classObj = org.argeo.ria.sample.Applet;
44 var rowData = viewsManager.getViewPaneSelection("list").getNodes();
45 var iView = viewsManager.initIViewClass(classObj, "applet", rowData[0]);
46 iView.load();
47 },
48 selectionChange : function(viewId, rowData){
49 if(viewId != "list") return;
50 this.setEnabled(false);
51 if(rowData == null || !rowData.length) return;
52 this.setEnabled(true);
53 },
54 command : null
55 }
56 }
57 },
58 viewSelection : {
59 nullable:false,
60 check:"org.argeo.ria.components.ViewSelection"
61 },
62 instanceId : {init:"0"},
63 instanceLabel : {init:"Sample List"}
64 },
65
66 members : {
67 init : function(viewPane, data){
68 this.setView(viewPane);
69 this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId()));
70
71 },
72 load : function(){
73 //
74 // Customize table appearance
75 //
76 this.table.set({
77 statusBarVisible: false,
78 showCellFocusIndicator:false,
79 columnVisibilityButtonVisible:false,
80 contextMenu : org.argeo.ria.event.CommandsManager.getInstance().createMenuFromIds(["opentest", "download", "copytocollection", "deletetest"]),
81 decorator : new qx.ui.decoration.Background("#fff")
82 });
83
84 //
85 // Link table selection changes to the standard viewSelection mechanism
86 //
87 var selectionModel = this.table.getSelectionManager().getSelectionModel();
88 selectionModel.addListener("changeSelection", function(e){
89 var viewSelection = this.getViewSelection();
90 viewSelection.clear();
91 if(!selectionModel.getSelectedCount()){
92 return;
93 }
94 var ranges = selectionModel.getSelectedRanges();
95 var rowData = this.table.getTableModel().getRowData(ranges[0].minIndex);
96 viewSelection.addNode(rowData);
97 }, this);
98
99 //
100 // Add table to the GUI component
101 //
102 this.add(this.table, {flex:1});
103
104 //
105 // Now create fake rows
106 //
107 var model = this.table.getTableModel();
108 model.addRows([
109 ["Id 1","Sample 1"],
110 ["Id 2","Sample 2"],
111 ["Id 3","Sample 3"]
112 ]);
113 },
114
115 addScroll : function(){
116 return false;
117 },
118
119 close : function(){
120
121 }
122 }
123 });