make DumbModePermission a top-level class, more readable assertion
authorpeter <peter@jetbrains.com>
Sat, 25 Jul 2015 10:32:18 +0000 (12:32 +0200)
committerpeter <peter@jetbrains.com>
Sat, 25 Jul 2015 10:42:07 +0000 (12:42 +0200)
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectConfigurable.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/AddCustomLibraryDialog.java
platform/core-api/src/com/intellij/openapi/project/DumbModePermission.java [new file with mode: 0644]
platform/core-api/src/com/intellij/openapi/project/DumbService.java
platform/core-impl/src/com/intellij/mock/MockDumbService.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/ExternalProjectDataSelectorDialog.java
platform/lang-impl/src/com/intellij/ide/util/DeleteHandler.java
platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java

index b6c53f1ca769fb48d92eb959b2bd9822af79a102..bbf5151c977ce2541f6b07860a1cae75b7f0ca6a 100644 (file)
@@ -25,6 +25,7 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor;
 import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
 import com.intellij.openapi.fileChooser.FileChooserFactory;
 import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.project.DumbModePermission;
 import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectBundle;
@@ -225,7 +226,7 @@ public class ProjectConfigurable extends ProjectStructureElementConfigurable<Pro
       throw new ConfigurationException("Please, specify project name!");
     }
 
-    DumbService.getInstance(myProject).allowStartingDumbModeInside(DumbService.DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
+    DumbService.getInstance(myProject).allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
       public void run() {
         ApplicationManager.getApplication().runWriteAction(new Runnable() {
           @Override
index b8cea4eff2c7998b3fb3a5696a5ccff95914f00e..87b3e3fae273c436e4b310390832ee46515cfe2b 100644 (file)
@@ -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.DumbModePermission;
 import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.roots.ModifiableRootModel;
 import com.intellij.openapi.roots.ModuleRootManager;
@@ -89,7 +90,7 @@ public class AddCustomLibraryDialog extends DialogWrapper {
   protected void doOKAction() {
     final LibraryCompositionSettings settings = myPanel.apply();
     if (settings != null && settings.downloadFiles(myPanel.getMainPanel())) {
-      DumbService.getInstance(myModule.getProject()).allowStartingDumbModeInside(DumbService.DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
+      DumbService.getInstance(myModule.getProject()).allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
         @Override
         public void run() {
           if (myModifiableRootModel == null) {
diff --git a/platform/core-api/src/com/intellij/openapi/project/DumbModePermission.java b/platform/core-api/src/com/intellij/openapi/project/DumbModePermission.java
new file mode 100644 (file)
index 0000000..54aa5a0
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2000-2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.project;
+
+/**
+ * Permits the dumb mode to start at a specific moment, either modally or in background.
+ * @see DumbService#allowStartingDumbModeInside(DumbModePermission, Runnable)
+ */
+public enum DumbModePermission {
+  MAY_START_MODAL,
+  MAY_START_BACKGROUND
+}
index 826f09b7eee39024f1d200e4d85470f58316a4c2..4a6ee694c2cad35737c00235a296f11504d923af 100644 (file)
@@ -279,15 +279,6 @@ public abstract class DumbService {
    */
   public abstract void allowStartingDumbModeInside(@NotNull DumbModePermission permission, @NotNull Runnable runnable);
 
-  /**
-   * Permits the dumb mode to start at a specific moment, either modally or in background.
-   * @see #allowStartingDumbModeInside(DumbModePermission, Runnable)
-   */
-  public enum DumbModePermission {
-    MAY_START_MODAL,
-    MAY_START_BACKGROUND
-  }
-
 
   /**
    * @see #DUMB_MODE
index 12a1afa24b34e99e728c7c6e3b1588493454528f..eef23109b6e9b6d978eadfca5100c2f4432e8553 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.mock;
 import com.intellij.openapi.Disposable;
 import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.progress.EmptyProgressIndicator;
+import com.intellij.openapi.project.DumbModePermission;
 import com.intellij.openapi.project.DumbModeTask;
 import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
index 66a06c0976cc312595f5f2a776cfca4e41d25b48..8f51b03692919df3f1a9cc491a712347da500151 100644 (file)
@@ -33,6 +33,7 @@ import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataMan
 import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange;
 import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
 import com.intellij.openapi.externalSystem.util.ExternalSystemUiUtil;
+import com.intellij.openapi.project.DumbModePermission;
 import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
@@ -216,7 +217,7 @@ public class ExternalProjectDataSelectorDialog extends DialogWrapper {
           @Override
           public void execute() {
             DumbService.getInstance(myProject).allowStartingDumbModeInside(
-              DumbService.DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
+              DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
                 public void run() {
                   ProjectRootManagerEx.getInstanceEx(myProject).mergeRootsChangesDuring(new Runnable() {
                     @Override
index d2f0deb88604b9c653c1972b404ad58ceb8f1680..f93c7a1e10f9ed7222f6e64fa653755c0dc9dc0c 100644 (file)
@@ -29,6 +29,7 @@ import com.intellij.openapi.application.ApplicationBundle;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.ApplicationNamesInfo;
 import com.intellij.openapi.command.CommandProcessor;
+import com.intellij.openapi.project.DumbModePermission;
 import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.DialogWrapper;
@@ -138,7 +139,7 @@ public class DeleteHandler {
             }
           }, elements, dialog.isSearchInComments(), dialog.isSearchForTextOccurences(), true);
 
-          DumbService.getInstance(project).allowStartingDumbModeInside(DumbService.DumbModePermission.MAY_START_BACKGROUND, processor);
+          DumbService.getInstance(project).allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, processor);
         }
       }) {
         @Override
index c4b82fa5ee0e4d81b0ca2974bb00eebbb7d6cafc..5b3c47efe103020f326b22c50bfe1e4cd6fd716e 100644 (file)
@@ -202,7 +202,9 @@ 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 environment; see DumbService.allowStartingDumbModeInside documentation. Current modality: " + modality + ", all premissions: " + myPermissions, trace);
+          LOG.error("Dumb mode not permitted in modal environment; see DumbService.allowStartingDumbModeInside documentation." +
+                    "\n Current modality: " + modality +
+                    "\n all permissions: " + myPermissions, trace);
         }
 
         myProgresses.put(task, new ProgressIndicatorBase());