Example usage for com.badlogic.gdx.scenes.scene2d.utils Selection toArray

List of usage examples for com.badlogic.gdx.scenes.scene2d.utils Selection toArray

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.utils Selection toArray.

Prototype

public Array<T> toArray() 

Source Link

Usage

From source file:com.o2d.pkayjava.editor.view.ui.box.UIItemsTreeBoxMediator.java

License:Apache License

@Override
public void handleNotification(Notification notification) {
    super.handleNotification(notification);
    Sandbox sandbox = Sandbox.getInstance();
    if (SceneDataManager.SCENE_LOADED.equals(notification.getName())) {
        Entity rootEntity = sandbox.getRootEntity();
        viewComponent.init(rootEntity);// w ww .  j  av  a 2s .  c om
    } else if (ItemFactory.NEW_ITEM_ADDED.equals(notification.getName())) {
        Entity rootEntity = sandbox.getRootEntity();
        rootEntity = sandbox.getRootEntity();
        viewComponent.init(rootEntity);
    } else if (DeleteItemsCommand.DONE.equals(notification.getName())) {
        Entity rootEntity = sandbox.getRootEntity();
        rootEntity = sandbox.getRootEntity();
        viewComponent.init(rootEntity);
    } else if (UIItemsTreeBox.ITEMS_SELECTED.equals(notification.getName())) {
        Selection<Tree.Node> selection = notification.getBody();
        Array<Tree.Node> nodes = selection.toArray();
        Set<Entity> items = new HashSet<>();

        for (Tree.Node node : nodes) {
            Integer entityId = (Integer) node.getObject();
            Entity item = EntityUtils.getByUniqueId(entityId);
            //layer lock thing
            LayerItemVO layerItemVO = EntityUtils.getEntityLayer(item);
            if (layerItemVO != null && layerItemVO.isLocked) {
                continue;
            }
            if (item != null) {
                items.add(item);
            }
        }
        sendSelectionNotification(items);
    } else if (SetSelectionCommand.DONE.equals(notification.getName())) {
        viewComponent.setSelection(sandbox.getSelector().getSelectedItems());
    } else if (AddSelectionCommand.DONE.equals(notification.getName())) {
        viewComponent.setSelection(sandbox.getSelector().getSelectedItems());
    } else if (ReleaseSelectionCommand.DONE.equals(notification.getName())) {
        viewComponent.setSelection(sandbox.getSelector().getSelectedItems());
    }
}

From source file:com.uwsoft.editor.view.ui.box.UIItemsTreeBoxMediator.java

License:Apache License

@Override
public void handleNotification(Notification notification) {
    super.handleNotification(notification);
    Sandbox sandbox = Sandbox.getInstance();
    switch (notification.getName()) {
    case SceneDataManager.SCENE_LOADED:
        Entity rootEntity = sandbox.getRootEntity();
        viewComponent.init(rootEntity);//from   w w  w.j  a v a 2  s.c om
        break;
    case ItemFactory.NEW_ITEM_ADDED:
        rootEntity = sandbox.getRootEntity();
        viewComponent.init(rootEntity);
        break;
    case DeleteItemsCommand.DONE:
        rootEntity = sandbox.getRootEntity();
        viewComponent.init(rootEntity);
        break;
    case UIItemsTreeBox.ITEMS_SELECTED:
        Selection<Tree.Node> selection = notification.getBody();
        Array<Tree.Node> nodes = selection.toArray();
        for (Tree.Node node : nodes) {
            Integer entityId = (Integer) node.getObject();
            Entity item = EntityUtils.getByUniqueId(entityId);
            if (item != null) {
                addSelectionAction(item);
            }
        }

        break;
    }
}