vcs: Refactored "DetailsPanel" - removed unused logic, code simplified
authorKonstantin Kolosovsky <konstantin.kolosovsky@jetbrains.com>
Tue, 8 Nov 2016 14:54:36 +0000 (17:54 +0300)
committerKonstantin Kolosovsky <konstantin.kolosovsky@jetbrains.com>
Wed, 16 Nov 2016 18:01:56 +0000 (21:01 +0300)
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/AbstractRefreshablePanel.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/DetailsPanel.java

index 93192c6f897a7116def4b2cb06f89425b954088b..7eca447bc921a1c4a414eb97abb7a6f38b4a2551 100644 (file)
@@ -59,7 +59,6 @@ public abstract class AbstractRefreshablePanel<T> implements RefreshablePanel {
     myTicket = new Ticket();
     myDetailsPanel = new DetailsPanel();
     myDetailsPanel.loading();
-    myDetailsPanel.layout();
   }
 
   @CalledInAwt
@@ -77,7 +76,6 @@ public abstract class AbstractRefreshablePanel<T> implements RefreshablePanel {
       }
 
       myDetailsPanel.loading();
-      myDetailsPanel.layout();
     } else {
       refreshPresentation();
     }
@@ -93,9 +91,7 @@ public abstract class AbstractRefreshablePanel<T> implements RefreshablePanel {
   
   @CalledInAwt
   private void acceptData(final T t) {
-    final JPanel panel = dataToPresentation(t);
-    myDetailsPanel.data(panel);
-    myDetailsPanel.layout();
+    myDetailsPanel.data(dataToPresentation(t));
   }
 
   @Override
index 0c41d231298af1a507a09842b18b7eaf619b0501..e067e6012ae01ee7e7fef37876f90f6328cc0ca5 100644 (file)
  */
 package com.intellij.openapi.vcs.changes;
 
+import com.intellij.util.ui.JBUI;
 import com.intellij.vcsUtil.UIVcsUtil;
 
 import javax.swing.*;
 import java.awt.*;
 
-/**
-* Created by IntelliJ IDEA.
-* User: Irina.Chernushina
-* Date: 9/7/11
-* Time: 2:43 PM
-*/
 public class DetailsPanel {
   private CardLayout myLayout;
   private JPanel myPanel;
-  private Layer myCurrentLayer;
 
   public DetailsPanel() {
     myPanel = new JPanel();
     myLayout = new CardLayout();
     myPanel.setLayout(myLayout);
-    JPanel dataPanel = new JPanel(new BorderLayout());
-
-    myPanel.add(UIVcsUtil.errorPanel("No details available", false), Layer.notAvailable.name());
-    myPanel.add(UIVcsUtil.errorPanel("Nothing selected", false), Layer.nothingSelected.name());
-    myPanel.add(UIVcsUtil.errorPanel("Changes content is not loaded yet", false), Layer.notLoadedInitial.name());
     myPanel.add(UIVcsUtil.errorPanel("Loading...", false), Layer.loading.name());
-    myPanel.add(dataPanel, Layer.data.name());
-  }
-
-  public void nothingSelected() {
-    myCurrentLayer = Layer.nothingSelected;
-  }
-
-  public void notAvailable() {
-    myCurrentLayer = Layer.notAvailable;
+    myPanel.add(JBUI.Panels.simplePanel(), Layer.data.name());
   }
 
   public void loading() {
-    myCurrentLayer = Layer.loading;
+    myLayout.show(myPanel, Layer.loading.name());
   }
 
-  public void loadingInitial() {
-    myCurrentLayer = Layer.notLoadedInitial;
-  }
-
-  public void data(final JPanel panel) {
-    myCurrentLayer = Layer.data;
+  public void data(JPanel panel) {
     myPanel.add(panel, Layer.data.name());
+    myLayout.show(myPanel, Layer.data.name());
   }
 
-  public void layout() {
-    myLayout.show(myPanel, myCurrentLayer.name());
-  }
-
-  public void clear() {
-    myPanel.removeAll();
-  }
-
-  private static enum Layer {
-    notAvailable,
-    nothingSelected,
-    notLoadedInitial,
+  private enum Layer {
     loading,
     data,
   }