Search in sources :

Example 1 with WrapTreeNode

use of org.develnext.jphp.swing.classes.components.tree.WrapTreeNode in project jphp by jphp-compiler.

the class JTreeXEventProvider method register.

@Override
public void register(final Environment env, final JTreeX component, final ComponentProperties properties) {
    final ObjectMemory self = new ObjectMemory(new UITree(env, component));
    component.getContent().addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(final TreeSelectionEvent e) {
            trigger(env, properties, "selected", new Function<Memory[]>() {

                @Override
                public Memory[] call() {
                    Memory oldNode = Memory.NULL;
                    if (e.getOldLeadSelectionPath() != null) {
                        oldNode = new ObjectMemory(new WrapTreeNode(env, (DefaultMutableTreeNode) e.getOldLeadSelectionPath().getLastPathComponent()));
                    }
                    Memory node = Memory.NULL;
                    if (e.getNewLeadSelectionPath() != null) {
                        node = new ObjectMemory(new WrapTreeNode(env, (DefaultMutableTreeNode) e.getNewLeadSelectionPath().getLastPathComponent()));
                    }
                    return new Memory[] { self, node, oldNode, TrueMemory.valueOf(e.isAddedPath()) };
                }
            });
        }
    });
    component.getContent().addTreeWillExpandListener(new TreeWillExpandListener() {

        @Override
        public void treeWillExpand(final TreeExpansionEvent event) {
            trigger(env, properties, "willExpand", new Function<Memory[]>() {

                @Override
                public Memory[] call() {
                    return new Memory[] { self, new ObjectMemory(new WrapTreeNode(env, (DefaultMutableTreeNode) event.getPath().getLastPathComponent())) };
                }
            });
        }

        @Override
        public void treeWillCollapse(final TreeExpansionEvent event) {
            trigger(env, properties, "willCollapse", new Function<Memory[]>() {

                @Override
                public Memory[] call() {
                    return new Memory[] { self, new ObjectMemory(new WrapTreeNode(env, (DefaultMutableTreeNode) event.getPath().getLastPathComponent())) };
                }
            });
        }
    });
    component.getContent().addTreeExpansionListener(new TreeExpansionListener() {

        @Override
        public void treeExpanded(final TreeExpansionEvent event) {
            trigger(env, properties, "expanded", new Function<Memory[]>() {

                @Override
                public Memory[] call() {
                    return new Memory[] { self, new ObjectMemory(new WrapTreeNode(env, (DefaultMutableTreeNode) event.getPath().getLastPathComponent())) };
                }
            });
        }

        @Override
        public void treeCollapsed(final TreeExpansionEvent event) {
            trigger(env, properties, "collapsed", new Function<Memory[]>() {

                @Override
                public Memory[] call() {
                    return new Memory[] { self, new ObjectMemory(new WrapTreeNode(env, (DefaultMutableTreeNode) event.getPath().getLastPathComponent())) };
                }
            });
        }
    });
}
Also used : Function(php.runtime.common.Function) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ObjectMemory(php.runtime.memory.ObjectMemory) TrueMemory(php.runtime.memory.TrueMemory) Memory(php.runtime.Memory) ObjectMemory(php.runtime.memory.ObjectMemory) WrapTreeNode(org.develnext.jphp.swing.classes.components.tree.WrapTreeNode) UITree(org.develnext.jphp.swing.classes.components.tree.UITree)

Aggregations

DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 UITree (org.develnext.jphp.swing.classes.components.tree.UITree)1 WrapTreeNode (org.develnext.jphp.swing.classes.components.tree.WrapTreeNode)1 Memory (php.runtime.Memory)1 Function (php.runtime.common.Function)1 ObjectMemory (php.runtime.memory.ObjectMemory)1 TrueMemory (php.runtime.memory.TrueMemory)1