This is an automated email from the ASF dual-hosted git repository.

neilcsmith pushed a commit to branch delivery
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/delivery by this push:
     new bf0e82d  [NETBEANS-5301] Fixed readability of HTML code completion 
items
     new 53f76f4  Merge pull request #2719 from 
KacerCZ/netbeans-5301-fix-html-completion-colors
bf0e82d is described below

commit bf0e82d073a609d01b9b36711390708d83faa729
Author: Tomas Prochazka <ka...@razdva.cz>
AuthorDate: Fri Jan 29 17:33:43 2021 +0100

    [NETBEANS-5301] Fixed readability of HTML code completion items
    
    https://issues.apache.org/jira/browse/NETBEANS-5301
    
    - Fixes color of elements in code completion.
    - Fixes color of directories in code completion.
    - Simplifies code for completion item coloring.
---
 .../editor/api/completion/HtmlCompletionItem.java  | 64 +++++++++++-----------
 .../web/common/ui/api/FileReferenceCompletion.java |  3 +-
 2 files changed, 34 insertions(+), 33 deletions(-)

diff --git 
a/ide/html.editor/src/org/netbeans/modules/html/editor/api/completion/HtmlCompletionItem.java
 
b/ide/html.editor/src/org/netbeans/modules/html/editor/api/completion/HtmlCompletionItem.java
index eaa6f6b..e95bc23 100644
--- 
a/ide/html.editor/src/org/netbeans/modules/html/editor/api/completion/HtmlCompletionItem.java
+++ 
b/ide/html.editor/src/org/netbeans/modules/html/editor/api/completion/HtmlCompletionItem.java
@@ -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
+    }
 }
diff --git 
a/ide/web.common.ui/src/org/netbeans/modules/web/common/ui/api/FileReferenceCompletion.java
 
b/ide/web.common.ui/src/org/netbeans/modules/web/common/ui/api/FileReferenceCompletion.java
index d42e964..ba03001 100644
--- 
a/ide/web.common.ui/src/org/netbeans/modules/web/common/ui/api/FileReferenceCompletion.java
+++ 
b/ide/web.common.ui/src/org/netbeans/modules/web/common/ui/api/FileReferenceCompletion.java
@@ -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) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to