diff --git a/platform/platform-api/src/com/intellij/execution/process/CapturingProcessHandler.java b/platform/platform-api/src/com/intellij/execution/process/CapturingProcessHandler.java index 7e3b67142f79..dbc11b463a53 100644 --- a/platform/platform-api/src/com/intellij/execution/process/CapturingProcessHandler.java +++ b/platform/platform-api/src/com/intellij/execution/process/CapturingProcessHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -99,6 +99,7 @@ public class CapturingProcessHandler extends OSProcessHandler { * @param destroyOnTimeout whether to kill the process after timeout passes */ public ProcessOutput runProcess(int timeoutInMilliseconds, boolean destroyOnTimeout) { + // keep in sync with runProcessWithProgressIndicator if (timeoutInMilliseconds <= 0) { return runProcess(); } @@ -124,7 +125,7 @@ public class CapturingProcessHandler extends OSProcessHandler { @NotNull public ProcessOutput runProcessWithProgressIndicator(@NotNull ProgressIndicator indicator) { - return runProcessWithProgressIndicator(indicator, Integer.MAX_VALUE); + return runProcessWithProgressIndicator(indicator, -1); } @NotNull @@ -134,6 +135,11 @@ public class CapturingProcessHandler extends OSProcessHandler { @NotNull public ProcessOutput runProcessWithProgressIndicator(@NotNull ProgressIndicator indicator, int timeoutInMilliseconds, boolean destroyOnTimeout) { + // keep in sync with runProcess + if (timeoutInMilliseconds <= 0) { + timeoutInMilliseconds = Integer.MAX_VALUE; + } + final int WAIT_INTERVAL = 100; int waitingTime = 0; boolean setExitCode = true; diff --git a/platform/platform-api/src/com/intellij/ui/HighlightableComponent.java b/platform/platform-api/src/com/intellij/ui/HighlightableComponent.java index 762f6d31b96a..e20c3dc538e3 100644 --- a/platform/platform-api/src/com/intellij/ui/HighlightableComponent.java +++ b/platform/platform-api/src/com/intellij/ui/HighlightableComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -79,6 +79,8 @@ public class HighlightableComponent extends JComponent implements Accessible { public void setIcon(Icon icon) { myIcon = icon; + invalidate(); + repaint(); } public void addHighlighter(int startOffset, int endOffset, TextAttributes attributes) { diff --git a/platform/platform-api/src/com/intellij/ui/HyperlinkLabel.java b/platform/platform-api/src/com/intellij/ui/HyperlinkLabel.java index 8d29644358d4..f927ab3f9905 100644 --- a/platform/platform-api/src/com/intellij/ui/HyperlinkLabel.java +++ b/platform/platform-api/src/com/intellij/ui/HyperlinkLabel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -53,6 +53,7 @@ public class HyperlinkLabel extends HighlightableComponent { private static final Logger LOG = Logger.getInstance(HyperlinkLabel.class.getName()); + private UIUtil.FontSize myFontSize; private HighlightedText myHighlightedText; private final List myListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private boolean myUseIconAsLink; @@ -90,6 +91,10 @@ public class HyperlinkLabel extends HighlightableComponent { adjustSize(); } + public void setFontSize(@Nullable UIUtil.FontSize fontSize) { + myFontSize = fontSize; + } + public void setHyperlinkText(String text) { setHyperlinkText("", text, ""); } @@ -97,8 +102,6 @@ public class HyperlinkLabel extends HighlightableComponent { public void setHyperlinkText(String beforeLinkText, String linkText, String afterLinkText) { myUseIconAsLink = beforeLinkText.length() == 0; prepareText(beforeLinkText, linkText, afterLinkText); - revalidate(); - adjustSize(); } public void setUseIconAsLink(boolean useIconAsLink) { @@ -162,19 +165,21 @@ public class HyperlinkLabel extends HighlightableComponent { } private void prepareText(String beforeLinkText, String linkText, String afterLinkText) { - setFont(UIUtil.getLabelFont()); + applyFont(); myHighlightedText = new HighlightedText(); myHighlightedText.appendText(beforeLinkText, null); myHighlightedText.appendText(linkText, myAnchorAttributes); myHighlightedText.appendText(afterLinkText, null); myHighlightedText.applyToComponent(this); - adjustSize(); + updateOnTextChange(); } @Override public void setText(String text) { + applyFont(); myUseIconAsLink = false; super.setText(text); + updateOnTextChange(); } public void setHyperlinkTarget(@Nullable final String url) { @@ -247,9 +252,15 @@ public class HyperlinkLabel extends HighlightableComponent { LOG.error(e); } highlightedText.applyToComponent(this); + updateOnTextChange(); + } + + private void updateOnTextChange() { final JComponent parent = (JComponent)getParent(); - parent.revalidate(); - parent.repaint(); + if (parent != null) { + parent.revalidate(); + parent.repaint(); + } adjustSize(); } @@ -263,7 +274,11 @@ public class HyperlinkLabel extends HighlightableComponent { @Override public void updateUI() { super.updateUI(); - setFont(UIUtil.getLabelFont()); + applyFont(); + } + + private void applyFont() { + setFont(myFontSize == null ? UIUtil.getLabelFont() : UIUtil.getLabelFont(myFontSize)); } @Override