private class Listener implements ListSelectionListener {
public void valueChanged(ListSelectionEvent e) {
ListModel model = (ListModel)e.getSource();
OrPredicate orP = (OrPredicate)m_query;
if ( model.isSelectionEmpty() )
{
orP.clear();
}
else if ( m_includeAll && model.isSelectedIndex(0) )
{
orP.set(BooleanLiteral.TRUE);
}
else
{
int min = model.getMinSelectionIndex();
int max = model.getMaxSelectionIndex();
int count = 0;
for ( int i=min; i<=max; ++i ) {
if ( model.isSelectedIndex(i) )
++count;
}
if ( count == model.getSize() ) {
orP.set(BooleanLiteral.TRUE);
} else if ( count == 1 ) {
orP.set(getComparison(model.getElementAt(min)));
} else {
Predicate[] p = new Predicate[count];
for ( int i=min, j=0; i<=max; ++i ) {
if ( model.isSelectedIndex(i) )
p[j++] = getComparison(model.getElementAt(i));
}
orP.set(p);
}
}
}