]>
git.argeo.org Git - gpl/argeo-slc.git/blob - server/org.argeo.slc.ria/src/argeo-ria-lib/jcr/class/org/argeo/jcr/ria/views/ListView.js
14c14275c228e3dfa6665836a7eff124b5b56644
1 qx
.Class
.define("org.argeo.jcr.ria.views.ListView", {
2 extend
: qx
.ui
.container
.Composite
,
3 implement
: [org
.argeo
.ria
.components
.IView
],
6 * The commands definition Map that will be automatically added and wired to the menubar and toolbar.
7 * See {@link org.argeo.ria.event.CommandsManager#definitions} for the keys to use for defining commands.
14 check
:"org.argeo.ria.components.ViewSelection"
18 event
: "changeInstanceId"
22 event
: "changeInstanceLabel"
29 construct : function(){
35 * The implementation should contain the GUI initialisation.
36 * This is the role of the manager to actually add the graphical component to the pane,
37 * so it's not necessary to do it here.
38 * @param viewPane {org.argeo.ria.components.ViewPane} The pane manager
39 * @param data {Mixed} Any object or data passed by the initiator of the view
42 init : function(viewPane
, dataModel
){
43 this.setViewSelection(new org
.argeo
.ria
.components
.ViewSelection(viewPane
.getViewId()));
44 this.setLayout(new qx
.ui
.layout
.VBox());
45 this.setDataModel(dataModel
);
47 var split
= new qx
.ui
.splitpane
.Pane("vertical");
48 split
.setDecorator(null);
49 this.add(split
, {flex
:1});
51 this.list
= new qx
.ui
.form
.List();
52 split
.add(this.list
,1);
54 this.propInput
= new qx
.ui
.form
.TextArea();
55 split
.add(this.propInput
,1);
56 var call
= new qx
.util
.DeferredCall(function(){
57 qx
.bom
.element
.Style
.set(this.propInput
.getContentElement().getDomElement(), "lineHeight", "1.8");
62 * The implementation should contain the real data loading (i.o. query...)
66 var dataModel
= this.getDataModel();
67 dataModel
.addListener("changeSelection", function(event
){
68 if(dataModel
.getSelectionSource() == this) return;
69 var selection
= event
.getData();
70 this.list
.removeAll();
71 if(!selection
.length
) {
74 var contextNode
= selection
[0];
75 this._parseNode(contextNode
);
79 _parseNode : function (jcrNode
){
80 if(jcrNode
.getLoadState() == "loaded"){
81 this.list
.removeAll();
82 if(jcrNode
.getParent()){
83 this.list
.add(this._initListItem(jcrNode
.getParent(), ".."));
85 var children
= jcrNode
.getChildren();
86 for(var i
=0;i
<children
.length
;i
++){
87 this.list
.add(this._initListItem(children
[i
]));
89 if(this.list
.hasChildren()){
90 this.list
.setSelection([this.list
.getChildren()[0]]);
92 var properties
= jcrNode
.getProperties();
94 for(var i
=0;i
<properties
.length
;i
++){
95 propString
+= properties
[i
].getName()+"="+properties
[i
].getValue()+"\n";
97 this.propInput
.setValue(propString
);
99 var listener = function(event
){
100 if(event
.getData() == "loaded"){
101 this._parseNode(jcrNode
);
102 jcrNode
.removeListener("changeLoadState", listener
, this);
105 jcrNode
.addListener("changeLoadState", listener
, this);
106 if(jcrNode
.getLoadState() != "loading"){
112 _initListItem : function(jcrNode
, label
){
113 var li
= new qx
.ui
.form
.ListItem((label
?label
:jcrNode
.getName()), "org.argeo.jcr.ria/folder.png");
114 li
.setModel(jcrNode
);
115 li
.addListener("dblclick", function(){
116 this.getDataModel().setSelectionWithSource([jcrNode
], this);
122 * Whether this component is already contained in a scroller (return false) or not (return true).
125 addScroll : function(){
129 * Called at destruction time
130 * Perform all the clean operations (stopping polling queries, etc.)