Examples of XMLMemento


Examples of org.eclipse.ui.XMLMemento

    }
    return log.getAdapter(clazz);
  }

  private void save() throws CoreException {
    XMLMemento rootElem = XMLMemento.createWriteRoot(ELEM_ROOT);
    for (ARestriction<?> rest : restrictions) {
      final IMemento clauseElem = rootElem.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_FILTER, w.toString());
    } catch (IOException e) {
      // Unexpected exception; wrap with CoreException
      throw new CoreException(new Status(IStatus.ERROR, UIPlugin.PLUGIN_ID,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.