Package org.eclipse.ui

Examples of org.eclipse.ui.XMLMemento


    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,
View Full Code Here


  }

  public IProject[] importProjectSetFromString(String psfContents,
      String filename, Shell shell, IProgressMonitor monitor)
      throws InvocationTargetException {
    XMLMemento xmlMemento = getXMLMementoHelper().stringToXMLMemento(
        psfContents);
    return importProjectSet(xmlMemento, filename, shell, monitor);
  }
View Full Code Here

    return importProjectSet(xmlMemento, filename, shell, monitor);
  }

  public IProject[] importProjectSet(String filename, Shell shell,
      IProgressMonitor monitor) throws InvocationTargetException {
    XMLMemento xmlMemento = getXMLMementoHelper().filenameToXMLMemento(
        filename);
    return importProjectSet(xmlMemento, filename, shell, monitor);
  }
View Full Code Here

    }

    protected void storeDialog(IDialogSettings settings) {
        super.storeDialog(settings);

        XMLMemento memento = XMLMemento.createWriteRoot("workingSet"); //$NON-NLS-1$
        workingSetFilterActionGroup.saveState(memento);
        workingSetFilterActionGroup.dispose();
        StringWriter writer = new StringWriter();
        try {
            memento.save(writer);
            settings.put(WORKINGS_SET_SETTINGS, writer.getBuffer().toString());
        } catch (IOException e) {
            StatusManager.getManager().handle(
                    new Status(IStatus.ERROR, AnalysisPlugin.getPluginID(), IStatus.ERROR, "", e)); //$NON-NLS-1$
            // don't do anything. Simply don't store the settings
View Full Code Here

    public void testInfoFactory() throws Exception {
        InfoFactory infoFactory = new InfoFactory(new AdditionalInfoAndIInfo(null, null));
        DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document document = documentBuilder.newDocument();
        Element root = document.createElement("root");
        IMemento memento = new XMLMemento(document, root);
        infoFactory.saveState(memento);

        assertNull(infoFactory.createElement(memento));

        ClassInfo info = new ClassInfo(null, null, null);
View Full Code Here

    if (all.length() == 0)
      return Collections.emptySet();
    int max = getCommitHistorySize();
    if (max < 1)
      return Collections.emptySet();
    XMLMemento memento;
    try {
      memento = XMLMemento.createReadRoot(new StringReader(all));
    } catch (WorkbenchException e) {
      org.eclipse.egit.ui.Activator.logError(
          "Error reading commit message history", e); //$NON-NLS-1$
      return Collections.emptySet();
    }
    Set<String> messages = new LinkedHashSet<String>();
    for (IMemento child : memento.getChildren(KEY_MESSAGE)) {
      messages.add(child.getTextData());
      if (messages.size() == max)
        break;
    }
    return messages;
View Full Code Here

      return;
    int size = getCommitHistorySize();
    if (size < 1)
      return;

    XMLMemento memento = XMLMemento.createWriteRoot(KEY_MESSAGES);
    memento.createChild(KEY_MESSAGE).putTextData(message);

    int count = 1;
    if (count < size) {
      Set<String> history = getCommitHistory();
      history.remove(message);
      for (String previous : history) {
        memento.createChild(KEY_MESSAGE).putTextData(previous);
        count++;
        if (count == size)
          break;
      }
    }
    StringWriter writer = new StringWriter();
    try {
      memento.save(writer);
      getPreferenceStore().setValue(
          UIPreferences.COMMIT_DIALOG_HISTORY_MESSAGES,
          writer.toString());
    } catch (IOException e) {
      org.eclipse.egit.ui.Activator.logError(
View Full Code Here

    try {
      projects = ProjectUtil.getValidOpenProjects(repository);
    } catch (CoreException e) {
      return null;
    }
    XMLMemento memento = XMLMemento.createWriteRoot(KEY_PROJECTS);
    memento.putString(KEY_BRANCH, branch);
    final String workDir = repository.getWorkTree().getAbsolutePath();
    for (IProject project : projects) {
      IPath path = project.getLocation();
      if (path == null)
        continue;
      // Only remember mapped projects
      if (!(RepositoryProvider.getProvider(project) instanceof GitProvider))
        continue;
      String fullPath = path.toOSString();
      if (fullPath.startsWith(workDir)) {
        String relative = fullPath.substring(workDir.length());
        if (relative.length() == 0)
          relative = REPO_ROOT;
        IMemento child = memento.createChild(KEY_PROJECT);
        child.putTextData(relative);
      }
    }
    return memento;
  }
View Full Code Here

    String pref = getPreference(branch);
    String value = Activator.getDefault().getPreferenceStore()
        .getString(pref);
    if (value.length() == 0)
      return new String[0];
    XMLMemento memento;
    try {
      memento = XMLMemento.createReadRoot(new StringReader(value));
    } catch (WorkbenchException e) {
      Activator.logError("Error reading branch-project associations", e); //$NON-NLS-1$
      return new String[0];
    }
    IMemento[] children = memento.getChildren(KEY_PROJECT);
    if (children.length == 0)
      return new String[0];
    List<String> projects = new ArrayList<String>(children.length);
    for (int i = 0; i < children.length; i++) {
      String path = children[i].getTextData();
View Full Code Here

    {
        try
        {
            final StringWriter w = new StringWriter();
            new Persister().write(benchmarkSettings, w);
            XMLMemento memento = XMLMemento
                .createReadRoot(new StringReader(w.toString()));
            return memento;
        }
        catch (Exception e)
        {
View Full Code Here

TOP

Related Classes of org.eclipse.ui.XMLMemento

Copyright © 2018 www.massapicom. 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.