You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2020/08/12 19:51:10 UTC

[jmeter] branch master updated (53873bc -> f2e1750)

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

fschumacher pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git.


    from 53873bc  Correct possible thread wake-up problem and typo
     new 0070acb  Make use of newer Darklaf API to create laf menu items.
     new f2e1750  Update to Darklaf version 2.4.4

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 gradle.properties                                  |  2 +-
 .../jmeter/gui/action/LookAndFeelCommand.java      | 71 +++++++---------------
 xdocs/changes.xml                                  |  3 +-
 3 files changed, 26 insertions(+), 50 deletions(-)


[jmeter] 02/02: Update to Darklaf version 2.4.4

Posted by fs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git

commit f2e17500c4b297e3fb70f19d95ba4bbc4de3fd1c
Author: weisj <we...@arcor.de>
AuthorDate: Tue Aug 11 21:18:34 2020 +0200

    Update to Darklaf version 2.4.4
    
    Closes #609
---
 gradle.properties | 2 +-
 xdocs/changes.xml | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gradle.properties b/gradle.properties
index 568ca11..1ce1c6c 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -67,7 +67,7 @@ commons-math3.version=3.6.1
 commons-net.version=3.6
 commons-pool2.version=2.8.0
 commons-text.version=1.8
-darklaf.version=2.4.2
+darklaf.version=2.4.4
 dec.version=0.1.2
 dnsjava.version=2.1.9
 equalsverifier.version=3.1.13
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index 014db1c..fb3e260 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -122,11 +122,12 @@ Summary
     <li><bug>64454</bug>More precise error message, when no datasource value can be found in JDBC sampler</li>
     <li><bug>64440</bug>Log exeptions reported via <code>JMeterUtils#reportToUser</code> even when in GUI mode</li>
     <li><pr>591</pr>Remove deprecated sudo flag from travis file. Deng Liming (liming.d.pro at gmail.com)</li>
-    <li>Updated Darklaf to 2.4.2 (from 2.1.1)</li>
+    <li>Updated Darklaf to 2.4.4 (from 2.1.1)</li>
     <li>Updated Groovy to 3.0.5 (from 3.0.3)</li>
     <li><pr>596</pr>Use neutral words in documentation</li>
     <li><bug>63809</bug><pr>557</pr>Updated commons-collections to 4.4 (from 3.2.2) while keeping the jars for the old commons-collections 3.x for compatibility</li>
     <li><pr>598</pr>Add another option for creating diffs to the building page. Contributed by jmetertea (github.com/jmetertea)</li>
+    <li><pr>609</pr>Make use of newer API for darklaf installation. Jannis Weis</li>
 </ul>
 
  <!-- =================== Bug fixes =================== -->


[jmeter] 01/02: Make use of newer Darklaf API to create laf menu items.

Posted by fs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git

commit 0070acbf1635ca05ef384c8e47ec4863ae7e3bd1
Author: weisj <we...@arcor.de>
AuthorDate: Tue Aug 11 20:58:03 2020 +0200

    Make use of newer Darklaf API to create laf menu items.
---
 .../jmeter/gui/action/LookAndFeelCommand.java      | 71 +++++++---------------
 1 file changed, 23 insertions(+), 48 deletions(-)

diff --git a/src/core/src/main/java/org/apache/jmeter/gui/action/LookAndFeelCommand.java b/src/core/src/main/java/org/apache/jmeter/gui/action/LookAndFeelCommand.java
index 7b29594..5e549ac 100644
--- a/src/core/src/main/java/org/apache/jmeter/gui/action/LookAndFeelCommand.java
+++ b/src/core/src/main/java/org/apache/jmeter/gui/action/LookAndFeelCommand.java
@@ -18,7 +18,6 @@
 package org.apache.jmeter.gui.action;
 
 import java.awt.event.ActionEvent;
-import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -41,12 +40,6 @@ import org.slf4j.LoggerFactory;
 
 import com.github.weisj.darklaf.LafManager;
 import com.github.weisj.darklaf.theme.DarculaTheme;
-import com.github.weisj.darklaf.theme.HighContrastDarkTheme;
-import com.github.weisj.darklaf.theme.HighContrastLightTheme;
-import com.github.weisj.darklaf.theme.IntelliJTheme;
-import com.github.weisj.darklaf.theme.OneDarkTheme;
-import com.github.weisj.darklaf.theme.SolarizedDarkTheme;
-import com.github.weisj.darklaf.theme.SolarizedLightTheme;
 import com.github.weisj.darklaf.theme.Theme;
 
 /**
@@ -70,9 +63,9 @@ public class LookAndFeelCommand extends AbstractAction {
         final String title;
         final String command;
         final String lafClassName;
-        final Class<? extends Theme> lafTheme;
+        final Theme lafTheme;
 
-        private MenuItem(String title, String command, String lafClassName, Class<? extends Theme> lafTheme) {
+        private MenuItem(String title, String command, String lafClassName, Theme lafTheme) {
             this.title = title;
             this.command = command;
             this.lafClassName = lafClassName;
@@ -88,14 +81,14 @@ public class LookAndFeelCommand extends AbstractAction {
         }
 
         private static MenuItem of(String title, String lafClass) {
-            return new MenuItem(title,ActionNames.LAF_PREFIX + lafClass, lafClass, null);
+            return new MenuItem(title, ActionNames.LAF_PREFIX + lafClass, lafClass, null);
         }
 
-        private static MenuItem ofDarklafTheme(Class<? extends Theme> lafTheme) {
-            return new MenuItem("Darklaf - " + lafTheme.getSimpleName().replace("Theme", ""),
-                    JMeterMenuBar.DARKLAF_LAF_CLASS + ":" + lafTheme.getName(),
+        private static MenuItem ofDarklafTheme(Theme theme) {
+            return new MenuItem("Darklaf - " + theme.getName(),
+                    JMeterMenuBar.DARKLAF_LAF_CLASS + ":" + theme.getThemeClass().getName(),
                     JMeterMenuBar.DARKLAF_LAF_CLASS,
-                    lafTheme);
+                    theme);
         }
     }
 
@@ -106,21 +99,17 @@ public class LookAndFeelCommand extends AbstractAction {
         if (System.getProperty("darklaf.allowNativeCode") == null) {
             System.setProperty("darklaf.allowNativeCode", "false");
         }
-        UIManager.installLookAndFeel(JMeterMenuBar.DARKLAF_LAF, JMeterMenuBar.DARKLAF_LAF_CLASS);
+        UIManager.installLookAndFeel(JMeterMenuBar.DARCULA_LAF, JMeterMenuBar.DARCULA_LAF_CLASS);
 
         List<MenuItem> items = new ArrayList<>();
         for (UIManager.LookAndFeelInfo laf : JMeterMenuBar.getAllLAFs()) {
-            if (!laf.getClassName().equals(JMeterMenuBar.DARKLAF_LAF_CLASS)) {
+            if (!laf.getClassName().equals(JMeterMenuBar.DARCULA_LAF_CLASS)) {
                 items.add(MenuItem.of(laf.getName(), laf.getClassName()));
-                continue;
+            } else {
+                for (Theme theme : LafManager.getRegisteredThemes()) {
+                    items.add(MenuItem.ofDarklafTheme(theme));
+                }
             }
-            items.add(MenuItem.ofDarklafTheme(DarculaTheme.class));
-            items.add(MenuItem.ofDarklafTheme(IntelliJTheme.class));
-            items.add(MenuItem.ofDarklafTheme(OneDarkTheme.class));
-            items.add(MenuItem.ofDarklafTheme(SolarizedDarkTheme.class));
-            items.add(MenuItem.ofDarklafTheme(SolarizedLightTheme.class));
-            items.add(MenuItem.ofDarklafTheme(HighContrastDarkTheme.class));
-            items.add(MenuItem.ofDarklafTheme(HighContrastLightTheme.class));
         }
         items.sort(Comparator.comparing(MenuItem::getTitle));
         for (MenuItem item : items) {
@@ -184,7 +173,7 @@ public class LookAndFeelCommand extends AbstractAction {
         String jMeterLaf = getJMeterLaf();
         if (jMeterLaf.equals(JMeterMenuBar.DARCULA_LAF_CLASS)) {
             // Convert old Darcula to new Darklaf-Darcula LaF
-            return MenuItem.ofDarklafTheme(DarculaTheme.class).command;
+            return MenuItem.ofDarklafTheme(new DarculaTheme()).command;
         }
 
         return MenuItem.of("default", jMeterLaf).command; // $NON-NLS-1$
@@ -208,12 +197,7 @@ public class LookAndFeelCommand extends AbstractAction {
     public static boolean isDark() {
         String lookAndFeelID = UIManager.getLookAndFeel().getID();
         if (lookAndFeelID.equals("Darklaf")) { // $NON-NLS-1$
-            Theme lafTheme = LafManager.getTheme();
-            if (lafTheme == null) {
-                return false;
-            }
-            String name = lafTheme.getName();
-            return name.equals("darcula") || name.equals("solarized_dark"); // $NON-NLS-1$
+            return Theme.isDark(LafManager.getTheme());
         }
         return false;
     }
@@ -221,24 +205,15 @@ public class LookAndFeelCommand extends AbstractAction {
     public static void activateLookAndFeel(String command) {
         MenuItem item = items.get(command);
         String className = item.lafClassName;
-        try {
-            if (item.lafTheme != null) {
-                LafManager.setTheme(item.lafTheme.getConstructor().newInstance());
-            }
-            GuiPackage instance = GuiPackage.getInstance();
-            if (instance != null) {
-                instance.updateUIForHiddenComponents();
-            }
-            JFactory.refreshUI(className);
-            PREFS.put(USER_PREFS_KEY, item.command);
-        } catch ( InstantiationException
-                | NoSuchMethodException
-                | IllegalAccessException e) {
-            throw new IllegalArgumentException("Look and Feel unavailable:" + e.toString(), e);
-        } catch (InvocationTargetException e) {
-            Throwable c = e.getCause();
-            throw new IllegalArgumentException("Look and Feel unavailable:" + c.toString(), c);
+        if (item.lafTheme != null) {
+            LafManager.setTheme(item.lafTheme);
+        }
+        GuiPackage instance = GuiPackage.getInstance();
+        if (instance != null) {
+            instance.updateUIForHiddenComponents();
         }
+        JFactory.refreshUI(className);
+        PREFS.put(USER_PREFS_KEY, item.command);
     }
 
     @Override