public void focusOppositeSide() {
   if (myCurrentSide == myLeftSide) {
     myRightSide.getEditor().getContentComponent().requestFocus();
   } else {
     myLeftSide.getEditor().getContentComponent().requestFocus();
   }
 }
  public void onContentChangedIn(EditorSource source) {
    myDiffUpdater.contentRemoved(source);
    final EditorEx editor = source.getEditor();
    if (myIsHorizontal && source.getSide() == FragmentSide.SIDE1 && editor != null) {
      editor.setVerticalScrollbarOrientation(EditorEx.VERTICAL_SCROLLBAR_LEFT);
    }
    DiffSideView viewSide = getSideView(source.getSide());
    viewSide.setEditorSource(getProject(), source);
    Disposer.dispose(myScrollSupport);
    if (editor == null) {
      if (!myDisposed) {
        rediff();
      }
      return;
    }

    final MouseListener mouseListener =
        PopupHandler.installUnknownPopupHandler(
            editor.getContentComponent(),
            new MergeActionGroup(this, source.getSide()),
            ActionManager.getInstance());
    myDiffUpdater.contentAdded(source);
    editor.getSettings().setLineNumbersShown(true);
    editor.getSettings().setFoldingOutlineShown(false);
    editor.getFoldingModel().setFoldingEnabled(false);
    ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);

    Editor editor1 = getEditor(FragmentSide.SIDE1);
    Editor editor2 = getEditor(FragmentSide.SIDE2);
    if (editor1 != null && editor2 != null && myIsSyncScroll) {
      myScrollSupport.install(new EditingSides[] {this});
    }

    final VisibleAreaListener visibleAreaListener = mySplitter.getVisibleAreaListener();
    final ScrollingModel scrollingModel = editor.getScrollingModel();
    if (visibleAreaListener != null) {
      scrollingModel.addVisibleAreaListener(visibleAreaListener);
      scrollingModel.addVisibleAreaListener(myVisibleAreaListener);
    }
    myFontSizeSynchronizer.synchronize(editor);
    source.addDisposable(
        new Disposable() {
          public void dispose() {
            myFontSizeSynchronizer.stopSynchronize(editor);
          }
        });
    source.addDisposable(
        new Disposable() {
          public void dispose() {
            if (visibleAreaListener != null) {
              scrollingModel.removeVisibleAreaListener(visibleAreaListener);
              scrollingModel.removeVisibleAreaListener(myVisibleAreaListener);
            }
            editor.getContentComponent().removeMouseListener(mouseListener);
          }
        });
  }
  private void setTitles(@NotNull DiffRequest data) {
    LineSeparator sep1 = data.getContents()[0].getLineSeparator();
    LineSeparator sep2 = data.getContents()[1].getLineSeparator();

    String title1 = addReadOnly(data.getContentTitles()[0], myLeftSide.getEditor());
    String title2 = addReadOnly(data.getContentTitles()[1], myRightSide.getEditor());

    setTitle1(createComponentForTitle(title1, sep1, sep2, true));
    setTitle2(createComponentForTitle(title2, sep1, sep2, false));
  }
 private void setTitle(String title, boolean left) {
   Editor editor = left ? getEditor1() : getEditor2();
   if (editor == null) return;
   title = addReadOnly(title, editor);
   JLabel label = new JLabel(title);
   if (left) {
     myLeftSide.setTitle(label);
   } else {
     myRightSide.setTitle(label);
   }
 }
 @Nullable
 public Editor getEditor2() {
   if (myDisposed) LOG.error("Disposed");
   Editor editor = myRightSide.getEditor();
   if (editor != null) return editor;
   if (myData.getContent2() == null) LOG.error("No content 2");
   return editor;
 }
 public void setContents(DiffContent content1, DiffContent content2) {
   LOG.assertTrue(content1 != null && content2 != null);
   LOG.assertTrue(!myDisposed);
   myData.setContents(content1, content2);
   Project project = myData.getProject();
   FileType[] types = DiffUtil.chooseContentTypes(new DiffContent[] {content1, content2});
   VirtualFile beforeFile = content1.getFile();
   VirtualFile afterFile = content2.getFile();
   String path = myDiffRequest == null ? null : myDiffRequest.getWindowTitle();
   myLeftSide.setHighlighterFactory(
       createHighlighter(types[0], beforeFile, afterFile, path, project));
   myRightSide.setHighlighterFactory(
       createHighlighter(types[1], afterFile, beforeFile, path, project));
   setSplitterProportion(content1, content2);
   rediff();
   if (myIsRequestFocus) {
     myPanel.requestScrollEditors();
   }
 }
 private void setTitle2(JComponent title) {
   myRightSide.setTitle(title);
 }
 private void setTitle1(JComponent title) {
   myLeftSide.setTitle(title);
 }
 public void setCurrentSide(@NotNull DiffSideView viewSide) {
   LOG.assertTrue(viewSide != myCurrentSide);
   if (myCurrentSide != null) myCurrentSide.beSlave();
   myCurrentSide = viewSide;
 }
 @Nullable
 public JComponent getPreferredFocusedComponent() {
   return myCurrentSide.getFocusableComponent();
 }
 private int[] getFragmentBeginnings() {
   return getFragmentBeginnings(myCurrentSide.getSide());
 }
 @Nullable
 public Editor getEditor1() {
   return myLeftSide.getEditor();
 }
  public DiffPanelImpl(
      final Window owner,
      @NotNull Project project,
      boolean enableToolbar,
      boolean horizontal,
      int diffDividerPolygonsOffset,
      DiffTool parentTool) {
    myProject = project;
    myIsHorizontal = horizontal;
    myParentTool = parentTool;
    myOptions = new DiffPanelOptions(this);
    myPanel = new DiffPanelOuterComponent(TextDiffType.DIFF_TYPES, null);
    myPanel.disableToolbar(!enableToolbar);
    if (enableToolbar) myPanel.resetToolbar();
    myOwnerWindow = owner;
    myIsSyncScroll = true;
    final boolean v = !horizontal;
    myLeftSide = new DiffSideView(this, new CustomLineBorder(1, 0, v ? 0 : 1, v ? 0 : 1));
    myRightSide = new DiffSideView(this, new CustomLineBorder(v ? 0 : 1, v ? 0 : 1, 1, 0));
    myLeftSide.becomeMaster();
    myDiffUpdater = new Rediffers(this);

    myDiffDividerPolygonsOffset = diffDividerPolygonsOffset;

    myData = createDiffPanelState(this);

    if (horizontal) {
      mySplitter =
          new DiffSplitter(
              myLeftSide.getComponent(),
              myRightSide.getComponent(),
              new DiffDividerPaint(this, FragmentSide.SIDE1, diffDividerPolygonsOffset),
              myData);
    } else {
      mySplitter =
          new HorizontalDiffSplitter(myLeftSide.getComponent(), myRightSide.getComponent());
    }

    myPanel.insertDiffComponent(mySplitter.getComponent(), new MyScrollingPanel());
    myDataProvider = new MyGenericDataProvider(this);
    myPanel.setDataProvider(myDataProvider);

    ComparisonPolicy comparisonPolicy = getComparisonPolicy();
    ComparisonPolicy defaultComparisonPolicy =
        DiffManagerImpl.getInstanceEx().getComparisonPolicy();
    if (comparisonPolicy != defaultComparisonPolicy) {
      setComparisonPolicy(defaultComparisonPolicy, false);
    }

    HighlightMode highlightMode = getHighlightMode();
    HighlightMode defaultHighlightMode = DiffManagerImpl.getInstanceEx().getHighlightMode();
    if (highlightMode != defaultHighlightMode) {
      setHighlightMode(defaultHighlightMode, false);
    }

    myVisibleAreaListener =
        new VisibleAreaListener() {
          @Override
          public void visibleAreaChanged(VisibleAreaEvent e) {
            Editor editor1 = getEditor1();
            if (editor1 != null) {
              editor1.getComponent().repaint();
            }
            Editor editor2 = getEditor2();
            if (editor2 != null) {
              editor2.getComponent().repaint();
            }
          }
        };
    registerActions();
  }
 @Override
 public void navigate(boolean requestFocus) {
   showSource(mySide.getCurrentOpenFileDescriptor());
 }