GP-2862 fixing table selection colors

This commit is contained in:
ghidragon
2022-11-23 11:01:43 -05:00
parent f0a8af3e8b
commit 2a4758caa0
10 changed files with 99 additions and 79 deletions

View File

@@ -41,7 +41,6 @@ public class ApplicationThemeManager extends ThemeManager {
protected ThemePreferences themePreferences = new ThemePreferences();
private Map<String, GColorUIResource> gColorMap = new HashMap<>();
private Map<String, GIconUIResource> gIconMap = new HashMap<>();
// stores the original value for ids whose value has changed from the current theme
private GThemeValueMap changedValuesMap = new GThemeValueMap();
@@ -237,7 +236,13 @@ public class ApplicationThemeManager extends ThemeManager {
lookAndFeelManager.iconsChanged(changedIconIds, newIcon);
}
@Override
/**
* Gets a UIResource version of the GColor for the given id. Using this method ensures that
* the same instance is used for a given id. This fixes an issue with some
* {@link LookAndFeel}s that internally use '==' comparisons.
* @param id the id to get a GColorUIResource for
* @return a GColorUIResource for the given id
*/
public GColorUIResource getGColorUiResource(String id) {
GColorUIResource gColor = gColorMap.get(id);
if (gColor == null) {
@@ -247,17 +252,6 @@ public class ApplicationThemeManager extends ThemeManager {
return gColor;
}
@Override
public GIconUIResource getGIconUiResource(String id) {
GIconUIResource gIcon = gIconMap.get(id);
if (gIcon == null) {
gIcon = new GIconUIResource(id);
gIconMap.put(id, gIcon);
}
return gIcon;
}
/**
* Sets specially defined system UI values. These values are created by the application as a
* convenience for mapping generic concepts to values that differ by Look and Feel. This allows

View File

@@ -15,6 +15,8 @@
*/
package generic.theme;
import java.awt.Color;
import javax.swing.UIDefaults;
import javax.swing.plaf.UIResource;
@@ -30,4 +32,12 @@ public class GColorUIResource extends GColor implements UIResource {
super(id);
}
/**
* Returns a non-UIResource GColor for this GColorUiResource's id
* @return a non-UIResource GColor for this GColorUiResource's id
*/
public Color toGColor() {
return new GColor(getId());
}
}

View File

@@ -160,16 +160,6 @@ public class StubThemeManager extends ThemeManager {
currentValues.addIcon(newValue);
}
@Override
public GColorUIResource getGColorUiResource(String id) {
throw new UnsupportedOperationException();
}
@Override
public GIconUIResource getGIconUiResource(String id) {
throw new UnsupportedOperationException();
}
@Override
public GThemeValueMap getJavaDefaults() {
throw new UnsupportedOperationException();

View File

@@ -397,28 +397,6 @@ public abstract class ThemeManager {
throw new UnsupportedOperationException();
}
/**
* gets a UIResource version of the GColor for the given id. Using this method ensures that
* the same instance is used for a given id. This combats some poor code in some of the
* {@link LookAndFeel}s where the use == in some places to test for equals.
* @param id the id to get a GColorUIResource for
* @return a GColorUIResource for the given id
*/
public GColorUIResource getGColorUiResource(String id) {
throw new UnsupportedOperationException();
}
/**
* gets a UIResource version of the GIcon for the given id. Using this method ensures that
* the same instance is used for a given id. This combats some poor code in some of the
* {@link LookAndFeel}s where the use == in some places to test for equals.
* @param id the id to get a {@link GIconUIResource} for
* @return a GIconUIResource for the given id
*/
public GIconUIResource getGIconUiResource(String id) {
throw new UnsupportedOperationException();
}
/**
* Returns the {@link GThemeValueMap} containing all the default theme values defined by the
* current {@link LookAndFeel}.

View File

@@ -275,7 +275,7 @@ public abstract class LookAndFeelManager {
return new ThemeGrouper();
}
private void installPropertiesBackIntoUiDefaults(GThemeValueMap javaDefaults) {
protected void installPropertiesBackIntoUiDefaults(GThemeValueMap javaDefaults) {
UIDefaults defaults = UIManager.getDefaults();
GTheme theme = themeManager.getActiveTheme();

View File

@@ -104,4 +104,9 @@ public class NimbusLookAndFeelManager extends LookAndFeelManager {
// (see NimbusDefaults for key values that can be changed here)
}
@Override
protected void installPropertiesBackIntoUiDefaults(GThemeValueMap javaDefaults) {
// do nothing, this was handled when we overrode the getDefaults() method in the
// GNimubusLookAndFeel
}
}

View File

@@ -49,7 +49,7 @@ public class ApplicationThemeManagerTest {
private GTheme NIMBUS_THEME = new NimbusTheme();
private GTheme WINDOWS_THEME = new WindowsTheme();
private GTheme MAC_THEME = new MacTheme();
private ThemeManager themeManager;
private ApplicationThemeManager themeManager;
private boolean errorsExpected;
@@ -291,16 +291,6 @@ public class ApplicationThemeManagerTest {
assertTrue(color == color2);
}
@Test
public void testGetGIconUiResource() {
Icon icon = themeManager.getGIconUiResource("icon.test.foo");
assertTrue(icon instanceof UIResource);
// make sure there is only one instance for an id;
Icon gIcon2 = themeManager.getGIconUiResource("icon.test.foo");
assertTrue(icon == gIcon2);
}
@Test
public void testGetApplicationLightDefaults() {
assertEquals(defaultValues, themeManager.getApplicationLightDefaults());