X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=org.argeo.slc.webapp%2Fsrc%2Fmain%2Fwebapp%2Fargeo-ria-src%2Fclass%2Forg%2Fargeo%2Fria%2Fcomponents%2FViewSelection.js;fp=org.argeo.slc.webapp%2Fsrc%2Fmain%2Fwebapp%2Fargeo-ria-src%2Fclass%2Forg%2Fargeo%2Fria%2Fcomponents%2FViewSelection.js;h=6c3e873abe37b1a0368e27fe4910ec036c012918;hb=a10c083ba5bde2d7ebb466153c99858247ddb0aa;hp=0000000000000000000000000000000000000000;hpb=eea4bceab5bed0001c049b46cd6842ebdf41c95f;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewSelection.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewSelection.js new file mode 100644 index 000000000..6c3e873ab --- /dev/null +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewSelection.js @@ -0,0 +1,85 @@ +/** + * Generic selection model associated to an IView content opened in a given ViewPane. + * It contains in an array any row/data/node, and triggers changeSelection data events. + * @author Charles du Jeu + */ +qx.Class.define("org.argeo.ria.components.ViewSelection", +{ + extend : qx.core.Object, + + /** + * @param viewId {String} The ViewPane unique id + */ + construct : function(viewId){ + this.base(arguments); + this.nodes = []; + this.setViewId(viewId); + }, + + properties : { + /** + * The viewPane unique id + */ + viewId : { + check : "String", + nullable: false + } + }, + + events : { + /** + * Triggered each time the selection changes. + */ + "changeSelection" : "qx.event.type.Data" + }, + + /* + ***************************************************************************** + MEMBERS + ***************************************************************************** + */ + + members : + { + /** + * Empty the selection + */ + clear : function(){ + this.nodes = []; + this.triggerEvent(); + }, + + /** + * Add a row or xml node or whatever + * @param node {mixed} Data to add to the selection + */ + addNode : function(node) { + this.nodes.push(node); + this.triggerEvent(); + }, + + /** + * The number of rows/nodes selected + * @return {Integer} + */ + getCount : function() { + return this.nodes.length; + }, + + /** + * Returns the content of the selection + * @return {Array} + */ + getNodes : function(){ + return this.nodes; + }, + + /** + * Creates and fire a data event changeSelection + */ + triggerEvent : function(){ + this.fireDataEvent("changeSelection", this); + } + + } +}); \ No newline at end of file