mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
diagnostics and allow bg dumb mode in AddCustomLibraryDialog (IDEA-143007)
This commit is contained in:
+19
-12
@@ -22,6 +22,7 @@ import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
@@ -88,19 +89,25 @@ public class AddCustomLibraryDialog extends DialogWrapper {
|
||||
protected void doOKAction() {
|
||||
final LibraryCompositionSettings settings = myPanel.apply();
|
||||
if (settings != null && settings.downloadFiles(myPanel.getMainPanel())) {
|
||||
if (myModifiableRootModel == null) {
|
||||
final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull final Result result) {
|
||||
addLibraries(model, settings);
|
||||
model.commit();
|
||||
DumbService.getInstance(myModule.getProject()).allowStartingDumbModeInside(DumbService.DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myModifiableRootModel == null) {
|
||||
final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull final Result result) {
|
||||
addLibraries(model, settings);
|
||||
model.commit();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
else {
|
||||
addLibraries(myModifiableRootModel, settings);
|
||||
}
|
||||
else {
|
||||
addLibraries(myModifiableRootModel, settings);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
super.doOKAction();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,10 @@ public abstract class DumbService {
|
||||
*
|
||||
* If the dialog (e.g. Project Structure) starting background dumb mode is an expected situation, the dumb mode should be started inside the runnable
|
||||
* passed to this method. This will suppress the exception and allow either modal or background indexing. Note that this will only affect the invocation time
|
||||
* modality state, so showing other dialogs from within the runnable and starting dumb mode from them would still result in an assertion failure.
|
||||
* modality state, so showing other dialogs from within the runnable and starting dumb mode from them would still result in an assertion failure.<p/>
|
||||
*
|
||||
* If this exception occurs inside invokeLater call which happens to run when a modal dialog is shown, the correct fix is supplying an explicit modality state
|
||||
* in {@link com.intellij.openapi.application.Application#invokeLater(Runnable, ModalityState)}.
|
||||
*/
|
||||
public abstract void allowStartingDumbModeInside(@NotNull DumbModePermission permission, @NotNull Runnable runnable);
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica
|
||||
ModalityState modality = ModalityState.current();
|
||||
final DumbModePermission permission = getDumbModePermission(modality);
|
||||
if (permission == null) {
|
||||
LOG.error("Dumb mode not permitted in modal envirnonment; please use DumbService.allowStartingDumbModeInside in your dialog or invokeLater(..., NON_MODAL)", trace);
|
||||
LOG.error("Dumb mode not permitted in modal environment; see DumbService.allowStartingDumbModeInside documentation. Current modality: " + modality + ", all premissions: " + myPermissions, trace);
|
||||
}
|
||||
|
||||
myProgresses.put(task, new ProgressIndicatorBase());
|
||||
|
||||
Reference in New Issue
Block a user