Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ public static void setPreferredTheme(String themeName, boolean reload) {
public static void installPreferredTheme(boolean update) {
Theme theme = getPreferredTheme();

// UI_DEFAULTS also holds the preferred theme name, which must survive
// the next look and feel change
String themeName = (String) UI_DEFAULTS.get(PREFERRED_THEME_KEY);
UI_DEFAULTS.clear();
setProperty(PREFERRED_THEME_KEY, themeName);
setProperty(View.class, theme.getViewUI());
setProperty(Titlebar.class, theme.getTitlebarUI());
setProperty(Button.class, theme.getButtonUI());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import org.flexdock.plaf.PlafManager;
import org.flexdock.plaf.theme.Theme;
import org.flexdock.plaf.theme.UIFactory;
import org.flexdock.plaf.theme.ViewUI;
import org.flexdock.view.View;
import org.junit.jupiter.api.Test;

import javax.swing.LookAndFeel;
Expand All @@ -27,6 +29,12 @@ private static Properties createProperties() {
return properties;
}

private static String getInstalledViewUiName() {
ViewUI ui = (ViewUI) PlafManager.getUI(new View("theme.view", "View"));

return ui.getCreationParameters().getName();
}

@Test
void testDefaultPrefsDefineNamedUis() {
assertTrue(Configurator.getNamedElementsByTagName(UIFactory.VIEW_KEY).containsKey("default"));
Expand Down Expand Up @@ -81,4 +89,21 @@ void testCustomThemeUnderUnmappedLookAndFeel() throws Exception {
}
}

@Test
void testPreferredThemeSurvivesLookAndFeelChange() throws Exception {
LookAndFeel original = UIManager.getLookAndFeel();
try {
PlafManager.setPreferredTheme("officeXP");
assertEquals("officeXP", getInstalledViewUiName());

// A new instance, so the look and feel change event fires and the theme is reinstalled
UIManager.setLookAndFeel(new MetalLookAndFeel());

assertEquals("officeXP", getInstalledViewUiName());
} finally {
PlafManager.setPreferredTheme((String) null);
UIManager.setLookAndFeel(original);
}
}

}
1 change: 1 addition & 0 deletions release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Fixes:
* PerspectiveManager: ignore detached docking ports when finding the main one
* DefaultDockingPort: clear() also clears the nested docking ports
* DockingStateListener: validate pending layout before capturing docking state
* PlafManager: keep the preferred theme after a look and feel change
* DockingSplitPane: track the divider percentage from the first drag
* DockingSplitPane: apply the percentage consistently in setDividerLocation()
* DockingSplitPane: keep the percentage set before the size is known
Expand Down
Loading