Unverified Commit 53f76f45 authored by Neil C Smith's avatar Neil C Smith Committed by GitHub
Browse files

Merge pull request #2719 from KacerCZ/netbeans-5301-fix-html-completion-colors

[NETBEANS-5301] Fixed readability of HTML code completion items
parents 818d41ab bf0e82d0
......@@ -62,7 +62,8 @@ import org.openide.xml.XMLUtil;
public class HtmlCompletionItem implements CompletionItem {
protected static final int DEFAULT_SORT_PRIORITY = 20;
private static final String END_FONT = "</font>"; // NOI18N
//----------- Factory methods --------------
public static HtmlCompletionItem createTag(HtmlTag tag, String name, int substitutionOffset, String helpId, boolean possible) {
return new Tag(tag, name, substitutionOffset, helpId, possible);
......@@ -110,7 +111,8 @@ public class HtmlCompletionItem implements CompletionItem {
public static HtmlCompletionItem createFileCompletionItem(FileObject file, int substitutionOffset) {
boolean folder = file.isFolder();
String name = new StringBuilder().append(file.getNameExt()).append(folder ? '/' : "").toString();
Color color = folder ? Color.BLUE : null;
// Should match color in o.n.m.web.common.ui.api.FileReferenceCompletion.getItems()
Color color = folder ? new Color(224, 160, 65) : null;
ImageIcon icon = FileReferenceCompletion.getIcon(file);
return new FileAttributeValue(folder, name, substitutionOffset, color, icon);
......@@ -422,7 +424,7 @@ public class HtmlCompletionItem implements CompletionItem {
= ImageUtilities.loadImageIcon("org/netbeans/modules/html/editor/resources/mathml.png", false); // NOI18N
private static final Color GRAY_COLOR = Color.GRAY;
private static final Color DEFAULT_FG_COLOR = new Color(0, 0, 0xFF);
private static final Color DEFAULT_FG_COLOR = new Color(64, 64, 217);
private boolean possible;
private HtmlTag tag;
......@@ -455,19 +457,19 @@ public class HtmlCompletionItem implements CompletionItem {
@Override
protected String getLeftHtmlText() {
Color tagColor = possible ? DEFAULT_FG_COLOR : GRAY_COLOR;
boolean isPossibleHtmlTag = possible && tag != null && tag.getTagClass() == HtmlTagType.HTML;
StringBuilder b = new StringBuilder();
if (possible) {
b.append("<font color=#");
b.append(hexColorCode(DEFAULT_FG_COLOR));
b.append(">&lt;");
b.append(getItemText());
b.append("&gt;</font>");
} else {
b.append("<font color=#");
b.append(hexColorCode(GRAY_COLOR));
b.append(">&lt;");
b.append(getItemText());
b.append("&gt;</font>");
if (isPossibleHtmlTag) {
b.append("<b>");
}
b.append(getHtmlColor(tagColor));
b.append("&lt;"); // NO18N
b.append(getItemText());
b.append("&gt;"); // NOI18N
b.append(END_FONT);
if (isPossibleHtmlTag) {
b.append("</b>");
}
return b.toString();
}
......@@ -570,7 +572,7 @@ public class HtmlCompletionItem implements CompletionItem {
@Override
protected String getLeftHtmlText() {
return (type.bold ? "<b>" : "") + //NOI18N
"<font color=#" + hexColorCode(type.color) + ">&lt;/" + getItemText() + "&gt;</font>" + //NOI18N
getHtmlColor(type.color) + "&lt;/" + getItemText() + "&gt;" + END_FONT + //NOI18N
(type.bold ? "</b>" : ""); //NOI18N
}
......@@ -634,11 +636,11 @@ public class HtmlCompletionItem implements CompletionItem {
strVal = Character.toString(value);
}
return new StringBuilder()
.append("<b><font color=#")
.append(hexColorCode(FG))
.append(">")
.append("<b>") // NOI18N
.append(getHtmlColor(FG))
.append(strVal)
.append("</font></b>").toString(); //NOI18N
.append(END_FONT)
.append("</b>").toString(); // NOI18N
}
}
......@@ -738,11 +740,9 @@ public class HtmlCompletionItem implements CompletionItem {
if (required) {
sb.append("<b>"); //NOI18N
}
sb.append("<font color=#"); //NOI18N
sb.append(hexColorCode(getAttributeColor()));
sb.append(">"); //NOI18N
sb.append(getHtmlColor(getAttributeColor()));
sb.append(getItemText());
sb.append("</font>"); //NOI18N
sb.append(END_FONT);
if (required) {
sb.append("</b>"); //NOI18N
}
......@@ -772,11 +772,9 @@ public class HtmlCompletionItem implements CompletionItem {
if (required) {
sb.append("<b>"); //NOI18N
}
sb.append("<font color=#"); //NOI18N
sb.append(hexColorCode(ATTR_NAME_COLOR));
sb.append(">"); //NOI18N
sb.append(getHtmlColor(ATTR_NAME_COLOR));
sb.append(getItemText());
sb.append("</font>"); //NOI18N
sb.append(END_FONT);
if (required) {
sb.append("</b>"); //NOI18N
}
......@@ -813,11 +811,9 @@ public class HtmlCompletionItem implements CompletionItem {
return getItemText();
} else {
StringBuilder sb = new StringBuilder();
sb.append("<font color=#"); //NOI18N
sb.append(hexColorCode(color));
sb.append(">"); //NOI18N
sb.append(getHtmlColor(color));
sb.append(getItemText());
sb.append("</font>"); //NOI18N
sb.append(END_FONT);
return sb.toString();
}
}
......@@ -895,4 +891,8 @@ public class HtmlCompletionItem implements CompletionItem {
}
return s;
}
private static String getHtmlColor(Color c) {
return "<font color=#" + hexColorCode(c) + ">"; // NOI18N
}
}
......@@ -111,7 +111,8 @@ public abstract class FileReferenceCompletion<T> implements ValueCompletion<T> {
|| fileNamePart.equals(".") // ../.| case
|| fileNamePart.equals("..")) //../..| case
) { // NOI18N
result.add(createGoUpItem(anchor, Color.BLUE, PACKAGE_ICON)); // NOI18N
// Should match color in o.n.m.html.editor.api.completion.HtmlCompletionItem.createFileCompletionItem()
result.add(createGoUpItem(anchor, new Color(224, 160, 65), PACKAGE_ICON));
}
}
} catch (FileStateInvalidException | IllegalArgumentException ex) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment