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