Package sortpom

Source Code of sortpom.FileContentReplaceAction

package sortpom;

import com.intellij.openapi.editor.Document;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;

/**
* Replaces the context of a file when the run method is invoked
*
* @author bjorn
* @since 2013-01-02
*/
public class FileContentReplaceAction implements Runnable {
    private final String mySortedXml;
    private final PsiFile myPsiFile;

    public FileContentReplaceAction(String sortedXml, PsiFile psiFile) {
        this.mySortedXml = sortedXml;
        this.myPsiFile = psiFile;
    }

    public void run() {
        PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myPsiFile.getProject());
        Document document = documentManager.getDocument(myPsiFile);
        document.setText(mySortedXml);

        documentManager.commitDocument(document);
    }
}
TOP

Related Classes of sortpom.FileContentReplaceAction

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.