Search in sources :

Example 1 with ShortVcsRevisionNumber

use of com.intellij.openapi.vcs.history.ShortVcsRevisionNumber in project intellij-community by JetBrains.

the class VcsVirtualFile method loadContent.

private void loadContent() throws IOException {
    if (myContent != null)
        return;
    assert myFileRevision != null;
    final VcsFileSystem vcsFileSystem = ((VcsFileSystem) getFileSystem());
    try {
        myFileRevision.loadContent();
        fireBeforeContentsChange();
        myModificationStamp++;
        final VcsRevisionNumber revisionNumber = myFileRevision.getRevisionNumber();
        if (revisionNumber instanceof ShortVcsRevisionNumber) {
            setRevision(((ShortVcsRevisionNumber) revisionNumber).toShortString());
        } else {
            setRevision(revisionNumber.asString());
        }
        myContent = myFileRevision.getContent();
        myCharset = new CharsetToolkit(myContent).guessEncoding(myContent.length);
        ApplicationManager.getApplication().runWriteAction(new Runnable() {

            public void run() {
                vcsFileSystem.fireContentsChanged(this, VcsVirtualFile.this, 0);
            }
        });
    } catch (VcsException e) {
        myContentLoadFailed = true;
        ApplicationManager.getApplication().runWriteAction(new Runnable() {

            public void run() {
                vcsFileSystem.fireBeforeFileDeletion(this, VcsVirtualFile.this);
            }
        });
        myContent = ArrayUtil.EMPTY_BYTE_ARRAY;
        setRevision("0");
        Messages.showMessageDialog(VcsBundle.message("message.text.could.not.load.virtual.file.content", getPresentableUrl(), e.getLocalizedMessage()), VcsBundle.message("message.title.could.not.load.content"), Messages.getInformationIcon());
        ApplicationManager.getApplication().runWriteAction(new Runnable() {

            public void run() {
                vcsFileSystem.fireFileDeleted(this, VcsVirtualFile.this, getName(), getParent());
            }
        });
    } catch (ProcessCanceledException ex) {
        myContent = null;
    }
}
Also used : CharsetToolkit(com.intellij.openapi.vfs.CharsetToolkit) ShortVcsRevisionNumber(com.intellij.openapi.vcs.history.ShortVcsRevisionNumber) VcsException(com.intellij.openapi.vcs.VcsException) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) ShortVcsRevisionNumber(com.intellij.openapi.vcs.history.ShortVcsRevisionNumber) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Aggregations

ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 VcsException (com.intellij.openapi.vcs.VcsException)1 ShortVcsRevisionNumber (com.intellij.openapi.vcs.history.ShortVcsRevisionNumber)1 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)1 CharsetToolkit (com.intellij.openapi.vfs.CharsetToolkit)1