Repository: flex-asjs Updated Branches: refs/heads/develop d9724b829 -> 6e43cd2d6
PAYG-ifying the earlier change to LayoutBase, added 'RemovableBasicLayout' which is necessary to avoid a related error in FlexJSStore Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/6e43cd2d Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/6e43cd2d Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/6e43cd2d Branch: refs/heads/develop Commit: 6e43cd2d6b4e36d03b0b931e6ab2c8b76f128ecd Parents: d9724b8 Author: greg-dove <[email protected]> Authored: Fri Jul 7 20:01:13 2017 +1200 Committer: greg-dove <[email protected]> Committed: Fri Jul 7 20:01:13 2017 +1200 ---------------------------------------------------------------------- .../flex/productsView/ProductCatalogPanel.mxml | 2 +- .../Basic/src/main/flex/BasicClasses.as | 1 + .../flex/org/apache/flex/core/LayoutBase.as | 35 ++------- .../html/beads/layouts/RemovableBasicLayout.as | 81 ++++++++++++++++++++ .../Basic/src/main/resources/basic-manifest.xml | 1 + 5 files changed, 92 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6e43cd2d/examples/flexjs/FlexJSStore/src/main/flex/productsView/ProductCatalogPanel.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/FlexJSStore/src/main/flex/productsView/ProductCatalogPanel.mxml b/examples/flexjs/FlexJSStore/src/main/flex/productsView/ProductCatalogPanel.mxml index 38b09a6..f7824af 100755 --- a/examples/flexjs/FlexJSStore/src/main/flex/productsView/ProductCatalogPanel.mxml +++ b/examples/flexjs/FlexJSStore/src/main/flex/productsView/ProductCatalogPanel.mxml @@ -505,7 +505,7 @@ limitations under the License. <js:beads> <js:ContainerDataBinding /> - <js:BasicLayout /> + <js:RemovableBasicLayout /> <js:DragMouseController id="dragger" /> <js:ParentDocumentBead id="pdb" /> <js:PanelView> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6e43cd2d/frameworks/projects/Basic/src/main/flex/BasicClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/BasicClasses.as b/frameworks/projects/Basic/src/main/flex/BasicClasses.as index ffbeab1..539beaa 100644 --- a/frameworks/projects/Basic/src/main/flex/BasicClasses.as +++ b/frameworks/projects/Basic/src/main/flex/BasicClasses.as @@ -145,6 +145,7 @@ internal class BasicClasses import org.apache.flex.html.beads.layouts.HorizontalLayoutWithPaddingAndGap; HorizontalLayoutWithPaddingAndGap; import org.apache.flex.html.beads.layouts.HorizontalFlexLayout; HorizontalFlexLayout; import org.apache.flex.html.beads.layouts.BasicLayout; BasicLayout; + import org.apache.flex.html.beads.layouts.RemovableBasicLayout; RemovableBasicLayout; import org.apache.flex.html.beads.layouts.OneFlexibleChildHorizontalLayout; OneFlexibleChildHorizontalLayout; import org.apache.flex.html.beads.layouts.OneFlexibleChildVerticalLayout; OneFlexibleChildVerticalLayout; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6e43cd2d/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as index 4e7423b..7bc5ab0 100644 --- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as @@ -80,35 +80,16 @@ package org.apache.flex.core */ public function set strand(value:IStrand):void { - var newHost:ILayoutChild = value as ILayoutChild; - var oldHost:ILayoutChild = host; - if (newHost != oldHost) { - var sizeChange:Function = handleSizeChange; - var childrenAdded:Function =handleChildrenAdded; - var initComplete:Function = handleInitComplete; - var layoutNeeded:Function = handleLayoutNeeded; - if (oldHost) { - IEventDispatcher(oldHost).removeEventListener("widthChanged", sizeChange); - IEventDispatcher(oldHost).removeEventListener("heightChanged", sizeChange); - IEventDispatcher(oldHost).removeEventListener("sizeChanged", sizeChange); + host = value as ILayoutChild; + var sizeChange:Function = handleSizeChange; + IEventDispatcher(value).addEventListener("widthChanged", sizeChange); + IEventDispatcher(value).addEventListener("heightChanged", sizeChange); + IEventDispatcher(value).addEventListener("sizeChanged", sizeChange); - IEventDispatcher(oldHost).removeEventListener("childrenAdded", childrenAdded); - IEventDispatcher(oldHost).removeEventListener("initComplete", initComplete); + IEventDispatcher(value).addEventListener("childrenAdded", handleChildrenAdded); + IEventDispatcher(value).addEventListener("initComplete", handleInitComplete); + IEventDispatcher(value).addEventListener("layoutNeeded", handleLayoutNeeded); - IEventDispatcher(oldHost).removeEventListener("layoutNeeded", layoutNeeded); - } - host = newHost; - if (newHost) { - IEventDispatcher(newHost).addEventListener("widthChanged", sizeChange); - IEventDispatcher(newHost).addEventListener("heightChanged", sizeChange); - IEventDispatcher(newHost).addEventListener("sizeChanged", sizeChange); - - IEventDispatcher(newHost).addEventListener("childrenAdded", childrenAdded); - IEventDispatcher(newHost).addEventListener("initComplete", initComplete); - - IEventDispatcher(newHost).addEventListener("layoutNeeded", layoutNeeded); - } - } } /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6e43cd2d/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/RemovableBasicLayout.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/RemovableBasicLayout.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/RemovableBasicLayout.as new file mode 100644 index 0000000..49753b3 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/RemovableBasicLayout.as @@ -0,0 +1,81 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads.layouts { +import org.apache.flex.core.IStrand; +import org.apache.flex.core.IBeadLayout; +import org.apache.flex.core.ILayoutChild; +import org.apache.flex.events.IEventDispatcher; + +/** + * The RemovableBasicLayout class is a simple layout + * bead. It takes the set of children and lays them out + * as specified by CSS properties like left, right, top + * and bottom. It correctly handles removal and replacement between + * different strands, and null strand assignment + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ +public class RemovableBasicLayout extends BasicLayout implements IBeadLayout { + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + * + * @flexjsignorecoercion org.apache.flex.core.ILayoutChild + * @flexjsignorecoercion org.apache.flex.events.IEventDispatcher + */ + override public function set strand(value:IStrand):void { + var newHost:ILayoutChild = value as ILayoutChild; + var oldHost:ILayoutChild = host; + if (newHost != oldHost) { + var sizeChange:Function = handleSizeChange; + var childrenAdded:Function = handleChildrenAdded; + var initComplete:Function = handleInitComplete; + var layoutNeeded:Function = handleLayoutNeeded; + if (oldHost) { + IEventDispatcher(oldHost).removeEventListener("widthChanged", sizeChange); + IEventDispatcher(oldHost).removeEventListener("heightChanged", sizeChange); + IEventDispatcher(oldHost).removeEventListener("sizeChanged", sizeChange); + IEventDispatcher(oldHost).removeEventListener("childrenAdded", childrenAdded); + IEventDispatcher(oldHost).removeEventListener("initComplete", initComplete); + IEventDispatcher(oldHost).removeEventListener("layoutNeeded", layoutNeeded); + } + + host = newHost; + if (newHost) { + //note, could call super.strand = newHost here, to avoid DRY + //but not doing so, because it will be slower with the repeated closure lookups in js + IEventDispatcher(newHost).addEventListener("widthChanged", sizeChange); + IEventDispatcher(newHost).addEventListener("heightChanged", sizeChange); + IEventDispatcher(newHost).addEventListener("sizeChanged", sizeChange); + IEventDispatcher(newHost).addEventListener("childrenAdded", childrenAdded); + IEventDispatcher(newHost).addEventListener("initComplete", initComplete); + IEventDispatcher(newHost).addEventListener("layoutNeeded", layoutNeeded); + } + } + } +} +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6e43cd2d/frameworks/projects/Basic/src/main/resources/basic-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml index 0eecefd..3908e93 100644 --- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml +++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml @@ -67,6 +67,7 @@ <component id="ToolTip" class="org.apache.flex.html.ToolTip"/> <component id="Tree" class="org.apache.flex.html.Tree"/> <component id="BasicLayout" class="org.apache.flex.html.beads.layouts.BasicLayout"/> + <component id="RemovableBasicLayout" class="org.apache.flex.html.beads.layouts.RemovableBasicLayout"/> <component id="VerticalLayout" class="org.apache.flex.html.beads.layouts.VerticalLayout"/> <component id="VerticalLayoutWithPaddingAndGap" class="org.apache.flex.html.beads.layouts.VerticalLayoutWithPaddingAndGap"/> <component id="VerticalFlexLayout" class="org.apache.flex.html.beads.layouts.VerticalFlexLayout"/>
