updateOKButton();
setDefaultButton();
}
private void save() throws CoreException {
XMLMemento rootElem = XMLMemento.createWriteRoot(ELEM_ROOT);
for (NamedFilter flt : namedFilters) {
final IMemento filterElem = rootElem.createChild(ELEM_FILTER);
filterElem.putString(ATTRIB_NAME, flt.getName());
for (ARestriction<?> rest : flt.getRestrictions()) {
final IMemento clauseElem = filterElem.createChild(ELEM_CLAUSE);
clauseElem.putString(ATTRIB_FIELD, rest.getField().getKey());
clauseElem.putInteger(ATTRIB_OPERATOR, rest.getOperator().getId());
rest.visit(new IRestrictionVisitor() {
/* (non-Javadoc)
* @see net.sf.logsaw.core.query.IRestrictionVisitor#visit(net.sf.logsaw.core.query.LevelRestriction)
*/
@Override
public void visit(LevelRestriction restriction) {
clauseElem.putTextData(restriction.getField().toInputValue(restriction.getValue(), log));
}
/* (non-Javadoc)
* @see net.sf.logsaw.core.query.IRestrictionVisitor#visit(net.sf.logsaw.core.query.StringRestriction)
*/
@Override
public void visit(StringRestriction restriction) {
clauseElem.putTextData(restriction.getField().toInputValue(restriction.getValue(), log));
}
/* (non-Javadoc)
* @see net.sf.logsaw.core.query.IRestrictionVisitor#visit(net.sf.logsaw.core.query.DateRestriction)
*/
@Override
public void visit(DateRestriction restriction) {
clauseElem.putTextData(restriction.getField().toInputValue(restriction.getValue(), log));
}
});
}
}
try {
StringWriter w = new StringWriter();
// Save to byte buffer first
rootElem.save(w);
// Update log resource
log.configure(OPTION_NAMED_FILTERS, w.toString());
} catch (IOException e) {
// Unexpected exception; wrap with CoreException
throw new CoreException(new Status(IStatus.ERROR, UIPlugin.PLUGIN_ID,