Skip to content

Commit

Permalink
step-13 The Property Inspector
Browse files Browse the repository at this point in the history
* Adding an ExampleObject with Inspectable properties
* Creating an InspectableContext with the ExampleObject as the default
selection
* Viewing and manipulating the ExampleObject's properties in the
PropertiesInspector
  • Loading branch information
robsilv committed Jul 3, 2014
1 parent 2c6aeaf commit 3743114
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
34 changes: 11 additions & 23 deletions src/helloWorld/contexts/HelloWorldContext.as
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
package helloWorld.contexts
{
import helloWorld.ui.views.HelloWorldView;
import flash.display.DisplayObject;

import core.appEx.core.contexts.ISelectionContext;
import core.appEx.core.contexts.IInspectableContext;
import core.appEx.core.contexts.IVisualContext;
import core.appEx.events.ContextSelectionValidatorEvent;
import core.appEx.validators.ContextSelectionValidator;
import core.editor.CoreEditor;
import core.data.ArrayCollection;

import helloWorld.entities.ExampleObject;
import helloWorld.ui.views.HelloWorldView;

public class HelloWorldContext implements IVisualContext
public class HelloWorldContext implements IVisualContext, IInspectableContext
{
private var _view :HelloWorldView;
private var contextSelectionValidator :ContextSelectionValidator;
private var _selection :ArrayCollection;

public function HelloWorldContext()
{
_view = new HelloWorldView();
_view.text = "Hello World";

contextSelectionValidator = new ContextSelectionValidator(CoreEditor.contextManager, ISelectionContext, String);
contextSelectionValidator.addEventListener(ContextSelectionValidatorEvent.VALID_SELECTION_CHANGED, selectionChangeHandler);
_selection = new ArrayCollection();
_selection.addItem( new ExampleObject() );
}

public function get view():DisplayObject
Expand All @@ -30,20 +29,9 @@ package helloWorld.contexts

public function dispose():void
{
contextSelectionValidator.removeEventListener(ContextSelectionValidatorEvent.VALID_SELECTION_CHANGED, selectionChangeHandler);
contextSelectionValidator.dispose();

}

private function selectionChangeHandler(event:ContextSelectionValidatorEvent):void
{
_view.text = "";

var selection:Array = contextSelectionValidator.getValidSelection();
for ( var i:int = 0; i < selection.length; i++ )
{
var item:String = selection[i];
_view.text += item + "\n";
}
}
public function get selection():ArrayCollection { return _selection; }
}
}
19 changes: 19 additions & 0 deletions src/helloWorld/entities/ExampleObject.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package helloWorld.entities
{
public class ExampleObject
{
[Inspectable]
public var propertyA :String = "This is property A";
[Inspectable]
public var propertyB :Number = 12345;
[Inspectable ( editor="ColorPicker" )]
public var propertyC :uint = 0xFFFFFF;
[Inspectable]
public var propertyD :Boolean = false;

public function ExampleObject ()
{

}
}
}

0 comments on commit 3743114

Please sign in to comment.