From 554eff0f418504f05a1a959e8182a232519c9596 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Sat, 11 Apr 2015 15:22:10 +0300 Subject: [PATCH] diff: remove duplication, extract notifications --- .../diff/tools/binary/BinaryDiffPanel.java | 60 ------------------- .../diff/tools/binary/BinaryDiffViewer.java | 31 +++++----- .../tools/fragmented/OnesideDiffPanel.java | 5 +- .../tools/fragmented/OnesideDiffViewer.java | 10 ++-- .../diff/tools/simple/SimpleDiffViewer.java | 8 +-- .../simple/SimpleThreesideDiffViewer.java | 6 +- .../diff/tools/util/DiffNotifications.java | 56 +++++++++++++++++ ...iffPanelBase.java => SimpleDiffPanel.java} | 23 ++----- .../diff/tools/util/base/DiffPanelBase.java | 51 +--------------- .../threeside/ThreesideTextDiffPanel.java | 41 ------------- .../threeside/ThreesideTextDiffViewer.java | 7 ++- .../util/twoside/TwosideTextDiffPanel.java | 41 ------------- .../util/twoside/TwosideTextDiffViewer.java | 7 ++- 13 files changed, 100 insertions(+), 246 deletions(-) delete mode 100644 platform/diff-impl/src/com/intellij/diff/tools/binary/BinaryDiffPanel.java create mode 100644 platform/diff-impl/src/com/intellij/diff/tools/util/DiffNotifications.java rename platform/diff-impl/src/com/intellij/diff/tools/util/{EditorsDiffPanelBase.java => SimpleDiffPanel.java} (76%) delete mode 100644 platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffPanel.java delete mode 100644 platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffPanel.java diff --git a/platform/diff-impl/src/com/intellij/diff/tools/binary/BinaryDiffPanel.java b/platform/diff-impl/src/com/intellij/diff/tools/binary/BinaryDiffPanel.java deleted file mode 100644 index b0da942bff45..000000000000 --- a/platform/diff-impl/src/com/intellij/diff/tools/binary/BinaryDiffPanel.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.diff.tools.binary; - -import com.intellij.diff.DiffContext; -import com.intellij.diff.tools.util.EditorsDiffPanelBase; -import com.intellij.diff.util.TextDiffType; -import com.intellij.openapi.actionSystem.DataProvider; -import com.intellij.openapi.fileEditor.FileEditor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; - -public class BinaryDiffPanel extends EditorsDiffPanelBase { - @NotNull protected final JPanel INSERTED_CONTENT_NOTIFICATION = - createNotification("Content added", TextDiffType.INSERTED.getColor(null)); - @NotNull protected final JPanel REMOVED_CONTENT_NOTIFICATION = - createNotification("Content removed", TextDiffType.DELETED.getColor(null)); - - @NotNull private final BinaryDiffViewer myViewer; - - public BinaryDiffPanel(@NotNull BinaryDiffViewer viewer, - @NotNull BinaryContentPanel editorsPanel, - @NotNull DataProvider dataProvider, - @NotNull DiffContext context) { - super(editorsPanel, dataProvider, context); - myViewer = viewer; - } - - @Nullable - @Override - protected JComponent getCurrentEditor() { - FileEditor editor = myViewer.getCurrentEditor(); - return editor != null ? editor.getComponent() : null; - } - - public void addInsertedContentNotification() { - myNotificationsPanel.add(INSERTED_CONTENT_NOTIFICATION); - myNotificationsPanel.revalidate(); - } - - public void addRemovedContentNotification() { - myNotificationsPanel.add(REMOVED_CONTENT_NOTIFICATION); - myNotificationsPanel.revalidate(); - } -} diff --git a/platform/diff-impl/src/com/intellij/diff/tools/binary/BinaryDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/binary/BinaryDiffViewer.java index 1bc4a78ac348..9079242200e0 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/binary/BinaryDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/binary/BinaryDiffViewer.java @@ -23,6 +23,8 @@ import com.intellij.diff.contents.EmptyContent; import com.intellij.diff.contents.FileContent; import com.intellij.diff.requests.ContentDiffRequest; import com.intellij.diff.requests.DiffRequest; +import com.intellij.diff.tools.util.DiffNotifications; +import com.intellij.diff.tools.util.SimpleDiffPanel; import com.intellij.diff.tools.util.StatusPanel; import com.intellij.diff.tools.util.base.ListenerDiffViewerBase; import com.intellij.diff.util.DiffUserDataKeys; @@ -67,7 +69,7 @@ import java.util.List; public class BinaryDiffViewer extends ListenerDiffViewerBase { public static final Logger LOG = Logger.getInstance(BinaryDiffViewer.class); - @NotNull private final BinaryDiffPanel myPanel; + @NotNull private final SimpleDiffPanel myPanel; @NotNull private final BinaryContentPanel myContentPanel; @NotNull private final MyStatusPanel myStatusPanel; @@ -105,7 +107,7 @@ public class BinaryDiffViewer extends ListenerDiffViewerBase { myContentPanel = new BinaryContentPanel(titlePanel, myEditor1, myEditor2); - myPanel = new BinaryDiffPanel(this, myContentPanel, this, context); + myPanel = new SimpleDiffPanel(myContentPanel, this, context); myStatusPanel = new MyStatusPanel(); @@ -256,7 +258,7 @@ public class BinaryDiffViewer extends ListenerDiffViewerBase { @Override public void run() { clearDiffPresentation(); - myPanel.addInsertedContentNotification(); + myPanel.addNotification(DiffNotifications.INSERTED_CONTENT); } }; } @@ -266,7 +268,7 @@ public class BinaryDiffViewer extends ListenerDiffViewerBase { @Override public void run() { clearDiffPresentation(); - myPanel.addRemovedContentNotification(); + myPanel.addNotification(DiffNotifications.REMOVED_CONTENT); } }; } @@ -286,7 +288,7 @@ public class BinaryDiffViewer extends ListenerDiffViewerBase { return new Runnable() { @Override public void run() { - myPanel.addDiffErrorNotification(); + myPanel.addNotification(DiffNotifications.ERROR); clearDiffPresentation(); } }; @@ -314,7 +316,7 @@ public class BinaryDiffViewer extends ListenerDiffViewerBase { @Override public void run() { clearDiffPresentation(); - if (equal) myPanel.addContentsEqualNotification(); + if (equal) myPanel.addNotification(DiffNotifications.EQUAL_CONTENTS); } }; } @@ -323,7 +325,7 @@ public class BinaryDiffViewer extends ListenerDiffViewerBase { @Override public void run() { clearDiffPresentation(); - myPanel.addOperationCanceledNotification(); + myPanel.addNotification(DiffNotifications.OPERATION_CANCELED); } }; } @@ -333,7 +335,7 @@ public class BinaryDiffViewer extends ListenerDiffViewerBase { @Override public void run() { clearDiffPresentation(); - myPanel.addDiffErrorNotification(); + myPanel.addNotification(DiffNotifications.ERROR); } }; } @@ -357,7 +359,7 @@ public class BinaryDiffViewer extends ListenerDiffViewerBase { @Nullable @Override public JComponent getPreferredFocusedComponent() { - return myPanel.getPreferredFocusedComponent(); + return getCurrentEditor().getPreferredFocusedComponent(); } @NotNull @@ -375,8 +377,9 @@ public class BinaryDiffViewer extends ListenerDiffViewerBase { return myEditor1; } - @Nullable + @NotNull FileEditor getCurrentEditor() { + //noinspection ConstantConditions return getCurrentSide().select(myEditor1, myEditor2); } @@ -393,13 +396,7 @@ public class BinaryDiffViewer extends ListenerDiffViewerBase { @Nullable @Override protected OpenFileDescriptor getOpenFileDescriptor() { - ContentDiffRequest request = getRequest(); - FileEditor editor = getCurrentEditor(); - if (editor == null) return null; - - DiffContent content = getCurrentSide().selectNotNull(request.getContents()); - - return content.getOpenFileDescriptor(); + return getCurrentSide().selectNotNull(getRequest().getContents()).getOpenFileDescriptor(); } public static boolean canShowRequest(@NotNull DiffContext context, @NotNull DiffRequest request) { diff --git a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffPanel.java b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffPanel.java index ed398dc7b7fd..493c4c494f97 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffPanel.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffPanel.java @@ -106,8 +106,7 @@ public class OnesideDiffPanel extends DiffPanelBase { // Misc // - @Nullable - public JComponent getPreferredFocusedComponent() { - return myCurrentCard == GOOD_CONTENT ? myEditor.getContentComponent() : null; + public boolean isGoodContent() { + return myCurrentCard == GOOD_CONTENT; } } diff --git a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java index 22c5e088349e..652904780f43 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java @@ -26,10 +26,7 @@ import com.intellij.diff.contents.DocumentContent; import com.intellij.diff.fragments.LineFragment; import com.intellij.diff.requests.ContentDiffRequest; import com.intellij.diff.requests.DiffRequest; -import com.intellij.diff.tools.util.DiffDataKeys; -import com.intellij.diff.tools.util.FoldingModelSupport; -import com.intellij.diff.tools.util.PrevNextDifferenceIterable; -import com.intellij.diff.tools.util.StatusPanel; +import com.intellij.diff.tools.util.*; import com.intellij.diff.tools.util.base.HighlightPolicy; import com.intellij.diff.tools.util.base.IgnorePolicy; import com.intellij.diff.tools.util.base.InitialScrollPositionSupport; @@ -412,7 +409,7 @@ public class OnesideDiffViewer extends TextDiffViewerBase { myFoldingModel.updateContext(myRequest, getFoldingModelSettings()); clearDiffPresentation(); - if (isEqual) myPanel.addContentsEqualNotification(); + if (isEqual) myPanel.addNotification(DiffNotifications.EQUAL_CONTENTS); TIntFunction separatorLines = myFoldingModel.getLineNumberConvertor(); myEditor.getGutterComponentEx().setLineNumberConvertor(mergeConverters(data.getLineConvertor1(), separatorLines), @@ -756,7 +753,8 @@ public class OnesideDiffViewer extends TextDiffViewerBase { @Nullable @Override public JComponent getPreferredFocusedComponent() { - return myPanel.getPreferredFocusedComponent(); + if (!myPanel.isGoodContent()) return null; + return myEditor.getComponent(); } @NotNull diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java index 47ee8af91d0b..d4f592a27333 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java @@ -250,7 +250,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { @Override public void run() { clearDiffPresentation(); - myPanel.addTooBigContentNotification(); + myPanel.addNotification(DiffNotifications.DIFF_TOO_BIG); } }; } @@ -259,7 +259,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { @Override public void run() { clearDiffPresentation(); - myPanel.addOperationCanceledNotification(); + myPanel.addNotification(DiffNotifications.OPERATION_CANCELED); } }; } @@ -269,7 +269,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { @Override public void run() { clearDiffPresentation(); - myPanel.addDiffErrorNotification(); + myPanel.addNotification(DiffNotifications.ERROR); } }; } @@ -286,7 +286,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { if (myFoldingModel != null) myFoldingModel.updateContext(myRequest, getFoldingModelSettings()); clearDiffPresentation(); - if (data.isEqualContent()) myPanel.addContentsEqualNotification(); + if (data.isEqualContent()) myPanel.addNotification(DiffNotifications.EQUAL_CONTENTS); if (data.getFragments() != null) { for (LineFragment fragment : data.getFragments()) { diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java index 740e6fcac5b0..7820a0e6dbe2 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java @@ -202,7 +202,7 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer { @Override public void run() { clearDiffPresentation(); - myPanel.addTooBigContentNotification(); + myPanel.addNotification(DiffNotifications.DIFF_TOO_BIG); } }; } @@ -211,7 +211,7 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer { @Override public void run() { clearDiffPresentation(); - myPanel.addOperationCanceledNotification(); + myPanel.addNotification(DiffNotifications.OPERATION_CANCELED); } }; } @@ -221,7 +221,7 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer { @Override public void run() { clearDiffPresentation(); - myPanel.addDiffErrorNotification(); + myPanel.addNotification(DiffNotifications.ERROR); } }; } diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/DiffNotifications.java b/platform/diff-impl/src/com/intellij/diff/tools/util/DiffNotifications.java new file mode 100644 index 000000000000..1d5f6565baea --- /dev/null +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/DiffNotifications.java @@ -0,0 +1,56 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.diff.tools.util; + +import com.intellij.diff.comparison.DiffTooBigException; +import com.intellij.diff.util.TextDiffType; +import com.intellij.openapi.diff.DiffBundle; +import com.intellij.ui.EditorNotificationPanel; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.awt.*; + +public class DiffNotifications { + @NotNull public static final JPanel INSERTED_CONTENT = + createNotification("Content added", TextDiffType.INSERTED.getColor(null)); + @NotNull public static final JPanel REMOVED_CONTENT = + createNotification("Content removed", TextDiffType.DELETED.getColor(null)); + + @NotNull public static final JPanel EQUAL_CONTENTS = + createNotification(DiffBundle.message("diff.contents.are.identical.message.text")); + @NotNull public static final JPanel ERROR = + createNotification("Can not calculate diff"); + @NotNull public static final JPanel OPERATION_CANCELED = + createNotification("Can not calculate diff. Operation canceled."); + @NotNull public static final JPanel DIFF_TOO_BIG = + createNotification("Can not calculate diff. " + DiffTooBigException.MESSAGE); + + @NotNull + public static JPanel createNotification(@NotNull String text) { + return new EditorNotificationPanel().text(text); + } + + @NotNull + public static JPanel createNotification(@NotNull String text, @NotNull final Color background) { + return new EditorNotificationPanel() { + @Override + public Color getBackground() { + return background; + } + }.text(text); + } +} diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/EditorsDiffPanelBase.java b/platform/diff-impl/src/com/intellij/diff/tools/util/SimpleDiffPanel.java similarity index 76% rename from platform/diff-impl/src/com/intellij/diff/tools/util/EditorsDiffPanelBase.java rename to platform/diff-impl/src/com/intellij/diff/tools/util/SimpleDiffPanel.java index d4cb95b84fee..fd498a4a070f 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/EditorsDiffPanelBase.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/SimpleDiffPanel.java @@ -20,20 +20,19 @@ import com.intellij.diff.tools.util.base.DiffPanelBase; import com.intellij.diff.util.DiffUtil; import com.intellij.openapi.actionSystem.DataProvider; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; -public abstract class EditorsDiffPanelBase extends DiffPanelBase { +public class SimpleDiffPanel extends DiffPanelBase { private static final String GOOD_CONTENT = "GoodContent"; private static final String ERROR_CONTENT = "ErrorContent"; @NotNull private final JComponent myEditorsPanel; - public EditorsDiffPanelBase(@NotNull JComponent editorPanel, - @NotNull DataProvider dataProvider, - @NotNull DiffContext context) { + public SimpleDiffPanel(@NotNull JComponent editorPanel, + @NotNull DataProvider dataProvider, + @NotNull DiffContext context) { super(context.getProject(), dataProvider, context); myEditorsPanel = editorPanel; @@ -63,17 +62,7 @@ public abstract class EditorsDiffPanelBase extends DiffPanelBase { // Misc // - @Nullable - public JComponent getPreferredFocusedComponent() { - if (myCurrentCard != GOOD_CONTENT) return null; - - return getCurrentEditor(); + public boolean isGoodContent() { + return myCurrentCard == GOOD_CONTENT; } - - // - // Abstract - // - - @Nullable - protected abstract JComponent getCurrentEditor(); } diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/base/DiffPanelBase.java b/platform/diff-impl/src/com/intellij/diff/tools/util/base/DiffPanelBase.java index 2c7932f522f6..faaf09f7cb71 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/base/DiffPanelBase.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/base/DiffPanelBase.java @@ -16,11 +16,8 @@ package com.intellij.diff.tools.util.base; import com.intellij.diff.DiffContext; -import com.intellij.diff.comparison.DiffTooBigException; import com.intellij.openapi.actionSystem.DataProvider; -import com.intellij.openapi.diff.DiffBundle; import com.intellij.openapi.project.Project; -import com.intellij.ui.EditorNotificationPanel; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -29,15 +26,6 @@ import javax.swing.*; import java.awt.*; public abstract class DiffPanelBase extends JPanel implements DataProvider { - @NotNull protected final JPanel CONTENTS_EQUAL_NOTIFICATION = - createNotification(DiffBundle.message("diff.contents.are.identical.message.text")); - @NotNull protected final JPanel CANT_CALCULATE_DIFF = - createNotification("Can not calculate diff"); - @NotNull protected final JPanel CONTENTS_OPERATION_CANCELED_NOTIFICATION = - createNotification("Can not calculate diff. Operation canceled."); - @NotNull protected final JPanel CONTENTS_TOO_BIG_NOTIFICATION = - createNotification("Can not calculate diff. " + DiffTooBigException.MESSAGE); - @Nullable protected final Project myProject; @NotNull private final DataProvider myDataProvider; @NotNull protected final DiffContext myContext; @@ -110,50 +98,17 @@ public abstract class DiffPanelBase extends JPanel implements DataProvider { return myDataProvider.getData(dataId); } - @Nullable - public abstract JComponent getPreferredFocusedComponent(); - // // Notifications // - public void addContentsEqualNotification() { - myNotificationsPanel.add(CONTENTS_EQUAL_NOTIFICATION); - myNotificationsPanel.revalidate(); - } - - public void addTooBigContentNotification() { - myNotificationsPanel.add(CONTENTS_TOO_BIG_NOTIFICATION); - myNotificationsPanel.revalidate(); - } - - public void addOperationCanceledNotification() { - myNotificationsPanel.add(CONTENTS_OPERATION_CANCELED_NOTIFICATION); - myNotificationsPanel.revalidate(); - } - - public void addDiffErrorNotification() { - myNotificationsPanel.add(CANT_CALCULATE_DIFF); - myNotificationsPanel.revalidate(); - } - public void resetNotifications() { myNotificationsPanel.removeAll(); myNotificationsPanel.revalidate(); } - @NotNull - public static JPanel createNotification(@NotNull String text) { - return new EditorNotificationPanel().text(text); - } - - @NotNull - public static JPanel createNotification(@NotNull String text, @NotNull final Color background) { - return new EditorNotificationPanel() { - @Override - public Color getBackground() { - return background; - } - }.text(text); + public void addNotification(@NotNull JComponent notification) { + myNotificationsPanel.add(notification); + myNotificationsPanel.revalidate(); } } diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffPanel.java b/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffPanel.java deleted file mode 100644 index 32d44d3a3a11..000000000000 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffPanel.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.diff.tools.util.threeside; - -import com.intellij.diff.DiffContext; -import com.intellij.diff.tools.util.EditorsDiffPanelBase; -import com.intellij.openapi.actionSystem.DataProvider; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; - -public class ThreesideTextDiffPanel extends EditorsDiffPanelBase { - @NotNull private final ThreesideTextDiffViewer myViewer; - - public ThreesideTextDiffPanel(@NotNull ThreesideTextDiffViewer viewer, - @NotNull ThreesideTextContentPanel editorPanel, - @NotNull DataProvider dataProvider, - @NotNull DiffContext context) { - super(editorPanel, dataProvider, context); - myViewer = viewer; - } - - @NotNull - @Override - protected JComponent getCurrentEditor() { - return myViewer.getCurrentEditor().getContentComponent(); - } -} diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffViewer.java index 20e203917eca..a1f81110d4d1 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffViewer.java @@ -24,6 +24,7 @@ import com.intellij.diff.requests.ContentDiffRequest; import com.intellij.diff.requests.DiffRequest; import com.intellij.diff.requests.SimpleDiffRequest; import com.intellij.diff.tools.util.DiffDataKeys; +import com.intellij.diff.tools.util.SimpleDiffPanel; import com.intellij.diff.tools.util.SyncScrollSupport; import com.intellij.diff.tools.util.SyncScrollSupport.ThreesideSyncScrollSupport; import com.intellij.diff.tools.util.base.InitialScrollPositionSupport; @@ -64,7 +65,7 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase { @NotNull private final EditorFactory myEditorFactory = EditorFactory.getInstance(); - @NotNull protected final ThreesideTextDiffPanel myPanel; + @NotNull protected final SimpleDiffPanel myPanel; @NotNull protected final ThreesideTextContentPanel myContentPanel; @NotNull protected final List myEditors; @@ -100,7 +101,7 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase { myContentPanel = new ThreesideTextContentPanel(myEditors, titlePanel); - myPanel = new ThreesideTextDiffPanel(this, myContentPanel, this, context); + myPanel = new SimpleDiffPanel(myContentPanel, this, context); //new MyFocusOppositePaneAction().setupAction(myPanel, this); // TODO @@ -237,7 +238,7 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase { @Nullable @Override public JComponent getPreferredFocusedComponent() { - return myPanel.getPreferredFocusedComponent(); + return getCurrentEditor().getContentComponent(); } @NotNull diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffPanel.java b/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffPanel.java deleted file mode 100644 index 2b08d6d7767c..000000000000 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffPanel.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.diff.tools.util.twoside; - -import com.intellij.diff.DiffContext; -import com.intellij.diff.tools.util.EditorsDiffPanelBase; -import com.intellij.openapi.actionSystem.DataProvider; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; - -public class TwosideTextDiffPanel extends EditorsDiffPanelBase { - @NotNull private final TwosideTextDiffViewer myViewer; - - public TwosideTextDiffPanel(@NotNull TwosideTextDiffViewer viewer, - @NotNull TwosideTextContentPanel content, - @NotNull DataProvider dataProvider, - @NotNull DiffContext context) { - super(content, dataProvider, context); - myViewer = viewer; - } - - @NotNull - @Override - protected JComponent getCurrentEditor() { - return myViewer.getCurrentEditor().getContentComponent(); - } -} diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffViewer.java index 648f86acc077..0a767ff45e5e 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffViewer.java @@ -24,6 +24,7 @@ import com.intellij.diff.contents.EmptyContent; import com.intellij.diff.requests.ContentDiffRequest; import com.intellij.diff.requests.DiffRequest; import com.intellij.diff.tools.util.DiffDataKeys; +import com.intellij.diff.tools.util.SimpleDiffPanel; import com.intellij.diff.tools.util.SyncScrollSupport; import com.intellij.diff.tools.util.SyncScrollSupport.TwosideSyncScrollSupport; import com.intellij.diff.tools.util.base.InitialScrollPositionSupport; @@ -61,7 +62,7 @@ public abstract class TwosideTextDiffViewer extends TextDiffViewerBase { @NotNull private final EditorFactory myEditorFactory = EditorFactory.getInstance(); - @NotNull protected final TwosideTextDiffPanel myPanel; + @NotNull protected final SimpleDiffPanel myPanel; @NotNull protected final TwosideTextContentPanel myContentPanel; @Nullable protected final EditorEx myEditor1; @@ -100,7 +101,7 @@ public abstract class TwosideTextDiffViewer extends TextDiffViewerBase { myContentPanel = new TwosideTextContentPanel(titlePanel, myEditor1, myEditor2); - myPanel = new TwosideTextDiffPanel(this, myContentPanel, this, context); + myPanel = new SimpleDiffPanel(myContentPanel, this, context); new MyFocusOppositePaneAction(true).setupAction(myPanel); @@ -263,7 +264,7 @@ public abstract class TwosideTextDiffViewer extends TextDiffViewerBase { @Nullable @Override public JComponent getPreferredFocusedComponent() { - return myPanel.getPreferredFocusedComponent(); + return getCurrentEditor().getContentComponent(); } @NotNull