mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
modality wars
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,8 +20,6 @@ import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.diff.DiffRequest;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -271,31 +269,26 @@ public class VirtualFileDiffElement extends DiffElement<VirtualFile> {
|
||||
final FileDocumentManager manager = FileDocumentManager.getInstance();
|
||||
for (Document document : manager.getUnsavedDocuments()) {
|
||||
VirtualFile file = manager.getFile(document);
|
||||
if (file!=null && VfsUtilCore.isAncestor(virtualFile, file, false)) {
|
||||
if (file != null && VfsUtilCore.isAncestor(virtualFile, file, false)) {
|
||||
docsToSave.add(document);
|
||||
}
|
||||
}
|
||||
|
||||
if (!docsToSave.isEmpty()) {
|
||||
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AccessToken token = WriteAction.start();
|
||||
try {
|
||||
for (Document document : docsToSave) {
|
||||
manager.saveDocument(document);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
AccessToken token = WriteAction.start();
|
||||
try {
|
||||
for (Document document : docsToSave) {
|
||||
manager.saveDocument(document);
|
||||
}
|
||||
}, ModalityState.defaultModalityState());
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
}
|
||||
if (!FileWatcher.getInstance().isWatched(virtualFile)) {
|
||||
((NewVirtualFile)virtualFile).markDirtyRecursively();
|
||||
}
|
||||
virtualFile.refresh(true, true);
|
||||
}
|
||||
if (!FileWatcher.getInstance().isWatched(virtualFile)) {
|
||||
((NewVirtualFile)virtualFile).markDirtyRecursively();
|
||||
}
|
||||
virtualFile.refresh(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class DirDiffManagerImpl extends DirDiffManager {
|
||||
frame.show();
|
||||
} else {
|
||||
DirDiffDialog dirDiffDialog = new DirDiffDialog(myProject, model);
|
||||
if (myProject == null || myProject.isDefault() || isFromModalDialog(myProject)) {
|
||||
if (myProject == null || myProject.isDefault()/* || isFromModalDialog(myProject)*/) {
|
||||
dirDiffDialog.setModal(true);
|
||||
}
|
||||
setWindowListener(onWindowClose, dirDiffDialog.getOwner());
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
@@ -206,8 +206,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode
|
||||
myUpdating.set(true);
|
||||
final JBLoadingPanel loadingPanel = getLoadingPanel();
|
||||
loadingPanel.startLoading();
|
||||
|
||||
final Runnable action = new Runnable() {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
updater = new Updater(loadingPanel, 100);
|
||||
@@ -229,12 +228,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode
|
||||
applySettings();
|
||||
}
|
||||
}
|
||||
};
|
||||
if (DirDiffManagerImpl.isFromModalDialog(myProject)) {
|
||||
action.run();
|
||||
} else {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(action);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void reportException(final String htmlContent) {
|
||||
@@ -285,7 +279,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode
|
||||
clear();
|
||||
myElements.addAll(elements);
|
||||
myUpdating.set(false);
|
||||
myTable.revalidate();
|
||||
fireTableDataChanged();
|
||||
DirDiffTableModel.this.text.set("");
|
||||
if (loadingPanel.isLoading()) {
|
||||
loadingPanel.stopLoading();
|
||||
@@ -301,13 +295,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode
|
||||
if (myProject.isDefault()) {
|
||||
SwingUtilities.invokeLater(uiThread);
|
||||
} else {
|
||||
final AccessToken token = ApplicationManager.getApplication().acquireReadActionLock();
|
||||
try {
|
||||
ApplicationManagerEx.getApplicationEx().runEdtSafeAction(uiThread);
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
app.invokeLater(uiThread, ModalityState.any());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -779,7 +767,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode
|
||||
}
|
||||
catch (InterruptedException e) {//
|
||||
}
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final String s = text.get();
|
||||
@@ -787,7 +775,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode
|
||||
myLoadingPanel.setLoadingText(s);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, ModalityState.stateForComponent(myLoadingPanel));
|
||||
updater = new Updater(myLoadingPanel, mySleep);
|
||||
updater.start();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user