Merge remote-tracking branch 'origin/master'

This commit is contained in:
Pavel Dolgov
2016-02-12 17:03:03 +03:00
7 changed files with 80 additions and 30 deletions
+1
View File
@@ -122,5 +122,6 @@
<orderEntry type="module" module-name="android-jps-plugin" scope="TEST" />
<orderEntry type="module" module-name="script-debugger-ui" scope="TEST" />
<orderEntry type="module" module-name="remote-servers-git-java" />
<orderEntry type="module" module-name="terminal" />
</component>
</module>
@@ -17,7 +17,7 @@ package com.intellij.diff.chains;
public class DiffRequestProducerException extends Exception {
public DiffRequestProducerException(Throwable cause) {
super(cause);
super(cause.getMessage(), cause);
}
public DiffRequestProducerException(String message, Throwable cause) {
@@ -17,7 +17,6 @@ package com.intellij.diff.requests;
import com.intellij.diff.DiffContext;
import com.intellij.diff.DiffContextEx;
import com.intellij.diff.util.DiffUtil;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.fileTypes.UnknownFileType;
@@ -28,11 +27,14 @@ import com.intellij.openapi.vcs.changes.issueLinks.LinkMouseListenerBase;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.SimpleColoredComponent;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.util.ui.GridBag;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
public class UnknownFileTypeDiffRequest extends ComponentDiffRequest {
@Nullable private final String myFileName;
@@ -52,6 +54,7 @@ public class UnknownFileTypeDiffRequest extends ComponentDiffRequest {
@Override
public JComponent getComponent(@NotNull final DiffContext context) {
final SimpleColoredComponent label = new SimpleColoredComponent();
label.setTextAlign(SwingConstants.CENTER);
label.append("Can't show diff for unknown file type. ",
new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, UIUtil.getInactiveTextColor()));
if (myFileName != null) {
@@ -69,7 +72,7 @@ public class UnknownFileTypeDiffRequest extends ComponentDiffRequest {
});
LinkMouseListenerBase.installSingleTagOn(label);
}
return DiffUtil.createMessagePanel(label);
return JBUI.Panels.simplePanel(label).withBorder(JBUI.Borders.empty(5));
}
@Nullable
@@ -84,7 +84,7 @@ import com.intellij.util.DocumentUtil;
import com.intellij.util.Function;
import com.intellij.util.LineSeparator;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.GridBag;
import com.intellij.util.ui.JBInsets;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.*;
@@ -284,24 +284,21 @@ public class DiffUtil {
@NotNull
public static JPanel createMessagePanel(@NotNull String message) {
Pair<JPanel, JLabel> pair = createMessagePanel();
pair.getSecond().setText(message);
return pair.getFirst();
}
@NotNull
public static Pair<JPanel, JLabel> createMessagePanel() {
JLabel label = new JLabel();
String text = StringUtil.replace(message, "\n", "<br>");
JLabel label = new JBLabel(text) {
@Override
public Dimension getMinimumSize() {
Dimension size = super.getMinimumSize();
size.width = Math.min(size.width, 200);
size.height = Math.min(size.height, 100);
return size;
}
}.setCopyable(true);
label.setForeground(UIUtil.getInactiveTextColor());
JPanel wrapper = createMessagePanel(label);
return Pair.create(wrapper, label);
}
@NotNull
public static JPanel createMessagePanel(@NotNull JComponent comp) {
JPanel wrapper = new JPanel(new GridBagLayout());
wrapper.add(comp, new GridBag().insets(JBUI.insets(1)));
return wrapper;
JPanel panel = new CenteredPanel(label);
panel.setBorder(JBUI.Borders.empty(5));
return panel;
}
public static void addActionBlock(@NotNull DefaultActionGroup group, AnAction... actions) {
@@ -1289,4 +1286,49 @@ public class DiffUtil {
return height;
}
}
private static class CenteredPanel extends JPanel {
private final JComponent myComponent;
public CenteredPanel(@NotNull JComponent component) {
myComponent = component;
add(component);
}
@Override
public void doLayout() {
final Dimension size = getSize();
final Dimension preferredSize = myComponent.getPreferredSize();
Insets insets = getInsets();
JBInsets.removeFrom(size, insets);
int width = Math.min(size.width, preferredSize.width);
int height = Math.min(size.height, preferredSize.height);
int x = Math.max(0, (size.width - preferredSize.width) / 2);
int y = Math.max(0, (size.height - preferredSize.height) / 2);
myComponent.setBounds(insets.left + x, insets.top + y, width, height);
}
@Override
public Dimension getPreferredSize() {
return addInsets(myComponent.getPreferredSize());
}
@Override
public Dimension getMinimumSize() {
return addInsets(myComponent.getMinimumSize());
}
@Override
public Dimension getMaximumSize() {
return addInsets(myComponent.getMaximumSize());
}
private Dimension addInsets(Dimension dimension) {
JBInsets.addTo(dimension, getInsets());
return dimension;
}
}
}
@@ -17,7 +17,6 @@ package com.intellij.ide.navigationToolbar.ui;
import com.intellij.ide.navigationToolbar.NavBarItem;
import com.intellij.ide.navigationToolbar.NavBarPanel;
import com.intellij.ide.navigationToolbar.NavBarRootPaneExtension;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.ui.ColorUtil;
@@ -290,15 +289,15 @@ public abstract class AbstractNavBarUI implements NavBarUI {
@Override
public Insets getWrapperPanelInsets(Insets insets) {
//final JBInsets result = JBUI.insets(insets);
//if (shouldPaintWrapperPanel()) {
// result.top += JBUI.scale(1);
//}
return insets;
final JBInsets result = JBUI.insets(insets);
if (shouldPaintWrapperPanel()) {
result.top += JBUI.scale(1);
}
return result;
}
private static boolean shouldPaintWrapperPanel() {
return !UISettings.getInstance().SHOW_MAIN_TOOLBAR && NavBarRootPaneExtension.runToolbarExists();
return false; //return !UISettings.getInstance().SHOW_MAIN_TOOLBAR && NavBarRootPaneExtension.runToolbarExists();
}
protected Color getBackgroundColor() {
@@ -30,6 +30,7 @@ import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.help.HelpManager;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.util.PopupUtil;
import com.intellij.openapi.util.*;
@@ -710,7 +711,7 @@ public abstract class DialogWrapper {
final char mnemonic = (char)eachInfo.getMnemonic();
JRootPane rootPane = getPeer().getRootPane();
if (rootPane != null) {
new AnAction() {
new DumbAwareAction() {
@Override
public void actionPerformed(AnActionEvent e) {
final JBOptionButton buttonToActivate = eachInfo.getButton();
@@ -1250,7 +1251,7 @@ public abstract class DialogWrapper {
myPeer.setContentPane(root);
final CustomShortcutSet sc = new CustomShortcutSet(SHOW_OPTION_KEYSTROKE);
final AnAction toggleShowOptions = new AnAction() {
final AnAction toggleShowOptions = new DumbAwareAction() {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
expandNextOptionButton();
@@ -1306,7 +1307,7 @@ public abstract class DialogWrapper {
}
private static void installEnterHook(JComponent root, Disposable disposable) {
new AnAction() {
new DumbAwareAction() {
@Override
public void actionPerformed(AnActionEvent e) {
final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
@@ -156,6 +156,10 @@ public class LineStatusTracker {
for (final Range range : myRanges) {
createHighlighter(range);
}
if (myRanges.isEmpty()) {
markFileUnchanged();
}
}
catch (FilesTooBigForDiffException e) {
installAnathema();