super.setDefaultRightRenderer(Object.class, _rightRenderer);*/
HighlightPredicate paintIconExpanded=new HighlightPredicate() {
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
if (adapter.column==0) {
CNodeIndex cnode=_model.getCNodeIndex(adapter.row, 0);
if (cnode.nodeRow==-1) {
return _model.getNodeExpanded(cnode.nodeIndex);
} else {
return false;
}
} else {
return false;
}
}
};
HighlightPredicate paintIconClosed=new HighlightPredicate() {
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
if (adapter.column==0) {
CNodeIndex cnode=_model.getCNodeIndex(adapter.row, 0);
if (cnode.nodeRow==-1) {
return !_model.getNodeExpanded(cnode.nodeIndex);
} else {
return false;
}
} else {
return false;
}
}
};
HighlightPredicate splitRow=new HighlightPredicate() {
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
CNodeIndex cnode=_model.getCNodeIndex(adapter.row, adapter.column);
if (cnode.nodeRow==-1) {
return true;
} else {
return false;
}
}
};
HighlightPredicate top=new HighlightPredicate() {
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
return (adapter.row==0);
}
};
HighlightPredicate left=new HighlightPredicate() {
public boolean isHighlighted(Component rederer, ComponentAdapter adapter) {
return (adapter.column==0);
}
};
super.addHighlighter(new IconHighlighter(paintIconExpanded,new ExpandIcon(true)),true);
super.addHighlighter(new IconHighlighter(paintIconClosed,new ExpandIcon(false)),true);
super.addHighlighter(new ColorHighlighter(splitRow,SplitTableDefaults.tablePartOfBg(),Color.black),true);
super.addHighlighter(new ColorHighlighter(splitRow,SplitTableDefaults.tablePartOfBg(),Color.black),false);
super.addHighlighter(new BorderHighlighter(top,SplitTableDefaults.topCellBorder()), true);
super.addHighlighter(new BorderHighlighter(left,SplitTableDefaults.leftCellBorder()), false);
super.addSelectionListener(new JXSplitTable.SelectionListener() {
public void choosen(int row, int col, boolean left) {
AbstractTwoLevelSplitTableModel.CNodeIndex cnode=_model.getCNodeIndex(row,col);
if (cnode.isValid()) {
Iterator<SelectionListener> it=_listeners.iterator();
if (cnode.nodeRow==-1) {
boolean expanded=_model.getNodeExpanded(cnode.nodeIndex);
boolean newExpanded=_model.setNodeExpanded(cnode.nodeIndex, !expanded);
if (newExpanded!=expanded) { _model.fireTableDataChanged(); }
}
while(it.hasNext()) {
it.next().choosen(cnode.nodeIndex, cnode.nodeRow, cnode.column, left);
}
}
}
public void selected(int row, int col, boolean left) {
AbstractTwoLevelSplitTableModel.CNodeIndex cnode=_model.getCNodeIndex(row,col);
if (cnode.isValid()) {
Iterator<SelectionListener> it=_listeners.iterator();
while(it.hasNext()) {
it.next().selected(cnode.nodeIndex,cnode.nodeRow,cnode.column,left);
}
}