This commit is contained in:
Vladimir Krivosheev
2016-09-05 12:31:41 +02:00
parent 75e059742e
commit 28ae441a00
3 changed files with 13 additions and 37 deletions
@@ -19,14 +19,14 @@ package com.intellij.ui;
import com.intellij.openapi.editor.markup.TextAttributes;
import java.util.ArrayList;
import java.util.List;
public class HighlightedText {
private final StringBuffer myBuffer;
private final ArrayList myHighlightedRegions;
private final StringBuilder myBuffer;
private final List<HighlightedRegion> myHighlightedRegions = new ArrayList<>();
public HighlightedText() {
myBuffer = new StringBuffer();
myHighlightedRegions = new ArrayList(3);
myBuffer = new StringBuilder();
}
public void appendText(String text, TextAttributes attributes) {
@@ -37,16 +37,11 @@ public class HighlightedText {
}
}
public void insertTextAtStart(String text, TextAttributes attributes) {
int textLength = text.length();
for (int i=0; i < myHighlightedRegions.size(); i++) {
HighlightedRegion info = (HighlightedRegion)myHighlightedRegions.get(i);
info.startOffset += textLength;
info.endOffset += textLength;
}
myBuffer.insert(0, text);
public void appendText(char[] text, TextAttributes attributes) {
int startOffset = myBuffer.length();
myBuffer.append(text);
if (attributes != null) {
myHighlightedRegions.add(new HighlightedRegion(0, textLength, attributes));
myHighlightedRegions.add(new HighlightedRegion(startOffset, myBuffer.length(), attributes));
}
}
@@ -67,10 +62,8 @@ public class HighlightedText {
public void applyToComponent(HighlightableComponent renderer) {
renderer.setText(myBuffer.toString());
for (int i=0; i < myHighlightedRegions.size(); i++) {
HighlightedRegion info = (HighlightedRegion)myHighlightedRegions.get(i);
for (HighlightedRegion info : myHighlightedRegions) {
renderer.addHighlighter(info.startOffset, info.endOffset, info.textAttributes);
}
}
}
@@ -16,20 +16,18 @@
package com.intellij.ui;
import javax.accessibility.AccessibleAction;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.markup.EffectType;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.util.NotNullProducer;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.PlatformColors;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.accessibility.AccessibleAction;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
@@ -204,7 +202,7 @@ public class HyperlinkLabel extends HighlightableComponent {
@Override
public void handleText(char[] data, int pos) {
highlightedText.appendText(new String(data), currentAttributes);
highlightedText.appendText(data, currentAttributes);
}
@Override
@@ -41,21 +41,6 @@ public class AuthenticationDialog extends DialogWrapper {
init();
}
public AuthenticationDialog(String title, String description, final String login, final String password, final boolean rememberPassword) {
super(JOptionPane.getRootFrame(), true);
setTitle(title);
MnemonicHelper.init(getContentPane());
panel = new AuthenticationPanel(description, login, password, rememberPassword);
final Window window = getWindow();
if (window instanceof JDialog) {
((JDialog) window).setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
}
init();
}
@Nullable
@Override
public JComponent getPreferredFocusedComponent() {