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