Пример #1
0
  protected void performSaveAs(IProgressMonitor progressMonitor) {
    FileEditorInput input = (FileEditorInput) getEditorInput();
    String path = input.getFile().getFullPath().toString();
    ResourceSet resourceSet = getResourceSet();
    URI platformURI = URI.createPlatformResourceURI(path, true);
    Resource oldFile = resourceSet.getResource(platformURI, true);

    super.performSaveAs(progressMonitor);

    // load and resave - input has been changed to new path by super
    FileEditorInput newInput = (FileEditorInput) getEditorInput();
    String newPath = newInput.getFile().getFullPath().toString();
    URI newPlatformURI = URI.createPlatformResourceURI(newPath, true);
    Resource newFile = resourceSet.createResource(newPlatformURI);
    // if the extension is the same, saving was already performed by super by saving
    // the plain text
    if (platformURI.fileExtension().equals(newPlatformURI.fileExtension())) {
      oldFile.unload();
      // save code folding state, is it possible with a new name
      codeFoldingManager.saveCodeFoldingStateFile(getResource().getURI().toString());
    } else {
      newFile.getContents().clear();
      newFile.getContents().addAll(oldFile.getContents());
      try {
        oldFile.unload();
        if (newFile.getErrors().isEmpty()) {
          newFile.save(null);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Пример #2
0
  protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) {

    super.performSave(overwrite, progressMonitor);

    // Save code folding state
    codeFoldingManager.saveCodeFoldingStateFile(getResource().getURI().toString());
  }