Example usage for java.beans.beancontext BeanContext add

List of usage examples for java.beans.beancontext BeanContext add

Introduction

In this page you can find the example usage for java.beans.beancontext BeanContext add.

Prototype

boolean add(E e);

Source Link

Document

Ensures that this collection contains the specified element (optional operation).

Usage

From source file:net.team2xh.crt.gui.entities.EntityTree.java

public void loadScene(Scene scene) {
    // Entities/*  w  w  w .  ja  v  a  2  s . co m*/
    List<Node> entities = new LinkedList<>();
    for (Entity e : scene.getEntities()) {
        try {
            // TODO: Some way of differentiating similar objects in a scene
            // Counter ? maybe keep track of named variables
            entities.add(new DynamicNode(e) {
                @Override
                public String getHtmlDisplayName() {
                    return getDisplayName() + " <font color='!controlShadow'><i>"
                            + StringEscapeUtils.escapeHtml3(e.getCenter().toString()) + "</i></font>";
                }
            });
        } catch (IntrospectionException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    Children entitiesChildren = new Children.Array();
    entitiesChildren.add(entities.toArray(new Node[0]));
    for (Node n : entitiesChildren.getNodes()) {

    }
    Node entitiesNode = createNode(entitiesChildren, ICON_ENTITIES);
    entitiesNode.setDisplayName("Entities");
    entitiesNode.setShortDescription("The entities present in the compiled scene.");

    // Lights
    BeanContext lights = new BeanContextSupport();
    for (Light l : scene.getLights()) {
        lights.add(l);
    }
    Children lightsChildren = new BeanChildren(lights);
    Node lightsNode = createNode(lightsChildren, ICON_LIGHTS);
    lightsNode.setDisplayName("Lights");
    lightsNode.setShortDescription("The lights present in the compiled scene.");

    // Scene
    Children sceneChildren = new Children.Array();
    sceneChildren.add(new Node[] { lightsNode, entitiesNode });

    Node root = createNode(sceneChildren, ICON_SCENE);
    root.setDisplayName("Scene");
    root.setShortDescription("The current scene after execution of the script.");

    manager.setRootContext(root);

    SwingUtilities.invokeLater(() -> {
        tree.expandAll();
    });
}