You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2019/12/11 23:58:37 UTC

[GitHub] [netbeans] DevCharly commented on a change in pull request #1771: [NETBEANS-3428] FlatLaf: UI delegates for editor and view tabs in main window

DevCharly commented on a change in pull request #1771: [NETBEANS-3428] FlatLaf: UI delegates for editor and view tabs in main window
URL: https://github.com/apache/netbeans/pull/1771#discussion_r356898547
 
 

 ##########
 File path: platform/o.n.swing.plaf/src/org/netbeans/swing/plaf/Startup.java
 ##########
 @@ -421,29 +421,39 @@ private LFCustoms findDefaultCustoms() {
                 }
             }
         }
-        
-        StringBuffer buf = new StringBuffer(40);
-        buf.append("Nb."); //NOI18N
-        buf.append(UIManager.getLookAndFeel().getID());
-        if (UIUtils.isXPLF()) {
-            if (isWindows8() || isWindows10()) {
-                buf.append("Windows8LFCustoms"); //NOI18N
-            } else if (isWindowsVista() || isWindows7()) {
-                buf.append("VistaLFCustoms"); //NOI18N
-            } else {
-                buf.append("XPLFCustoms"); //NOI18N
-            }
-        } else {
-            buf.append("LFCustoms"); //NOI18N
-        }
-        
+
         LFCustoms result = null;
         try {
-            result = (LFCustoms)UIManager.get(buf.toString());
+            // check whether the current look and feel specifies customs in its UI defaults
+            result = (LFCustoms)UIManager.getLookAndFeelDefaults().get("Nb.LFCustoms");
         } catch (ClassCastException cce) {
             //do nothing - the look and feel happens to have something matching
             //our generated key there
         }
+
+        if (result == null) {
+            StringBuffer buf = new StringBuffer(40);
+            buf.append("Nb."); //NOI18N
+            buf.append(UIManager.getLookAndFeel().getID());
+            if (UIUtils.isXPLF()) {
+                if (isWindows8() || isWindows10()) {
+                    buf.append("Windows8LFCustoms"); //NOI18N
+                } else if (isWindowsVista() || isWindows7()) {
+                    buf.append("VistaLFCustoms"); //NOI18N
+                } else {
+                    buf.append("XPLFCustoms"); //NOI18N
+                }
+            } else {
+                buf.append("LFCustoms"); //NOI18N
 
 Review comment:
   No, "Nb.LFCustoms" key was not checked before.
   It was (and still is) "Nb.{look-and-feel-id}LFCustoms".
   
   Now "Nb.LFCustoms" is checked first, but it is read from the "Look and feel defaults", which are created by `LookAndFeel.getDefaults()`. Each LaF has its own independent "Look and feel defaults". Other existing LaFs do not set "Nb.LFCustoms", so the LAF ID is used as before.
   
   `UIManager` uses two independent sets of UI defaults: "developer defaults" and "Look and feel defaults". `UIManager.put()` writes into the "developer defaults". `UIManager.get()` reads first from the "developer defaults" and if the value does not exist there, it reads from the "Look and feel defaults". For a more detailed description see section "Defaults" in the [UIManager Javadoc](https://docs.oracle.com/javase/8/docs/api/javax/swing/UIManager.html).
   
   The problem with FlatLaf is that there are multiple themes, which all have different IDs. Well, currently only two themes are used, but maybe more in the future.
   
   An I think it is possible to put one or more of the JSON files from [here](https://github.com/JFormDesigner/FlatLaf/tree/master/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/intellijthemes) into a new NetBeans plugin, invoke `UIManager.installLookAndFeel()` from the plugin installer, and ready is a NetBeans theme plugin that can be uploaded to plugin portal.
   In this case it is good to have `FlatLFCustoms` installed, independent from the LAF ID.
   
   > What are the changes here supposed to do?
   
   New are only following lines: https://github.com/apache/netbeans/blob/d11c6bf5d20dcd79f0bb4010061391eb50004c4c/platform/o.n.swing.plaf/src/org/netbeans/swing/plaf/Startup.java#L426-L434
   
   The other differences are removed ending whitespace and indentation:
   
   ![image](https://user-images.githubusercontent.com/5604048/70670231-ca113500-1c78-11ea-97d5-b0f551b65ea8.png)
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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