|
|
@ -22,6 +22,7 @@ |
|
|
|
package com.github.weisj.darklaf; |
|
|
|
package com.github.weisj.darklaf; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.Window; |
|
|
|
import java.awt.Window; |
|
|
|
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
|
import java.util.logging.Level; |
|
|
|
import java.util.logging.Level; |
|
|
|
import java.util.logging.Logger; |
|
|
|
import java.util.logging.Logger; |
|
|
|
|
|
|
|
|
|
|
@ -38,10 +39,14 @@ import com.github.weisj.darklaf.util.LogUtil; |
|
|
|
final class LafInstaller { |
|
|
|
final class LafInstaller { |
|
|
|
|
|
|
|
|
|
|
|
private static final Logger LOGGER = LogUtil.getLogger(LafManager.class); |
|
|
|
private static final Logger LOGGER = LogUtil.getLogger(LafManager.class); |
|
|
|
|
|
|
|
private static final AtomicBoolean isInstalling = new AtomicBoolean(false); |
|
|
|
private static final ThemeEventSupport<ThemeChangeEvent, ThemeChangeListener> eventSupport = |
|
|
|
private static final ThemeEventSupport<ThemeChangeEvent, ThemeChangeListener> eventSupport = |
|
|
|
new ThemeEventSupport<>(); |
|
|
|
new ThemeEventSupport<>(); |
|
|
|
|
|
|
|
|
|
|
|
void install(final Theme theme) { |
|
|
|
void install(final Theme theme) { |
|
|
|
|
|
|
|
if (!isInstalling.compareAndSet(false, true)) { |
|
|
|
|
|
|
|
throw new IllegalStateException("Can't install Laf while installation is in progress"); |
|
|
|
|
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
LOGGER.fine(() -> "Installing theme " + theme); |
|
|
|
LOGGER.fine(() -> "Installing theme " + theme); |
|
|
|
LafTransition transition = LafTransition.showSnapshot(); |
|
|
|
LafTransition transition = LafTransition.showSnapshot(); |
|
|
@ -51,6 +56,8 @@ final class LafInstaller { |
|
|
|
notifyThemeInstalled(theme); |
|
|
|
notifyThemeInstalled(theme); |
|
|
|
} catch (final UnsupportedLookAndFeelException e) { |
|
|
|
} catch (final UnsupportedLookAndFeelException e) { |
|
|
|
LOGGER.log(Level.SEVERE, "Could not install LaF", e); |
|
|
|
LOGGER.log(Level.SEVERE, "Could not install LaF", e); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
isInstalling.set(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|