Search in sources :

Example 6 with TreeNode

use of org.apache.pivot.wtk.content.TreeNode in project pivot by apache.

the class EventLoggerSkin method sourceChanged.

// EventLoggerListener methods
@Override
public void sourceChanged(EventLogger eventLogger, Component previousSource) {
    // Component source = eventLogger.getSource();
    HashMap<Class<?>, ArrayList<Method>> buckets = new HashMap<>();
    for (Method event : eventLogger.getDeclaredEvents()) {
        Class<?> listenerInterface = event.getDeclaringClass();
        ArrayList<Method> bucket = buckets.get(listenerInterface);
        if (bucket == null) {
            bucket = new ArrayList<>();
            buckets.put(listenerInterface, bucket);
        }
        bucket.add(event);
    }
    ArrayList<TreeNode> treeData = new ArrayList<>(treeNodeComparator);
    declaredEventsTreeView.setTreeData(treeData);
    updating = true;
    try {
        for (Class<?> listenerInterface : buckets) {
            TreeBranch treeBranch = new TreeBranch(listenerInterface.getSimpleName());
            treeBranch.setComparator(treeNodeComparator);
            treeData.add(treeBranch);
            for (Method event : buckets.get(listenerInterface)) {
                treeBranch.add(new EventNode(event));
                eventLogger.getIncludeEvents().add(event);
            }
        }
        Sequence.Tree.ItemIterator<TreeNode> iter = Sequence.Tree.depthFirstIterator(treeData);
        while (iter.hasNext()) {
            iter.next();
            declaredEventsTreeView.setNodeChecked(iter.getPath(), true);
        }
    } finally {
        updating = false;
    }
}
Also used : HashMap(org.apache.pivot.collections.HashMap) ArrayList(org.apache.pivot.collections.ArrayList) Method(java.lang.reflect.Method) TreeBranch(org.apache.pivot.wtk.content.TreeBranch) TreeNode(org.apache.pivot.wtk.content.TreeNode)

Example 7 with TreeNode

use of org.apache.pivot.wtk.content.TreeNode in project pivot by apache.

the class EventLoggerSkin method setEventIncluded.

private void setEventIncluded(Method event, boolean included) {
    @SuppressWarnings("unchecked") List<TreeNode> treeData = (List<TreeNode>) declaredEventsTreeView.getTreeData();
    Sequence.Tree.ItemIterator<TreeNode> iter = Sequence.Tree.depthFirstIterator(treeData);
    while (iter.hasNext()) {
        TreeNode treeNode = iter.next();
        if (treeNode instanceof EventNode) {
            EventNode eventNode = (EventNode) treeNode;
            if (eventNode.getEvent() == event) {
                declaredEventsTreeView.setNodeChecked(iter.getPath(), included);
                break;
            }
        }
    }
}
Also used : TreeNode(org.apache.pivot.wtk.content.TreeNode) ArrayList(org.apache.pivot.collections.ArrayList) List(org.apache.pivot.collections.List)

Aggregations

TreeNode (org.apache.pivot.wtk.content.TreeNode)7 TreeBranch (org.apache.pivot.wtk.content.TreeBranch)4 ArrayList (org.apache.pivot.collections.ArrayList)3 List (org.apache.pivot.collections.List)3 Path (org.apache.pivot.collections.Sequence.Tree.Path)3 TreeView (org.apache.pivot.wtk.TreeView)3 IOException (java.io.IOException)2 Method (java.lang.reflect.Method)2 SerializationException (org.apache.pivot.serialization.SerializationException)2 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)2 Component (org.apache.pivot.wtk.Component)2 PushButton (org.apache.pivot.wtk.PushButton)2 TreeViewSelectionListener (org.apache.pivot.wtk.TreeViewSelectionListener)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)1 BeanAdapter (org.apache.pivot.beans.BeanAdapter)1 DefaultProperty (org.apache.pivot.beans.DefaultProperty)1 HashMap (org.apache.pivot.collections.HashMap)1 Map (org.apache.pivot.collections.Map)1 Sequence (org.apache.pivot.collections.Sequence)1