本文整理汇总了Java中com.intellij.openapi.fileEditor.FileDocumentManagerAdapter类的典型用法代码示例。如果您正苦于以下问题:Java FileDocumentManagerAdapter类的具体用法?Java FileDocumentManagerAdapter怎么用?Java FileDocumentManagerAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileDocumentManagerAdapter类属于com.intellij.openapi.fileEditor包,在下文中一共展示了FileDocumentManagerAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SwaggerUiUrlProvider
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
private SwaggerUiUrlProvider(final FileDetector fileDetector) {
this.fileDetector = fileDetector;
ApplicationManager.getApplication().getMessageBus().connect().subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void beforeDocumentSaving(@NotNull final Document document) {
SwaggerFileService swaggerFileService = ServiceManager.getService(SwaggerFileService.class);
final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
if (openProjects.length > 0) {
final PsiFile psiFile = PsiDocumentManager.getInstance(openProjects[0]).getPsiFile(document);
if (psiFile != null && swaggerFileService.swaggerContentExistsFor(psiFile)) {
final boolean swaggerFile = fileDetector.isMainSwaggerFile(psiFile) || fileDetector.isMainOpenApiFile(psiFile);
if (swaggerFile) {
swaggerFileService.convertSwaggerToHtml(psiFile);
}
}
}
}
});
}
示例2: install
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
@Override
public void install(@NotNull StatusBar statusBar) {
Toolkit.getDefaultToolkit().addAWTEventListener(this,
AWTEvent.KEY_EVENT_MASK |
AWTEvent.MOUSE_EVENT_MASK |
AWTEvent.MOUSE_MOTION_EVENT_MASK
);
saveDocumentListener = new FileDocumentManagerAdapter() {
@Override
public void beforeAllDocumentsSaving() {
foldRunningTime();
}
@Override
public void beforeDocumentSaving(@NotNull Document document) {
foldRunningTime();
}
};
Extensions.getArea(null).getExtensionPoint(FileDocumentManagerListener.EP_NAME).registerExtension(saveDocumentListener);
synchronized (ALL_OPENED_TRACKERS_LOCK) {
ALL_OPENED_TRACKERS.add(this);
}
}
示例3: activate
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
public void activate() {
if (myConnection == null) {
myListenerDisposable = Disposer.newDisposable();
Disposer.register(myProject, myListenerDisposable);
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(myListener, myListenerDisposable);
myConnection = ApplicationManager.getApplication().getMessageBus().connect(myProject);
myConnection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void beforeAllDocumentsSaving() {
myDocumentSavingInProgress = true;
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
myDocumentSavingInProgress = false;
}
}, ModalityState.any());
}
});
}
}
示例4: JavaFileManagerImpl
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
public JavaFileManagerImpl(final PsiManagerEx manager, final ProjectRootManager projectRootManager, MessageBus bus,
final StartupManager startupManager) {
super(manager, projectRootManager, bus);
myConnection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void fileWithNoDocumentChanged(@NotNull final VirtualFile file) {
clearNonRepositoryMaps();
}
});
startupManager.registerStartupActivity(
new Runnable() {
@Override
public void run() {
initialize();
}
}
);
}
示例5: install
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
@Override
public void install(@NotNull StatusBar statusBar) {
super.install(statusBar);
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(this);
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void fileContentReloaded(@NotNull VirtualFile file, @NotNull Document document) {
update();
}
});
}
示例6: initComponent
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
public void initComponent() {
ApplicationManager.getApplication().getMessageBus().connect().subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void beforeAllDocumentsSaving() {
Map<Document, Project> documentsToWarn = getDocumentsBeingCommitted();
if (!documentsToWarn.isEmpty()) {
boolean allowSave = showAllowSaveDialog(documentsToWarn);
updateSaveability(documentsToWarn, allowSave);
}
}
});
}
示例7: install
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
public void install() {
class Listener extends FileDocumentManagerAdapter implements ProjectEx.ProjectSaved {
@Override
public void beforeDocumentSaving(@NotNull Document document) {
if (document == myConsole.getEditorDocument()) {
saveHistory();
}
}
@Override
public void saved(@NotNull Project project) {
saveHistory();
}
}
Listener listener = new Listener();
ApplicationManager.getApplication().getMessageBus().connect(myConsole).subscribe(ProjectEx.ProjectSaved.TOPIC, listener);
myConsole.getProject().getMessageBus().connect(myConsole).subscribe(AppTopics.FILE_DOCUMENT_SYNC, listener);
myConsole.getVirtualFile().putUserData(CONTROLLER_KEY, this);
Disposer.register(myConsole, new Disposable() {
@Override
public void dispose() {
myConsole.getVirtualFile().putUserData(CONTROLLER_KEY, null);
saveHistory();
}
});
if (myHelper.getModel().getHistorySize() == 0) {
loadHistory(myHelper.getId());
}
configureActions();
myLastSaveStamp = getCurrentTimeStamp();
}
示例8: PsiDocumentManagerImpl
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
public PsiDocumentManagerImpl(@NotNull final Project project,
@NotNull PsiManager psiManager,
@NotNull EditorFactory editorFactory,
@NotNull MessageBus bus,
@NonNls @NotNull final DocumentCommitThread documentCommitThread) {
super(project, psiManager, bus, documentCommitThread);
myDocumentCommitThread = documentCommitThread;
editorFactory.getEventMulticaster().addDocumentListener(this, project);
MessageBusConnection busConnection = bus.connect();
busConnection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void fileContentLoaded(@NotNull final VirtualFile virtualFile, @NotNull Document document) {
PsiFile psiFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
@Override
public PsiFile compute() {
return myProject.isDisposed() || !virtualFile.isValid() ? null : getCachedPsiFile(virtualFile);
}
});
fireDocumentCreated(document, psiFile);
}
});
busConnection.subscribe(DocumentBulkUpdateListener.TOPIC, new DocumentBulkUpdateListener.Adapter() {
@Override
public void updateFinished(@NotNull Document doc) {
documentCommitThread.queueCommit(project, doc, "Bulk update finished", ApplicationManager.getApplication().getDefaultModalityState());
}
});
}
示例9: install
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
@Override
public void install(@NotNull StatusBar statusBar) {
super.install(statusBar);
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(this);
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void fileContentReloaded(VirtualFile file, @NotNull Document document) {
update();
}
});
}
示例10: install
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
@Override
public void install(@NotNull StatusBar statusBar) {
super.install(statusBar);
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(this);
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void fileContentReloaded(@NotNull VirtualFile file, @NotNull Document document) {
update();
}
});
}
示例11: activate
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
public void activate() {
if (myConnection == null) {
myListenerDisposable = Disposer.newDisposable();
Disposer.register(myProject, myListenerDisposable);
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(myListener, myListenerDisposable);
myConnection = ApplicationManager.getApplication().getMessageBus().connect(myProject);
myConnection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void beforeAllDocumentsSaving() {
myDocumentSavingInProgress = true;
ApplicationManager.getApplication().invokeLater(() -> myDocumentSavingInProgress = false, ModalityState.any());
}
});
}
}
示例12: install
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
@Override
public void install(@Nonnull StatusBar statusBar) {
super.install(statusBar);
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(this);
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void fileContentReloaded(@Nonnull VirtualFile file, @Nonnull Document document) {
update();
}
});
}
示例13: install
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
public void install() {
class Listener extends FileDocumentManagerAdapter implements ProjectEx.ProjectSaved {
@Override
public void beforeDocumentSaving(@Nonnull Document document) {
if (document == myConsole.getEditorDocument()) {
saveHistory();
}
}
@Override
public void saved(@Nonnull Project project) {
saveHistory();
}
}
Listener listener = new Listener();
ApplicationManager.getApplication().getMessageBus().connect(myConsole).subscribe(ProjectEx.ProjectSaved.TOPIC, listener);
myConsole.getProject().getMessageBus().connect(myConsole).subscribe(AppTopics.FILE_DOCUMENT_SYNC, listener);
myConsole.getVirtualFile().putUserData(CONTROLLER_KEY, this);
Disposer.register(myConsole, new Disposable() {
@Override
public void dispose() {
myConsole.getVirtualFile().putUserData(CONTROLLER_KEY, null);
saveHistory();
}
});
if (myHelper.getModel().getHistorySize() == 0) {
loadHistory(myHelper.getId());
}
configureActions();
myLastSaveStamp = getCurrentTimeStamp();
}
示例14: PsiDocumentManagerImpl
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
public PsiDocumentManagerImpl(@Nonnull final Project project,
@Nonnull PsiManager psiManager,
@Nonnull EditorFactory editorFactory,
@Nonnull MessageBus bus,
@NonNls @Nonnull final DocumentCommitProcessor documentCommitThread) {
super(project, psiManager, bus, documentCommitThread);
myDocumentCommitThread = documentCommitThread;
editorFactory.getEventMulticaster().addDocumentListener(this, project);
MessageBusConnection connection = bus.connect();
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void fileContentLoaded(@Nonnull final VirtualFile virtualFile, @Nonnull Document document) {
PsiFile psiFile = ReadAction.compute(() -> myProject.isDisposed() || !virtualFile.isValid() ? null : getCachedPsiFile(virtualFile));
fireDocumentCreated(document, psiFile);
}
});
connection.subscribe(DocumentBulkUpdateListener.TOPIC, new DocumentBulkUpdateListener.Adapter() {
@Override
public void updateFinished(@Nonnull Document doc) {
documentCommitThread.commitAsynchronously(project, doc, "Bulk update finished", TransactionGuard.getInstance().getContextTransaction());
}
});
Disposer.register(project, () -> ((DocumentCommitThread)myDocumentCommitThread).cancelTasksOnProjectDispose(project));
}
示例15: reloadIn
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; //导入依赖的package包/类
static void reloadIn(@NotNull final VirtualFile virtualFile, @NotNull final Charset charset) {
final FileDocumentManager documentManager = FileDocumentManager.getInstance();
//Project project = ProjectLocator.getInstance().guessProjectForFile(myFile);
//if (documentManager.isFileModified(myFile)) {
// int result = Messages.showDialog(project, "File is modified. Reload file anyway?", "File is Modified", new String[]{"Reload", "Cancel"}, 0, AllIcons.General.WarningDialog);
// if (result != 0) return;
//}
if (documentManager.getCachedDocument(virtualFile) == null) {
// no need to reload document
EncodingManager.getInstance().setEncoding(virtualFile, charset);
return;
}
final Disposable disposable = Disposer.newDisposable();
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(disposable);
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void beforeFileContentReload(VirtualFile file, @NotNull Document document) {
if (!file.equals(virtualFile)) return;
Disposer.dispose(disposable); // disconnect
EncodingManager.getInstance().setEncoding(file, charset);
LoadTextUtil.setCharsetWasDetectedFromBytes(file, null);
}
});
// if file was modified, the user will be asked here
try {
EncodingProjectManagerImpl.suppressReloadDuring(new Runnable() {
@Override
public void run() {
((VirtualFileListener)documentManager).contentsChanged(
new VirtualFileEvent(null, virtualFile, virtualFile.getName(), virtualFile.getParent()));
}
});
}
finally {
Disposer.dispose(disposable);
}
}