mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-144229 HTML tags in project compiler output path chooser
This commit is contained in:
@@ -242,7 +242,7 @@ public class MacFileChooserDialogImpl implements PathChooserDialog {
|
||||
|
||||
String description = chooserDescriptor.getDescription();
|
||||
if (!StringUtil.isEmpty(description)) {
|
||||
invoke(chooser, "setMessage:", Foundation.nsString(description));
|
||||
invoke(chooser, "setMessage:", Foundation.nsString(StringUtil.removeHtmlTags(description)));
|
||||
}
|
||||
|
||||
if (Foundation.isClassRespondsToSelector(nsOpenPanel, Foundation.createSelector("setCanCreateDirectories:"))) {
|
||||
|
||||
@@ -29,8 +29,12 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
import javax.swing.text.html.parser.ParserDelegator;
|
||||
import java.beans.Introspector;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -46,6 +50,27 @@ public class StringUtil extends StringUtilRt {
|
||||
@NonNls private static final Pattern EOL_SPLIT_PATTERN_WITH_EMPTY = Pattern.compile(" *(\r|\n|\r\n) *");
|
||||
@NonNls private static final Pattern EOL_SPLIT_DONT_TRIM_PATTERN = Pattern.compile("(\r|\n|\r\n)+");
|
||||
|
||||
private static class MyHtml2Text extends HTMLEditorKit.ParserCallback {
|
||||
@NotNull private final StringBuilder myBuffer = new StringBuilder();
|
||||
|
||||
public void parse(Reader in) throws IOException {
|
||||
myBuffer.setLength(0);
|
||||
new ParserDelegator().parse(in, this, Boolean.TRUE);
|
||||
}
|
||||
|
||||
public void handleText(char[] text, int pos) {
|
||||
if (myBuffer.length() > 0) myBuffer.append(SystemProperties.getLineSeparator());
|
||||
|
||||
myBuffer.append(text);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return myBuffer.toString();
|
||||
}
|
||||
};
|
||||
|
||||
private static MyHtml2Text html2TextParser = new MyHtml2Text();
|
||||
|
||||
public static final NotNullFunction<String, String> QUOTER = new NotNullFunction<String, String>() {
|
||||
@Override
|
||||
@NotNull
|
||||
@@ -2115,6 +2140,16 @@ public class StringUtil extends StringUtilRt {
|
||||
return replace(text, REPLACES_DISP, REPLACES_REFS);
|
||||
}
|
||||
|
||||
public static String removeHtmlTags (@NotNull String htmlString) {
|
||||
try {
|
||||
html2TextParser.parse(new StringReader(htmlString));
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
return html2TextParser.getText();
|
||||
}
|
||||
|
||||
@NonNls private static final String[] MN_QUOTED = {"&&", "__"};
|
||||
@NonNls private static final String[] MN_CHARS = {"&", "_"};
|
||||
|
||||
|
||||
@@ -443,9 +443,7 @@ class DetailsPanel extends JPanel implements ListSelectionListener {
|
||||
StringWriter sw = new StringWriter(p1.getOffset() - p0.getOffset());
|
||||
getEditorKit().write(sw, doc, p0.getOffset(), p1.getOffset() - p0.getOffset());
|
||||
|
||||
MyHtml2Text parser = new MyHtml2Text();
|
||||
parser.parse(new StringReader(sw.toString()));
|
||||
return parser.getText();
|
||||
return StringUtil.removeHtmlTags(sw.toString());
|
||||
}
|
||||
catch (BadLocationException e) {
|
||||
LOG.warn(e);
|
||||
@@ -456,25 +454,6 @@ class DetailsPanel extends JPanel implements ListSelectionListener {
|
||||
return super.getSelectedText();
|
||||
}
|
||||
|
||||
private static class MyHtml2Text extends HTMLEditorKit.ParserCallback {
|
||||
@NotNull private final StringBuilder myBuffer = new StringBuilder();
|
||||
|
||||
public void parse(Reader in) throws IOException {
|
||||
myBuffer.setLength(0);
|
||||
new ParserDelegator().parse(in, this, Boolean.TRUE);
|
||||
}
|
||||
|
||||
public void handleText(char[] text, int pos) {
|
||||
if (myBuffer.length() > 0) myBuffer.append(SystemProperties.getLineSeparator());
|
||||
|
||||
myBuffer.append(text);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return myBuffer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getBackground() {
|
||||
return getDetailsBackground();
|
||||
|
||||
Reference in New Issue
Block a user