Repository: flex-asjs Updated Branches: refs/heads/feature/mdl dd6421089 -> 1cb8e192b
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/StyleExample/src/models/MyModel.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/StyleExample/src/models/MyModel.as b/examples/flexjs/StyleExample/src/models/MyModel.as deleted file mode 100644 index 20ab016..0000000 --- a/examples/flexjs/StyleExample/src/models/MyModel.as +++ /dev/null @@ -1,53 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 models -{ - import org.apache.flex.collections.ArrayList; - import org.apache.flex.collections.IArrayList; - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - - public class MyModel extends EventDispatcher - { - public function MyModel() - { - } - - private var _strings:Array = ["AAPL", "ADBE", "FX", "GOOG", "MSFT", "NYSE", "YHOO"]; - [Bindable("__NoChangeEvent__")] - public function get strings():Array - { - return _strings; - } - - private var _gridData:ArrayList = new ArrayList([ - {month:"January", days:31}, {month:"February", days:28}, - {month:"March", days:31}, {month:"April", days:30}, - {month:"May", days:31}, {month:"June", days:30}, - {month:"July", days:31}, {month:"August", days:31}, - {month:"September", days:30}, {month:"October", days:31}, - {month:"November", days:30}, {month:"December", days:31}]); - [Bindable("__NoChangeEvent__")] - public function get gridData():IArrayList - { - return _gridData; - } - - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TodoListSampleApp/src/TodoListSampleApp.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/TodoListSampleApp.mxml b/examples/flexjs/TodoListSampleApp/src/TodoListSampleApp.mxml deleted file mode 100644 index e734026..0000000 --- a/examples/flexjs/TodoListSampleApp/src/TodoListSampleApp.mxml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!--- -// -// 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. -// -//////////////////////////////////////////////////////////////////////////////// ---> -<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:js="library://ns.apache.org/flexjs/basic" - xmlns:controllers="sample.todo.controllers.*" - xmlns:models="sample.todo.models.*" - xmlns:views="sample.todo.views.*"> - - <js:valuesImpl> - <js:SimpleCSSValuesImpl/> - </js:valuesImpl> - - <js:controller> - <controllers:TodoListController/> - </js:controller> - - <js:model> - <models:TodoListModel/> - </js:model> - - <js:initialView> - <views:TodoListView/> - </js:initialView> - -</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TodoListSampleApp/src/main/flex/TodoListSampleApp.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/main/flex/TodoListSampleApp.mxml b/examples/flexjs/TodoListSampleApp/src/main/flex/TodoListSampleApp.mxml new file mode 100644 index 0000000..e734026 --- /dev/null +++ b/examples/flexjs/TodoListSampleApp/src/main/flex/TodoListSampleApp.mxml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<!--- +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// +--> +<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:controllers="sample.todo.controllers.*" + xmlns:models="sample.todo.models.*" + xmlns:views="sample.todo.views.*"> + + <js:valuesImpl> + <js:SimpleCSSValuesImpl/> + </js:valuesImpl> + + <js:controller> + <controllers:TodoListController/> + </js:controller> + + <js:model> + <models:TodoListModel/> + </js:model> + + <js:initialView> + <views:TodoListView/> + </js:initialView> + +</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/controllers/TodoListController.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/controllers/TodoListController.as b/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/controllers/TodoListController.as new file mode 100644 index 0000000..6402a9c --- /dev/null +++ b/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/controllers/TodoListController.as @@ -0,0 +1,77 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 sample.todo.controllers { + import org.apache.flex.core.Application; + import org.apache.flex.core.IDocument; + import org.apache.flex.events.Event; + + import sample.todo.events.TodoListEvent; + import sample.todo.models.TodoListModel; + + public class TodoListController implements IDocument { + + private var model:TodoListModel; + + public function TodoListController(app:Application = null) { + if (app != null) { + // store the model for future use. + model = app.model as TodoListModel; + } + } + + /** + * + */ + public function setDocument(document:Object, id:String = null):void { + var app:Application = document as Application; + app.addEventListener("viewChanged", viewChangeHandler); + + // store the model for future use + model = app.model as TodoListModel; + } + + /** + * + * @param event + */ + private function viewChangeHandler(event:Event):void { + var app:Application = event.target as Application; + app.initialView.addEventListener(TodoListEvent.LOG_TODO, logTodo); + app.initialView.addEventListener(TodoListEvent.ITEM_CHECKED,handleItemChecked); + app.initialView.addEventListener(TodoListEvent.ITEM_REMOVE_REQUEST, handleItemRemove); + } + + /** + * log todo + * @param event + */ + public function logTodo(evt:TodoListEvent):void { + // still need to change model a view get the changes + model.addTodo(evt.todo); + } + + public function handleItemChecked(event:TodoListEvent):void { + model.toggleItemCheck(event.item); + } + + public function handleItemRemove(event:TodoListEvent):void { + model.removeItem(event.item); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/events/TodoListEvent.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/events/TodoListEvent.as b/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/events/TodoListEvent.as new file mode 100644 index 0000000..7c55b61 --- /dev/null +++ b/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/events/TodoListEvent.as @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 sample.todo.events { + import org.apache.flex.events.Event; + + public class TodoListEvent extends Event { + + public static const LOG_TODO:String = "logTodoEvent"; + public static const ITEM_CHECKED:String = "itemChecked"; + public static const ITEM_REMOVE_REQUEST:String = "itemRemoveRequest"; + + /** + * the todo to log + */ + public var todo:String = null; + + /** + * handle item selection or removal + */ + public var item:Object = null; + + public function TodoListEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false) { + super(type, bubbles, cancelable); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/models/TodoListModel.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/models/TodoListModel.as b/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/models/TodoListModel.as new file mode 100644 index 0000000..780d4f5 --- /dev/null +++ b/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/models/TodoListModel.as @@ -0,0 +1,99 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 sample.todo.models { + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + + public class TodoListModel extends EventDispatcher { + public function TodoListModel() { + super(); + _filterFunction(); + } + + private var _todos:Array = [{title:"Get something", selected:true}, + {title:"Do this", selected:true}, + {title:"Do that", selected:false}]; + + private var _filteredList:Array = []; + private var _filterFunction:Function = showAllTodos; + + [Bindable("todoListChanged")] + public function get todos():Array { + return _filteredList; + } + + public function set todos(value:Array):void { + _todos = value; + _filterFunction(); + dispatchEvent(new Event("todoListChanged")); + } + + public function addTodo(value:String):Object + { + var item:Object = {title:value, selected:false}; + _todos.push(item); + + _filterFunction(); + + return item; + } + + public function showAllTodos() : void { + _filteredList = _todos.slice(); + dispatchEvent(new Event("todoListChanged")); + _filterFunction = showAllTodos; + } + + public function showActiveTodos() : void { + _filteredList = []; + for (var i:int=0; i < _todos.length; i++) { + if (!_todos[i].selected) { + _filteredList.push(_todos[i]); + } + } + dispatchEvent(new Event("todoListChanged")); + _filterFunction = showActiveTodos; + } + + public function showCompletedTodos() : void { + _filteredList = []; + for (var i:int=0; i < _todos.length; i++) { + if (_todos[i].selected) { + _filteredList.push(_todos[i]); + } + } + dispatchEvent(new Event("todoListChanged")); + _filterFunction = showCompletedTodos; + } + + public function toggleItemCheck(item:Object) : void { + item.selected = !item.selected; + _filterFunction(); + dispatchEvent(new Event("todoListChanged")); + } + + public function removeItem(item:Object) : void { + var index:int = _todos.indexOf(item); + if (index >= 0) { + _todos.splice(index,1); + } + _filterFunction(); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/renderers/TodoItemRenderer.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/renderers/TodoItemRenderer.as b/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/renderers/TodoItemRenderer.as new file mode 100644 index 0000000..7a0d6e3 --- /dev/null +++ b/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/renderers/TodoItemRenderer.as @@ -0,0 +1,90 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 sample.todo.renderers { + + import org.apache.flex.events.Event; + import org.apache.flex.events.MouseEvent; + import org.apache.flex.html.Button; + import org.apache.flex.html.CheckBox; + import org.apache.flex.html.Label; + import org.apache.flex.html.supportClasses.DataItemRenderer; + + [Event("checkChanged","org.apache.flex.events.Event")] + [Event("removeRequest","org.apache.flex.events.Event")] + + public class TodoItemRenderer extends DataItemRenderer { + + public function TodoItemRenderer() { + super(); + className = "TodoItemRenderer"; + } + + private var checkbox:CheckBox; + private var title:Label; + private var removeButton:Button; + + override public function addedToParent():void { + super.addedToParent(); + + checkbox = new CheckBox(); + addElement(checkbox); + checkbox.addEventListener("change", checkBoxChange); + + title = new Label(); + addElement(title); + + removeButton = new Button(); + addElement(removeButton); + removeButton.addEventListener("click", removeClick); + } + + override public function set data(value:Object):void { + super.data = value; + + checkbox.selected = data.selected; + title.text = data.title; + } + + override public function adjustSize():void { + var hgt:Number = this.height; + var cy:Number = this.height / 2; + + checkbox.x = 10; + checkbox.y = cy; + + title.x = 60; + title.y = cy; + + removeButton.x = 300; + removeButton.y = cy; + + updateRenderer(); + } + + private function checkBoxChange(event:Event):void + { + dispatchEvent(new Event("checkChanged")); + } + + private function removeClick(event:MouseEvent):void + { + dispatchEvent(new Event("removeRequest")); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/views/TodoListView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/views/TodoListView.mxml b/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/views/TodoListView.mxml new file mode 100644 index 0000000..9ddf675 --- /dev/null +++ b/examples/flexjs/TodoListSampleApp/src/main/flex/sample/todo/views/TodoListView.mxml @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<js:View xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:svg="library://ns.apache.org/flexjs/svg" + initComplete="setup()" + xmlns:renderers="sample.todo.renderers.*"> + + <fx:Script> + <![CDATA[ + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.events.ItemRendererEvent; + import org.apache.flex.html.beads.controllers.ItemRendererMouseController; + + import sample.todo.events.TodoListEvent; + import sample.todo.models.TodoListModel; + import sample.todo.renderers.TodoItemRenderer; + + private function setup():void { + // Listening for events on the model will update the UI. Functions like + // showActive() change the model which results in this event being + // dispatched. + (applicationModel as TodoListModel).addEventListener("todoListChanged", updateStatus); + updateStatus(null); + } + + /** + * add to the list the text entered by the user, in the text box, + * as a new todo list item + */ + public function logTodo():void { + var logEvent:TodoListEvent = new TodoListEvent(TodoListEvent.LOG_TODO); + logEvent.todo = todoInput.text; + dispatchEvent(logEvent); + + todoInput.text = ""; + } + + private function updateStatus(event:org.apache.flex.events.Event):void { + var numberLeft:Number = 0; + + var model: TodoListModel = applicationModel as TodoListModel; + var list: Array = model.todos; + for (var i:int=0; i < list.length; i++) { + var item:Object = list[i]; + numberLeft += item.selected ? 0 : 1; + } + + statusLabel.text = numberLeft + " items left"; + } + + /** + * show all todos + */ + private function showAll():void { + (applicationModel as TodoListModel).showAllTodos(); + } + + /** + * show active todos + */ + private function showActive():void { + (applicationModel as TodoListModel).showActiveTodos(); + } + + /** + * show completed todos + */ + private function showCompleted():void { + (applicationModel as TodoListModel).showCompletedTodos(); + } + + /** + * Handle creation of itemRenderers by listening for the events they dispatch. + */ + private function handleRendererCreated(event:ItemRendererEvent):void { + var renderer:IEventDispatcher = event.itemRenderer as IEventDispatcher; + renderer.addEventListener("checkChanged",itemChecked); + renderer.addEventListener("removeRequest",itemRemove); + } + + /** + * When an item is checked, form new event and dispatch to controller. + */ + private function itemChecked(event:Event):void + { + var renderer:TodoItemRenderer = event.target as TodoItemRenderer; + + var newEvent:TodoListEvent = new TodoListEvent(TodoListEvent.ITEM_CHECKED); + newEvent.item = renderer.data; + dispatchEvent(newEvent); + } + + /** + * When an item is removed, form a new event and dispatch to the controller. + */ + private function itemRemove(event:Event):void + { + var renderer:TodoItemRenderer = event.target as TodoItemRenderer; + + var newEvent:TodoListEvent = new TodoListEvent(TodoListEvent.ITEM_REMOVE_REQUEST); + newEvent.item = renderer.data; + dispatchEvent(newEvent); + } + ]]> + </fx:Script> + + <js:beads> + <js:ViewDataBinding /> + </js:beads> + + <js:Panel title="FlexJS TODO List" width="600"> + <js:beads> + <js:VerticalLayout/> + </js:beads> + + <js:HContainer width="100%"> + <js:TextInput id="todoInput" + width="85%"/> + <js:TextButton text="Enter" click="logTodo()" width="15%" /> + </js:HContainer> + + <js:List id="todoList" + itemRenderer="sample.todo.renderers.TodoItemRenderer" + dataProvider="{TodoListModel(applicationModel).todos}" + width="100%" height="400"> + <js:beads> + <js:DataItemRendererFactoryForArrayData itemRendererCreated="handleRendererCreated(event)" /> + </js:beads> + </js:List> + + <js:Container> + <js:beads> + <js:HorizontalLayout/> + </js:beads> + <js:Label id="statusLabel" text="N items left" width="295"/> + <svg:TextButton text="All" width="100" height="30" click="showAll()" /> + <svg:TextButton text="Active" width="100" height="30" click="showActive()" /> + <svg:TextButton text="Completed" width="100" height="30" click="showCompleted()" /> + </js:Container> + </js:Panel> + + <fx:Style> + @namespace basic "library://ns.apache.org/flexjs/basic"; + @namespace renderers "sample.todo.renderers.*"; + + renderers|TodoItemRenderer { + backgroundColor: #FFFFFF; + height: 40px; + IBeadController: ClassReference("org.apache.flex.html.beads.controllers.ItemRendererMouseController"); + } + </fx:Style> + +</js:View> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TodoListSampleApp/src/sample/todo/controllers/TodoListController.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/sample/todo/controllers/TodoListController.as b/examples/flexjs/TodoListSampleApp/src/sample/todo/controllers/TodoListController.as deleted file mode 100644 index 6402a9c..0000000 --- a/examples/flexjs/TodoListSampleApp/src/sample/todo/controllers/TodoListController.as +++ /dev/null @@ -1,77 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 sample.todo.controllers { - import org.apache.flex.core.Application; - import org.apache.flex.core.IDocument; - import org.apache.flex.events.Event; - - import sample.todo.events.TodoListEvent; - import sample.todo.models.TodoListModel; - - public class TodoListController implements IDocument { - - private var model:TodoListModel; - - public function TodoListController(app:Application = null) { - if (app != null) { - // store the model for future use. - model = app.model as TodoListModel; - } - } - - /** - * - */ - public function setDocument(document:Object, id:String = null):void { - var app:Application = document as Application; - app.addEventListener("viewChanged", viewChangeHandler); - - // store the model for future use - model = app.model as TodoListModel; - } - - /** - * - * @param event - */ - private function viewChangeHandler(event:Event):void { - var app:Application = event.target as Application; - app.initialView.addEventListener(TodoListEvent.LOG_TODO, logTodo); - app.initialView.addEventListener(TodoListEvent.ITEM_CHECKED,handleItemChecked); - app.initialView.addEventListener(TodoListEvent.ITEM_REMOVE_REQUEST, handleItemRemove); - } - - /** - * log todo - * @param event - */ - public function logTodo(evt:TodoListEvent):void { - // still need to change model a view get the changes - model.addTodo(evt.todo); - } - - public function handleItemChecked(event:TodoListEvent):void { - model.toggleItemCheck(event.item); - } - - public function handleItemRemove(event:TodoListEvent):void { - model.removeItem(event.item); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TodoListSampleApp/src/sample/todo/events/TodoListEvent.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/sample/todo/events/TodoListEvent.as b/examples/flexjs/TodoListSampleApp/src/sample/todo/events/TodoListEvent.as deleted file mode 100644 index 7c55b61..0000000 --- a/examples/flexjs/TodoListSampleApp/src/sample/todo/events/TodoListEvent.as +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 sample.todo.events { - import org.apache.flex.events.Event; - - public class TodoListEvent extends Event { - - public static const LOG_TODO:String = "logTodoEvent"; - public static const ITEM_CHECKED:String = "itemChecked"; - public static const ITEM_REMOVE_REQUEST:String = "itemRemoveRequest"; - - /** - * the todo to log - */ - public var todo:String = null; - - /** - * handle item selection or removal - */ - public var item:Object = null; - - public function TodoListEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false) { - super(type, bubbles, cancelable); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TodoListSampleApp/src/sample/todo/models/TodoListModel.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/sample/todo/models/TodoListModel.as b/examples/flexjs/TodoListSampleApp/src/sample/todo/models/TodoListModel.as deleted file mode 100644 index 780d4f5..0000000 --- a/examples/flexjs/TodoListSampleApp/src/sample/todo/models/TodoListModel.as +++ /dev/null @@ -1,99 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 sample.todo.models { - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - - public class TodoListModel extends EventDispatcher { - public function TodoListModel() { - super(); - _filterFunction(); - } - - private var _todos:Array = [{title:"Get something", selected:true}, - {title:"Do this", selected:true}, - {title:"Do that", selected:false}]; - - private var _filteredList:Array = []; - private var _filterFunction:Function = showAllTodos; - - [Bindable("todoListChanged")] - public function get todos():Array { - return _filteredList; - } - - public function set todos(value:Array):void { - _todos = value; - _filterFunction(); - dispatchEvent(new Event("todoListChanged")); - } - - public function addTodo(value:String):Object - { - var item:Object = {title:value, selected:false}; - _todos.push(item); - - _filterFunction(); - - return item; - } - - public function showAllTodos() : void { - _filteredList = _todos.slice(); - dispatchEvent(new Event("todoListChanged")); - _filterFunction = showAllTodos; - } - - public function showActiveTodos() : void { - _filteredList = []; - for (var i:int=0; i < _todos.length; i++) { - if (!_todos[i].selected) { - _filteredList.push(_todos[i]); - } - } - dispatchEvent(new Event("todoListChanged")); - _filterFunction = showActiveTodos; - } - - public function showCompletedTodos() : void { - _filteredList = []; - for (var i:int=0; i < _todos.length; i++) { - if (_todos[i].selected) { - _filteredList.push(_todos[i]); - } - } - dispatchEvent(new Event("todoListChanged")); - _filterFunction = showCompletedTodos; - } - - public function toggleItemCheck(item:Object) : void { - item.selected = !item.selected; - _filterFunction(); - dispatchEvent(new Event("todoListChanged")); - } - - public function removeItem(item:Object) : void { - var index:int = _todos.indexOf(item); - if (index >= 0) { - _todos.splice(index,1); - } - _filterFunction(); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TodoListSampleApp/src/sample/todo/renderers/TodoItemRenderer.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/sample/todo/renderers/TodoItemRenderer.as b/examples/flexjs/TodoListSampleApp/src/sample/todo/renderers/TodoItemRenderer.as deleted file mode 100644 index 7a0d6e3..0000000 --- a/examples/flexjs/TodoListSampleApp/src/sample/todo/renderers/TodoItemRenderer.as +++ /dev/null @@ -1,90 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 sample.todo.renderers { - - import org.apache.flex.events.Event; - import org.apache.flex.events.MouseEvent; - import org.apache.flex.html.Button; - import org.apache.flex.html.CheckBox; - import org.apache.flex.html.Label; - import org.apache.flex.html.supportClasses.DataItemRenderer; - - [Event("checkChanged","org.apache.flex.events.Event")] - [Event("removeRequest","org.apache.flex.events.Event")] - - public class TodoItemRenderer extends DataItemRenderer { - - public function TodoItemRenderer() { - super(); - className = "TodoItemRenderer"; - } - - private var checkbox:CheckBox; - private var title:Label; - private var removeButton:Button; - - override public function addedToParent():void { - super.addedToParent(); - - checkbox = new CheckBox(); - addElement(checkbox); - checkbox.addEventListener("change", checkBoxChange); - - title = new Label(); - addElement(title); - - removeButton = new Button(); - addElement(removeButton); - removeButton.addEventListener("click", removeClick); - } - - override public function set data(value:Object):void { - super.data = value; - - checkbox.selected = data.selected; - title.text = data.title; - } - - override public function adjustSize():void { - var hgt:Number = this.height; - var cy:Number = this.height / 2; - - checkbox.x = 10; - checkbox.y = cy; - - title.x = 60; - title.y = cy; - - removeButton.x = 300; - removeButton.y = cy; - - updateRenderer(); - } - - private function checkBoxChange(event:Event):void - { - dispatchEvent(new Event("checkChanged")); - } - - private function removeClick(event:MouseEvent):void - { - dispatchEvent(new Event("removeRequest")); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TodoListSampleApp/src/sample/todo/views/TodoListView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/sample/todo/views/TodoListView.mxml b/examples/flexjs/TodoListSampleApp/src/sample/todo/views/TodoListView.mxml deleted file mode 100644 index 9ddf675..0000000 --- a/examples/flexjs/TodoListSampleApp/src/sample/todo/views/TodoListView.mxml +++ /dev/null @@ -1,172 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - -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. - ---> -<js:View xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:js="library://ns.apache.org/flexjs/basic" - xmlns:svg="library://ns.apache.org/flexjs/svg" - initComplete="setup()" - xmlns:renderers="sample.todo.renderers.*"> - - <fx:Script> - <![CDATA[ - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.events.ItemRendererEvent; - import org.apache.flex.html.beads.controllers.ItemRendererMouseController; - - import sample.todo.events.TodoListEvent; - import sample.todo.models.TodoListModel; - import sample.todo.renderers.TodoItemRenderer; - - private function setup():void { - // Listening for events on the model will update the UI. Functions like - // showActive() change the model which results in this event being - // dispatched. - (applicationModel as TodoListModel).addEventListener("todoListChanged", updateStatus); - updateStatus(null); - } - - /** - * add to the list the text entered by the user, in the text box, - * as a new todo list item - */ - public function logTodo():void { - var logEvent:TodoListEvent = new TodoListEvent(TodoListEvent.LOG_TODO); - logEvent.todo = todoInput.text; - dispatchEvent(logEvent); - - todoInput.text = ""; - } - - private function updateStatus(event:org.apache.flex.events.Event):void { - var numberLeft:Number = 0; - - var model: TodoListModel = applicationModel as TodoListModel; - var list: Array = model.todos; - for (var i:int=0; i < list.length; i++) { - var item:Object = list[i]; - numberLeft += item.selected ? 0 : 1; - } - - statusLabel.text = numberLeft + " items left"; - } - - /** - * show all todos - */ - private function showAll():void { - (applicationModel as TodoListModel).showAllTodos(); - } - - /** - * show active todos - */ - private function showActive():void { - (applicationModel as TodoListModel).showActiveTodos(); - } - - /** - * show completed todos - */ - private function showCompleted():void { - (applicationModel as TodoListModel).showCompletedTodos(); - } - - /** - * Handle creation of itemRenderers by listening for the events they dispatch. - */ - private function handleRendererCreated(event:ItemRendererEvent):void { - var renderer:IEventDispatcher = event.itemRenderer as IEventDispatcher; - renderer.addEventListener("checkChanged",itemChecked); - renderer.addEventListener("removeRequest",itemRemove); - } - - /** - * When an item is checked, form new event and dispatch to controller. - */ - private function itemChecked(event:Event):void - { - var renderer:TodoItemRenderer = event.target as TodoItemRenderer; - - var newEvent:TodoListEvent = new TodoListEvent(TodoListEvent.ITEM_CHECKED); - newEvent.item = renderer.data; - dispatchEvent(newEvent); - } - - /** - * When an item is removed, form a new event and dispatch to the controller. - */ - private function itemRemove(event:Event):void - { - var renderer:TodoItemRenderer = event.target as TodoItemRenderer; - - var newEvent:TodoListEvent = new TodoListEvent(TodoListEvent.ITEM_REMOVE_REQUEST); - newEvent.item = renderer.data; - dispatchEvent(newEvent); - } - ]]> - </fx:Script> - - <js:beads> - <js:ViewDataBinding /> - </js:beads> - - <js:Panel title="FlexJS TODO List" width="600"> - <js:beads> - <js:VerticalLayout/> - </js:beads> - - <js:HContainer width="100%"> - <js:TextInput id="todoInput" - width="85%"/> - <js:TextButton text="Enter" click="logTodo()" width="15%" /> - </js:HContainer> - - <js:List id="todoList" - itemRenderer="sample.todo.renderers.TodoItemRenderer" - dataProvider="{TodoListModel(applicationModel).todos}" - width="100%" height="400"> - <js:beads> - <js:DataItemRendererFactoryForArrayData itemRendererCreated="handleRendererCreated(event)" /> - </js:beads> - </js:List> - - <js:Container> - <js:beads> - <js:HorizontalLayout/> - </js:beads> - <js:Label id="statusLabel" text="N items left" width="295"/> - <svg:TextButton text="All" width="100" height="30" click="showAll()" /> - <svg:TextButton text="Active" width="100" height="30" click="showActive()" /> - <svg:TextButton text="Completed" width="100" height="30" click="showCompleted()" /> - </js:Container> - </js:Panel> - - <fx:Style> - @namespace basic "library://ns.apache.org/flexjs/basic"; - @namespace renderers "sample.todo.renderers.*"; - - renderers|TodoItemRenderer { - backgroundColor: #FFFFFF; - height: 40px; - IBeadController: ClassReference("org.apache.flex.html.beads.controllers.ItemRendererMouseController"); - } - </fx:Style> - -</js:View> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TreeExample/src/MyInitialView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/TreeExample/src/MyInitialView.mxml b/examples/flexjs/TreeExample/src/MyInitialView.mxml deleted file mode 100644 index 2418cd7..0000000 --- a/examples/flexjs/TreeExample/src/MyInitialView.mxml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - -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. - ---> -<js:View xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:js="library://ns.apache.org/flexjs/basic"> - - <js:beads> - <js:ViewDataBinding /> - </js:beads> - - <js:Tree id="tree" x="30" y="30" width="400" height="300" - labelField="title"> - <js:beads> - <js:ConstantBinding - sourceID="applicationModel" - sourcePropertyName="treeData" - destinationPropertyName="dataProvider" /> - </js:beads> - </js:Tree> - -</js:View> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TreeExample/src/TreeExample.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/TreeExample/src/TreeExample.mxml b/examples/flexjs/TreeExample/src/TreeExample.mxml deleted file mode 100644 index e969146..0000000 --- a/examples/flexjs/TreeExample/src/TreeExample.mxml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!--- -// -// 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. -// -//////////////////////////////////////////////////////////////////////////////// ---> -<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:local="*" - xmlns:models="models.*" - xmlns:js="library://ns.apache.org/flexjs/basic" - > - - <js:valuesImpl> - <js:SimpleCSSValuesImpl /> - </js:valuesImpl> - <js:model> - <models:MyModel /> - </js:model> - <js:initialView> - <local:MyInitialView /> - </js:initialView> -</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TreeExample/src/main/flex/MyInitialView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/TreeExample/src/main/flex/MyInitialView.mxml b/examples/flexjs/TreeExample/src/main/flex/MyInitialView.mxml new file mode 100644 index 0000000..2418cd7 --- /dev/null +++ b/examples/flexjs/TreeExample/src/main/flex/MyInitialView.mxml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<js:View xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:js="library://ns.apache.org/flexjs/basic"> + + <js:beads> + <js:ViewDataBinding /> + </js:beads> + + <js:Tree id="tree" x="30" y="30" width="400" height="300" + labelField="title"> + <js:beads> + <js:ConstantBinding + sourceID="applicationModel" + sourcePropertyName="treeData" + destinationPropertyName="dataProvider" /> + </js:beads> + </js:Tree> + +</js:View> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TreeExample/src/main/flex/TreeExample.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/TreeExample/src/main/flex/TreeExample.mxml b/examples/flexjs/TreeExample/src/main/flex/TreeExample.mxml new file mode 100644 index 0000000..e969146 --- /dev/null +++ b/examples/flexjs/TreeExample/src/main/flex/TreeExample.mxml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<!--- +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// +--> +<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:local="*" + xmlns:models="models.*" + xmlns:js="library://ns.apache.org/flexjs/basic" + > + + <js:valuesImpl> + <js:SimpleCSSValuesImpl /> + </js:valuesImpl> + <js:model> + <models:MyModel /> + </js:model> + <js:initialView> + <local:MyInitialView /> + </js:initialView> +</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TreeExample/src/main/flex/models/MyModel.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/TreeExample/src/main/flex/models/MyModel.as b/examples/flexjs/TreeExample/src/main/flex/models/MyModel.as new file mode 100644 index 0000000..d224293 --- /dev/null +++ b/examples/flexjs/TreeExample/src/main/flex/models/MyModel.as @@ -0,0 +1,72 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 models +{ + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + import org.apache.flex.collections.HierarchicalData; + + public class MyModel extends EventDispatcher + { + public function MyModel() + { + treeData = new HierarchicalData(store); + treeData.childrenField = "children"; + } + + public var treeData:HierarchicalData; + + private var store:Object = { title:"That's Entertainment", + children:[ + {title:"My Music", + children:[ + {title:"Language and Perspective", artist:"Bad Suns", + children:[ + {title:"Matthew James", length:"3:24"}, + {title:"We Move Like the Ocean", length:"3:56"}, + {title:"Cardiac Arrest", length:"3:15"} + ]}, + {title:"Strange Desire", artist:"Bleachers", + children:[ + {title:"Wild Heart", length:"4:15"}, + {title:"Rollercoaster", length:"3:39"}, + {title:"Shadow", length:"3:46"}, + {title:"I Wanna Get Better", length:"4:23"} + ]} + ]}, + {title:"My Books", + children:[ + {title:"Wizard of Oz", + children:[ + {title:"So this is Kansas?", length:"82"}, + {title:"A Might Dusty Here", length:"63"}, + {title:"Is that a Tornado?", length:"103"} + ]}, + {title:"Favorite Book #2", + children:[ + {title:"Chapter 1", length:"15"}, + {title:"Chapter 2", length:"86"}, + {title:"Chapter 3", length:"104"}, + {title:"Chapter 4", length:"99"} + ]} + ]} + ]}; + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/TreeExample/src/models/MyModel.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/TreeExample/src/models/MyModel.as b/examples/flexjs/TreeExample/src/models/MyModel.as deleted file mode 100644 index d224293..0000000 --- a/examples/flexjs/TreeExample/src/models/MyModel.as +++ /dev/null @@ -1,72 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 models -{ - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - import org.apache.flex.collections.HierarchicalData; - - public class MyModel extends EventDispatcher - { - public function MyModel() - { - treeData = new HierarchicalData(store); - treeData.childrenField = "children"; - } - - public var treeData:HierarchicalData; - - private var store:Object = { title:"That's Entertainment", - children:[ - {title:"My Music", - children:[ - {title:"Language and Perspective", artist:"Bad Suns", - children:[ - {title:"Matthew James", length:"3:24"}, - {title:"We Move Like the Ocean", length:"3:56"}, - {title:"Cardiac Arrest", length:"3:15"} - ]}, - {title:"Strange Desire", artist:"Bleachers", - children:[ - {title:"Wild Heart", length:"4:15"}, - {title:"Rollercoaster", length:"3:39"}, - {title:"Shadow", length:"3:46"}, - {title:"I Wanna Get Better", length:"4:23"} - ]} - ]}, - {title:"My Books", - children:[ - {title:"Wizard of Oz", - children:[ - {title:"So this is Kansas?", length:"82"}, - {title:"A Might Dusty Here", length:"63"}, - {title:"Is that a Tornado?", length:"103"} - ]}, - {title:"Favorite Book #2", - children:[ - {title:"Chapter 1", length:"15"}, - {title:"Chapter 2", length:"86"}, - {title:"Chapter 3", length:"104"}, - {title:"Chapter 4", length:"99"} - ]} - ]} - ]}; - - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/pom.xml ---------------------------------------------------------------------- diff --git a/examples/pom.xml b/examples/pom.xml index 6f981d4..d3e1598 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -42,10 +42,10 @@ </modules> <build> - <sourceDirectory>src</sourceDirectory> + <sourceDirectory>src/main/flex</sourceDirectory> <resources> <resource> - <directory>resources</directory> + <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index a7888f0..67695d2 100644 --- a/pom.xml +++ b/pom.xml @@ -74,9 +74,8 @@ <!-- Only configure the site distribution as the rest is handled by the apache parent --> <distributionManagement> <site> - <id>website</id> - <!-- TODO: Set this to the correct url --> - <url>scp://www.mycompany.com/www/docs/project/</url> + <id>apache.website</id> + <url>scm:git:https://git-wip-us.apache.org/repos/asf/flex-asjs.git</url> </site> </distributionManagement> @@ -196,6 +195,91 @@ </dependency> </dependencies> </plugin> + + <!-- Configure the Site generation --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <!-- Downgraded to 3.4 as 3.5 and 3.5.1 seem to have issues with the velocity tools --> + <version>3.4</version> + <configuration> + <generateReports>true</generateReports> + <generateSitemap>true</generateSitemap> + <relativizeDecorationLinks>false</relativizeDecorationLinks> + <locales>en</locales> + <inputEncoding>${project.build.sourceEncoding}</inputEncoding> + <outputEncoding>${project.reporting.outputencoding}</outputEncoding> + </configuration> + <dependencies> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.6</version> + </dependency> + <dependency> + <groupId>org.apache.maven.doxia</groupId> + <artifactId>doxia-core</artifactId> + <version>1.6</version> + </dependency> + <!-- All dependencies needed by the reflow skin --> + <dependency> + <groupId>lt.velykis.maven.skins</groupId> + <artifactId>reflow-velocity-tools</artifactId> + <version>1.1.1</version> + </dependency> + <dependency> + <groupId>org.apache.velocity</groupId> + <artifactId>velocity</artifactId> + <version>1.7</version> + </dependency> + <!-- add support for scm/git site deployment --> + <dependency> + <groupId>org.apache.maven.wagon</groupId> + <artifactId>wagon-scm</artifactId> + <version>2.10</version> + </dependency> + <dependency> + <groupId>org.apache.maven.scm</groupId> + <artifactId>maven-scm-api</artifactId> + <version>1.9.5</version> + </dependency> + <dependency> + <groupId>org.apache.maven.scm</groupId> + <artifactId>maven-scm-manager-plexus</artifactId> + <version>1.9.5</version> + </dependency> + <dependency> + <groupId>org.apache.maven.scm</groupId> + <artifactId>maven-scm-provider-gitexe</artifactId> + <version>1.9.5</version> + </dependency> + </dependencies> + </plugin> + + <!-- + Make the maven-site-plugin stage the output in the "asf-site" branch + --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-scm-publish-plugin</artifactId> + <version>1.1</version> + <executions> + <execution> + <id>scm-publish</id> + <phase>site-deploy</phase> + <!-- deploy site with maven-scm-publish-plugin --> + <goals> + <goal>publish-scm</goal> + </goals> + <configuration> + <!-- mono-module doesn't require site:stage --> + <content>${project.build.directory}/site</content> + <!-- branch where to deploy --> + <scmBranch>asf-site</scmBranch> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/src/site/site.xml ---------------------------------------------------------------------- diff --git a/src/site/site.xml b/src/site/site.xml index bf57b2c..a7a5a3a 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -19,24 +19,54 @@ --> <project name="Maven" xmlns="https://maven.apache.org/xsd/decoration-1.7.0.xsd"> - <!-- Use the nicer looking fluido skin instead of the default --> <skin> - <groupId>org.apache.maven.skins</groupId> - <artifactId>maven-fluido-skin</artifactId> - <version>1.5</version> + <groupId>lt.velykis.maven.skins</groupId> + <artifactId>reflow-maven-skin</artifactId> + <version>1.1.1</version> </skin> + <!-- + Details on how to configure the reflow skin: + http://andriusvelykis.github.io/reflow-maven-skin/skin/ + --> + <custom> + <reflowSkin> + <theme>site</theme> + <titleTemplate>Apache Flex� - %2$s</titleTemplate> + <breadcrumbs>false</breadcrumbs> + <highlightJs>true</highlightJs> + </reflowSkin> + </custom> + <bannerLeft> <name>Apache Flex</name> - <src>http://flex.apache.org/images/logo_01_fullcolor-sm.png</src> + <src>img/logo-flex.png</src> <href>http://flex.apache.org/</href> </bannerLeft> - <!--bannerRight> - <src>http://maven.apache.org/images/maven-small.gif</src> - </bannerRight--> + <bannerRight> + <name>An Apache Project</name> + <src>img/logo-asf.png</src> + <href>http://www.apache.org</href> + </bannerRight> <body> + <head> + <link rel="icon" type="image/x-icon" href="img/favicon.ico"/> + <link rel="apple-touch-icon" href="img/apple-touch-icon-60.png"/> + <link rel="apple-touch-icon" sizes="76x76" href="img/apple-touch-icon-76.png"/> + <link rel="apple-touch-icon" sizes="120x120" href="img/apple-touch-icon-120.png"/> + <link rel="apple-touch-icon" sizes="152x152" href="img/apple-touch-icon-152.png"/> + </head> + + <links> + <item name="Apache Flex Homepage" href="http://flex.apache.org/" /> + <!--item name="Apache FlexJS Homepage" href="http://flex.apache.org/" /--> + <item name="Apache Flex Wiki" href="https://cwiki.apache.org/confluence/display/FLEX/Apache+Flex+Wiki"/> + </links> + <menu ref="reports" /> + <menu ref="parent" /> + <menu ref="modules" /> </body> </project> \ No newline at end of file
