I'm trying to make an editor where users can select an editable item from a list (each item in the list might be a different type of editable object). When the user selects an item from the list its editable properties show up in a panel with a suitable item editor.
The problem I'm having is I don't want all item properties to be editable and I need to be able to specify what type of editor should be used e.g. TextInput, ColorPicker or custom editor.
I thought about creating an EditableItem objects which could have an ArrayCollection called editableItems which holds what can be edited and what type of editor to use in a EditConf object:
public class EditConf
public var value:*;
public var editor:String = "DefaultEditor";
public function EditConf(value:*, editor:String)
this.value = value;
this.editor = editor;
Inside the EditableItem would look something like this with an ArrayCollection holding the EditConf objects.
public class EditableItem
public var label:String;
public var colour:uint;
public var nonEditableVar:String;
public var nonEditableVar2:Boolean;
public var editableItems:ArrayCollection;
public function EditableItem()
The problem with this is when you assign the editor - say a TextInput to edit the value "label" from the editableItems ArrayCollection it updates the editableItem ArrayCollection but not the variable "label". I thought the ArrayCollection would just hold a pointer to "label" so it would update the variable but no such luck.
Does anyone know of a better way to create the application above or why the binding does function as I expected?
It sounds more like an architecture problem. If I had a problem like this, I would have a model class hold my selectedItem. This "selectedItem" property would be injected into a presenter model through a setter function. In the setter function, the presenter would look at the selectedItem and decide which properties on the view class ( viewstack or states ) should be editable.
I have some misgivings about the value objects holding the type of editor they should use, that sounds like something that should be delegated to a UI/Presenter class.