IntelliJ Themes: moved themes into own sub-project and build a JAR that contains all themes

This commit is contained in:
Karl Tauber
2020-04-23 11:06:12 +02:00
parent b08ccc9767
commit 13cbbd8bc1
81 changed files with 149 additions and 6 deletions

View File

@@ -60,7 +60,7 @@ 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( theme.substring( RESOURCE_PREFIX.length() ) ) );
IntelliJTheme.install( 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() ) ) ) );
else

View File

@@ -60,6 +60,8 @@ import net.miginfocom.swing.*;
public class IJThemesPanel
extends JPanel
{
public static final String THEMES_PACKAGE = "/com/formdev/flatlaf/intellijthemes/themes/";
private final IJThemesManager themesManager = new IJThemesManager();
private final List<IJThemeInfo> themes = new ArrayList<>();
private final HashMap<Integer, String> categories = new HashMap<>();
@@ -237,7 +239,7 @@ public class IJThemesPanel
showInformationDialog( "Failed to load '" + themeInfo.themeFile + "'.", ex );
}
} else {
IntelliJTheme.install( getClass().getResourceAsStream( themeInfo.resourceName ) );
IntelliJTheme.install( getClass().getResourceAsStream( THEMES_PACKAGE + themeInfo.resourceName ) );
DemoPrefs.getState().put( DemoPrefs.KEY_LAF_THEME, DemoPrefs.RESOURCE_PREFIX + themeInfo.resourceName );
}
@@ -260,7 +262,7 @@ public class IJThemesPanel
// save theme
try {
Files.copy( getClass().getResourceAsStream( themeInfo.resourceName ),
Files.copy( getClass().getResourceAsStream( THEMES_PACKAGE + themeInfo.resourceName ),
file.toPath(), StandardCopyOption.REPLACE_EXISTING );
} catch( IOException ex ) {
showInformationDialog( "Failed to save theme to '" + file + "'.", ex );
@@ -273,7 +275,7 @@ public class IJThemesPanel
File licenseFile = new File( file.getParentFile(),
StringUtils.removeTrailing( file.getName(), ".theme.json" ) +
themeInfo.licenseFile.substring( themeInfo.licenseFile.indexOf( '.' ) ) );
Files.copy( getClass().getResourceAsStream( themeInfo.licenseFile ),
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 );

View File

@@ -46,7 +46,7 @@ public class IJThemesUpdater
else if( fromUrl.contains( "gitlab.com" ) )
fromUrl = fromUrl.replace( "/blob/", "/raw/" );
String toPath = "src/main/resources/com/formdev/flatlaf/demo/intellijthemes/" + ti.resourceName;
String toPath = "../flatlaf-intellij-themes/src/main/resources" + IJThemesPanel.THEMES_PACKAGE + ti.resourceName;
download( fromUrl, toPath );
}