From d26eb2674f66bc700cea7ab5be80909e1890994a Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Tue, 25 Feb 2025 15:50:30 +0100 Subject: [PATCH] Demo/Testing: use IntelliJ Theme Laf classes (from package `com.formdev.flatlaf.intellijthemes`) in Demo and Testing apps instead of directly loading `.theme.json` (preparation for #824) --- .../com/formdev/flatlaf/demo/DemoPrefs.java | 44 ++---- .../demo/intellijthemes/IJThemesManager.java | 3 +- .../demo/intellijthemes/IJThemesPanel.java | 140 +++++++----------- .../demo/intellijthemes/IJThemesPanel.jfd | 10 +- .../formdev/flatlaf/demo/icons/download.svg | 7 - .../com/formdev/flatlaf/demo/icons/plugin.svg | 4 + .../flatlaf/demo/icons/plugin_dark.svg | 4 + .../flatlaf/demo/intellijthemes/themes.json | 48 ++++++ .../flatlaf/testing/FlatTestFrame.java | 2 +- 9 files changed, 133 insertions(+), 129 deletions(-) delete mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/download.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/plugin.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/plugin_dark.svg diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoPrefs.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoPrefs.java index 4af1d1ec..3bbd0ccf 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoPrefs.java +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoPrefs.java @@ -28,7 +28,6 @@ import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.FlatLightLaf; import com.formdev.flatlaf.FlatPropertiesLaf; import com.formdev.flatlaf.IntelliJTheme; -import com.formdev.flatlaf.demo.intellijthemes.IJThemesPanel; import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.StringUtils; import com.formdev.flatlaf.util.SystemInfo; @@ -38,15 +37,10 @@ import com.formdev.flatlaf.util.SystemInfo; */ public class DemoPrefs { - public static final String KEY_LAF = "laf"; - public static final String KEY_LAF_THEME = "lafTheme"; + public static final String KEY_LAF_CLASS_NAME = "lafClassName"; + public static final String KEY_LAF_THEME_FILE = "lafThemeFile"; public static final String KEY_SYSTEM_SCALE_FACTOR = "systemScaleFactor"; - public static final String RESOURCE_PREFIX = "res:"; - public static final String FILE_PREFIX = "file:"; - - public static final String THEME_UI_KEY = "__FlatLaf.demo.theme"; - private static Preferences state; public static Preferences getState() { @@ -63,29 +57,21 @@ public class DemoPrefs if( args.length > 0 ) UIManager.setLookAndFeel( args[0] ); else { - String lafClassName = state.get( KEY_LAF, FlatLightLaf.class.getName() ); - if( IntelliJTheme.ThemeLaf.class.getName().equals( lafClassName ) ) { - String theme = state.get( KEY_LAF_THEME, "" ); - if( theme.startsWith( RESOURCE_PREFIX ) ) - IntelliJTheme.setup( IJThemesPanel.class.getResourceAsStream( IJThemesPanel.THEMES_PACKAGE + theme.substring( RESOURCE_PREFIX.length() ) ) ); - else if( theme.startsWith( FILE_PREFIX ) ) - FlatLaf.setup( IntelliJTheme.createLaf( new FileInputStream( theme.substring( FILE_PREFIX.length() ) ) ) ); - else - FlatLightLaf.setup(); + String lafClassName = state.get( KEY_LAF_CLASS_NAME, FlatLightLaf.class.getName() ); + if( FlatPropertiesLaf.class.getName().equals( lafClassName ) || + IntelliJTheme.ThemeLaf.class.getName().equals( lafClassName ) ) + { + String themeFileName = state.get( KEY_LAF_THEME_FILE, "" ); + if( !themeFileName.isEmpty() ) { + File themeFile = new File( themeFileName ); - if( !theme.isEmpty() ) - UIManager.getLookAndFeelDefaults().put( THEME_UI_KEY, theme ); - } else if( FlatPropertiesLaf.class.getName().equals( lafClassName ) ) { - String theme = state.get( KEY_LAF_THEME, "" ); - if( theme.startsWith( FILE_PREFIX ) ) { - File themeFile = new File( theme.substring( FILE_PREFIX.length() ) ); - String themeName = StringUtils.removeTrailing( themeFile.getName(), ".properties" ); - FlatLaf.setup( new FlatPropertiesLaf( themeName, themeFile ) ); + if( themeFileName.endsWith( ".properties" ) ) { + String themeName = StringUtils.removeTrailing( themeFile.getName(), ".properties" ); + FlatLaf.setup( new FlatPropertiesLaf( themeName, themeFile ) ); + } else + FlatLaf.setup( IntelliJTheme.createLaf( new FileInputStream( themeFile ) ) ); } else FlatLightLaf.setup(); - - if( !theme.isEmpty() ) - UIManager.getLookAndFeelDefaults().put( THEME_UI_KEY, theme ); } else UIManager.setLookAndFeel( lafClassName ); } @@ -99,7 +85,7 @@ public class DemoPrefs // remember active look and feel UIManager.addPropertyChangeListener( e -> { if( "lookAndFeel".equals( e.getPropertyName() ) ) - state.put( KEY_LAF, UIManager.getLookAndFeel().getClass().getName() ); + state.put( KEY_LAF_CLASS_NAME, UIManager.getLookAndFeel().getClass().getName() ); } ); } diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/intellijthemes/IJThemesManager.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/intellijthemes/IJThemesManager.java index 90194dbb..97a60876 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/intellijthemes/IJThemesManager.java +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/intellijthemes/IJThemesManager.java @@ -58,6 +58,7 @@ class IJThemesManager String name = value.get( "name" ); boolean discontinued = Boolean.parseBoolean( value.get( "discontinued" ) ); boolean dark = Boolean.parseBoolean( value.get( "dark" ) ); + String lafClassName = value.get( "lafClassName" ); String license = value.get( "license" ); String licenseFile = value.get( "licenseFile" ); String pluginUrl = value.get( "pluginUrl" ); @@ -65,7 +66,7 @@ class IJThemesManager String sourceCodePath = value.get( "sourceCodePath" ); bundledThemes.add( new IJThemeInfo( name, resourceName, discontinued, dark, - license, licenseFile, pluginUrl, sourceCodeUrl, sourceCodePath, null, null ) ); + license, licenseFile, pluginUrl, sourceCodeUrl, sourceCodePath, null, lafClassName ) ); } } diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/intellijthemes/IJThemesPanel.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/intellijthemes/IJThemesPanel.java index 3b452434..5c8d716c 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/intellijthemes/IJThemesPanel.java +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/intellijthemes/IJThemesPanel.java @@ -33,8 +33,6 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.nio.file.Files; -import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; @@ -59,7 +57,6 @@ import com.formdev.flatlaf.extras.FlatSVGIcon; import com.formdev.flatlaf.themes.*; import com.formdev.flatlaf.ui.FlatListUI; import com.formdev.flatlaf.util.LoggingFacade; -import com.formdev.flatlaf.util.StringUtils; import net.miginfocom.swing.*; /** @@ -82,14 +79,13 @@ public class IJThemesPanel }; private Window window; - private File lastDirectory; private boolean isAdjustingThemesList; private long lastLafChangeTime = System.currentTimeMillis(); public IJThemesPanel() { initComponents(); - saveButton.setEnabled( false ); + pluginButton.setEnabled( false ); sourceCodeButton.setEnabled( false ); // create renderer @@ -144,7 +140,7 @@ public class IJThemesPanel private String buildToolTip( IJThemeInfo ti ) { if( ti.themeFile != null ) return ti.themeFile.getPath(); - if( ti.resourceName == null ) + if( ti.license == null ) return ti.name; return "Name: " + ti.name @@ -238,7 +234,6 @@ public class IJThemesPanel for( int i = 0; i < themes.size(); i++ ) { IJThemeInfo theme = themes.get( i ); if( oldSel.name.equals( theme.name ) && - Objects.equals( oldSel.resourceName, theme.resourceName ) && Objects.equals( oldSel.themeFile, theme.themeFile ) && Objects.equals( oldSel.lafClassName, theme.lafClassName ) ) { @@ -274,9 +269,8 @@ public class IJThemesPanel private void themesListValueChanged( ListSelectionEvent e ) { IJThemeInfo themeInfo = themesList.getSelectedValue(); - boolean bundledTheme = (themeInfo != null && themeInfo.resourceName != null); - saveButton.setEnabled( bundledTheme ); - sourceCodeButton.setEnabled( bundledTheme ); + pluginButton.setEnabled( themeInfo != null && themeInfo.pluginUrl != null ); + sourceCodeButton.setEnabled( themeInfo != null && themeInfo.sourceCodePath != null ); if( e.getValueIsAdjusting() || isAdjustingThemesList ) return; @@ -307,21 +301,21 @@ public class IJThemesPanel FlatAnimatedLafChange.showSnapshot(); try { - if( themeInfo.themeFile.getName().endsWith( ".properties" ) ) { + if( themeInfo.themeFile.getName().endsWith( ".properties" ) ) FlatLaf.setup( new FlatPropertiesLaf( themeInfo.name, themeInfo.themeFile ) ); - } else + else FlatLaf.setup( IntelliJTheme.createLaf( new FileInputStream( themeInfo.themeFile ) ) ); - DemoPrefs.getState().put( DemoPrefs.KEY_LAF_THEME, DemoPrefs.FILE_PREFIX + themeInfo.themeFile ); + DemoPrefs.getState().put( DemoPrefs.KEY_LAF_THEME_FILE, themeInfo.themeFile.getAbsolutePath() ); } catch( Exception ex ) { LoggingFacade.INSTANCE.logSevere( null, ex ); showInformationDialog( "Failed to load '" + themeInfo.themeFile + "'.", ex ); } } else { - FlatAnimatedLafChange.showSnapshot(); - - IntelliJTheme.setup( getClass().getResourceAsStream( THEMES_PACKAGE + themeInfo.resourceName ) ); - DemoPrefs.getState().put( DemoPrefs.KEY_LAF_THEME, DemoPrefs.RESOURCE_PREFIX + themeInfo.resourceName ); + JOptionPane.showMessageDialog( SwingUtilities.windowForComponent( this ), + "Missing lafClassName for '" + themeInfo.name + "'", + "FlatLaf", JOptionPane.INFORMATION_MESSAGE ); + return; } // update all components @@ -329,56 +323,31 @@ public class IJThemesPanel FlatAnimatedLafChange.hideSnapshotWithAnimation(); } - private void saveTheme() { + private void browsePlugin() { IJThemeInfo themeInfo = themesList.getSelectedValue(); - if( themeInfo == null || themeInfo.resourceName == null ) + if( themeInfo == null || themeInfo.pluginUrl == null ) return; - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setSelectedFile( new File( lastDirectory, themeInfo.resourceName ) ); - if( fileChooser.showSaveDialog( SwingUtilities.windowForComponent( this ) ) != JFileChooser.APPROVE_OPTION ) - return; - - File file = fileChooser.getSelectedFile(); - lastDirectory = file.getParentFile(); - - // save theme - try { - Files.copy( getClass().getResourceAsStream( THEMES_PACKAGE + themeInfo.resourceName ), - file.toPath(), StandardCopyOption.REPLACE_EXISTING ); - } catch( IOException ex ) { - showInformationDialog( "Failed to save theme to '" + file + "'.", ex ); - return; - } - - // save license - if( themeInfo.licenseFile != null ) { - try { - File licenseFile = new File( file.getParentFile(), - StringUtils.removeTrailing( file.getName(), ".theme.json" ) + - themeInfo.licenseFile.substring( themeInfo.licenseFile.indexOf( '.' ) ) ); - Files.copy( getClass().getResourceAsStream( THEMES_PACKAGE + themeInfo.licenseFile ), - licenseFile.toPath(), StandardCopyOption.REPLACE_EXISTING ); - } catch( IOException ex ) { - showInformationDialog( "Failed to save theme license to '" + file + "'.", ex ); - return; - } - } + browse( themeInfo.pluginUrl ); } private void browseSourceCode() { IJThemeInfo themeInfo = themesList.getSelectedValue(); - if( themeInfo == null || themeInfo.resourceName == null ) + if( themeInfo == null || themeInfo.sourceCodeUrl == null ) return; String themeUrl = themeInfo.sourceCodeUrl; if( themeInfo.sourceCodePath != null ) themeUrl += '/' + themeInfo.sourceCodePath; - themeUrl = themeUrl.replace( " ", "%20" ); + browse( themeUrl ); + } + + private void browse( String url ) { + url = url.replace( " ", "%20" ); try { - Desktop.getDesktop().browse( new URI( themeUrl ) ); + Desktop.getDesktop().browse( new URI( url ) ); } catch( IOException | URISyntaxException ex ) { - showInformationDialog( "Failed to browse '" + themeUrl + "'.", ex ); + showInformationDialog( "Failed to browse '" + url + "'.", ex ); } } @@ -414,7 +383,10 @@ public class IJThemesPanel private void lafChanged( PropertyChangeEvent e ) { if( "lookAndFeel".equals( e.getPropertyName() ) ) { - selectedCurrentLookAndFeel(); + // use invokeLater() because KEY_LAF_THEME_FILE is updated after this event + EventQueue.invokeLater( () -> { + selectedCurrentLookAndFeel(); + } ); lastLafChangeTime = System.currentTimeMillis(); } } @@ -430,19 +402,19 @@ public class IJThemesPanel if( laf instanceof FlatLaf ) { List> lafClasses = new ArrayList<>(); + // same as in UIDefaultsLoader.getLafClassesForDefaultsLoading() + for( Class lafClass = laf.getClass(); + FlatLaf.class.isAssignableFrom( lafClass ); + lafClass = lafClass.getSuperclass() ) + { + lafClasses.add( 0, lafClass ); + } + + // same as in IntelliJTheme.ThemeLaf.getLafClassesForDefaultsLoading() if( laf instanceof IntelliJTheme.ThemeLaf ) { boolean dark = ((FlatLaf)laf).isDark(); - lafClasses.add( FlatLaf.class ); - lafClasses.add( dark ? FlatDarkLaf.class : FlatLightLaf.class ); - lafClasses.add( dark ? FlatDarculaLaf.class : FlatIntelliJLaf.class ); - lafClasses.add( IntelliJTheme.ThemeLaf.class ); - } else { - for( Class lafClass = laf.getClass(); - FlatLaf.class.isAssignableFrom( lafClass ); - lafClass = lafClass.getSuperclass() ) - { - lafClasses.add( 0, lafClass ); - } + lafClasses.add( 1, dark ? FlatDarkLaf.class : FlatLightLaf.class ); + lafClasses.add( 2, dark ? FlatDarculaLaf.class : FlatIntelliJLaf.class ); } boolean reload = false; @@ -469,23 +441,19 @@ public class IJThemesPanel } private void selectedCurrentLookAndFeel() { - LookAndFeel lookAndFeel = UIManager.getLookAndFeel(); - String theme = UIManager.getLookAndFeelDefaults().getString( DemoPrefs.THEME_UI_KEY ); - - if( theme == null && (lookAndFeel instanceof IntelliJTheme.ThemeLaf || lookAndFeel instanceof FlatPropertiesLaf) ) - return; - Predicate test; - if( theme != null && theme.startsWith( DemoPrefs.RESOURCE_PREFIX ) ) { - String resourceName = theme.substring( DemoPrefs.RESOURCE_PREFIX.length() ); - test = ti -> Objects.equals( ti.resourceName, resourceName ); - } else if( theme != null && theme.startsWith( DemoPrefs.FILE_PREFIX ) ) { - File themeFile = new File( theme.substring( DemoPrefs.FILE_PREFIX.length() ) ); + String lafClassName = UIManager.getLookAndFeel().getClass().getName(); + if( FlatPropertiesLaf.class.getName().equals( lafClassName ) || + IntelliJTheme.ThemeLaf.class.getName().equals( lafClassName ) ) + { + String themeFileName = DemoPrefs.getState().get( DemoPrefs.KEY_LAF_THEME_FILE, "" ); + if( themeFileName == null ) + return; + + File themeFile = new File( themeFileName ); test = ti -> Objects.equals( ti.themeFile, themeFile ); - } else { - String lafClassName = lookAndFeel.getClass().getName(); + } else test = ti -> Objects.equals( ti.lafClassName, lafClassName ); - } int newSel = -1; for( int i = 0; i < themes.size(); i++ ) { @@ -512,7 +480,7 @@ public class IJThemesPanel // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents JLabel themesLabel = new JLabel(); toolBar = new JToolBar(); - saveButton = new JButton(); + pluginButton = new JButton(); sourceCodeButton = new JButton(); filterComboBox = new JComboBox<>(); themesScrollPane = new JScrollPane(); @@ -535,11 +503,11 @@ public class IJThemesPanel { toolBar.setFloatable(false); - //---- saveButton ---- - saveButton.setToolTipText("Save .theme.json of selected IntelliJ theme to file."); - saveButton.setIcon(new FlatSVGIcon("com/formdev/flatlaf/demo/icons/download.svg")); - saveButton.addActionListener(e -> saveTheme()); - toolBar.add(saveButton); + //---- pluginButton ---- + pluginButton.setToolTipText("Opens the IntelliJ plugin page of selected IntelliJ theme in the browser."); + pluginButton.setIcon(new FlatSVGIcon("com/formdev/flatlaf/demo/icons/plugin.svg")); + pluginButton.addActionListener(e -> browsePlugin()); + toolBar.add(pluginButton); //---- sourceCodeButton ---- sourceCodeButton.setToolTipText("Opens the source code repository of selected IntelliJ theme in the browser."); @@ -574,7 +542,7 @@ public class IJThemesPanel // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables private JToolBar toolBar; - private JButton saveButton; + private JButton pluginButton; private JButton sourceCodeButton; private JComboBox filterComboBox; private JScrollPane themesScrollPane; diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/intellijthemes/IJThemesPanel.jfd b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/intellijthemes/IJThemesPanel.jfd index efa7f335..8fa8e9ca 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/intellijthemes/IJThemesPanel.jfd +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/intellijthemes/IJThemesPanel.jfd @@ -1,4 +1,4 @@ -JFDML JFormDesigner: "8.1.0.0.283" Java: "19.0.2" encoding: "UTF-8" +JFDML JFormDesigner: "8.3" encoding: "UTF-8" new FormModel { contentType: "form/swing" @@ -22,10 +22,10 @@ new FormModel { name: "toolBar" "floatable": false add( new FormComponent( "javax.swing.JButton" ) { - name: "saveButton" - "toolTipText": "Save .theme.json of selected IntelliJ theme to file." - "icon": new com.jformdesigner.model.SwingIcon( 0, "/com/formdev/flatlaf/demo/icons/download.svg" ) - addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "saveTheme", false ) ) + name: "pluginButton" + "toolTipText": "Opens the IntelliJ plugin page of selected IntelliJ theme in the browser." + "icon": new com.jformdesigner.model.SwingIcon( 0, "/com/formdev/flatlaf/demo/icons/plugin.svg" ) + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "browsePlugin", false ) ) } ) add( new FormComponent( "javax.swing.JButton" ) { name: "sourceCodeButton" diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/download.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/download.svg deleted file mode 100644 index c0f92903..00000000 --- a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/download.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/plugin.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/plugin.svg new file mode 100644 index 00000000..a6eebf66 --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/plugin.svg @@ -0,0 +1,4 @@ + + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/plugin_dark.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/plugin_dark.svg new file mode 100644 index 00000000..f731fe34 --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/plugin_dark.svg @@ -0,0 +1,4 @@ + + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/intellijthemes/themes.json b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/intellijthemes/themes.json index 94ea24ed..1de054bc 100644 --- a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/intellijthemes/themes.json +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/intellijthemes/themes.json @@ -1,6 +1,7 @@ { "arc-theme.theme.json": { "name": "Arc", + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatArcIJTheme", "license": "MIT", "licenseFile": "arc-themes.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12451-arc-theme", @@ -9,6 +10,7 @@ }, "arc-theme-orange.theme.json": { "name": "Arc - Orange", + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatArcOrangeIJTheme", "license": "MIT", "licenseFile": "arc-themes.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12451-arc-theme", @@ -18,6 +20,7 @@ "arc_theme_dark.theme.json": { "name": "Arc Dark", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatArcDarkIJTheme", "license": "MIT", "licenseFile": "arc-themes.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/15175-arc-theme-dark", @@ -27,6 +30,7 @@ "arc_theme_dark_orange.theme.json": { "name": "Arc Dark - Orange", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatArcDarkOrangeIJTheme", "license": "MIT", "licenseFile": "arc-themes.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/15175-arc-theme-dark", @@ -36,6 +40,7 @@ "Carbon.theme.json": { "name": "Carbon", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatCarbonIJTheme", "license": "Apache License 2.0", "licenseFile": "arc-themes.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12280-carbon", @@ -45,6 +50,7 @@ "Cobalt_2.theme.json": { "name": "Cobalt 2", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatCobalt2IJTheme", "license": "MIT", "licenseFile": "Cobalt_2.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/10745-cobalt-2", @@ -54,6 +60,7 @@ "Cyan.theme.json": { "name": "Cyan light", "license": "MIT", + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatCyanLightIJTheme", "licenseFile": "Cyan.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12102-cyan-light-theme", "sourceCodeUrl": "https://github.com/OlyaB/CyanTheme", @@ -62,6 +69,7 @@ "DarkFlatTheme.theme.json": { "name": "Dark Flat", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatDarkFlatIJTheme", "license": "MIT", "licenseFile": "DarkFlatTheme.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12165-dark-flat-theme", @@ -71,6 +79,7 @@ "DarkPurple.theme.json": { "name": "Dark purple", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatDarkPurpleIJTheme", "license": "MIT", "licenseFile": "DarkPurple.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12100-dark-purple-theme", @@ -80,6 +89,7 @@ "Dracula.theme.json": { "name": "Dracula", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatDraculaIJTheme", "license": "MIT", "licenseFile": "Dracula.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12275-dracula-theme", @@ -89,6 +99,7 @@ "Gradianto_dark_fuchsia.theme.json": { "name": "Gradianto Dark Fuchsia", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatGradiantoDarkFuchsiaIJTheme", "license": "MIT", "licenseFile": "Gradianto.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12334-gradianto", @@ -98,6 +109,7 @@ "Gradianto_deep_ocean.theme.json": { "name": "Gradianto Deep Ocean", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatGradiantoDeepOceanIJTheme", "license": "MIT", "licenseFile": "Gradianto.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12334-gradianto", @@ -107,6 +119,7 @@ "Gradianto_midnight_blue.theme.json": { "name": "Gradianto Midnight Blue", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatGradiantoMidnightBlueIJTheme", "license": "MIT", "licenseFile": "Gradianto.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12334-gradianto", @@ -116,6 +129,7 @@ "Gradianto_Nature_Green.theme.json": { "name": "Gradianto Nature Green", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatGradiantoNatureGreenIJTheme", "license": "MIT", "licenseFile": "Gradianto.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12334-gradianto", @@ -125,6 +139,7 @@ "Gray.theme.json": { "name": "Gray", "license": "MIT", + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatGrayIJTheme", "licenseFile": "Gray.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12103-gray-theme", "sourceCodeUrl": "https://github.com/OlyaB/GreyTheme", @@ -133,6 +148,7 @@ "gruvbox_dark_hard.theme.json": { "name": "Gruvbox Dark Hard", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkHardIJTheme", "license": "MIT", "licenseFile": "gruvbox_theme.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12310-gruvbox-theme", @@ -142,6 +158,7 @@ "gruvbox_dark_medium.theme.json": { "name": "Gruvbox Dark Medium", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkMediumIJTheme", "license": "MIT", "licenseFile": "gruvbox_theme.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12310-gruvbox-theme", @@ -151,6 +168,7 @@ "gruvbox_dark_soft.theme.json": { "name": "Gruvbox Dark Soft", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkSoftIJTheme", "license": "MIT", "licenseFile": "gruvbox_theme.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12310-gruvbox-theme", @@ -160,6 +178,7 @@ "HiberbeeDark.theme.json": { "name": "Hiberbee Dark", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatHiberbeeDarkIJTheme", "license": "MIT", "licenseFile": "Hiberbee.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12118-hiberbee-theme", @@ -169,6 +188,7 @@ "HighContrast.theme.json": { "name": "High Contrast", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatHighContrastIJTheme", "license": "Apache License 2.0", "licenseFile": "HighContrast.LICENSE.txt", "sourceCodeUrl": "https://github.com/JetBrains/intellij-community", @@ -177,6 +197,7 @@ "LightFlatTheme.theme.json": { "name": "Light Flat", "license": "MIT", + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatLightFlatIJTheme", "licenseFile": "LightFlatTheme.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12169-light-flat-theme", "sourceCodeUrl": "https://github.com/nerzhulart/LightFlatTheme", @@ -185,6 +206,7 @@ "MaterialTheme.theme.json": { "name": "Material Design Dark", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatMaterialDesignDarkIJTheme", "license": "MIT", "licenseFile": "MaterialTheme.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12134-material-design-dark-theme", @@ -194,6 +216,7 @@ "Monocai.theme.json": { "name": "Monocai", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatMonocaiIJTheme", "license": "MIT", "licenseFile": "Monocai.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12163-monocai-color-theme", @@ -204,6 +227,7 @@ "name": "Monokai Pro", "discontinued": true, "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatMonokaiProIJTheme", "license": "MIT", "licenseFile": "Monokai_Pro.LICENSE.txt", "sourceCodeUrl": "https://github.com/subtheme-dev/monokai-pro" @@ -211,6 +235,7 @@ "nord.theme.json": { "name": "Nord", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatNordIJTheme", "license": "MIT", "licenseFile": "nord.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/10321-nord", @@ -220,6 +245,7 @@ "one_dark.theme.json": { "name": "One Dark", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatOneDarkIJTheme", "license": "MIT", "licenseFile": "one_dark.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/11938-one-dark-theme", @@ -230,6 +256,7 @@ "name": "Solarized Dark", "discontinued": true, "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatSolarizedDarkIJTheme", "license": "The Unlicense", "licenseFile": "Solarized.LICENSE.txt", "sourceCodeUrl": "https://github.com/4lex4/intellij-platform-solarized", @@ -238,6 +265,7 @@ "SolarizedLight.theme.json": { "name": "Solarized Light", "discontinued": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatSolarizedLightIJTheme", "license": "The Unlicense", "licenseFile": "Solarized.LICENSE.txt", "sourceCodeUrl": "https://github.com/4lex4/intellij-platform-solarized", @@ -246,6 +274,7 @@ "Spacegray.theme.json": { "name": "Spacegray", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatSpacegrayIJTheme", "license": "MIT", "licenseFile": "Spacegray.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12122-spacegray-theme", @@ -255,6 +284,7 @@ "vuesion_theme.theme.json": { "name": "Vuesion", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatVuesionIJTheme", "license": "MIT", "licenseFile": "vuesion_theme.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/12226-vuesion-theme", @@ -264,6 +294,7 @@ "Xcode-Dark.theme.json": { "name": "Xcode-Dark", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.FlatXcodeDarkIJTheme", "license": "MIT", "licenseFile": "Xcode-Dark.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/13106-xcode-dark-theme", @@ -274,6 +305,7 @@ "material-theme-ui-lite/Arc Dark.theme.json": { "name": "Material Theme UI Lite / Arc Dark", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatArcDarkIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -283,6 +315,7 @@ "material-theme-ui-lite/Atom One Dark.theme.json": { "name": "Material Theme UI Lite / Atom One Dark", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneDarkIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -291,6 +324,7 @@ }, "material-theme-ui-lite/Atom One Light.theme.json": { "name": "Material Theme UI Lite / Atom One Light", + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -300,6 +334,7 @@ "material-theme-ui-lite/Dracula.theme.json": { "name": "Material Theme UI Lite / Dracula", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatDraculaIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -308,6 +343,7 @@ }, "material-theme-ui-lite/GitHub.theme.json": { "name": "Material Theme UI Lite / GitHub", + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -317,6 +353,7 @@ "material-theme-ui-lite/GitHub Dark.theme.json": { "name": "Material Theme UI Lite / GitHub Dark", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubDarkIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -325,6 +362,7 @@ }, "material-theme-ui-lite/Light Owl.theme.json": { "name": "Material Theme UI Lite / Light Owl", + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatLightOwlIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -334,6 +372,7 @@ "material-theme-ui-lite/Material Darker.theme.json": { "name": "Material Theme UI Lite / Material Darker", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDarkerIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -343,6 +382,7 @@ "material-theme-ui-lite/Material Deep Ocean.theme.json": { "name": "Material Theme UI Lite / Material Deep Ocean", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDeepOceanIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -351,6 +391,7 @@ }, "material-theme-ui-lite/Material Lighter.theme.json": { "name": "Material Theme UI Lite / Material Lighter", + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialLighterIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -360,6 +401,7 @@ "material-theme-ui-lite/Material Oceanic.theme.json": { "name": "Material Theme UI Lite / Material Oceanic", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialOceanicIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -369,6 +411,7 @@ "material-theme-ui-lite/Material Palenight.theme.json": { "name": "Material Theme UI Lite / Material Palenight", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialPalenightIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -378,6 +421,7 @@ "material-theme-ui-lite/Monokai Pro.theme.json": { "name": "Material Theme UI Lite / Monokai Pro", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMonokaiProIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -387,6 +431,7 @@ "material-theme-ui-lite/Moonlight.theme.json": { "name": "Material Theme UI Lite / Moonlight", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMoonlightIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -396,6 +441,7 @@ "material-theme-ui-lite/Night Owl.theme.json": { "name": "Material Theme UI Lite / Night Owl", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatNightOwlIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -405,6 +451,7 @@ "material-theme-ui-lite/Solarized Dark.theme.json": { "name": "Material Theme UI Lite / Solarized Dark", "dark": true, + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedDarkIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", @@ -413,6 +460,7 @@ }, "material-theme-ui-lite/Solarized Light.theme.json": { "name": "Material Theme UI Lite / Solarized Light", + "lafClassName": "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedLightIJTheme", "license": "MIT", "licenseFile": "material-theme-ui-lite/Material Theme UI Lite.LICENSE.txt", "pluginUrl": "https://plugins.jetbrains.com/plugin/8006-material-theme-ui", diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java index 520220a9..5dfde8fb 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java @@ -576,7 +576,7 @@ public class FlatTestFrame UIManager.put( "defaultFont", null ); LookAndFeel lookAndFeel = UIManager.getLookAndFeel(); - IntelliJTheme theme = (lookAndFeel instanceof IntelliJTheme.ThemeLaf) + IntelliJTheme theme = (lookAndFeel.getClass() == IntelliJTheme.ThemeLaf.class) ? ((IntelliJTheme.ThemeLaf)lookAndFeel).getTheme() : null; String nameForProperties = null;