use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.CConditionCriterium in project binnavi by google.
the class CTreeNodeRenderer method getTreeCellRendererComponent.
@Override
public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (value instanceof JCriteriumTreeNode) {
final JCriteriumTreeNode node = (JCriteriumTreeNode) value;
final int count = node.getChildCount();
final ICriterium type = node.getCriterium();
if (!(type instanceof CConditionCriterium)) {
if (count == 1 && (type instanceof CNotCriterium || node.getLevel() == 0) || count > 1 && !(type instanceof CNotCriterium)) {
setForeground(VALID_NODE_FONT_COLOR);
} else {
setForeground(INVALID_NODE_FONT_COLOR);
}
}
}
return this;
}
use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.CConditionCriterium in project binnavi by google.
the class JCriteriumTreeModel method sortChildren.
/**
* Sorts visible tree nodes.
*
* @param parentNode Parent nodes whose children are sorted.
*/
private void sortChildren(final JCriteriumTreeNode parentNode) {
final List<JCriteriumTreeNode> operators = new ArrayList<JCriteriumTreeNode>();
final List<JCriteriumTreeNode> conditions = new ArrayList<JCriteriumTreeNode>();
final List<JCriteriumTreeNode> minus = new ArrayList<JCriteriumTreeNode>();
final Enumeration<?> children = parentNode.children();
while (children.hasMoreElements()) {
final JCriteriumTreeNode child = (JCriteriumTreeNode) children.nextElement();
final ICriterium type = child.getCriterium();
if (type instanceof CConditionCriterium) {
conditions.add(child);
} else {
operators.add(child);
}
}
parentNode.removeAllChildren();
for (final JCriteriumTreeNode child : operators) {
parentNode.add(child);
child.setParent(parentNode);
}
for (final JCriteriumTreeNode child : conditions) {
parentNode.add(child);
child.setParent(parentNode);
}
for (final JCriteriumTreeNode child : minus) {
parentNode.add(child);
child.setParent(parentNode);
}
}
Aggregations