mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
assert that refactoring dialogs are shown in transactions, and add one in the drag&drop handling
This commit is contained in:
@@ -23,6 +23,7 @@ import com.intellij.ide.dnd.TransferableWrapper;
|
||||
import com.intellij.ide.projectView.impl.nodes.DropTargetNode;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.application.TransactionGuard;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -320,7 +321,7 @@ class ProjectViewDropTarget implements DnDNativeTarget {
|
||||
if (!sourceElement.isValid()) return;
|
||||
}
|
||||
|
||||
getActionHandler().invoke(myProject, sourceElements, new DataContext() {
|
||||
DataContext context = new DataContext() {
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getData(@NonNls String dataId) {
|
||||
@@ -334,7 +335,9 @@ class ProjectViewDropTarget implements DnDNativeTarget {
|
||||
return externalDrop ? null : dataContext.getData(dataId);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
TransactionGuard.getInstance().submitTransactionAndWait(
|
||||
() -> getActionHandler().invoke(myProject, sourceElements, context));
|
||||
}
|
||||
|
||||
private RefactoringActionHandler getActionHandler() {
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.refactoring.ui;
|
||||
|
||||
import com.intellij.openapi.application.TransactionGuard;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -35,6 +37,7 @@ import java.util.List;
|
||||
* Author: msk
|
||||
*/
|
||||
public abstract class RefactoringDialog extends DialogWrapper {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.ui.RefactoringDialog");
|
||||
|
||||
private Action myRefactorAction;
|
||||
private Action myPreviewAction;
|
||||
@@ -55,6 +58,12 @@ public abstract class RefactoringDialog extends DialogWrapper {
|
||||
myCbPreviewResults = previewResults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
LOG.assertTrue(TransactionGuard.getInstance().getContextTransaction() != null, "Refactorings should be invoked inside transaction");
|
||||
super.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createDefaultActions() {
|
||||
super.createDefaultActions ();
|
||||
|
||||
Reference in New Issue
Block a user