Package org.eclipse.ui

Examples of org.eclipse.ui.XMLMemento$DOMWriter


    }

    @Override
    public void dispose() {
        // XXX see https://bugs.eclipse.org/bugs/show_bug.cgi?id=223068
        XMLMemento memento = XMLMemento.createWriteRoot("bugExplorer"); //$NON-NLS-1$
        saveState(memento);
        StringWriter writer = new StringWriter();
        try {
            memento.save(writer);
            IDialogSettings dialogSettings = FindbugsPlugin.getDefault().getDialogSettings();
            dialogSettings.put(TAG_MEMENTO, writer.getBuffer().toString());
        } catch (IOException e) {
            // don't do anything. Simply don't store the settings
        }
View Full Code Here


    public void loadUserSchemas()
    {
        try
        {
            FileReader reader = new FileReader( getSchemaPoolFile() );
            XMLMemento memento = XMLMemento.createReadRoot( reader );
            IMemento[] children = memento.getChildren( SCHEMA_TAG );
            for ( IMemento child : children )
            {
                try
                {
                    addSchema( Schema.localPathToURL( child.getString( PATH_TAG ) ), //$NON-NLS-1$
View Full Code Here

    /**
     * Saves the User Schemas Paths to a XML File.
     */
    public void saveUserSchemasPaths()
    {
        XMLMemento memento = XMLMemento.createWriteRoot( SCHEMAS_TAG );

        for ( Schema schema : schemaList )
        {
            if ( ( schema.type == Schema.SchemaType.userSchema ) && ( schema.getURL() != null ) )
            {
                IMemento child = memento.createChild( SCHEMA_TAG );
                child.putString( PATH_TAG, schema.getURL().getPath() );
            }
        }

        try
        {
            FileWriter writer = new FileWriter( getSchemaPoolFile() );
            memento.save( writer );
            writer.close();
        }
        catch ( IOException e )
        {
            logger.debug( "Error when saving opened schemas.", e ); //$NON-NLS-1$
View Full Code Here

        PerspectiveDescriptor realDesc = (PerspectiveDescriptor) desc;
        //get the layout from the registry 
        PerspectiveRegistry perspRegistry = (PerspectiveRegistry) WorkbenchPlugin
                .getDefault().getPerspectiveRegistry();
        // Capture the layout state. 
        XMLMemento memento = XMLMemento.createWriteRoot("perspective");//$NON-NLS-1$
        IStatus status = saveState(memento, realDesc, false);
        if (status.getSeverity() == IStatus.ERROR) {
            ErrorDialog.openError((Shell) null, WorkbenchMessages.Perspective_problemSavingTitle,
                    WorkbenchMessages.Perspective_problemSavingMessage,
                    status);
View Full Code Here

            PerspectiveDescriptor desc = new PerspectiveDescriptor(
                null, null, null);
            StringReader reader = new StringReader((String) event
                .getNewValue());
            try {
              XMLMemento memento = XMLMemento
                  .createReadRoot(reader);
              desc.restoreState(memento);
              addPerspective(desc);
            } catch (WorkbenchException e) {
              unableToLoadPerspective(e.getStatus());
View Full Code Here

        if (xmlString != null && xmlString.length() != 0) {
          reader = new StringReader(xmlString);
        }

        // Restore the layout state.
        XMLMemento memento = XMLMemento.createReadRoot(reader);
        PerspectiveDescriptor newPersp = new PerspectiveDescriptor(
            null, null, null);
        newPersp.restoreState(memento);
        String id = newPersp.getId();
        IPerspectiveDescriptor oldPersp = findPerspectiveWithId(id);
        if (oldPersp == null) {
          add(newPersp);
        }
        reader.close();
      } catch (IOException e) {
        unableToLoadPerspective(null);
      } catch (WorkbenchException e) {
        unableToLoadPerspective(e.getStatus());
      }
    }

    // Get the entries from files, if any
    // if -data @noDefault specified the state location may not be
    // initialized
    IPath path = WorkbenchPlugin.getDefault().getDataLocation();
    if (path == null) {
      return;
    }

    File folder = path.toFile();

    if (folder.isDirectory()) {
      File[] fileList = folder.listFiles();
      int nSize = fileList.length;
      for (int nX = 0; nX < nSize; nX++) {
        File file = fileList[nX];
        if (file.getName().endsWith(EXT)) {
          // get the memento
          InputStream stream = null;
          try {
            stream = new FileInputStream(file);
            reader = new BufferedReader(new InputStreamReader(
                stream, "utf-8")); //$NON-NLS-1$

            // Restore the layout state.
            XMLMemento memento = XMLMemento.createReadRoot(reader);
            PerspectiveDescriptor newPersp = new PerspectiveDescriptor(
                null, null, null);
            newPersp.restoreState(memento);
            IPerspectiveDescriptor oldPersp = findPerspectiveWithId(newPersp
                .getId());
View Full Code Here

        .getPreferenceStore();
    String xmlString = store.getString(id + PERSP);
    if (xmlString != null && xmlString.length() != 0) { // defined in store
      reader = new StringReader(xmlString);
    }
    XMLMemento memento = XMLMemento.createReadRoot(reader);
    reader.close();
    return memento;
  }
View Full Code Here

          if (editor != null) {
            String editorId = editor.getSite().getId();
            if (editorId != null) {
              try {
                if (editor instanceof IPersistableEditor) {
                  XMLMemento editorState = XMLMemento
                      .createWriteRoot(IWorkbenchConstants.TAG_EDITOR_STATE);
                  ((IPersistableEditor) editor)
                      .saveState(editorState);
                  ((WorkbenchPage) page).openEditor(editor
                      .getEditorInput(), editorId, true,
View Full Code Here

    }

    if (getWorkbenchConfigurer().getSaveAndRestore()) {
      SafeRunner.run(new SafeRunnable() {
        public void run() {
          XMLMemento mem = recordWorkbenchState();
          // Save the IMemento to a file.
          saveMementoToFile(mem);
        }

        public void handleException(Throwable e) {
View Full Code Here

  /*
   * Record the workbench UI in a document
   */
  private XMLMemento recordWorkbenchState() {
    XMLMemento memento = XMLMemento
        .createWriteRoot(IWorkbenchConstants.TAG_WORKBENCH);
    final IStatus status = saveState(memento);
    if (status.getSeverity() != IStatus.OK) {
      // don't use newWindow as parent because it has not yet been opened
      // (bug 76724)
View Full Code Here

TOP

Related Classes of org.eclipse.ui.XMLMemento$DOMWriter

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.