package com.nucleus.scene;

import com.nucleus.properties.EventManager.EventHandler;
import com.nucleus.properties.Property;

/**
 * Handles node related actions, there shall be only one node controller for each nodetree.
 * TODO How to check that only one nodecontroller is created for a RootNode
 * 
 * @author Richard Sahlin
 *
 */
public class NodeController implements EventHandler {

    /**
     * The key to register in the property handler for this class
     */
    private final static String HANDLER_KEY = "node";

    public enum Actions {
        /**
         * This will switch the specified node
         * Split value to get nodeId, switchId
         */
        SWITCH();
    }

    private RootNode root;

    /**
     * Creates a new node controller with the specified root node.
     * 
     * @param root
     */
    public NodeController(RootNode root) {
        this.root = root;
    }

    @Override
    public void handleEvent(String key, String value) {
        Property p = Property.create(value);
    }

    @Override
    public void handleObjectEvent(Object obj, String key, String value) {
        // TODO Auto-generated method stub
    }

    @Override
    public String getHandlerCategory() {
        return HANDLER_KEY;
    }

}

@@ -21,16 +21,60 @@
 scene;%0A%0A
+import com.nucleus.properties.EventManager;%0A
 import c
@@ -1061,32 +1061,619 @@
 (value);%0A    %7D%0A%0A
+    /**%0A     * Registers this class as a eventhandler for the key, if key is null the %7B@link #HANDLER_KEY%7D is used.%0A     * NOTE! Only register ONE instance. This shall be called with the%0A     * %7B@link #handleObjectEvent(Object, String, String)%7D method which will resolve the needed target.%0A     * TODO How to make sure only one instance of this class is registered?%0A     * %0A     * @param key The key to register this controller for, or null to use default.%0A     */%0A    public void registerEventHandler(String key) %7B%0A        EventManager.getInstance().registerCategory(key, this);%0A    %7D%0A%0A
     @Override%0A  
@@ -1719,26 +1719,31 @@
 obj, String 
-ke
+categor
 y, String va
@@ -1761,42 +1761,348 @@
     
-// TODO Auto-generated method stub
+Actions action = Actions.valueOf(category);%0A        Property p = Property.create(value);%0A        switch (action) %7B%0A        case SWITCH:%0A            SwitchNode node = (SwitchNode) root.getScene().getNodeById(p.getKey());%0A            if (node != null) %7B%0A                node.setActive(p.getValue());%0A            %7D%0A            break;%0A        %7D
 %0A   

Make it possible to affect switch nodes via event