mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
diff: remove duplication, extract notifications
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
+3
-3
@@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
+6
-17
@@ -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();
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
-41
@@ -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();
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -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<EditorEx> 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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user