本文整理汇总了Java中com.intellij.openapi.fileEditor.FileDocumentManager.isFileModified方法的典型用法代码示例。如果您正苦于以下问题:Java FileDocumentManager.isFileModified方法的具体用法?Java FileDocumentManager.isFileModified怎么用?Java FileDocumentManager.isFileModified使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.fileEditor.FileDocumentManager
的用法示例。
在下文中一共展示了FileDocumentManager.isFileModified方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doCreateEntry
import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
@Nullable
private Entry doCreateEntry(@NotNull VirtualFile file, boolean forDeletion) {
if (!file.isDirectory()) {
if (!isVersioned(file)) return null;
Pair<StoredContent, Long> contentAndStamps;
if (forDeletion) {
FileDocumentManager m = FileDocumentManager.getInstance();
Document d = m.isFileModified(file) ? m.getCachedDocument(file) : null; // should not try to load document
contentAndStamps = acquireAndClearCurrentContent(file, d);
}
else {
contentAndStamps = getActualContentNoAcquire(file);
}
return new FileEntry(file.getName(), contentAndStamps.first, contentAndStamps.second, !file.isWritable());
}
DirectoryEntry newDir = new DirectoryEntry(file.getName());
doCreateChildren(newDir, iterateDBChildren(file), forDeletion);
if (!isVersioned(file) && newDir.getChildren().isEmpty()) return null;
return newDir;
}
示例2: processUnsavedChanges
import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
/**
* Finds modified but unsaved files in the given list of dirty files and notifies the builder about MODIFIED changes.
* Changes contained in <code>alreadyProcessed</code> are skipped - they have already been processed as modified, or else.
*/
public void processUnsavedChanges(ChangelistBuilder builder, Set<FilePath> dirtyFiles, Collection<HgChange> alreadyProcessed) {
// exclude already processed
for (HgChange c : alreadyProcessed) {
dirtyFiles.remove(c.beforeFile().toFilePath());
dirtyFiles.remove(c.afterFile().toFilePath());
}
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
final FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
for (FilePath filePath : dirtyFiles) {
final VirtualFile vf = filePath.getVirtualFile();
if (vf != null && fileDocumentManager.isFileModified(vf)) {
final VirtualFile root = vcsManager.getVcsRootFor(vf);
if (root != null && HgUtil.isHgRoot(root)) {
final HgRevisionNumber beforeRevisionNumber = new HgWorkingCopyRevisionsCommand(myProject).tip(root);
final ContentRevision beforeRevision = (beforeRevisionNumber == null ? null :
HgContentRevision.create(myProject, new HgFile(myProject, vf), beforeRevisionNumber));
builder.processChange(new Change(beforeRevision, CurrentContentRevision.create(filePath), FileStatus.MODIFIED), myVcsKey);
}
}
}
}
示例3: processUnsaved
import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
private static void processUnsaved(@NotNull VcsDirtyScope dirtyScope,
ChangeListManagerGate addGate,
@NotNull SvnChangeProviderContext context)
throws SVNException {
FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
for (Document unsavedDocument : fileDocumentManager.getUnsavedDocuments()) {
final VirtualFile file = fileDocumentManager.getFile(unsavedDocument);
if (file != null && dirtyScope.belongsTo(VcsUtil.getFilePath(file)) && fileDocumentManager.isFileModified(file)) {
final FileStatus status = addGate.getStatus(file);
if (status == null || FileStatus.NOT_CHANGED.equals(status)) {
context.addModifiedNotSavedChange(file);
}
}
}
}
示例4: saveOrReload
import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
private static void saveOrReload(VirtualFile file, @NotNull Collection<VFilePropertyChangeEvent> events) {
if (file == null || file.isDirectory() || !file.isValid()) {
return;
}
FileDocumentManager documentManager = FileDocumentManager.getInstance();
if (documentManager.isFileModified(file)) {
Document document = documentManager.getDocument(file);
if (document != null) {
documentManager.saveDocumentAsIs(document); // this can be called e.g. in context of undo, so we shouldn't modify document
}
}
events.add(new VFilePropertyChangeEvent(FORCE_RELOAD_REQUESTOR, file, VirtualFile.PROP_NAME, file.getName(), file.getName(), false));
}
示例5: saveFileIfNecessary
import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
public static void saveFileIfNecessary(PsiFile psiFile) {
if (!needSave(ResourceHelper.getFolderType(psiFile.getVirtualFile()))) { // Avoid need for read lock in get parent
return;
}
VirtualFile file = psiFile.getVirtualFile();
if (file == null) {
return;
}
final FileDocumentManager fileManager = FileDocumentManager.getInstance();
if (!fileManager.isFileModified(file)) {
return;
}
final com.intellij.openapi.editor.Document document;
document = fileManager.getCachedDocument(file);
if (document == null || !fileManager.isDocumentUnsaved(document)) {
return;
}
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
fileManager.saveDocument(document);
}
});
}
}, ModalityState.any());
}
示例6: processEvent
import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
private void processEvent(@Nullable VirtualFile file) {
if (isSyncSensitiveFile(file)) {
FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
if (fileDocumentManager.isFileModified(file)) {
setDirty();
}
}
}