Search in sources :

Example 11 with HashMap

use of org.apache.pivot.collections.HashMap 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)

Aggregations

HashMap (org.apache.pivot.collections.HashMap)11 ArrayList (org.apache.pivot.collections.ArrayList)6 List (org.apache.pivot.collections.List)4 JSONSerializer (org.apache.pivot.json.JSONSerializer)3 Sheet (org.apache.pivot.wtk.Sheet)3 SheetCloseListener (org.apache.pivot.wtk.SheetCloseListener)3 StringReader (java.io.StringReader)2 Method (java.lang.reflect.Method)2 TaskAdapter (org.apache.pivot.wtk.TaskAdapter)2 Test (org.junit.Test)2 Color (java.awt.Color)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)1 BeanAdapter (org.apache.pivot.beans.BeanAdapter)1 BeanMonitor (org.apache.pivot.beans.BeanMonitor)1 Map (org.apache.pivot.collections.Map)1 SerializationException (org.apache.pivot.serialization.SerializationException)1 PostQuery (org.apache.pivot.web.PostQuery)1