this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

proper custom theme support

clover 58fc2f4d 54e4a463

+214 -146
+1
build.gradle.kts
··· 72 72 implementation("org.lwjglx:lwjgl3-awt:0.1.8") 73 73 74 74 implementation("commons-io:commons-io:2.16.1") 75 + implementation("org.apache.commons:commons-text:1.12.0") 75 76 implementation("org.apache.commons:commons-lang3:3.14.0") 76 77 77 78 implementation("com.miglayout:miglayout-core:11.3")
+6 -9
database/themes/README.txt
··· 1 + Star Rod can use custom themes desgined for IntelliJ. 2 + You can browse a collection of themes here: 1 3 2 - Custom Themes: 4 + https://plugins.jetbrains.com/search?tags=Theme 3 5 4 - Star Rod can use custom themes desgined for IntelliJ via a .theme.json file. 5 - You can browse a collection of such themes here: 6 - 7 - https://plugins.jetbrains.com/search?headline=0-theme&tags=Theme 8 - 9 - Find a theme you like and click "Souce File" to browse for the necessary file. 10 - Place the file anywhere in this folder and the custom theme will show up in 11 - the theme editor when you run Star Rod. 6 + Find a theme you like and download it as a JAR file. 7 + Place the JAR in this folder and the custom theme will show 8 + up in the theme editor next time you run Star Rod.
+182 -114
src/main/java/app/Themes.java
··· 5 5 import java.io.FileInputStream; 6 6 import java.io.FileNotFoundException; 7 7 import java.io.IOException; 8 - import java.util.ArrayList; 9 - import java.util.List; 8 + import java.util.Collection; 9 + import java.util.Enumeration; 10 + import java.util.jar.JarEntry; 11 + import java.util.jar.JarFile; 10 12 11 13 import javax.swing.UIManager; 14 + 15 + import org.apache.commons.text.WordUtils; 12 16 13 17 import com.formdev.flatlaf.IntelliJTheme; 14 18 15 19 import app.input.IOUtils; 20 + import util.CaseInsensitiveMap; 16 21 import util.Logger; 17 22 import util.Priority; 18 23 19 24 public abstract class Themes 20 25 { 21 - private static final List<Theme> THEMES = new ArrayList<>(); 26 + private static final CaseInsensitiveMap<Theme> THEME_MAP = new CaseInsensitiveMap<>(); 27 + 22 28 private static Theme DEFAULT_THEME; 23 29 private static Theme currentTheme = null; 30 + 31 + enum ThemeSource 32 + { 33 + BUILT_IN, 34 + CUSTOM_JAR, 35 + CUSTOM_JSON, 36 + }; 24 37 25 38 public static class Theme 26 39 { 27 40 public final String key; 28 41 public final String name; 42 + 43 + public final ThemeSource source; 29 44 public final String className; 30 - public final boolean custom; 45 + public final String fileName; 46 + public final String jarEntry; 31 47 32 - public Theme(String name, String className) 48 + private Theme(ThemeSource source, String key, String name, String className, String fileName, String jarEntry) 33 49 { 34 - this(name, className, false); 50 + this.key = key; 51 + this.name = name; 52 + this.source = source; 53 + this.className = className; 54 + this.fileName = fileName; 55 + this.jarEntry = jarEntry; 35 56 } 36 57 37 - public Theme(String name, String className, boolean custom) 58 + public static Theme createBuiltIn(String name, String className) 38 59 { 39 - this.name = name; 40 - this.key = name.replaceAll("\\s+", ""); 41 - this.className = className; 42 - this.custom = custom; 60 + String key = name.replaceAll("\\s+", ""); 61 + return new Theme(ThemeSource.BUILT_IN, key, name, className, "", ""); 62 + } 63 + 64 + public static Theme createFromJar(String fileName, String jarEntry) 65 + { 66 + String base = jarEntry.substring(0, jarEntry.length() - ".theme.json".length()); 67 + String key = base.replaceAll("\\s+", "_"); 68 + String name = WordUtils.capitalize(key.replaceAll("_", " ")); 69 + 70 + return new Theme(ThemeSource.CUSTOM_JAR, key, name, "", fileName, jarEntry); 71 + } 72 + 73 + public static Theme createFromJson(String fileName) 74 + { 75 + String base = fileName.substring(0, fileName.length() - ".theme.json".length()); 76 + String key = base.replaceAll("\\s+", "_"); 77 + String name = WordUtils.capitalize(key.replaceAll("_", " ")); 78 + 79 + return new Theme(ThemeSource.CUSTOM_JSON, key, name, "", fileName, ""); 43 80 } 44 - } 45 81 46 - public static String getCurrentThemeKey() 47 - { 48 - return currentTheme.key; 82 + @Override 83 + public String toString() 84 + { 85 + return name; 86 + } 49 87 } 50 88 51 - public static String getCurrentThemeName() 89 + public static Theme getCurrentTheme() 52 90 { 53 - return currentTheme.name; 91 + return currentTheme; 54 92 } 55 93 56 - public static List<String> getThemeNames() 94 + public static Collection<Theme> getThemes() 57 95 { 58 - List<String> list = new ArrayList<>(THEMES.size()); 59 - for (Theme theme : THEMES) 60 - list.add(theme.name); 61 - return list; 96 + return THEME_MAP.values(); 62 97 } 63 98 64 - private static void setTheme(Theme theme) 99 + public static void setTheme(Theme theme) 65 100 { 66 101 if (theme == null) 67 102 theme = DEFAULT_THEME; 68 - else if (theme == currentTheme) 103 + 104 + if (theme == currentTheme) 69 105 return; 70 106 71 - if (theme.custom) { 72 - try { 73 - IntelliJTheme.setup(new BufferedInputStream(new FileInputStream(new File(theme.className)))); 74 - currentTheme = theme; 75 - return; 76 - } 77 - catch (FileNotFoundException e) { 78 - Logger.logError("Could not find file for theme: " + theme.name); 79 - } 80 - // if error, reset to system 81 - theme = DEFAULT_THEME; 107 + switch (theme.source) { 108 + case CUSTOM_JSON: 109 + try { 110 + IntelliJTheme.setup(new BufferedInputStream(new FileInputStream(new File(theme.className)))); 111 + currentTheme = theme; 112 + return; 113 + } 114 + catch (FileNotFoundException e) { 115 + Logger.logError("Could not find file for theme: " + theme.name); 116 + 117 + // reset to default 118 + if (currentTheme == null) 119 + theme = DEFAULT_THEME; 120 + } 121 + break; 122 + case CUSTOM_JAR: 123 + try (JarFile jar = new JarFile(theme.fileName)) { 124 + JarEntry entry = jar.getJarEntry(theme.jarEntry); 125 + IntelliJTheme.setup(new BufferedInputStream(jar.getInputStream(entry))); 126 + currentTheme = theme; 127 + return; 128 + } 129 + catch (IOException e) { 130 + Logger.logError("Error loading theme " + theme.name); 131 + Logger.logError(e.getMessage()); 132 + 133 + // reset to default 134 + if (currentTheme == null) 135 + theme = DEFAULT_THEME; 136 + } 137 + break; 138 + case BUILT_IN: 139 + // handled after the switch 140 + break; 82 141 } 83 142 84 143 try { ··· 88 147 catch (Exception e) { 89 148 // many types of exceptions are possible here 90 149 Logger.log("Could not set UI to " + theme.key, Priority.ERROR); 150 + Logger.logError(e.getMessage()); 91 151 } 92 152 } 93 153 ··· 99 159 if (currentTheme != null && themeKey.equalsIgnoreCase(currentTheme.key)) 100 160 return; 101 161 102 - Theme newTheme = null; 103 - for (Theme theme : THEMES) { 104 - if (theme.key.equalsIgnoreCase(themeKey)) { 105 - newTheme = theme; 106 - break; 162 + Theme newTheme = THEME_MAP.get(themeKey); 163 + setTheme(newTheme); 164 + } 165 + 166 + private static void addCustomJarTheme(File file) 167 + { 168 + try (JarFile jar = new JarFile(file)) { 169 + Enumeration<JarEntry> entries = jar.entries(); 170 + while (entries.hasMoreElements()) { 171 + JarEntry entry = entries.nextElement(); 172 + if (entry.getName().endsWith(".theme.json")) { 173 + addTheme(Theme.createFromJar(jar.getName(), entry.getName())); 174 + return; 175 + } 107 176 } 108 177 } 178 + catch (IOException e) { 179 + Logger.logError("Error loading " + file.getName()); 180 + Logger.logError(e.getMessage()); 181 + } 182 + } 109 183 110 - setTheme(newTheme); 184 + private static void addCustomJsonTheme(File file) 185 + { 186 + addTheme(Theme.createFromJson(file.getName())); 111 187 } 112 188 113 - public static void setThemeByName(String themeName) 189 + private static void addTheme(Theme t) 114 190 { 115 - if (themeName == null || themeName.isEmpty()) 116 - themeName = DEFAULT_THEME.name; 117 - 118 - if (currentTheme != null && themeName.equalsIgnoreCase(currentTheme.name)) 191 + if (THEME_MAP.containsKey(t.key)) { 192 + Logger.log("Skipping duplicate theme: " + t.key); 119 193 return; 120 - 121 - Theme newTheme = null; 122 - for (Theme theme : THEMES) { 123 - if (theme.name.equalsIgnoreCase(themeName)) { 124 - newTheme = theme; 125 - break; 126 - } 127 194 } 128 195 129 - setTheme(newTheme); 196 + THEME_MAP.put(t.key, t); 130 197 } 131 198 132 199 static { 133 200 if (!Environment.isCommandLine()) { 134 - // SYSTEM_THEME = new Theme("System", UIManager.getSystemLookAndFeelClassName()); 201 + // @formatter:off 202 + DEFAULT_THEME = Theme.createBuiltIn("Flat Light", "com.formdev.flatlaf.FlatLightLaf"); 203 + addTheme(DEFAULT_THEME); 204 + 205 + addTheme(Theme.createBuiltIn("Flat Dark", "com.formdev.flatlaf.FlatDarkLaf")); 206 + addTheme(Theme.createBuiltIn("Arc Light", "com.formdev.flatlaf.intellijthemes.FlatArcIJTheme")); 207 + addTheme(Theme.createBuiltIn("Arc Light Orange", "com.formdev.flatlaf.intellijthemes.FlatArcOrangeIJTheme")); 208 + addTheme(Theme.createBuiltIn("Arc Dark", "com.formdev.flatlaf.intellijthemes.FlatArcDarkIJTheme")); 209 + addTheme(Theme.createBuiltIn("Arc Dark Orange", "com.formdev.flatlaf.intellijthemes.FlatArcDarkOrangeIJTheme")); 210 + addTheme(Theme.createBuiltIn("Arc Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatArcDarkIJTheme")); 211 + addTheme(Theme.createBuiltIn("Atom One Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneDarkIJTheme")); 212 + addTheme(Theme.createBuiltIn("Atom One Light (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightIJTheme")); 213 + addTheme(Theme.createBuiltIn("Carbon", "com.formdev.flatlaf.intellijthemes.FlatCarbonIJTheme")); 214 + addTheme(Theme.createBuiltIn("Cobalt 2", "com.formdev.flatlaf.intellijthemes.FlatCobalt2IJTheme")); 215 + addTheme(Theme.createBuiltIn("Cyan Light", "com.formdev.flatlaf.intellijthemes.FlatCyanLightIJTheme")); 216 + addTheme(Theme.createBuiltIn("Dark Flat", "com.formdev.flatlaf.intellijthemes.FlatDarkFlatIJTheme")); 217 + addTheme(Theme.createBuiltIn("Dark Purple", "com.formdev.flatlaf.intellijthemes.FlatDarkPurpleIJTheme")); 218 + addTheme(Theme.createBuiltIn("Dracula (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatDraculaIJTheme")); 219 + addTheme(Theme.createBuiltIn("Dracula", "com.formdev.flatlaf.intellijthemes.FlatDraculaIJTheme")); 220 + addTheme(Theme.createBuiltIn("GitHub (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubIJTheme")); 221 + addTheme(Theme.createBuiltIn("GitHub Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubDarkIJTheme")); 222 + addTheme(Theme.createBuiltIn("Gradianto Dark Fuchsia", "com.formdev.flatlaf.intellijthemes.FlatGradiantoDarkFuchsiaIJTheme")); 223 + addTheme(Theme.createBuiltIn("Gradianto Deep Ocean", "com.formdev.flatlaf.intellijthemes.FlatGradiantoDeepOceanIJTheme")); 224 + addTheme(Theme.createBuiltIn("Gradianto Midnight Blue", "com.formdev.flatlaf.intellijthemes.FlatGradiantoMidnightBlueIJTheme")); 225 + addTheme(Theme.createBuiltIn("Gradianto Nature Green", "com.formdev.flatlaf.intellijthemes.FlatGradiantoNatureGreenIJTheme")); 226 + addTheme(Theme.createBuiltIn("Gray", "com.formdev.flatlaf.intellijthemes.FlatGrayIJTheme")); 227 + addTheme(Theme.createBuiltIn("Gruvbox Dark Hard", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkHardIJTheme")); 228 + addTheme(Theme.createBuiltIn("Gruvbox Dark Medium", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkMediumIJTheme")); 229 + addTheme(Theme.createBuiltIn("Gruvbox Dark Soft", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkSoftIJTheme")); 230 + addTheme(Theme.createBuiltIn("Hiberbee Dark", "com.formdev.flatlaf.intellijthemes.FlatHiberbeeDarkIJTheme")); 231 + addTheme(Theme.createBuiltIn("High Contrast", "com.formdev.flatlaf.intellijthemes.FlatHighContrastIJTheme")); 232 + addTheme(Theme.createBuiltIn("Light Flat", "com.formdev.flatlaf.intellijthemes.FlatLightFlatIJTheme")); 233 + addTheme(Theme.createBuiltIn("Light Owl (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatLightOwlIJTheme")); 234 + addTheme(Theme.createBuiltIn("Material Darker (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDarkerIJTheme")); 235 + addTheme(Theme.createBuiltIn("Material Deep Ocean (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDeepOceanIJTheme")); 236 + addTheme(Theme.createBuiltIn("Material Design Dark", "com.formdev.flatlaf.intellijthemes.FlatMaterialDesignDarkIJTheme")); 237 + addTheme(Theme.createBuiltIn("Material Lighter (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialLighterIJTheme")); 238 + addTheme(Theme.createBuiltIn("Material Oceanic (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialOceanicIJTheme")); 239 + addTheme(Theme.createBuiltIn("Material Palenight (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialPalenightIJTheme")); 240 + addTheme(Theme.createBuiltIn("Monocai", "com.formdev.flatlaf.intellijthemes.FlatMonocaiIJTheme")); 241 + addTheme(Theme.createBuiltIn("Monokai Pro (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMonokaiProIJTheme")); 242 + addTheme(Theme.createBuiltIn("Monokai Pro", "com.formdev.flatlaf.intellijthemes.FlatMonokaiProIJTheme")); 243 + addTheme(Theme.createBuiltIn("Moonlight (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMoonlightIJTheme")); 244 + addTheme(Theme.createBuiltIn("Night Owl (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatNightOwlIJTheme")); 245 + addTheme(Theme.createBuiltIn("Nord", "com.formdev.flatlaf.intellijthemes.FlatNordIJTheme")); 246 + addTheme(Theme.createBuiltIn("One Dark", "com.formdev.flatlaf.intellijthemes.FlatOneDarkIJTheme")); 247 + addTheme(Theme.createBuiltIn("Solarized Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedDarkIJTheme")); 248 + addTheme(Theme.createBuiltIn("Solarized Dark", "com.formdev.flatlaf.intellijthemes.FlatSolarizedDarkIJTheme")); 249 + addTheme(Theme.createBuiltIn("Solarized Light (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedLightIJTheme")); 250 + addTheme(Theme.createBuiltIn("Solarized Light", "com.formdev.flatlaf.intellijthemes.FlatSolarizedLightIJTheme")); 251 + addTheme(Theme.createBuiltIn("Spacegray", "com.formdev.flatlaf.intellijthemes.FlatSpacegrayIJTheme")); 252 + addTheme(Theme.createBuiltIn("Vuesion", "com.formdev.flatlaf.intellijthemes.FlatVuesionIJTheme")); 253 + addTheme(Theme.createBuiltIn("Xcode-Dark", "com.formdev.flatlaf.intellijthemes.FlatXcodeDarkIJTheme")); 254 + // @formatter:on 135 255 136 256 try { 137 - for (File f : IOUtils.getFilesWithExtension(Directories.DATABASE_THEMES.toFile(), "theme.json", true)) { 138 - String name = f.getName().substring(0, f.getName().length() - 11); 139 - THEMES.add(new Theme(name, f.getAbsolutePath(), true)); 257 + for (File f : IOUtils.getFilesWithExtension(Directories.DATABASE_THEMES.toFile(), "jar", true)) { 258 + addCustomJarTheme(f); 259 + } 260 + 261 + for (File f : IOUtils.getFilesWithExtension(Directories.DATABASE_THEMES.toFile(), ".theme.json", true)) { 262 + addCustomJsonTheme(f); 140 263 } 141 264 } 142 265 catch (IOException e) { 143 266 Logger.logError("IOException while loading custom themes: " + e.getMessage()); 144 267 } 145 268 146 - // @formatter:off 147 - DEFAULT_THEME = new Theme("Flat Light", "com.formdev.flatlaf.FlatLightLaf"); 148 - THEMES.add(DEFAULT_THEME); 149 - 150 - THEMES.add(new Theme("Flat Dark", "com.formdev.flatlaf.FlatDarkLaf")); 151 - THEMES.add(new Theme("Arc Light", "com.formdev.flatlaf.intellijthemes.FlatArcIJTheme")); 152 - THEMES.add(new Theme("Arc Light Orange", "com.formdev.flatlaf.intellijthemes.FlatArcOrangeIJTheme")); 153 - THEMES.add(new Theme("Arc Dark", "com.formdev.flatlaf.intellijthemes.FlatArcDarkIJTheme")); 154 - THEMES.add(new Theme("Arc Dark Orange", "com.formdev.flatlaf.intellijthemes.FlatArcDarkOrangeIJTheme")); 155 - THEMES.add(new Theme("Arc Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatArcDarkIJTheme")); 156 - THEMES.add(new Theme("Atom One Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneDarkIJTheme")); 157 - THEMES.add(new Theme("Atom One Light (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightIJTheme")); 158 - THEMES.add(new Theme("Carbon", "com.formdev.flatlaf.intellijthemes.FlatCarbonIJTheme")); 159 - THEMES.add(new Theme("Cobalt 2", "com.formdev.flatlaf.intellijthemes.FlatCobalt2IJTheme")); 160 - THEMES.add(new Theme("Cyan Light", "com.formdev.flatlaf.intellijthemes.FlatCyanLightIJTheme")); 161 - THEMES.add(new Theme("Dark Flat", "com.formdev.flatlaf.intellijthemes.FlatDarkFlatIJTheme")); 162 - THEMES.add(new Theme("Dark Purple", "com.formdev.flatlaf.intellijthemes.FlatDarkPurpleIJTheme")); 163 - THEMES.add(new Theme("Dracula (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatDraculaIJTheme")); 164 - THEMES.add(new Theme("Dracula", "com.formdev.flatlaf.intellijthemes.FlatDraculaIJTheme")); 165 - THEMES.add(new Theme("GitHub (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubIJTheme")); 166 - THEMES.add(new Theme("GitHub Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubDarkIJTheme")); 167 - THEMES.add(new Theme("Gradianto Dark Fuchsia", "com.formdev.flatlaf.intellijthemes.FlatGradiantoDarkFuchsiaIJTheme")); 168 - THEMES.add(new Theme("Gradianto Deep Ocean", "com.formdev.flatlaf.intellijthemes.FlatGradiantoDeepOceanIJTheme")); 169 - THEMES.add(new Theme("Gradianto Midnight Blue", "com.formdev.flatlaf.intellijthemes.FlatGradiantoMidnightBlueIJTheme")); 170 - THEMES.add(new Theme("Gradianto Nature Green", "com.formdev.flatlaf.intellijthemes.FlatGradiantoNatureGreenIJTheme")); 171 - THEMES.add(new Theme("Gray", "com.formdev.flatlaf.intellijthemes.FlatGrayIJTheme")); 172 - THEMES.add(new Theme("Gruvbox Dark Hard", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkHardIJTheme")); 173 - THEMES.add(new Theme("Gruvbox Dark Medium", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkMediumIJTheme")); 174 - THEMES.add(new Theme("Gruvbox Dark Soft", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkSoftIJTheme")); 175 - THEMES.add(new Theme("Hiberbee Dark", "com.formdev.flatlaf.intellijthemes.FlatHiberbeeDarkIJTheme")); 176 - THEMES.add(new Theme("High Contrast", "com.formdev.flatlaf.intellijthemes.FlatHighContrastIJTheme")); 177 - THEMES.add(new Theme("Light Flat", "com.formdev.flatlaf.intellijthemes.FlatLightFlatIJTheme")); 178 - THEMES.add(new Theme("Light Owl (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatLightOwlIJTheme")); 179 - THEMES.add(new Theme("Material Darker (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDarkerIJTheme")); 180 - THEMES.add(new Theme("Material Deep Ocean (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDeepOceanIJTheme")); 181 - THEMES.add(new Theme("Material Design Dark", "com.formdev.flatlaf.intellijthemes.FlatMaterialDesignDarkIJTheme")); 182 - THEMES.add(new Theme("Material Lighter (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialLighterIJTheme")); 183 - THEMES.add(new Theme("Material Oceanic (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialOceanicIJTheme")); 184 - THEMES.add(new Theme("Material Palenight (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialPalenightIJTheme")); 185 - THEMES.add(new Theme("Monocai", "com.formdev.flatlaf.intellijthemes.FlatMonocaiIJTheme")); 186 - THEMES.add(new Theme("Monokai Pro (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMonokaiProIJTheme")); 187 - THEMES.add(new Theme("Monokai Pro", "com.formdev.flatlaf.intellijthemes.FlatMonokaiProIJTheme")); 188 - THEMES.add(new Theme("Moonlight (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMoonlightIJTheme")); 189 - THEMES.add(new Theme("Night Owl (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatNightOwlIJTheme")); 190 - THEMES.add(new Theme("Nord", "com.formdev.flatlaf.intellijthemes.FlatNordIJTheme")); 191 - THEMES.add(new Theme("One Dark", "com.formdev.flatlaf.intellijthemes.FlatOneDarkIJTheme")); 192 - THEMES.add(new Theme("Solarized Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedDarkIJTheme")); 193 - THEMES.add(new Theme("Solarized Dark", "com.formdev.flatlaf.intellijthemes.FlatSolarizedDarkIJTheme")); 194 - THEMES.add(new Theme("Solarized Light (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedLightIJTheme")); 195 - THEMES.add(new Theme("Solarized Light", "com.formdev.flatlaf.intellijthemes.FlatSolarizedLightIJTheme")); 196 - THEMES.add(new Theme("Spacegray", "com.formdev.flatlaf.intellijthemes.FlatSpacegrayIJTheme")); 197 - THEMES.add(new Theme("Vuesion", "com.formdev.flatlaf.intellijthemes.FlatVuesionIJTheme")); 198 - THEMES.add(new Theme("Xcode-Dark", "com.formdev.flatlaf.intellijthemes.FlatXcodeDarkIJTheme")); 199 - // @formatter:on 200 - 201 - Logger.log("Loaded " + THEMES.size() + " themes."); 269 + Logger.log("Loaded " + THEME_MAP.size() + " themes."); 202 270 } 203 271 } 204 272 }
+23 -21
src/main/java/app/ThemesEditor.java
··· 9 9 import javax.swing.JButton; 10 10 import javax.swing.JCheckBox; 11 11 import javax.swing.JComboBox; 12 + import javax.swing.JFrame; 12 13 import javax.swing.JLabel; 13 14 import javax.swing.JList; 14 15 import javax.swing.JOptionPane; ··· 22 23 import javax.swing.ListSelectionModel; 23 24 import javax.swing.SwingConstants; 24 25 import javax.swing.SwingUtilities; 25 - import javax.swing.WindowConstants; 26 26 import javax.swing.tree.DefaultMutableTreeNode; 27 27 import javax.swing.tree.DefaultTreeModel; 28 28 29 + import app.Themes.Theme; 29 30 import app.config.Options; 30 31 import net.miginfocom.swing.MigLayout; 31 32 ··· 37 38 private StarRodFrame frame; 38 39 public boolean exitToMainMenu; 39 40 40 - public String initialThemeName; 41 + public Theme initialTheme; 41 42 42 43 private JLabel lblR; 43 44 private JLabel lblG; ··· 56 57 57 58 public ThemesEditor(CountDownLatch guiClosedSignal) 58 59 { 59 - initialThemeName = Themes.getCurrentThemeName(); 60 + initialTheme = Themes.getCurrentTheme(); 60 61 61 62 frame = new StarRodFrame(); 62 63 ··· 65 66 frame.setBounds(0, 0, WINDOW_SIZE_X, WINDOW_SIZE_Y); 66 67 frame.setLocationRelativeTo(null); 67 68 68 - frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); 69 + frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); 69 70 frame.addWindowListener(new WindowAdapter() { 70 71 @Override 71 72 public void windowClosing(WindowEvent e) 72 73 { 73 74 exitToMainMenu = true; 74 - String currentThemeName = Themes.getCurrentThemeName(); 75 - if (!initialThemeName.equals(currentThemeName)) { 75 + Theme currentTheme = Themes.getCurrentTheme(); 76 + if (initialTheme != currentTheme) { 76 77 int choice = SwingUtils.getConfirmDialog() 77 78 .setTitle("Save Changes") 78 79 .setMessage("Theme has been changed.", "Do you want to save changes?") ··· 80 81 81 82 switch (choice) { 82 83 case JOptionPane.YES_OPTION: 83 - Environment.mainConfig.setString(Options.Theme, Themes.getCurrentThemeKey()); 84 - Environment.mainConfig.saveConfigFile(); 85 - 86 - SwingUtils.getWarningDialog() 87 - .setTitle("Theme Changed") 88 - .setMessage("Theme has been changed.", "Star Rod must restart.") 89 - .show(); 84 + if (Themes.getCurrentTheme() != null) { 85 + Environment.mainConfig.setString(Options.Theme, Themes.getCurrentTheme().key); 86 + Environment.mainConfig.saveConfigFile(); 90 87 91 - Environment.exit(); 88 + SwingUtils.getWarningDialog() 89 + .setTitle("Theme Changed") 90 + .setMessage("Theme has been changed.", "Star Rod must restart.") 91 + .show(); 92 + } 93 + exitToMainMenu = false; 92 94 break; 93 95 case JOptionPane.NO_OPTION: 94 - Themes.setThemeByName(initialThemeName); 96 + Themes.setTheme(initialTheme); 95 97 SwingUtilities.updateComponentTreeUI(frame); 96 98 break; 97 99 case JOptionPane.CANCEL_OPTION: ··· 113 115 114 116 private JPanel getThemesPanel() 115 117 { 116 - DefaultListModel<String> themes = new DefaultListModel<>(); 118 + DefaultListModel<Theme> themes = new DefaultListModel<>(); 117 119 118 - for (String name : Themes.getThemeNames()) 119 - themes.addElement(name); 120 + for (Theme theme : Themes.getThemes()) 121 + themes.addElement(theme); 120 122 121 - JList<String> themeList = new JList<>(themes); 123 + JList<Theme> themeList = new JList<>(themes); 122 124 themeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 123 125 124 - themeList.setSelectedValue(Themes.getCurrentThemeName(), true); 126 + themeList.setSelectedValue(Themes.getCurrentTheme(), true); 125 127 126 128 themeList.addListSelectionListener(e -> SwingUtilities.invokeLater(() -> { 127 - Themes.setThemeByName(themeList.getSelectedValue()); 129 + Themes.setTheme(themeList.getSelectedValue()); 128 130 SwingUtilities.updateComponentTreeUI(frame); 129 131 lblR.setForeground(SwingUtils.getRedTextColor()); 130 132 lblG.setForeground(SwingUtils.getGreenTextColor());
+2 -2
src/main/java/util/CaseInsensitiveMap.java
··· 1 1 package util; 2 2 3 3 import java.util.Collection; 4 - import java.util.HashMap; 4 + import java.util.LinkedHashMap; 5 5 6 6 public class CaseInsensitiveMap<T> 7 7 { 8 - private final HashMap<String, T> map = new HashMap<>(); 8 + private final LinkedHashMap<String, T> map = new LinkedHashMap<>(); 9 9 10 10 public T put(String key, T value) 11 11 {