renamed Flat*Laf.install() methods to Flat*Laf.setup() to avoid confusion with UIManager.installLookAndFeel(LookAndFeelInfo info); the old Flat*Laf.install() methods are still there, but marked as deprecated

This commit is contained in:
Karl Tauber
2021-04-22 14:19:26 +02:00
parent 1c52f1f76c
commit d97146393c
78 changed files with 742 additions and 153 deletions

View File

@@ -50,7 +50,7 @@ public class DemoPrefs
state = Preferences.userRoot().node( rootPath );
}
public static void initLaf( String[] args ) {
public static void setupLaf( String[] args ) {
// set look and feel
try {
if( args.length > 0 )
@@ -60,11 +60,11 @@ public class DemoPrefs
if( IntelliJTheme.ThemeLaf.class.getName().equals( lafClassName ) ) {
String theme = state.get( KEY_LAF_THEME, "" );
if( theme.startsWith( RESOURCE_PREFIX ) )
IntelliJTheme.install( IJThemesPanel.class.getResourceAsStream( IJThemesPanel.THEMES_PACKAGE + theme.substring( RESOURCE_PREFIX.length() ) ) );
IntelliJTheme.setup( IJThemesPanel.class.getResourceAsStream( IJThemesPanel.THEMES_PACKAGE + theme.substring( RESOURCE_PREFIX.length() ) ) );
else if( theme.startsWith( FILE_PREFIX ) )
FlatLaf.install( IntelliJTheme.createLaf( new FileInputStream( theme.substring( FILE_PREFIX.length() ) ) ) );
FlatLaf.setup( IntelliJTheme.createLaf( new FileInputStream( theme.substring( FILE_PREFIX.length() ) ) ) );
else
FlatLightLaf.install();
FlatLightLaf.setup();
if( !theme.isEmpty() )
UIManager.getLookAndFeelDefaults().put( THEME_UI_KEY, theme );
@@ -73,9 +73,9 @@ public class DemoPrefs
if( theme.startsWith( FILE_PREFIX ) ) {
File themeFile = new File( theme.substring( FILE_PREFIX.length() ) );
String themeName = StringUtils.removeTrailing( themeFile.getName(), ".properties" );
FlatLaf.install( new FlatPropertiesLaf( themeName, themeFile ) );
FlatLaf.setup( new FlatPropertiesLaf( themeName, themeFile ) );
} else
FlatLightLaf.install();
FlatLightLaf.setup();
if( !theme.isEmpty() )
UIManager.getLookAndFeelDefaults().put( THEME_UI_KEY, theme );
@@ -86,7 +86,7 @@ public class DemoPrefs
ex.printStackTrace();
// fallback
FlatLightLaf.install();
FlatLightLaf.setup();
}
// remember active look and feel

View File

@@ -48,7 +48,7 @@ public class FlatLafDemo
FlatLaf.registerCustomDefaultsSource( "com.formdev.flatlaf.demo" );
// set look and feel
DemoPrefs.initLaf( args );
DemoPrefs.setupLaf( args );
// install inspectors
FlatInspector.install( "ctrl shift alt X" );

View File

@@ -160,14 +160,22 @@ public class IJThemesClassGenerator
"{\n" +
" public static final String NAME = \"${themeName}\";\n" +
"\n" +
" public static boolean install() {\n" +
" public static boolean setup() {\n" +
" try {\n" +
" return install( new ${themeClass}() );\n" +
" return setup( new ${themeClass}() );\n" +
" } catch( RuntimeException ex ) {\n" +
" return false;\n" +
" }\n" +
" }\n" +
"\n" +
" /**\n" +
" * @deprecated use {@link #setup()} instead; this method will be removed in a future version\n" +
" */\n" +
" @Deprecated\n" +
" public static boolean install() {\n" +
" return setup();\n" +
" }\n" +
"\n" +
" public static void installLafInfo() {\n" +
" installLafInfo( NAME, ${themeClass}.class );\n" +
" }\n" +

View File

@@ -267,9 +267,9 @@ public class IJThemesPanel
try {
if( themeInfo.themeFile.getName().endsWith( ".properties" ) ) {
FlatLaf.install( new FlatPropertiesLaf( themeInfo.name, themeInfo.themeFile ) );
FlatLaf.setup( new FlatPropertiesLaf( themeInfo.name, themeInfo.themeFile ) );
} else
FlatLaf.install( IntelliJTheme.createLaf( new FileInputStream( themeInfo.themeFile ) ) );
FlatLaf.setup( IntelliJTheme.createLaf( new FileInputStream( themeInfo.themeFile ) ) );
DemoPrefs.getState().put( DemoPrefs.KEY_LAF_THEME, DemoPrefs.FILE_PREFIX + themeInfo.themeFile );
} catch( Exception ex ) {
@@ -279,7 +279,7 @@ public class IJThemesPanel
} else {
FlatAnimatedLafChange.showSnapshot();
IntelliJTheme.install( getClass().getResourceAsStream( THEMES_PACKAGE + themeInfo.resourceName ) );
IntelliJTheme.setup( getClass().getResourceAsStream( THEMES_PACKAGE + themeInfo.resourceName ) );
DemoPrefs.getState().put( DemoPrefs.KEY_LAF_THEME, DemoPrefs.RESOURCE_PREFIX + themeInfo.resourceName );
}