Package org.eclipse.ui

Examples of org.eclipse.ui.XMLMemento


    static <T> T fromMemento(Class<T> clazz, IMemento memento) throws IOException
    {
        try
        {
            final StringWriter sw = new StringWriter();
            final XMLMemento m = XMLMemento.createWriteRoot(memento.getType());
            m.putMemento(memento);
            m.save(sw);
            return new Persister().read(clazz, new StringReader(sw.toString()));
        }
        catch (Exception e)
        {
            throw ExceptionUtils.wrapAs(IOException.class, e);
View Full Code Here


     */
    public static String toString(IMemento memento)
    {
        if (!(memento instanceof XMLMemento))
        {
            XMLMemento m = XMLMemento.createWriteRoot(memento.getType());
            m.putMemento(memento);
            memento = m;
        }

        try
        {
View Full Code Here

    this.stateManager = stateManager;
  }

  public IStatus loadCompositeState(CompositeCheatSheetModel model, Map layoutData) {
    if (stateManager instanceof NoSaveStateManager) return Status.OK_STATUS;
    XMLMemento readMemento = CheatSheetPlugin.getPlugin().readMemento(model.getId() + DOT_XML);
    if (readMemento == null) {
      return Status.OK_STATUS;
   
        taskMementoMap = createTaskMap(readMemento);
        loadTaskState(taskMementoMap, (AbstractTask)model.getRootTask());
View Full Code Here

   * @param layoutData Will contain pairs of name/value Strings used to save and restore layout
   * @return
   */
  public IStatus saveCompositeState(CompositeCheatSheetModel model, Map layoutData) {
    if (stateManager instanceof NoSaveStateManager) return Status.OK_STATUS; 
    XMLMemento writeMemento = XMLMemento.createWriteRoot(ICompositeCheatsheetTags.COMPOSITE_CHEATSHEET_STATE);
    writeMemento.putString(IParserTags.ID, model.getId());   
        saveTaskState(writeMemento, (AbstractTask)model.getRootTask());
        saveCheatSheetManagerData(writeMemento, model.getCheatSheetManager());
    taskMementoMap = createTaskMap(writeMemento);
    if (layoutData != null) {
      saveMap(writeMemento, layoutData, ICompositeCheatsheetTags.LAYOUT_DATA);
View Full Code Here

   * Read a memento from the state directory for the cheatsheets plugin
   * @param filename A simple filename
   * @return A memento read from the state directory or null if the memento could not be read
   */
  public XMLMemento readMemento(String filename) {
    XMLMemento memento;
    InputStreamReader reader = null;

    try {
      // Read the cheatsheet state file.
      final File stateFile = getCheatSheetStateFile(filename);
View Full Code Here

   * Saves the current cheatsheet history so it can be restored later on
   */
  private void saveCheatSheetHistory() {
    SafeRunner.run(new SafeRunnable() {
      public void run() {
        XMLMemento memento = XMLMemento.createWriteRoot(MEMENTO_TAG_CHEATSHEET);

        // Save the version number.
        memento.putString(MEMENTO_TAG_VERSION, VERSION_STRING[1]);

        // Save perspective history.
        getCheatSheetHistory().saveState(memento.createChild(MEMENTO_TAG_CHEATSHEET_HISTORY));

        IStatus status = saveMemento(memento, HISTORY_FILENAME);
        if (!status.isOK()) {
          CheatSheetPlugin.getPlugin().getLog().log(status);
        }
View Full Code Here

   * @param contentPath
   * @param csm
   */
  public IStatus saveState(Properties properties, CheatSheetManager csm) { 
    String csID = (String) properties.get(IParserTags.ID);
    XMLMemento writeMemento = XMLMemento.createWriteRoot(IParserTags.CHEATSHEET_STATE);
        IStatus status = saveToMemento(properties, csm, writeMemento);
        if (!status.isOK()) {
          return status;
        }
    return CheatSheetPlugin.getPlugin().saveMemento(writeMemento, csID + DOT_XML);
View Full Code Here

  /**
   * @param csID The id of this cheatsheet
   * @return The state of this cheatsheet or null
   */
  public Properties loadState(String csID) {
    XMLMemento readMemento = CheatSheetPlugin.getPlugin().readMemento(csID + DOT_XML);
    if (readMemento == null) {
      return null;
   
    return loadFromMemento(readMemento);
  }
View Full Code Here

  };

  public void run(final IAction action) {
    Runnable op = new Runnable() {
      public void run() {
        XMLMemento memento = XMLMemento.createWriteRoot(IWorkbenchConstants.TAG_WORKBENCH);
        saveState(memento);
        saveMementoToFile(memento);

      }
    };
View Full Code Here

    }
  }

  private void savePreferenceCache() {
    String mementoString = null;
    XMLMemento rootMemento = XMLMemento.createWriteRoot(KEY_ROOT);
    for (Combo combo : comboList) {
      String textLabel = (String) combo.getData(KEY_URL_DATA);
      String value = combo.getText();
      List<String> subList = cacheMap.get(textLabel);
      if (subList == null) {
        subList = new LinkedList<String>();
      }
      subList.remove(value);
      subList.add(0, value);
      cacheMap.put(textLabel, subList);

      for (int i = 0; i < subList.size(); i++) {
        if (i >= 10) {
          break;
        }
        IMemento child = rootMemento.createChild(KEY_URL_DATA);
        child.putString(KEY_NAME, textLabel);
        child.putString(KEY_VALUE, subList.get(i));
      }
    }

    try {
      StringWriter writer = new StringWriter();
      rootMemento.save(writer);
      mementoString = writer.getBuffer().toString();
      prefStore.setValue(prefStoreKey, mementoString);
    }
    catch (IOException e) {
      StatusHandler.log(new Status(IStatus.ERROR, MetadataPlugin.PLUGIN_ID,
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.