Fix PY-14096 Minor Refactor output panel creation
authorValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Fri, 7 Oct 2016 11:23:13 +0000 (14:23 +0300)
committerValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Mon, 24 Oct 2016 17:09:44 +0000 (20:09 +0300)
python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/code/IpnbCodePanel.java

index 85857c98a19f59375e8b1e65fd66bb526e5e42a8..e933564146f1fc0a823cd91dc15461f4f103d292 100644 (file)
@@ -87,17 +87,16 @@ public class IpnbCodePanel extends IpnbEditablePanel<JComponent, IpnbCodeCell> {
   }
 
   public JPanel createHideableOutputPanel() {
-    OnePixelSplitter splitter = new OnePixelSplitter(true);
-    JPanel firstComponent = createToggleBar(splitter);
-    JPanel secondComponent = createOutputPanel(createHideOutputListener(splitter, firstComponent));
-
+    final OnePixelSplitter splitter = new OnePixelSplitter(true);
+    final JPanel secondComponent = createOutputPanel(splitter);
     splitter.setSecondComponent(secondComponent);
 
     return splitter;
   }
 
   @NotNull
-  private JPanel createOutputPanel(MouseAdapter hideOutputListener) {
+  private JPanel createOutputPanel(@NotNull OnePixelSplitter splitter) {
+    final MouseAdapter hideOutputListener = createHideOutputListener(splitter);
     final JPanel outputPanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, true, false));
     outputPanel.setBackground(IpnbEditorUtil.getBackground());
     for (IpnbOutputCell outputCell : myCell.getCellOutputs()) {
@@ -109,7 +108,8 @@ public class IpnbCodePanel extends IpnbEditablePanel<JComponent, IpnbCodeCell> {
   }
 
   @NotNull
-  private MouseAdapter createHideOutputListener(final OnePixelSplitter splitter, final JPanel firstComponent) {
+  private MouseAdapter createHideOutputListener(final OnePixelSplitter splitter) {
+    final JPanel toggleBar = createToggleBar(splitter);
     return new MouseAdapter() {
       @Override
       public void mouseClicked(MouseEvent e) {
@@ -120,7 +120,7 @@ public class IpnbCodePanel extends IpnbEditablePanel<JComponent, IpnbCodeCell> {
 
       private void hideOutputPanel() {
         setOutputStateInCell(true);
-        splitter.setFirstComponent(firstComponent);
+        splitter.setFirstComponent(toggleBar);
         splitter.setSecondComponent(null);
       }
     };
@@ -155,7 +155,7 @@ public class IpnbCodePanel extends IpnbEditablePanel<JComponent, IpnbCodeCell> {
         setOutputStateInCell(false);
         updateBackground(IpnbEditorUtil.getBackground());
         splitter.setFirstComponent(null);
-        splitter.setSecondComponent(createOutputPanel(createHideOutputListener(splitter, secondPanel)));
+        splitter.setSecondComponent(createOutputPanel(splitter));
       }
     };
   }