flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [4/4] git commit: [flex-asjs] [refs/heads/develop] - rudimentary filtering for ASDoc app
Date Thu, 22 Dec 2016 06:13:46 GMT
rudimentary filtering for ASDoc app


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/94439939
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/94439939
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/94439939

Branch: refs/heads/develop
Commit: 944399397781ae3a6a5e4e5b300cc4cb3a5ff6e4
Parents: d437a33
Author: Alex Harui <aharui@apache.org>
Authored: Wed Dec 21 22:12:45 2016 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Wed Dec 21 22:13:32 2016 -0800

----------------------------------------------------------------------
 .../ASDoc/src/main/flex/ASDocMainView.mxml      | 22 ++++-
 .../main/flex/controllers/ASDocController.as    | 32 +++++++
 .../ASDoc/src/main/flex/models/ASDocModel.as    | 90 +++++++++++++++++++-
 3 files changed, 140 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94439939/examples/flexjs/ASDoc/src/main/flex/ASDocMainView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/ASDoc/src/main/flex/ASDocMainView.mxml b/examples/flexjs/ASDoc/src/main/flex/ASDocMainView.mxml
index 25d4884..e7dde44 100644
--- a/examples/flexjs/ASDoc/src/main/flex/ASDocMainView.mxml
+++ b/examples/flexjs/ASDoc/src/main/flex/ASDocMainView.mxml
@@ -24,6 +24,7 @@ limitations under the License.
         <![CDATA[
 			import models.ASDocModel;
             import org.apache.flex.events.Event;
+            import org.apache.flex.events.DetailEvent;
 			
             public var currentPackage:String;
             
@@ -40,7 +41,17 @@ limitations under the License.
                 currentClass = classList.selectedItem as String;
                 dispatchEvent(new Event("classChanged"));
             }
-                        
+            
+            private function showTopLevel():void
+            {
+                dispatchEvent(new DetailEvent(topLevel.selected ? "addTag" : "removeTag",
false, false, "toplevel"));
+            }
+            
+            private function showViewBeads():void
+            {
+                dispatchEvent(new DetailEvent(viewBeads.selected ? "addTag" : "removeTag",
false, false, "viewbead"));
+            }
+                                    
 		]]>
     </fx:Script>
 	<fx:Style>
@@ -49,7 +60,14 @@ limitations under the License.
         <js:ViewDataBinding />
         <js:OneFlexibleChildVerticalLayout flexibleChild="topContainer" />        
       
     </js:beads>
-    <js:Label text="FlexJS ActionScript Library Reference" width="100%" height="30" style="fontSize:20"/>
+    <js:Container width="100%">
+        <js:beads>
+            <js:FlexibleFirstChildHorizontalLayout/>
+        </js:beads>
+        <js:Label text="FlexJS ActionScript Library Reference" height="30" style="fontSize:20"/>
+        <js:CheckBox id="topLevel" text="Top-Level" click="showTopLevel()" />
+        <js:CheckBox id="viewBeads" text="View Bead" click="showViewBeads()" />
+    </js:Container>
     <js:Container className="topContainer" id="topContainer" width="100%">
         <js:beads>
             <js:OneFlexibleChildHorizontalLayout flexibleChild="rightSide" />

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94439939/examples/flexjs/ASDoc/src/main/flex/controllers/ASDocController.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/ASDoc/src/main/flex/controllers/ASDocController.as b/examples/flexjs/ASDoc/src/main/flex/controllers/ASDocController.as
index 1f2115b..2e3eb28 100644
--- a/examples/flexjs/ASDoc/src/main/flex/controllers/ASDocController.as
+++ b/examples/flexjs/ASDoc/src/main/flex/controllers/ASDocController.as
@@ -19,6 +19,7 @@
 package controllers
 {
 	import org.apache.flex.events.Event;
+    import org.apache.flex.events.DetailEvent;
 
 	import org.apache.flex.core.Application;
 	import org.apache.flex.core.IDocument;
@@ -46,10 +47,41 @@ package controllers
             mainView = app.mainView as ASDocMainView;
 			mainView.addEventListener("packageChanged", packageChangedHandler);
             mainView.addEventListener("classChanged", classChangedHandler);
+            mainView.addEventListener("addTag", addTagHandler);
+            mainView.addEventListener("removeTag", removeTagHandler);
 
 			model = app.model as ASDocModel;
 		}
 
+        private function addTagHandler(event:DetailEvent):void
+        {
+            var tags:Array = model.filterTags;
+            if (!tags)
+            {
+                tags = [];
+            }
+            tags.push({name: event.detail});
+            model.filterTags = tags;
+        }
+        
+        private function removeTagHandler(event:DetailEvent):void
+        {
+            var tags:Array = model.filterTags;
+            var n:int = tags.length;
+            for (var i:int = 0; i < n; i++)
+            {
+                if (tags[i].name == event.detail)
+                {
+                    tags.splice(i, 1);
+                    break;
+                }
+            }
+            if (tags.length == 0)
+                model.filterTags = null;
+            else
+                model.filterTags = tags;
+        }
+
         private function packageChangedHandler(event:Event):void
         {
             var sym:String = mainView.currentPackage;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94439939/examples/flexjs/ASDoc/src/main/flex/models/ASDocModel.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/ASDoc/src/main/flex/models/ASDocModel.as b/examples/flexjs/ASDoc/src/main/flex/models/ASDocModel.as
index d2af8bb..09671b3 100644
--- a/examples/flexjs/ASDoc/src/main/flex/models/ASDocModel.as
+++ b/examples/flexjs/ASDoc/src/main/flex/models/ASDocModel.as
@@ -47,12 +47,31 @@ package models
         
         private var tagNameMap:Object;
         
+        private var _knownTags:Array;
+        
+        [Bindable("packageListChanged")]
+        public function get knownTags():Array
+        {
+            return _knownTags;
+        }
+        
         private function configCompleteHandler(event:Event):void
         {
             app.service.removeEventListener("complete", configCompleteHandler);
             var config:Object = JSON.parse(app.service.data);
             tagNameMap = config.tagNames;
             
+            app.service.addEventListener("complete", tagsCompleteHandler);
+            app.service.url = "tags.json";
+            app.service.send();
+        }
+        
+        private function tagsCompleteHandler(event:Event):void
+        {
+            app.service.removeEventListener("complete", tagsCompleteHandler);
+            var config:Object = JSON.parse(app.service.data);
+            _knownTags = config.tags;
+            
             app.service.addEventListener("complete", completeHandler);
             app.service.url = "classes.json";
             app.service.send();
@@ -64,6 +83,11 @@ package models
         {
             app.service.removeEventListener("complete", completeHandler);
             masterData = JSON.parse(app.service.data);
+            filterPackageList();
+        }
+        
+        private function filterPackageList():void
+        {
             var packages:Object = {};
             for each (var classData:Object in masterData.classes)
             {
@@ -86,7 +110,10 @@ package models
             var arr:Array = [];
             for (var p:String in packages)
             {
-                arr.push(p);
+                if (filter == null)
+                    arr.push(p);
+                else if (filterPackage(p))
+                    arr.push(p);
             }
             arr.sort();
             _packageList = arr;
@@ -121,7 +148,10 @@ package models
                 var arr:Array = [];
                 for (var p:String in packageData)
                 {
-                    arr.push(p);
+                    if (filter == null)
+                        arr.push(p);
+                    else if (filter(packageData[p]))
+                        arr.push(p);
                 }
                 arr.sort();
                 _classList = arr;
@@ -391,5 +421,61 @@ package models
             }
             return _attributes;
         }
+        
+        public function filterPackage(p:String):Boolean
+        {
+            var packageData:Object = allPackages[p];
+            for (var pd:String in packageData)
+            {
+                if (filter(packageData[pd]))
+                    return true;
+            }
+            return false;
+        }
+        
+        private var filter:Function;
+        
+        private var _filterTags:Array;
+        
+        /**
+         *  Array of name/value pairs to search for 
+         */
+        public function get filterTags():Array
+        {
+            return _filterTags;
+        }
+        
+        public function set filterTags(value:Array):void
+        {
+            _filterTags = value;
+            if (_filterTags)
+                filter = filterByTags;
+            else
+                filter = null;
+            filterPackageList();
+        }
+
+        public function filterByTags(classData:Object):Boolean
+        {
+            var tags:Array = classData.tags;
+            if (!tags) return false;
+            for each (var tag:Object in tags)
+            {
+                for each (var obj:Object in filterTags)
+                {
+                    if (obj.name == tag.tagName)
+                    {
+                        if (tag.values == null || tag.values.length == 0)
+                            return true;
+                        for each (var v:Object in tag.values)
+                        {
+                            if (v == obj.value)
+                                return true;
+                        }
+                    }
+                }
+            }
+            return false;            
+        }
 	}
 }
\ No newline at end of file


Mime
View raw message