PY-17265 Get rid of awkward singleton dialog policy
authorMikhail Golubev <mikhail.golubev@jetbrains.com>
Mon, 19 Oct 2015 12:36:51 +0000 (15:36 +0300)
committerMikhail Golubev <mikhail.golubev@jetbrains.com>
Mon, 24 Oct 2016 21:03:49 +0000 (00:03 +0300)
python/src/com/jetbrains/python/refactoring/move/PyMoveModuleMembersDelegate.java
python/src/com/jetbrains/python/refactoring/move/PyMoveModuleMembersDialog.java

index b9aa2ed1590fde6ad5ec98e5221929e7344bd604..c969e47c68bb61a44c464e2a0a38361724ef2720 100644 (file)
@@ -80,7 +80,7 @@ public class PyMoveModuleMembersDelegate extends MoveHandlerDelegate {
     if (initialPath == null) {
       initialPath = StringUtil.notNullize(PyPsiUtils.getContainingFilePath(elements[0]));
     }
-    final PyMoveModuleMembersDialog dialog = PyMoveModuleMembersDialog.getInstance(project, initialElements, initialPath, initialPath);
+    final PyMoveModuleMembersDialog dialog = new PyMoveModuleMembersDialog(project, initialElements, initialPath, initialPath);
     if (!dialog.showAndGet()) {
       return;
     }
index 4e19705a4c29e7ce788fba7f3aa15c9b07492b57..cdba75637cc3eb408f54ff92f785e798585d5f77 100644 (file)
@@ -36,7 +36,6 @@ import com.jetbrains.python.psi.impl.PyPsiUtils;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.annotations.TestOnly;
 
 import javax.swing.*;
 import javax.swing.event.TableModelEvent;
@@ -52,51 +51,20 @@ import java.util.List;
 public class PyMoveModuleMembersDialog extends PyBaseMoveDialog {
   @NonNls private final static String BULK_MOVE_TABLE_VISIBLE = "python.move.module.members.dialog.show.table";
 
-  /**
-   * Instance to be injected to mimic this class in tests
-   */
-  private static PyMoveModuleMembersDialog ourInstanceToReplace = null;
-
   private final TopLevelSymbolsSelectionTable myMemberSelectionTable;
   private final PyModuleMemberInfoModel myModuleMemberModel;
   private final boolean mySeveralElementsSelected;
 
-  /**
-   * Either creates new dialog or return singleton instance initialized with {@link #setInstanceToReplace)}.
-   * Singleton dialog is intended to be used in tests.
-   *
-   * @param project dialog project
-   * @param elements elements to move
-   * @param source
-   *@param destination destination where elements have to be moved  @return dialog
-   */
-  public static PyMoveModuleMembersDialog getInstance(@NotNull Project project,
-                                                      @NotNull List<PsiNamedElement> elements,
-                                                      @NotNull String source, 
-                                                      @NotNull String destination) {
-    return ourInstanceToReplace != null ? ourInstanceToReplace : new PyMoveModuleMembersDialog(project, elements, source, destination);
-  }
-
-  /**
-   * Injects instance to be used in tests
-   *
-   * @param instanceToReplace instance to be used in tests
-   */
-  @TestOnly
-  public static void setInstanceToReplace(@NotNull final PyMoveModuleMembersDialog instanceToReplace) {
-    ourInstanceToReplace = instanceToReplace;
-  }
-
   /**
    * @param project dialog project
    * @param elements elements to move
    * @param source
    * @param destination destination where elements have to be moved
    */
-  protected PyMoveModuleMembersDialog(@NotNull Project project,
-                                      @NotNull List<PsiNamedElement> elements,
-                                      @NotNull String source, 
-                                      @NotNull String destination) {
+  public PyMoveModuleMembersDialog(@NotNull Project project,
+                                   @NotNull List<PsiNamedElement> elements,
+                                   @NotNull String source,
+                                   @NotNull String destination) {
     super(project, source, destination);
 
     assert !elements.isEmpty();