Arquillian refactoring
authorNikolay Mikhaylov <nikolay.mikhaylov@gmail.com>
Wed, 2 Sep 2015 11:11:30 +0000 (14:11 +0300)
committerNikolay Mikhaylov <nikolay.mikhaylov@gmail.com>
Thu, 3 Sep 2015 11:58:47 +0000 (14:58 +0300)
plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryPropertiesEditor.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibrarySupportInModuleConfigurable.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryWithDescriptionEditor.java

index 289ea84f1a1e5f8f5b4311d214eac87420987726..9067503359ebd41f2d4fc15c3fc865ca73f51e32 100644 (file)
@@ -1,6 +1,8 @@
 package org.jetbrains.idea.maven.utils.library;
 
 import com.google.common.base.Strings;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.progress.ProgressIndicator;
 import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.progress.Task;
@@ -9,6 +11,7 @@ import com.intellij.openapi.project.ProjectManager;
 import com.intellij.openapi.ui.ComboBox;
 import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Disposer;
 import com.intellij.ui.CollectionComboBoxModel;
 import com.intellij.ui.components.JBCheckBox;
 import com.intellij.util.containers.JBIterable;
@@ -67,6 +70,8 @@ public class RepositoryLibraryPropertiesEditor extends DialogWrapper {
       }
     });
     reloadVersionsAsync();
+
+    super.init();
   }
 
   private static VersionKind getVersionKind(String version) {
@@ -245,20 +250,30 @@ public class RepositoryLibraryPropertiesEditor extends DialogWrapper {
       return;
     }
 
-    SwingUtilities.invokeLater(new Runnable() {
+    ApplicationManager.getApplication().invokeLater(new Runnable() {
       @Override
       public void run() {
         initVersionsPanel();
       }
+    }, ModalityState.any(), new Condition() {
+      @Override
+      public boolean value(Object o) {
+        return Disposer.isDisposed(myDisposable);
+      }
     });
   }
 
   private void versionsFailedToLoad() {
-    SwingUtilities.invokeLater(new Runnable() {
+    ApplicationManager.getApplication().invokeLater(new Runnable() {
       @Override
       public void run() {
         setState(State.FailedToLoad);
       }
+    }, ModalityState.any(), new Condition() {
+      @Override
+      public boolean value(Object o) {
+        return Disposer.isDisposed(myDisposable);
+      }
     });
   }
 
@@ -298,11 +313,6 @@ public class RepositoryLibraryPropertiesEditor extends DialogWrapper {
     return mainPanel;
   }
 
-  @Override
-  public void init() {
-    super.init();
-  }
-
   private enum VersionKind {
     Unselected,
     Release,
index 551b10a6857ddcf3fea7c58b8d016be7a5ce4ce8..c8db44a8f26443d2ac35260904dea82d41af456b 100644 (file)
@@ -31,23 +31,17 @@ public class RepositoryLibrarySupportInModuleConfigurable extends FrameworkSuppo
   public RepositoryLibrarySupportInModuleConfigurable(@Nullable Project project, @NotNull RepositoryLibraryDescription libraryDescription) {
     this.libraryDescription = libraryDescription;
     this.project = project;
+    editor = new RepositoryLibraryPropertiesEditor(project, false, false, libraryDescription.createDefaultProperties());
   }
 
   @Nullable
   @Override
   public JComponent createComponent() {
-    if (editor == null) {
-      editor = new RepositoryLibraryPropertiesEditor(project, false, false, libraryDescription.createDefaultProperties());
-    }
     return editor.getMainPanel();
   }
 
   public boolean showEditorAndGet() {
-    if (editor == null) {
-      editor = new RepositoryLibraryPropertiesEditor(project, false, false, libraryDescription.createDefaultProperties());
-    }
     editor.setTitle(ProjectBundle.message("maven.add.library.support", libraryDescription.getDisplayName()));
-    editor.init();
     return editor.showAndGet();
   }
 
index 4eb8b7b436988c95b3f18011382ea1e65af61002..ea31507cc5cf98c7ee59d269e93ca299cff684fd 100644 (file)
@@ -18,7 +18,7 @@ public class RepositoryLibraryWithDescriptionEditor
   @Override
   protected void edit() {
     @NotNull RepositoryLibraryProperties properties = myEditorComponent.getProperties();
-    String oldVersion = properties.getVersion();
+    //String oldVersion = properties.getVersion();
     boolean wasGeneratedName =
       RepositoryLibraryType.getInstance().getDescription(properties).equals(myEditorComponent.getLibraryEditor().getName());
     RepositoryLibraryPropertiesEditor editor = new RepositoryLibraryPropertiesEditor(
@@ -26,7 +26,6 @@ public class RepositoryLibraryWithDescriptionEditor
       RepositoryUtils.libraryHasSources(myEditorComponent.getLibraryEditor()),
       RepositoryUtils.libraryHasJavaDocs(myEditorComponent.getLibraryEditor()),
       properties);
-    editor.init();
     editor.setTitle(RepositoryLibraryDescription.findDescription(properties).getDisplayName());
     if (!editor.showAndGet()) {
       return;