+++ /dev/null
-qx.Class.define("org.argeo.jcr.ria.views.ListView", {\r
- extend : qx.ui.container.Composite, \r
- implement : [org.argeo.ria.components.IView],\r
- properties : {\r
- /**\r
- * The commands definition Map that will be automatically added and wired to the menubar and toolbar.\r
- * See {@link org.argeo.ria.event.CommandsManager#definitions} for the keys to use for defining commands.\r
- */\r
- commands : {\r
- init : {}\r
- },\r
- viewSelection : {\r
- nullable:false, \r
- check:"org.argeo.ria.components.ViewSelection"\r
- },\r
- instanceId : {\r
- init:"listView",\r
- event : "changeInstanceId"\r
- },\r
- instanceLabel : {\r
- init:"Nodes List",\r
- event : "changeInstanceLabel"\r
- },\r
- dataModel : {\r
- \r
- }\r
- },\r
- \r
- construct : function(){\r
- this.base(arguments);\r
- },\r
- \r
- members : {\r
- /**\r
- * The implementation should contain the GUI initialisation.\r
- * This is the role of the manager to actually add the graphical component to the pane, \r
- * so it's not necessary to do it here. \r
- * @param viewPane {org.argeo.ria.components.ViewPane} The pane manager\r
- * @param data {Mixed} Any object or data passed by the initiator of the view\r
- * @return {Boolean}\r
- */\r
- init : function(viewPane, dataModel){\r
- this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId())); \r
- this.setLayout(new qx.ui.layout.VBox());\r
- this.setDataModel(dataModel);\r
- \r
- var split = new qx.ui.splitpane.Pane("vertical");\r
- split.setDecorator(null);\r
- this.add(split, {flex:1});\r
- \r
- this.list = new qx.ui.form.List(); \r
- split.add(this.list,1);\r
- \r
- this.propInput = new qx.ui.form.TextArea();\r
- split.add(this.propInput,1);\r
- var call = new qx.util.DeferredCall(function(){\r
- qx.bom.element.Style.set(this.propInput.getContentElement().getDomElement(), "lineHeight", "1.8");\r
- }, this);\r
- call.schedule();\r
- },\r
- /**\r
- * The implementation should contain the real data loading (i.o. query...)\r
- * @return {Boolean}\r
- */\r
- load : function(){\r
- var dataModel = this.getDataModel();\r
- dataModel.addListener("changeSelection", function(event){\r
- if(dataModel.getSelectionSource() == this) return;\r
- var selection = event.getData();\r
- this.list.removeAll();\r
- if(!selection.length) {\r
- return;\r
- }\r
- var contextNode = selection[0];\r
- this._parseNode(contextNode);\r
- }, this);\r
- },\r
- \r
- _parseNode : function (jcrNode){\r
- if(jcrNode.getLoadState() == "loaded"){\r
- this.list.removeAll();\r
- if(jcrNode.getParent()){\r
- this.list.add(this._initListItem(jcrNode.getParent(), ".."));\r
- }\r
- var children = jcrNode.getChildren();\r
- for(var i=0;i<children.length;i++){\r
- this.list.add(this._initListItem(children[i]));\r
- }\r
- if(this.list.hasChildren()){\r
- this.list.setSelection([this.list.getChildren()[0]]);\r
- }\r
- var properties = jcrNode.getProperties();\r
- var propString = "";\r
- for(var i=0;i<properties.length;i++){\r
- propString += properties[i].getName()+"="+properties[i].getValue()+"\n";\r
- }\r
- this.propInput.setValue(propString);\r
- }else{\r
- var listener = function(event){\r
- if(event.getData() == "loaded"){\r
- this._parseNode(jcrNode);\r
- jcrNode.removeListener("changeLoadState", listener, this);\r
- }\r
- };\r
- jcrNode.addListener("changeLoadState", listener, this);\r
- if(jcrNode.getLoadState() != "loading"){\r
- jcrNode.load();\r
- }\r
- }\r
- },\r
- \r
- _initListItem : function(jcrNode, label){\r
- var li = new qx.ui.form.ListItem((label?label:jcrNode.getName()), "org.argeo.jcr.ria/folder.png");\r
- li.setModel(jcrNode);\r
- li.addListener("dblclick", function(){\r
- this.getDataModel().setSelectionWithSource([jcrNode], this);\r
- }, this);\r
- return li;\r
- },\r
- \r
- /**\r
- * Whether this component is already contained in a scroller (return false) or not (return true).\r
- * @return {Boolean}\r
- */\r
- addScroll : function(){\r
- return false;\r
- },\r
- /**\r
- * Called at destruction time\r
- * Perform all the clean operations (stopping polling queries, etc.) \r
- */\r
- close : function(){\r
- \r
- } \r
- \r
- }\r
-});\r