From dd37027f69fcd90708068d1908437013d83cd32e Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 2 Sep 2013 13:29:12 +0400 Subject: [PATCH] EA-49390 - assert: WriteCommandAction.execute --- .../typeMigration/ui/MigrationPanel.java | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java index 52f67fb3e8fe..c571e76b5a21 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -19,6 +19,7 @@ import com.intellij.CommonBundle; import com.intellij.ide.util.treeView.AbstractTreeNode; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.Result; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.diagnostic.Logger; @@ -28,7 +29,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.vfs.ReadonlyStatusHandler; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.presentation.java.SymbolPresentationUtil; @@ -193,28 +194,35 @@ public class MigrationPanel extends JPanel implements Disposable { if (userObject instanceof MigrationRootNode) { ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { public void run() { - new WriteCommandAction(myProject) { - protected void run(Result result) throws Throwable { - final Collection children = ((MigrationRootNode)userObject).getChildren(); - for (AbstractTreeNode child : children) { - expandTree((MigrationNode)child); + final Collection children = ((MigrationRootNode)userObject).getChildren(); + for (AbstractTreeNode child : children) { + expandTree((MigrationNode)child); + } + final TypeMigrationUsageInfo[] usages = myLabeler.getMigratedUsages(); + final HashSet files = new HashSet(); + for (TypeMigrationUsageInfo usage : usages) { + if (!usage.isExcluded()) { + final PsiElement element = usage.getElement(); + if (element != null) { + files.add(element.getContainingFile().getVirtualFile()); } - final TypeMigrationUsageInfo[] usages = myLabeler.getMigratedUsages(); - final HashSet files = new HashSet(); - for (TypeMigrationUsageInfo usage : usages) { - if (!usage.isExcluded()) { - final PsiElement element = usage.getElement(); - if (element != null) { - files.add(element.getContainingFile().getVirtualFile()); - } - } - } - if (ReadonlyStatusHandler.getInstance(myProject). - ensureFilesWritable(VfsUtil.toVirtualFileArray(files)).hasReadonlyFiles()) return; - - TypeMigrationProcessor.change(myLabeler, usages); } - }.execute(); + } + + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + if (ReadonlyStatusHandler.getInstance(myProject). + ensureFilesWritable(VfsUtilCore.toVirtualFileArray(files)).hasReadonlyFiles()) { + return; + } + new WriteCommandAction(myProject) { + protected void run(Result result) throws Throwable { + TypeMigrationProcessor.change(myLabeler, usages); + } + }.execute(); + } + }, myProject.getDisposed()); } }, "Type Migration", false, myProject); }