use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.
the class PostprocessReformattingAspect method decrementPostponedCounter.
private void decrementPostponedCounter() {
Application application = ApplicationManager.getApplication();
application.assertIsDispatchThread();
if (--getContext().myPostponedCounter == 0) {
if (application.isWriteAccessAllowed()) {
doPostponedFormatting();
} else {
application.runWriteAction(() -> doPostponedFormatting());
}
}
}
use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.
the class InstalledPackagesPanel method refreshLatestVersions.
private void refreshLatestVersions(@NotNull final PackageManagementService packageManagementService) {
final Application application = ApplicationManager.getApplication();
application.executeOnPooledThread(() -> {
if (packageManagementService == myPackageManagementService) {
try {
List<RepoPackage> packages = packageManagementService.reloadAllPackages();
final Map<String, RepoPackage> packageMap = buildNameToPackageMap(packages);
application.invokeLater(() -> {
for (int i = 0; i != myPackagesTableModel.getRowCount(); ++i) {
final InstalledPackage pyPackage = (InstalledPackage) myPackagesTableModel.getValueAt(i, 0);
final RepoPackage repoPackage = packageMap.get(pyPackage.getName());
myPackagesTableModel.setValueAt(repoPackage == null ? null : repoPackage.getLatestVersion(), i, 2);
}
myPackagesTable.setPaintBusy(false);
}, ModalityState.stateForComponent(myPackagesTable));
} catch (IOException ignored) {
myPackagesTable.setPaintBusy(false);
}
}
});
}
use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.
the class CoreCommandProcessor method executeCommand.
private void executeCommand(@Nullable Project project, @NotNull Runnable command, @Nullable String name, @Nullable Object groupId, @NotNull UndoConfirmationPolicy confirmationPolicy, boolean shouldRecordCommandForActiveDocument, @Nullable Document document) {
Application application = ApplicationManager.getApplication();
application.assertIsDispatchThread();
if (project != null && project.isDisposed()) {
CommandLog.LOG.error("Project " + project + " already disposed");
return;
}
if (CommandLog.LOG.isDebugEnabled()) {
CommandLog.LOG.debug("executeCommand: " + command + ", name = " + name + ", groupId = " + groupId);
}
if (myCurrentCommand != null) {
command.run();
return;
}
Throwable throwable = null;
try {
myCurrentCommand = new CommandDescriptor(command, project, name, groupId, confirmationPolicy, shouldRecordCommandForActiveDocument, document);
fireCommandStarted();
command.run();
} catch (Throwable th) {
throwable = th;
} finally {
finishCommand(project, myCurrentCommand, throwable);
}
}
use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.
the class DocumentImpl method beforeChangedUpdate.
private void beforeChangedUpdate(DocumentEvent event) {
Application app = ApplicationManager.getApplication();
if (app != null) {
FileDocumentManager manager = FileDocumentManager.getInstance();
VirtualFile file = manager.getFile(this);
if (file != null && !file.isValid()) {
LOG.error("File of this document has been deleted.");
}
}
assertInsideCommand();
// initialize line set to track changed lines
getLineSet();
if (!ShutDownTracker.isShutdownHookRunning()) {
DocumentListener[] listeners = getListeners();
for (int i = listeners.length - 1; i >= 0; i--) {
try {
listeners[i].beforeDocumentChange(event);
} catch (Throwable e) {
LOG.error(e);
}
}
}
myEventsHandling = true;
}
use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.
the class DocumentImpl method assertWriteAccess.
private void assertWriteAccess() {
if (myAssertThreading) {
final Application application = ApplicationManager.getApplication();
if (application != null) {
application.assertWriteAccessAllowed();
VirtualFile file = FileDocumentManager.getInstance().getFile(this);
if (file != null && file.isInLocalFileSystem()) {
((TransactionGuardImpl) TransactionGuard.getInstance()).assertWriteActionAllowed();
}
}
}
}
Aggregations