Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gerdwagner committed Jul 11, 2023
1 parent 25d53ad commit a696ed1
Showing 1 changed file with 8 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,17 @@
import net.sourceforge.squirrel_sql.plugins.laf.LAFPlugin;
import net.sourceforge.squirrel_sql.plugins.laf.LAFRegister;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
import java.util.*;

public class FlatLookAndFeelController extends DefaultLookAndFeelController
{
private final static ILogger s_log = LoggerController.createLogger(FlatLookAndFeelController.class);

public static final String FLAT_LAF_PLACEHOLDER_CLASS_NAME = new FlatLafPlaceholder().getClass().getName();

private static ILogger log = LoggerController.createLogger(FlatLookAndFeelController.class);

private FlatThemePreference selectedTheme;

private Map<String, Object> availableThemes;
Expand Down Expand Up @@ -64,7 +52,7 @@ public FlatLookAndFeelController(LAFPlugin plugin, LAFRegister register)
}
catch (DuplicateObjectException e)
{
log.warn("FlatTheme object already in XMLObjectCache", e);
s_log.warn("FlatTheme object already in XMLObjectCache", e);
}
}
}
Expand Down Expand Up @@ -94,18 +82,15 @@ Map<String, Object> getAvailableThemes()
}
catch (IOException e)
{
if (log.isDebugEnabled())
log.warn("Could not read: " + json.getAbsolutePath(), e);
else
log.warn("Could not read: " + json.getAbsolutePath() + "\n\t" + e);
s_log.error("Could not read: " + json.getAbsolutePath(), e);
}
}
// FlatLaf .properties
for (FileWrapper props : userExtraLAFFolder.listFiles((dir, name) -> name.endsWith(".properties")))
{
if (props.getName().equals("extralafs.properties"))
{
log.debug("FlatLaf theme: extralafs.properties skipped");
s_log.debug("FlatLaf theme: extralafs.properties skipped");
continue;
}

Expand All @@ -114,17 +99,14 @@ Map<String, Object> getAvailableThemes()
{
theme.load(in);
if (theme.getProperty("@baseTheme") == null) {
log.info("Properties file doesn't appear to be a FlatLaf theme: " + props);
s_log.info("Properties file doesn't appear to be a FlatLaf theme: " + props);
continue;
}
themes.put(props.getName().replaceFirst(".properties$", ""), theme);
}
catch (IOException e)
{
if (log.isDebugEnabled())
log.warn("Could not read: " + props.getAbsolutePath(), e);
else
log.warn("Could not read: " + props.getAbsolutePath() + "\n\t" + e);
s_log.error("Could not read: " + props.getAbsolutePath(), e);
}
}
return themes;
Expand Down Expand Up @@ -166,7 +148,7 @@ else if(theme instanceof Properties)
}
catch (Exception e)
{
log.error("Problem setting look and feel: " + theme, e);
s_log.error("Problem setting look and feel: " + theme, e);
}
}

Expand Down Expand Up @@ -201,7 +183,6 @@ public void applyTheme(String flatLafThemeName)
}


@SuppressWarnings("serial")
private static class ThemePrefsPanel extends BaseLAFPreferencesPanelComponent
{
private FlatLookAndFeelController ctrl;
Expand Down

0 comments on commit a696ed1

Please sign in to comment.