public IPredicate getPredicate() { IPredicate predicate = null; if (myStandardSeach.isSelected()) { Enumeration optionsEnum = myOptions.elements(); while (optionsEnum.hasMoreElements()) { TextOption option = (TextOption) optionsEnum.nextElement(); if (option.isSelected()) { IPredicate optionPredicate = option.getPredicate(); if (predicate == null) { predicate = optionPredicate; } else { predicate = new AndPredicate(predicate, optionPredicate); } } } } else if (myAdvancedSearch.isSelected()) { try { String searchString = myAdvancedTextField.getText(); PredicateParser predParser = new PredicateParser(); predicate = predParser.parse(searchString); } catch (ParseException e) { String error = e.getMessage(); Debug.handleError(myContext.getFrame(), error, true); } } return predicate; }
public void stateChanged(ChangeEvent _event) { boolean standardEnabled = myStandardSeach.isSelected(); Enumeration optionsEnum = myOptions.elements(); while (optionsEnum.hasMoreElements()) { TextOption option = (TextOption) optionsEnum.nextElement(); option.setEnabled(standardEnabled); } myAdvancedTextField.setEnabled(!standardEnabled); }
protected void addOption(JComponent _comp, TextOption _option) { myOptions.addElement(_option); _comp.add(_option.getCheckBox()); _comp.add(_option.getTextField()); }