jtulach commented on code in PR #9627:
URL: https://github.com/apache/netbeans/pull/9627#discussion_r4047249619


##########
ide/projectui/src/org/netbeans/modules/project/ui/ProjectsLaF.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.project.ui;
+
+import java.awt.Color;
+import javax.swing.UIManager;
+
+final class ProjectsLaF {
+    private ProjectsLaF() {
+    }
+
+    /** Computes customized, or defaulted indentation prefix for
+     * {@link ProjectsRootNode}. Reads two {@link UIManager} properties:
+     * <ul>
+     *   <li><code>nb.project.identation.char</code> - can be set to -1 to
+     *      disable indentation altogether<li>
+     *   <li><code>nb.project.indentation.color</code> - a color to use
+     *      when rendering the indentation character in HTML
+     * </ul>
+     * both values come with reasonable defaults for L&Fs that don't specify 
them.
+     *
+     * @param html should we use or avoid HTML formatting
+     * @return {@code null} when indentation is disabled, otherwise returns
+     *    a text to insert on each indentation level
+     */
+    static String indentationPrefix(boolean html) {
+        int indentChar = UIManager.getInt("nb.project.identation.char"); // 
NOI18N
+        if (indentChar < 0) {
+            // no indentation when explicitly set to negative
+            return null;
+        }
+        if (indentChar == 0) {
+            indentChar = 0xbb;
+        }
+        if (html) {
+            Color indentColor = 
UIManager.getColor("nb.project.indentation.color"); // NOI18N
+            if (indentColor == null) {
+                indentColor = Color.gray;
+            }
+            int r = indentColor.getRed();
+            int g = indentColor.getGreen();
+            int b = indentColor.getBlue();
+
+            return String.format("<font color='#%02x%02x%02x'>&#%d; </font>", 
r, g, b, indentChar); // NOI18N
+        } else {

Review Comment:
   - I didn't know about these capabilities of 
[HtmlRenderer](https://bits.netbeans.org/31/javadoc/org-openide-awt/org/openide/awt/HtmlRenderer.html).
   - Yes, I can use `<font color='!nb.project.indentation.color'>`
      - I even like it much more, because referencing `UIManager` from _"`Node` 
handling"_ code feels bad
   - But how does one define default value?
      - Without default value one needs to use `UIManager` to check for "null" 
and provide reasonable default
      - Or use well defined key (as you suggest) like `<font 
color='!controlShadow'>`
   - Shouldn't there be a way to register default values and make them 
available for `UIManager`? I'd interested in designing a system like that. But 
of course outside of scope of this PR.
   
   ### TL;DR
   
   I guess I just use `<font color='!controlShadow'>` in this PR. As that's 
your final suggestion anyway.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

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

Reply via email to