Skip to content

Commit

Permalink
step-6 Creating a More Complex Context
Browse files Browse the repository at this point in the history
* Creating a List view
* Creating a Context with an ArrayCollection dataProvider
* Contributing both via the extension
  • Loading branch information
robsilv committed Jul 3, 2014
1 parent 3fb4dc2 commit 6463be2
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/HelloWorldExtension.as
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ package

import helloWorld.commandHandlers.MyCommandHandler;
import helloWorld.contexts.HelloWorldContext;
import helloWorld.contexts.StringListContext;
import helloWorld.entities.Commands;

public class HelloWorldExtension extends Sprite
{
public function HelloWorldExtension()
{
CoreApp.resourceManager.addResource( new FactoryResource( HelloWorldContext, "Hello World" ) );
CoreApp.resourceManager.addResource( new FactoryResource( StringListContext, "String List" ) );

CoreApp.resourceManager.addResource( new ActionFactory( IGlobalViewContainer, Commands.MY_COMMAND, "My Action", "myActions", "Actions/myActions", CoreEditorIcons.Resource ) );
CoreApp.resourceManager.addResource( new CommandHandlerFactory( Commands.MY_COMMAND, MyCommandHandler ) );
CoreApp.resourceManager.addResource( new KeyBinding( Commands.MY_COMMAND, 77, KeyModifier.CTRL ) );
Expand Down
40 changes: 40 additions & 0 deletions src/helloWorld/contexts/StringListContext.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package helloWorld.contexts
{
import flash.display.DisplayObject;

import core.appEx.core.contexts.IVisualContext;
import core.data.ArrayCollection;

import helloWorld.ui.views.StringListView;

public class StringListContext implements IVisualContext
{
private var _view :StringListView;

private var _dataProvider :ArrayCollection;

public function StringListContext()
{
_view = new StringListView();

_dataProvider = new ArrayCollection();
_dataProvider.addItem( "Item 1" );
_dataProvider.addItem( "Item 2" );
_dataProvider.addItem( "Item 3" );

_view.dataProvider = _dataProvider;
}

public function get view():DisplayObject
{
return _view;
}

public function dispose():void
{

}

public function get dataProvider():ArrayCollection { return _dataProvider; }
}
}
18 changes: 18 additions & 0 deletions src/helloWorld/ui/views/StringListView.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package helloWorld.ui.views
{
import core.ui.components.List;

public class StringListView extends List
{
public function StringListView()
{

}

override protected function init():void
{
super.init();
_percentWidth = _percentHeight = 100;
}
}
}

0 comments on commit 6463be2

Please sign in to comment.