Return-Path: X-Original-To: apmail-flex-commits-archive@www.apache.org Delivered-To: apmail-flex-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 665561023B for ; Fri, 6 Sep 2013 20:58:11 +0000 (UTC) Received: (qmail 46044 invoked by uid 500); 6 Sep 2013 20:58:11 -0000 Delivered-To: apmail-flex-commits-archive@flex.apache.org Received: (qmail 46023 invoked by uid 500); 6 Sep 2013 20:58:11 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 46017 invoked by uid 99); 6 Sep 2013 20:58:11 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Sep 2013 20:58:10 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id BB9F8902C91; Fri, 6 Sep 2013 20:58:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: pent@apache.org To: commits@flex.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: [flex-asjs] [refs/heads/develop] - Completed the implementation of List component such that it matches the ActionScript implementation, including itemRenderer factory, dataGroup, and mouse controllers. Date: Fri, 6 Sep 2013 20:58:10 +0000 (UTC) Updated Branches: refs/heads/develop c44f74710 -> 7c9e6a1c9 Completed the implementation of List component such that it matches the ActionScript implementation, including itemRenderer factory, dataGroup, and mouse controllers. Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/7c9e6a1c Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/7c9e6a1c Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/7c9e6a1c Branch: refs/heads/develop Commit: 7c9e6a1c950ce07e69cb014340d2209d0e10ad3c Parents: c44f747 Author: Peter Ent Authored: Fri Sep 6 16:57:57 2013 -0400 Committer: Peter Ent Committed: Fri Sep 6 16:57:57 2013 -0400 ---------------------------------------------------------------------- .../org/apache/flex/core/IItemRendererParent.js | 31 ++++++ .../FlexJS/src/org/apache/flex/core/ListBase.js | 4 +- .../org/apache/flex/html/staticControls/List.js | 52 ++++----- .../flex/html/staticControls/beads/ListView.js | 77 +++++++++++++ .../TextItemRendererFactoryForArrayData.js | 77 +++++++++++++ .../controllers/ItemRendererMouseController.js | 77 ++++++++++--- .../ListSingleSelectionMouseController.js | 64 +++++++++++ .../beads/models/ArraySelectionModel.js | 48 ++++++++- .../supportClasses/NonVirtualDataGroup.js | 84 +++++++++++++++ .../supportClasses/StringItemRenderer.js | 107 ++++++++++++++++--- 10 files changed, 553 insertions(+), 68 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7c9e6a1c/frameworks/js/FlexJS/src/org/apache/flex/core/IItemRendererParent.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/IItemRendererParent.js b/frameworks/js/FlexJS/src/org/apache/flex/core/IItemRendererParent.js new file mode 100644 index 0000000..345ff5b --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/core/IItemRendererParent.js @@ -0,0 +1,31 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +goog.provide('org.apache.flex.core.IItemRendererParent'); + +/** + * @constructor + */ +org.apache.flex.core.IItemRendererParent = function() { +}; + + +/** + * @expose + * @this {org.apache.flex.core.IItemRendererParent} + * @param {number} index The selected index. + */ +org.apache.flex.core.IItemRendererParent.prototype. +getItemRendererForIndex = function(index) { +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7c9e6a1c/frameworks/js/FlexJS/src/org/apache/flex/core/ListBase.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/ListBase.js b/frameworks/js/FlexJS/src/org/apache/flex/core/ListBase.js index d1c998d..fedac12 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/core/ListBase.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/core/ListBase.js @@ -51,7 +51,7 @@ org.apache.flex.core.ListBase.prototype.createElement = function() { // goog.events.listen(this.element, 'change', // goog.bind(this.changeHandler, this)); this.element = document.createElement('div'); - this.element.style.overflow='auto'; + this.element.style.overflow = 'auto'; this.element.style.border = 'solid'; this.element.style.borderWidth = '1px'; this.element.style.borderColor = '#333333'; @@ -110,7 +110,7 @@ org.apache.flex.core.ListBase.prototype.set_selectedIndex = */ org.apache.flex.core.ListBase.prototype.get_selectedItem = function() { - this.model.get_selectedItem(); + return this.model.get_selectedItem(); }; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7c9e6a1c/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js index 788a5a2..8805adc 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js @@ -15,6 +15,9 @@ goog.provide('org.apache.flex.html.staticControls.List'); goog.require('org.apache.flex.core.ListBase'); +goog.require('org.apache.flex.html.staticControls.beads.ListView'); +goog.require('org.apache.flex.html.staticControls.beads.TextItemRendererFactoryForArrayData'); +goog.require('org.apache.flex.html.staticControls.beads.controllers.ListSingleSelectionMouseController'); goog.require('org.apache.flex.html.staticControls.beads.models.ArraySelectionModel'); @@ -24,13 +27,6 @@ goog.require('org.apache.flex.html.staticControls.beads.models.ArraySelectionMod * @extends {org.apache.flex.core.ListBase} */ org.apache.flex.html.staticControls.List = function() { - this.model = new org.apache.flex.html.staticControls.beads.models.ArraySelectionModel(); - - this.renderers = new Array(); - - this.model.addEventListener('dataProviderChanged', - goog.bind(this.dataProviderChangedHandler,this)); - goog.base(this); }; goog.inherits(org.apache.flex.html.staticControls.List, @@ -44,35 +40,27 @@ goog.inherits(org.apache.flex.html.staticControls.List, org.apache.flex.html.staticControls.List.prototype.createElement = function() { goog.base(this, 'createElement'); + this.set_className('List'); - this.element.size = 5; + this.model = new + org.apache.flex.html.staticControls.beads.models.ArraySelectionModel(); + this.addBead(this.model); + this.addBead(new + org.apache.flex.html.staticControls.beads.ListView()); + this.addBead(new + org.apache.flex.html.staticControls.beads. + TextItemRendererFactoryForArrayData()); + this.addBead(new + org.apache.flex.html.staticControls.beads.controllers. + ListSingleSelectionMouseController()); }; -org.apache.flex.html.staticControls.List.prototype.dataProviderChangedHandler = -function(event) { - var dp, i, n, opt; - - while (this.element.hasChildNodes()) { - this.element.removeChild(this.element.lastChild); - } - - this.renderers.splice(0,this.renderers.length); - - dp = this.model.get_dataProvider(); - n = dp.length; - for (i = 0; i < n; i++) { - opt = new org.apache.flex.html.staticControls.supportClasses.StringItemRenderer(); - this.addElement(opt); - opt.set_strand(this); - opt.set_text(dp[i]); - - this.renderers.push(opt); - - goog.events.listen(opt, 'selected', - goog.bind(this.selectedHandler, this)); - } -}; +/** + * @expose + * @this {org.apache.flex.html.staticControls.TextInput} + * @param {object} event The event that triggered the selection. + */ org.apache.flex.html.staticControls.List.prototype.selectedHandler = function(event) { var itemRenderer = event.currentTarget; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7c9e6a1c/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/ListView.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/ListView.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/ListView.js new file mode 100644 index 0000000..d905015 --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/ListView.js @@ -0,0 +1,77 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +goog.provide('org.apache.flex.html.staticControls.beads.ListView'); + +goog.require('org.apache.flex.core.IItemRendererParent'); +goog.require('org.apache.flex.html.staticControls.beads.TextItemRendererFactoryForArrayData'); +goog.require('org.apache.flex.html.staticControls.beads.models.ArraySelectionModel'); +goog.require('org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup'); + +/** + * @constructor + */ +org.apache.flex.html.staticControls.beads.ListView = function() { + this.lastSelectedIndex = -1; +}; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.ListView} + * @param {Object} value The new host. + */ +org.apache.flex.html.staticControls.beads.ListView.prototype.set_strand = + function(value) { + + this.strand_ = value; + + this.model = value.getBeadByType( + org.apache.flex.html.staticControls.beads.models.ArraySelectionModel); + this.model.addEventListener('selectedIndexChanged', + goog.bind(this.selectionChangeHandler, this)); + + this.dataGroup_ = new + org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup(); + this.strand_.addElement(this.dataGroup_); +}; + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.ListView} + * @return {object} The DataGroup instance. + */ +org.apache.flex.html.staticControls.beads.ListView.prototype.get_dataGroup = +function() { + return this.dataGroup_; +}; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.ListView} + * @param {object} value The event that triggered the selection. + */ +org.apache.flex.html.staticControls.beads.ListView.prototype. +selectionChangeHandler = function(value) { + if (this.lastSelectedIndex != -1) { + var ir = this.dataGroup_.getItemRendererForIndex(this.lastSelectedIndex); + if (ir) ir.set_selected(false); + } + if (this.model.get_selectedIndex() != -1) { + ir = this.dataGroup_.getItemRendererForIndex( + this.model.get_selectedIndex()); + if (ir) ir.set_selected(true); + } + this.lastSelectedIndex = this.model.get_selectedIndex(); +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7c9e6a1c/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForArrayData.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForArrayData.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForArrayData.js new file mode 100644 index 0000000..c46e469 --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForArrayData.js @@ -0,0 +1,77 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +goog.provide('org.apache.flex.html.staticControls.beads.TextItemRendererFactoryForArrayData'); + +goog.require('org.apache.flex.events.EventDispatcher'); +goog.require('org.apache.flex.html.staticControls.beads.models.ArraySelectionModel'); + +/** + * @constructor + * @extends {org.apache.flex.events.EventDispatcher} + */ +org.apache.flex.html.staticControls.beads.TextItemRendererFactoryForArrayData = +function() { + goog.base(this); +}; +goog.inherits( + org.apache.flex.html.staticControls.beads.TextItemRendererFactoryForArrayData, + org.apache.flex.events.EventDispatcher); + + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads. + TextItemRendererFactoryForArrayData} + * @param {object} value The component strand. + */ +org.apache.flex.html.staticControls.beads.TextItemRendererFactoryForArrayData. +prototype.set_strand = function(value) { + this.strand_ = value; + + this.model = value.getBeadByType( + org.apache.flex.html.staticControls.beads.models.ArraySelectionModel); + + this.listView = value.getBeadByType( + org.apache.flex.html.staticControls.beads.ListView); + this.dataGroup = this.listView.get_dataGroup(); + + this.model.addEventListener('dataProviderChanged', + goog.bind(this.dataProviderChangedHandler, this)); +}; + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads. + TextItemRendererFactoryForArrayData} + * @param {object} event The event that triggered the dataProvider change. + */ +org.apache.flex.html.staticControls.beads.TextItemRendererFactoryForArrayData. +prototype.dataProviderChangedHandler = function(event) { + var dp, i, n, opt; + + dp = this.model.get_dataProvider(); + n = dp.length; + for (i = 0; i < n; i++) { + opt = new + org.apache.flex.html.staticControls.supportClasses.StringItemRenderer(); + this.dataGroup.addElement(opt); + opt.set_text(dp[i]); + } + + var newEvent = new org.apache.flex.events.Event('itemsCreated'); + this.dispatchEvent(newEvent); +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7c9e6a1c/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/controllers/ItemRendererMouseController.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/controllers/ItemRendererMouseController.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/controllers/ItemRendererMouseController.js index e907de2..12c79df 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/controllers/ItemRendererMouseController.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/controllers/ItemRendererMouseController.js @@ -18,14 +18,22 @@ goog.provide('org.apache.flex.html.staticControls.beads.controllers.ItemRenderer /** * @constructor */ -org.apache.flex.html.staticControls.beads.controllers.ItemRendererMouseController = -function() { +org.apache.flex.html.staticControls.beads.controllers. +ItemRendererMouseController = function() { }; -org.apache.flex.html.staticControls.beads.controllers.ItemRendererMouseController. -prototype.set_strand = function(value) { + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.controllers. + * ItemRendererMouseController} + * @param {object} value The strand for this component. + */ +org.apache.flex.html.staticControls.beads.controllers. +ItemRendererMouseController.prototype.set_strand = function(value) { this.strand_ = value; - + goog.events.listen(this.strand_.element, goog.events.EventType.MOUSEOVER, goog.bind(this.handleMouseOver, this)); @@ -39,28 +47,65 @@ prototype.set_strand = function(value) { goog.bind(this.handleMouseUp, this)); }; -org.apache.flex.html.staticControls.beads.controllers.ItemRendererMouseController. -prototype.handleMouseOver = function(event) { + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.controllers. + * ItemRendererMouseController} + * @param {object} event The mouse event that triggered the hover. + */ +org.apache.flex.html.staticControls.beads.controllers. +ItemRendererMouseController.prototype.handleMouseOver = function(event) { this.strand_.set_hovered(true); }; -org.apache.flex.html.staticControls.beads.controllers.ItemRendererMouseController. -prototype.handleMouseOut = function(event) { + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.controllers. + * ItemRendererMouseController} + * @param {object} event The mouse-out event. + */ +org.apache.flex.html.staticControls.beads.controllers. +ItemRendererMouseController.prototype.handleMouseOut = function(event) { this.strand_.set_hovered(false); }; -org.apache.flex.html.staticControls.beads.controllers.ItemRendererMouseController. -prototype.handleMouseDown = function(event) { + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.controllers. + * ItemRendererMouseController} + * @param {object} event The mouse-down event. + */ +org.apache.flex.html.staticControls.beads.controllers. +ItemRendererMouseController.prototype.handleMouseDown = function(event) { // ?? }; -org.apache.flex.html.staticControls.beads.controllers.ItemRendererMouseController. -prototype.handleMouseUp = function(event) { - var target = event.currentTarget; +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.controllers. + * ItemRendererMouseController} + * @param {object} event The mouse-up event that triggers the selection. + */ +org.apache.flex.html.staticControls.beads.controllers. +ItemRendererMouseController.prototype.handleMouseUp = function(event) { + var newEvent = new goog.events.Event('selected'); - this.strand_.dispatchEvent(newEvent); -}; \ No newline at end of file + + // normally you do not - and should not - change the target of an event, + // but these events do not propagate nor bubble up the object tree, so + // we have to force the event's target to be this item renderer instance. + + newEvent.target = this.strand_; + + // since the event is not going to up the chain, we also have to dispatch + // it against its final destination. + + this.strand_.get_itemRendererParent().dispatchEvent(newEvent); +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7c9e6a1c/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/controllers/ListSingleSelectionMouseController.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/controllers/ListSingleSelectionMouseController.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/controllers/ListSingleSelectionMouseController.js new file mode 100644 index 0000000..444104a --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/controllers/ListSingleSelectionMouseController.js @@ -0,0 +1,64 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +goog.provide('org.apache.flex.html.staticControls.beads.controllers.ListSingleSelectionMouseController'); + +goog.require('org.apache.flex.html.staticControls.beads.ListView'); +goog.require('org.apache.flex.html.staticControls.beads.models.ArraySelectionModel'); + + +/** + * @constructor + */ +org.apache.flex.html.staticControls.beads.controllers. +ListSingleSelectionMouseController = function() { +}; + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.controllers. + * ListSingleSelectionMouseController} + * @param {object} value The strand for this component. + */ +org.apache.flex.html.staticControls.beads.controllers. +ListSingleSelectionMouseController.prototype.set_strand = function(value) { + this.strand_ = value; + + this.model = value.getBeadByType( + org.apache.flex.html.staticControls.beads.models.ArraySelectionModel); + this.listView = value.getBeadByType( + org.apache.flex.html.staticControls.beads.ListView); + + this.dataGroup = this.listView.get_dataGroup(); + this.dataGroup.addEventListener('selected', + goog.bind(this.selectedHandler, this)); +}; + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.controllers. + * ListSingleSelectionMouseController} + * @param {object} event The event that triggered the selection. + */ +org.apache.flex.html.staticControls.beads.controllers. +ListSingleSelectionMouseController.prototype.selectedHandler = function(event) { + + var index = event.target.get_index(); + this.model.set_selectedIndex(index); + + var newEvent = new org.apache.flex.events.Event('change'); + this.strand_.dispatchEvent(newEvent); +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7c9e6a1c/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/models/ArraySelectionModel.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/models/ArraySelectionModel.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/models/ArraySelectionModel.js index f93f903..12944a1 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/models/ArraySelectionModel.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/models/ArraySelectionModel.js @@ -20,11 +20,13 @@ goog.require('org.apache.flex.events.EventDispatcher'); * @constructor * @extends {org.apache.flex.events.EventDispatcher} */ -org.apache.flex.html.staticControls.beads.models.ArraySelectionModel = function() { +org.apache.flex.html.staticControls.beads.models.ArraySelectionModel = +function() { goog.base(this); }; -goog.inherits(org.apache.flex.html.staticControls.beads.models.ArraySelectionModel, - org.apache.flex.events.EventDispatcher); +goog.inherits( + org.apache.flex.html.staticControls.beads.models.ArraySelectionModel, + org.apache.flex.events.EventDispatcher); /** @@ -37,33 +39,69 @@ set_strand = function(value) { this.strand_ = value; }; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.models.ArraySelectionModel} + * @return {Object} value The dataProvider. + */ org.apache.flex.html.staticControls.beads.models.ArraySelectionModel.prototype. get_dataProvider = function() { return this.dataProvider_; }; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.models.ArraySelectionModel} + * @param {Object} value The dataProvider. + */ org.apache.flex.html.staticControls.beads.models.ArraySelectionModel.prototype. set_dataProvider = function(value) { this.dataProvider_ = value; this.dispatchEvent('dataProviderChanged'); }; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.models.ArraySelectionModel} + * @return {Object} value The selected index. + */ org.apache.flex.html.staticControls.beads.models.ArraySelectionModel.prototype. get_selectedIndex = function() { return this.selectedIndex_; }; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.models.ArraySelectionModel} + * @param {Object} value The selected index. + */ org.apache.flex.html.staticControls.beads.models.ArraySelectionModel.prototype. set_selectedIndex = function(value) { this.selectedIndex_ = value; this.dispatchEvent('selectedIndexChanged'); }; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.models.ArraySelectionModel} + * @return {Object} value The selected item. + */ org.apache.flex.html.staticControls.beads.models.ArraySelectionModel.prototype. get_selectedItem = function() { return this.selectedItem_; }; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.beads.models.ArraySelectionModel} + * @param {Object} value The selected item. + */ org.apache.flex.html.staticControls.beads.models.ArraySelectionModel.prototype. set_selectedItem = function(value) { this.selectedItem_ = value; @@ -71,14 +109,14 @@ set_selectedItem = function(value) { this.selectedIndex_ = -1; var n = this.dataProvider_.length; - for (var i=0; i < n; i++) { + for (var i = 0; i < n; i++) { var item = this.dataProvider_[i]; if (item == value) { this.selectedIndex_ = i; break; } } - + this.dispatchEvent('selectedItemChanged'); this.dispatchEvent('selectedIndexChanged'); }; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7c9e6a1c/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/NonVirtualDataGroup.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/NonVirtualDataGroup.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/NonVirtualDataGroup.js new file mode 100644 index 0000000..31ba2e4 --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/NonVirtualDataGroup.js @@ -0,0 +1,84 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +goog.provide('org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup'); + +goog.require('org.apache.flex.core.UIBase'); + +/** + * @constructor + * @extends {org.apache.flex.core.UIBase} + */ +org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup = +function() { + this.renderers = new Array(); + goog.base(this); +}; +goog.inherits( + org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup, + org.apache.flex.core.UIBase); + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.supportClasses. + * NonVirtualDataGroup} + * @param {Object} value The strand. + */ +org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup. +prototype.set_strand = function(value) { + this.strand_ = value; +}; + + +/** + * @override + * @this {org.apache.flex.html.staticControls.supportClasses. + * NonVirtualDataGroup} + */ +org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup. +prototype.createElement = function() { + this.element = document.createElement('div'); + this.element.style.overflow = 'auto'; + this.set_className('NonVirtualDataGroup'); +}; + + +/** + * @override + * @this {org.apache.flex.html.staticControls.supportClasses. + * NonVirtualDataGroup} + * @param {Object} value The child element being added. + */ +org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup. +prototype.addElement = function(value) { + goog.base(this, 'addElement', value); + + value.set_index(this.renderers.length); + value.set_itemRendererParent(this); + this.renderers.push(value); +}; + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.supportClasses. + * NonVirtualDataGroup} + * @param {Object} index The index for the itemRenderer. + * @return {Object} The itemRenderer that matches the index. + */ +org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup. +prototype.getItemRendererForIndex = function(index) { + return this.renderers[index]; +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7c9e6a1c/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/StringItemRenderer.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/StringItemRenderer.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/StringItemRenderer.js index 87040be..5c83083 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/StringItemRenderer.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/StringItemRenderer.js @@ -21,16 +21,18 @@ goog.require('org.apache.flex.html.staticControls.beads.controllers.ItemRenderer * @constructor * @extends {org.apache.flex.core.UIBase} */ -org.apache.flex.html.staticControls.supportClasses.StringItemRenderer = function() { +org.apache.flex.html.staticControls.supportClasses.StringItemRenderer = +function() { goog.base(this); }; -goog.inherits(org.apache.flex.html.staticControls.supportClasses.StringItemRenderer, - org.apache.flex.core.UIBase); +goog.inherits( + org.apache.flex.html.staticControls.supportClasses.StringItemRenderer, + org.apache.flex.core.UIBase); /** * @override - * @this {org.apache.flex.html.staticControls.Label} + * @this {org.apache.flex.html.staticControls.supportClasses.StringItemRenderer} */ org.apache.flex.html.staticControls.supportClasses.StringItemRenderer. prototype.createElement = function() { @@ -40,62 +42,141 @@ prototype.createElement = function() { this.element.flexjs_wrapper = this; this.set_className('StringItemRenderer'); - + // itemRenderers should provide something for the background to handle - // the selection and highlight + // the selection and highlight this.backgroundView = this.element; - - this.controller = new org.apache.flex.html.staticControls.beads.controllers.ItemRendererMouseController(); + + this.controller = new org.apache.flex.html.staticControls.beads.controllers. + ItemRendererMouseController(); this.controller.set_strand(this); }; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.supportClasses.StringItemRenderer} + * @param {Object} value The strand. + */ org.apache.flex.html.staticControls.supportClasses.StringItemRenderer. prototype.set_strand = function(value) { this.strand_ = value; }; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.supportClasses.StringItemRenderer} + * @return {Object} The strand. + */ org.apache.flex.html.staticControls.supportClasses.StringItemRenderer. prototype.get_strand = function() { return this.strand_; }; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.supportClasses.StringItemRenderer} + * @return {Object} The item renderer's parent. + */ +org.apache.flex.html.staticControls.supportClasses.StringItemRenderer. +prototype.get_itemRendererParent = function() { + return this.rendererParent_; +}; + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.supportClasses.StringItemRenderer} + * @param {Object} value The item renderer's parent. + */ +org.apache.flex.html.staticControls.supportClasses.StringItemRenderer. +prototype.set_itemRendererParent = function(value) { + this.rendererParent_ = value; +}; + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.supportClasses.StringItemRenderer} + * @return {Object} The renderer's index. + */ +org.apache.flex.html.staticControls.supportClasses.StringItemRenderer. +prototype.get_index = function() { + return this.index_; +}; + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.supportClasses.StringItemRenderer} + * @param {Object} value The renderer's index. + */ +org.apache.flex.html.staticControls.supportClasses.StringItemRenderer. +prototype.set_index = function(value) { + this.index_ = value; +}; + + +/** + * @expose + * @this {org.apache.flex.html.staticControls.supportClasses.StringItemRenderer} + * @param {Object} value The text to display. + */ org.apache.flex.html.staticControls.supportClasses.StringItemRenderer. prototype.set_text = function(value) { this.element.innerHTML = value; }; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.supportClasses.StringItemRenderer} + * @return {Object} The text being displayed. + */ org.apache.flex.html.staticControls.supportClasses.StringItemRenderer. prototype.get_text = function() { return this.element.innerHTML; }; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.supportClasses.StringItemRenderer} + * @param {boolean} value The selection state. + */ org.apache.flex.html.staticControls.supportClasses.StringItemRenderer. prototype.set_selected = function(value) { this.selected_ = value; if (value) { - this.backgroundView.style.backgroundColor = '#ACACAC'; + this.backgroundView.style.backgroundColor = '#9C9C9C'; } else { this.backgroundView.style.backgroundColor = null; } }; + +/** + * @expose + * @this {org.apache.flex.html.staticControls.supportClasses.StringItemRenderer} + * @param {boolean} value The hovered state. + */ org.apache.flex.html.staticControls.supportClasses.StringItemRenderer. prototype.set_hovered = function(value) { this.hovered_ = value; if (value) { - this.backgroundView.style.backgroundColor='#999999'; + this.backgroundView.style.backgroundColor = '#ECECEC'; } else { if (this.selected_) { - this.backgroundView.style.backgroundColor = '#ACACAC'; + this.backgroundView.style.backgroundColor = '#9C9C9C'; } else { this.backgroundView.style.backgroundColor = null; } } }; - -