Permalink
Browse files

Flex Components (in progress…)

  • Loading branch information...
1 parent acdab1e commit affafa213d7b5021ae5a25108922e0b52d7c2ba1 @derekdon committed Jul 6, 2010
Showing with 900 additions and 0 deletions.
  1. +50 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/IconDropDownListContext.as
  2. +11 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/assets/ViewAsset.as
  3. BIN as3/com/derekdonnelly/flex/components/IconDropDownList/assets/default_lineitem_icon.png
  4. BIN as3/com/derekdonnelly/flex/components/IconDropDownList/assets/default_selected_icon.png
  5. +26 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/controller/AddLineItemCommand.as
  6. +23 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/controller/RemoveAllCommand.as
  7. +26 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/controller/RemoveLineItemCommand.as
  8. +26 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/controller/SetLineItemsCommand.as
  9. +30 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/events/IconDropDownListEvent.as
  10. +25 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/events/IconDropDownListModelEvent.as
  11. +28 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/events/LineItemEvent.as
  12. +29 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/events/LineItemsEvent.as
  13. +9 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/interfaces/ILineItem.as
  14. +66 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/model/IconDropDownListModel.as
  15. +19 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/model/enums/IconDropDownListState.as
  16. +41 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/model/vo/LineItem.as
  17. +56 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/model/vo/LineItems.as
  18. +87 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/presenter/IconDropDownListPresenter.as
  19. +69 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/view/IconDropDownList.mxml
  20. +89 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/view/IconDropDownListMediator.as
  21. +27 −0 ...m/derekdonnelly/flex/components/IconDropDownList/view/renderers/IconDropDownListItemRenderer.mxml
  22. +163 −0 as3/com/derekdonnelly/flex/components/IconDropDownList/view/skins/IconDropDownListSkin.mxml
@@ -0,0 +1,50 @@
+package com.derekdonnelly.flex.components.IconDropDownList
+{
+ import flash.display.DisplayObjectContainer;
+ import org.robotlegs.core.IInjector;
+ import org.robotlegs.utilities.modular.mvcs.ModuleContext;
+
+ import com.derekdonnelly.flex.components.IconDropDownList.events.*;
+ import com.derekdonnelly.flex.components.IconDropDownList.controller.*;
+ import com.derekdonnelly.flex.components.IconDropDownList.view.IconDropDownList;
+ import com.derekdonnelly.flex.components.IconDropDownList.view.IconDropDownListMediator;
+ import com.derekdonnelly.flex.components.IconDropDownList.model.IconDropDownListModel;
+
+ public class IconDropDownListContext
+ extends ModuleContext
+ {
+ /**
+ * Because this modular style component <b>requires</b> an injector we need to use its constructor to initialize
+ * the context properly.
+ *
+ * @param contextView
+ * @param injector
+ *
+ */
+ public function IconDropDownListContext(contextView:DisplayObjectContainer, injector:IInjector)
+ {
+ super(contextView, true, injector);
+ }
+
+ override public function startup():void
+ {
+ // Map Model classes for injection
+ injector.mapSingleton(IconDropDownListModel); // might not be needed if we go the presenter design route?
+
+ // Map the mediator
+ mediatorMap.mapView(IconDropDownList, IconDropDownListMediator);
+
+ // Map commands on the module event bus to also allow external modules to call these commands
+ moduleCommandMap.mapEvent(LineItemEvent.ADD, AddLineItemCommand, LineItemEvent);
+ moduleCommandMap.mapEvent(LineItemEvent.REMOVE, RemoveLineItemCommand, LineItemEvent);
+ moduleCommandMap.mapEvent(LineItemsEvent.SET, SetLineItemsCommand, LineItemsEvent);
+ moduleCommandMap.mapEvent(LineItemsEvent.REMOVE_ALL, RemoveAllCommand, LineItemsEvent);
+ }
+
+ override public function dispose():void
+ {
+ mediatorMap.removeMediatorByView(contextView);
+ super.dispose();
+ }
+ }
+}
@@ -0,0 +1,11 @@
+package com.derekdonnelly.flex.components.IconDropDownList.assets
+{
+ public class ViewAsset
+ {
+ [Embed(source="default_selected_icon.png")]
+ public static const DefaultSelectedIcon:Class;
+
+ [Embed(source="default_lineitem_icon.png")]
+ public static const DefaultLineItemIcon:Class;
+ }
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,26 @@
+package com.derekdonnelly.flex.components.IconDropDownList.controller
+{
+ import com.derekdonnelly.flex.components.IconDropDownList.events.LineItemEvent;
+ import com.derekdonnelly.flex.components.IconDropDownList.model.IconDropDownListModel;
+ import com.derekdonnelly.flex.components.IconDropDownList.presenter.IconDropDownListPresenter;
+ import org.robotlegs.utilities.modular.mvcs.ModuleCommand;
+
+ public class AddLineItemCommand
+ extends ModuleCommand
+ {
+ [Inject]
+ public var event:LineItemEvent;
+
+ [Inject]
+ public var model:IconDropDownListModel;
+
+ [Inject]
+ public var presenter:IconDropDownListPresenter;
+
+ override public function execute():void
+ {
+ //model.addItem(event.lineItem);
+ presenter.addItem(event.lineItem);
+ }
+ }
+}
@@ -0,0 +1,23 @@
+package com.derekdonnelly.flex.components.IconDropDownList.controller
+{
+ import com.derekdonnelly.flex.components.IconDropDownList.events.LineItemEvent;
+ import com.derekdonnelly.flex.components.IconDropDownList.model.IconDropDownListModel;
+ import com.derekdonnelly.flex.components.IconDropDownList.presenter.IconDropDownListPresenter;
+ import org.robotlegs.utilities.modular.mvcs.ModuleCommand;
+
+ public class RemoveAllCommand
+ extends ModuleCommand
+ {
+ [Inject]
+ public var model:IconDropDownListModel;
+
+ [Inject]
+ public var presenter:IconDropDownListPresenter;
+
+ override public function execute():void
+ {
+ //model.removeAll();
+ presenter.removeAll();
+ }
+ }
+}
@@ -0,0 +1,26 @@
+package com.derekdonnelly.flex.components.IconDropDownList.controller
+{
+ import com.derekdonnelly.flex.components.IconDropDownList.events.LineItemEvent;
+ import com.derekdonnelly.flex.components.IconDropDownList.model.IconDropDownListModel;
+ import com.derekdonnelly.flex.components.IconDropDownList.presenter.IconDropDownListPresenter;
+ import org.robotlegs.utilities.modular.mvcs.ModuleCommand;
+
+ public class RemoveLineItemCommand
+ extends ModuleCommand
+ {
+ [Inject]
+ public var event:LineItemEvent;
+
+ [Inject]
+ public var model:IconDropDownListModel;
+
+ [Inject]
+ public var presenter:IconDropDownListPresenter;
+
+ override public function execute():void
+ {
+ //model.removeItem(event.lineItem);
+ presenter.removeItem(event.lineItem);
+ }
+ }
+}
@@ -0,0 +1,26 @@
+package com.derekdonnelly.flex.components.IconDropDownList.controller
+{
+ import com.derekdonnelly.flex.components.IconDropDownList.events.LineItemsEvent;
+ import com.derekdonnelly.flex.components.IconDropDownList.model.IconDropDownListModel;
+ import com.derekdonnelly.flex.components.IconDropDownList.presenter.IconDropDownListPresenter;
+ import org.robotlegs.utilities.modular.mvcs.ModuleCommand;
+
+ public class SetLineItemsCommand
+ extends ModuleCommand
+ {
+ [Inject]
+ public var event:LineItemsEvent;
+
+ [Inject]
+ public var model:IconDropDownListModel;
+
+ [Inject]
+ public var presenter:IconDropDownListPresenter;
+
+ override public function execute():void
+ {
+ //model.lineItems.items = event.lineItems.items;
+ presenter.lineItems.items = event.lineItems.items;
+ }
+ }
+}
@@ -0,0 +1,30 @@
+package com.derekdonnelly.flex.components.IconDropDownList.events
+{
+ import flash.events.Event;
+
+ public class IconDropDownListEvent
+ extends Event
+ {
+ // Opening
+ public static const OPEN:String = "IconDropDownListEvent.OPEN";
+ public static const OPENING:String = "IconDropDownListEvent.OPENING";
+ public static const OPEN_SUCCESS:String = "IconDropDownListEvent.OPEN_SUCCESS";
+ public static const OPEN_ERROR:String = "IconDropDownListEvent.OPEN_ERROR";
+
+ // Closing
+ public static const CLOSE:String = "IconDropDownListEvent.CLOSE";
+ public static const CLOSING:String = "IconDropDownListEvent.CLOSING";
+ public static const CLOSE_SUCCESS:String = "IconDropDownListEvent.CLOSE_SUCCESS";
+ public static const CLOSE_ERROR:String = "IconDropDownListEvent.CLOSE_ERROR";
+
+ public function IconDropDownListEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
+ {
+ super(type, bubbles, cancelable);
+ }
+
+ override public function clone():Event
+ {
+ return new IconDropDownListEvent(type, bubbles, cancelable);
+ }
+ }
+}
@@ -0,0 +1,25 @@
+package com.derekdonnelly.flex.components.IconDropDownList.events
+{
+ import com.derekdonnelly.flex.components.IconDropDownList.model.vo.LineItems;
+ import flash.events.Event;
+
+ public class IconDropDownListModelEvent
+ extends Event
+ {
+ public static const UPDATED:String = "IconDropDownListModelEvent.UPDATED";
+
+ private var _lineItems:LineItems;
+ public function get lineItems():LineItems { return _lineItems; }
+
+ public function IconDropDownListModelEvent(type:String, lineItems:LineItems = null, bubbles:Boolean=false, cancelable:Boolean=false)
+ {
+ _lineItems = lineItems;
+ super(type, bubbles, cancelable);
+ }
+
+ override public function clone():Event
+ {
+ return new IconDropDownListModelEvent(type, lineItems, bubbles, cancelable);
+ }
+ }
+}
@@ -0,0 +1,28 @@
+package com.derekdonnelly.flex.components.IconDropDownList.events
+{
+ import com.derekdonnelly.flex.components.IconDropDownList.model.vo.LineItem;
+ import flash.events.Event;
+
+ public class LineItemEvent
+ extends Event
+ {
+ public static const ADD:String = "LineItemEvent.ADD";
+ public static const ITEM_ADDED:String = "LineItemEvent.ITEM_ADDED";
+ public static const REMOVE:String = "LineItemEvent.REMOVE";
+ public static const ITEM_REMOVED:String = "LineItemEvent.ITEM_REMOVED";
+
+ private var _lineItem:LineItem;
+ public function get lineItem():LineItem { return _lineItem; }
+
+ public function LineItemEvent(type:String, lineItem:LineItem = null, bubbles:Boolean=false, cancelable:Boolean=false)
+ {
+ _lineItem = lineItem;
+ super(type, bubbles, cancelable);
+ }
+
+ override public function clone():Event
+ {
+ return new LineItemEvent(type, lineItem, bubbles, cancelable);
+ }
+ }
+}
@@ -0,0 +1,29 @@
+package com.derekdonnelly.flex.components.IconDropDownList.events
+{
+ import com.derekdonnelly.flex.components.IconDropDownList.model.vo.LineItems;
+ import flash.events.Event;
+
+ public class LineItemsEvent
+ extends Event
+ {
+ public static const SET:String = "LineItemsEvent.SET";
+ public static const UPDATED:String = "LineItemsEvent.UPDATED";
+ public static const REMOVE_ALL:String = "LineItemsEvent.REMOVE_ALL";
+ public static const SELECTED:String = "LineItemsEvent.SELECTED";
+ public static const NONE_SELECTED:String = "LineItemsEvent.NONE_SELECTED";
+
+ private var _lineItems:LineItems;
+ public function get lineItems():LineItems { return _lineItems; }
+
+ public function LineItemsEvent(type:String, lineItems:LineItems = null, bubbles:Boolean=false, cancelable:Boolean=false)
+ {
+ _lineItems = lineItems;
+ super(type, bubbles, cancelable);
+ }
+
+ override public function clone():Event
+ {
+ return new LineItemsEvent(type, lineItems, bubbles, cancelable);
+ }
+ }
+}
@@ -0,0 +1,9 @@
+package com.derekdonnelly.flex.components.IconDropDownList.interfaces
+{
+ public interface ILineItem
+ {
+ function get icon():Class;
+ function get text():String;
+ function toString():String;
+ }
+}
@@ -0,0 +1,66 @@
+package com.derekdonnelly.flex.components.IconDropDownList.model
+{
+ import com.derekdonnelly.flex.components.IconDropDownList.events.LineItemEvent;
+ import com.derekdonnelly.flex.components.IconDropDownList.events.LineItemsEvent;
+ import com.derekdonnelly.flex.components.IconDropDownList.model.vo.*;
+
+ import mx.collections.ArrayCollection;
+
+ import org.robotlegs.utilities.modular.mvcs.ModuleActor;
+
+ public class IconDropDownListModel
+ extends ModuleActor
+ {
+ private var _lineItems:LineItems;
+ private var _currentItemSelection:LineItem;
+
+ public function get lineItems():LineItems
+ {
+ return _lineItems;
+ }
+
+ public function get currentItemSelection():LineItem
+ {
+ return _currentItemSelection;
+ }
+
+ public function set currentItemSelection(v:LineItem):void
+ {
+ _currentItemSelection = v;
+ }
+
+ public function addItem(item:LineItem):void
+ {
+ lineItems.addItem(item);
+
+ dispatchToModules(new LineItemEvent(LineItemEvent.ITEM_ADDED, item));
+ dispatchToModules(new LineItemsEvent(LineItemsEvent.UPDATED, lineItems));
+ }
+
+ public function removeItem(item:LineItem):void
+ {
+ lineItems.removeItem(item);
+
+ dispatchToModules(new LineItemEvent(LineItemEvent.ITEM_REMOVED, item));
+ dispatchToModules(new LineItemsEvent(LineItemsEvent.UPDATED, lineItems));
+ }
+
+ public function removeAll():void
+ {
+ _init();
+ dispatchToModules(new LineItemsEvent(LineItemsEvent.NONE_SELECTED, lineItems));
+ dispatchToModules(new LineItemsEvent(LineItemsEvent.UPDATED, lineItems));
+ }
+
+ public function IconDropDownListModel()
+ {
+ _init();
+ }
+
+ private function _init():void
+ {
+ _lineItems = new LineItems();
+ _currentItemSelection = null;
+ }
+ }
+}
@@ -0,0 +1,19 @@
+package com.derekdonnelly.flex.components.IconDropDownList.model.enums
+{
+ public class IconDropDownListState
+ {
+ // Default
+ public static const NONE:String = "";
+ public static const ADDED:String = "IconDropDownList component added";
+
+ // Opening
+ public static const OPENING:String = "opening IconDropDownList component";
+ public static const OPEN_SUCCESS:String = "IconDropDownList component open";
+ public static const OPEN_ERROR:String = "error opening IconDropDownList component";
+
+ // Closing
+ public static const CLOSING:String = "closing IconDropDownList component";
+ public static const CLOSE_SUCCESS:String = "IconDropDownList component closed";
+ public static const CLOSE_ERROR:String = "error closing IconDropDownList component";
+ }
+}
Oops, something went wrong.

0 comments on commit affafa2

Please sign in to comment.