IDEA-85081 diff needs border

This commit is contained in:
Konstantin Bulenkov
2012-04-30 14:18:05 +02:00
parent 1deefef0ec
commit 2460e9c296
3 changed files with 30 additions and 8 deletions
@@ -57,9 +57,11 @@ import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.pom.Navigatable;
import com.intellij.ui.EditorNotificationPanel;
import com.intellij.ui.PopupHandler;
import com.intellij.ui.border.CustomLineBorder;
import com.intellij.util.containers.CacheOneStepIterator;
import com.intellij.util.containers.Convertor;
import com.intellij.util.diff.FilesTooBigForDiffException;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -115,8 +117,8 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
if (enableToolbar) myPanel.resetToolbar();
myOwnerWindow = owner;
myIsSyncScroll = true;
myLeftSide = new DiffSideView("", this);
myRightSide = new DiffSideView("", this);
myLeftSide = new DiffSideView("", this, new CustomLineBorder(UIUtil.getBorderColor(), 1, 0, 1, 1));
myRightSide = new DiffSideView("", this, new CustomLineBorder(UIUtil.getBorderColor(), 1, 1, 1, 0));
myLeftSide.becomeMaster();
myDiffUpdater = new Rediffers(this);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 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.
@@ -40,6 +40,7 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
@@ -51,7 +52,7 @@ public class DiffSideView {
}
private static final DiffHighlighterFactory DUMMY_HIGHLIGHTER_FACTORY = new DiffHighlighterFactoryImpl(null, null, null);
private final LabeledEditor myPanel = new LabeledEditor();
private final LabeledEditor myPanel;
private final DiffSidesContainer myContainer;
private final CurrentLineMarker myLineMarker = new CurrentLineMarker();
@@ -61,12 +62,17 @@ public class DiffSideView {
private boolean myIsMaster = false;
private String myTitle;
public DiffSideView(String title, DiffSidesContainer container) {
public DiffSideView(String title, DiffSidesContainer container, @Nullable Border editorBorder) {
myTitle = title;
myContainer = container;
myPanel = new LabeledEditor(editorBorder);
insertComponent(MOCK_COMPONENT);
}
public DiffSideView(String title, DiffSidesContainer container) {
this(title, container, null);
}
public JComponent getComponent() {
return myPanel;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 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.
@@ -16,18 +16,27 @@
package com.intellij.openapi.diff.impl.util;
import com.intellij.openapi.diff.DiffBundle;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
public class LabeledEditor extends JPanel {
private final JLabel myLabel = new JLabel();
private final Border myEditorBorder;
public LabeledEditor() {
public LabeledEditor(@Nullable Border editorBorder) {
super(new BorderLayout());
myLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));
myEditorBorder = editorBorder;
}
public LabeledEditor() {
this(null);
}
private static String addReadOnly(String title, boolean readonly) {
if (readonly) title += " " + DiffBundle.message("diff.content.read.only.content.title.suffix");
return title;
@@ -35,7 +44,12 @@ public class LabeledEditor extends JPanel {
public void setComponent(JComponent component, String title) {
removeAll();
add(component, BorderLayout.CENTER);
final JPanel p = new JPanel(new BorderLayout());
if (myEditorBorder != null) {
p.setBorder(myEditorBorder);
}
p.add(component, BorderLayout.CENTER);
add(p, BorderLayout.CENTER);
add(myLabel, BorderLayout.NORTH);
setLabelTitle(title);
revalidate();