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())) };
}
});
}
});
}
Aggregations