Skip to content

Commit d63ad70

Browse files
committed
Feature: Look and Feel Plugin: The Look and Feel preferences now allows to adjust several controls,
e.g the SQL editor and the message panel, to dark Look and Feels. See menu File -- > Global Preferences --> tab "L & F" Note: This option replaces the previous theme choice at tab "General". The new option now does support any Look and Feel instead of only FlatLaf's Flat Dark
1 parent 3637416 commit d63ad70

File tree

12 files changed

+207
-197
lines changed

12 files changed

+207
-197
lines changed

sql12/core/doc/changes.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Not yet released, available in our GIT repository, snapshots and future releases
66

77
Enhancements:
88

9+
Look and Feel Plugin: The Look and Feel preferences now allows to adjust several controls,
10+
e.g the SQL editor and the message panel, to dark Look and Feels.
11+
See menu File -- > Global Preferences --> tab "L & F"
12+
Note: This option replaces the previous theme choice at tab "General".
13+
The new option now does support any Look and Feel instead of only FlatLaf's Flat Dark
14+
915
Look and Feel Plugin: The following dark radiance L&Fs are available:
1016
Graphite,GraphiteChalk,GraphiteAqua,GraphiteElectric,GraphiteGold,GraphiteSienna,GraphiteSunset,GraphiteGlass
1117
Raven,NightShade,Twilight,Magellan

sql12/core/src/net/sourceforge/squirrel_sql/client/preferences/GeneralPreferencesGUI.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package net.sourceforge.squirrel_sql.client.preferences;
22

33
import net.sourceforge.squirrel_sql.client.gui.db.passwordaccess.PasswordAccessPrefsCtrl;
4-
import net.sourceforge.squirrel_sql.client.preferences.themes.ThemesController;
54
import net.sourceforge.squirrel_sql.client.session.messagepanel.MessagePrefsCtrl;
65
import net.sourceforge.squirrel_sql.client.util.ApplicationFiles;
76
import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
@@ -257,11 +256,11 @@ private JPanel createAppearancePanel()
257256
++gbc.gridy;
258257
pnl.add(createValuePopupPanel(), gbc);
259258

260-
++gbc.gridy;
261-
final GridBagConstraints gbcThemes = (GridBagConstraints) gbc.clone();
262-
gbcThemes.fill = GridBagConstraints.NONE;
263-
gbcThemes.anchor = GridBagConstraints.NORTHWEST;
264-
pnl.add(new ThemesController(_messagePrefsCtrl).getPanel(), gbcThemes);
259+
//++gbc.gridy;
260+
//final GridBagConstraints gbcThemes = (GridBagConstraints) gbc.clone();
261+
//gbcThemes.fill = GridBagConstraints.NONE;
262+
//gbcThemes.anchor = GridBagConstraints.NORTHWEST;
263+
//pnl.add(new ThemesController(_messagePrefsCtrl).getPanel(), gbcThemes);
265264

266265
++gbc.gridy;
267266
final GridBagConstraints gbcMessagePanel = (GridBagConstraints) gbc.clone();

sql12/core/src/net/sourceforge/squirrel_sql/client/preferences/GlobalPreferencesSheet.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,17 @@
3636
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
3737
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
3838

39-
import javax.swing.*;
40-
import java.awt.*;
39+
import javax.swing.BorderFactory;
40+
import javax.swing.JButton;
41+
import javax.swing.JLabel;
42+
import javax.swing.JPanel;
43+
import javax.swing.JScrollPane;
44+
import javax.swing.JTabbedPane;
45+
import javax.swing.WindowConstants;
46+
import java.awt.Component;
47+
import java.awt.Dimension;
48+
import java.awt.GridBagConstraints;
49+
import java.awt.GridBagLayout;
4150
import java.awt.event.ActionEvent;
4251
import java.awt.event.ActionListener;
4352
import java.util.ArrayList;
@@ -58,9 +67,6 @@ public class GlobalPreferencesSheet extends DialogWidget
5867

5968
private final static ILogger s_log = LoggerController.createLogger(GlobalPreferencesSheet.class);
6069

61-
/**
62-
* Singleton instance of this class.
63-
*/
6470
private static GlobalPreferencesSheet s_instance;
6571

6672
/**
@@ -91,14 +97,13 @@ private GlobalPreferencesSheet(boolean toUseByPreferencesFinderOnly)
9197

9298
createGUI();
9399

94-
for (Iterator<IGlobalPreferencesPanel> it = _globalPreferencesPanels.iterator(); it.hasNext(); )
100+
for(IGlobalPreferencesPanel pnl : _globalPreferencesPanels)
95101
{
96-
IGlobalPreferencesPanel pnl = it.next();
97102
try
98103
{
99104
pnl.initialize(Main.getApplication());
100105
}
101-
catch (Throwable th)
106+
catch(Throwable th)
102107
{
103108
final String msg = s_stringMgr.getString("GlobalPreferencesSheet.error.loading", pnl.getTitle());
104109
s_log.error(msg, th);
@@ -217,9 +222,8 @@ public void dispose()
217222
Props.putInt(PREF_KEY_GLOBAL_PREFS_SHEET_WIDTH, size.width);
218223
Props.putInt(PREF_KEY_GLOBAL_PREFS_SHEET_HEIGHT, size.height);
219224

220-
for (Iterator<IGlobalPreferencesPanel> it = _globalPreferencesPanels.iterator(); it.hasNext(); )
225+
for(IGlobalPreferencesPanel pnl : _globalPreferencesPanels)
221226
{
222-
IGlobalPreferencesPanel pnl = it.next();
223227
pnl.uninitialize(Main.getApplication());
224228
}
225229

@@ -257,14 +261,13 @@ private void performOk()
257261
cursorChg.show();
258262
try
259263
{
260-
for (Iterator<IGlobalPreferencesPanel> it = _globalPreferencesPanels.iterator(); it.hasNext(); )
264+
for(IGlobalPreferencesPanel pnl : _globalPreferencesPanels)
261265
{
262-
IGlobalPreferencesPanel pnl = it.next();
263266
try
264267
{
265268
pnl.applyChanges();
266269
}
267-
catch (Throwable th)
270+
catch(Throwable th)
268271
{
269272
final String msg = s_stringMgr.getString("GlobalPreferencesSheet.error.saving", pnl.getTitle());
270273
s_log.error(msg, th);
Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
ThemesEnum.light=Light
22
ThemesEnum.dark=Dark
33

4-
ThemesPanel.chose.theme.label=Choose theme (requires restart)
5-
6-
ThemesPanel.apply=Apply...
7-
84
LAFPluginAccessor.lafPluginNeeded=Setting themes is only available with the Look and Feel Plugin.\nGet the plugin from www.squirrelsql.org. It's free.
95
10-
ThemesController.apply.dark.theme=This will make SQuirreL appear dark by changing Look&Feel to FlatLaf with theme Flat Dark.\n\
11-
All background colors of the SQL editor will be set to black and some of its foreground colors will be adjusted.\n\
12-
Please restart SQuirreL after this function was executed.\n\
13-
Do you wish to continue?
14-
15-
ThemesController.apply.light.theme=This will set SQuirreL to its standard Look&Feel and SQL editor colors.\n\
16-
Please restart SQuirreL after this function was executed.\n\
17-
Do you wish to continue?
18-
196
SyntaxPluginAccessor.syntaxPluginNeeded=Syntax Highlighting Plugin is not available.\nGet the plugin from www.squirrelsql.org. It's free.

sql12/core/src/net/sourceforge/squirrel_sql/client/preferences/themes/ThemesController.java

Lines changed: 0 additions & 75 deletions
This file was deleted.

sql12/core/src/net/sourceforge/squirrel_sql/client/preferences/themes/ThemesPanel.java

Lines changed: 0 additions & 44 deletions
This file was deleted.

sql12/core/src/net/sourceforge/squirrel_sql/client/session/messagepanel/MessagePrefsCtrl.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -141,27 +141,27 @@ public void applyChanges(SquirrelPreferences prefs)
141141
Main.getApplication().getMainFrame().getMessagePanel().applyMessagePanelStyle(prefs);
142142
}
143143

144-
public void switchToLight()
145-
{
146-
loadData(new SquirrelPreferences()); // Setting to default
147-
applyChanges(Main.getApplication().getSquirrelPreferences());
148-
}
149-
150-
public void switchToDark()
151-
{
152-
final SquirrelPreferences darkThemePrefs = new SquirrelPreferences(); // Start with default
153-
154-
darkThemePrefs.setMessagePanelMessageForeground(Color.green.getRGB());
155-
darkThemePrefs.setMessagePanelMessageBackground(Color.white.getRGB());
156-
darkThemePrefs.setMessagePanelMessageHistoryForeground(Color.black.getRGB());
157-
darkThemePrefs.setMessagePanelMessageHistoryBackground(Color.white.getRGB());
158-
159-
darkThemePrefs.setMessagePanelWarningForeground(Color.yellow.getRGB());
160-
darkThemePrefs.setMessagePanelWarningBackground(Color.white.getRGB());
161-
darkThemePrefs.setMessagePanelWarningHistoryForeground(Color.yellow.darker().darker().getRGB());
162-
darkThemePrefs.setMessagePanelWarningHistoryBackground(Color.white.getRGB());
163-
164-
loadData(darkThemePrefs);
165-
applyChanges(Main.getApplication().getSquirrelPreferences());
166-
}
144+
//public void switchToLight()
145+
//{
146+
// loadData(new SquirrelPreferences()); // Setting to default
147+
// applyChanges(Main.getApplication().getSquirrelPreferences());
148+
//}
149+
//
150+
//public void switchToDark()
151+
//{
152+
// final SquirrelPreferences darkThemePrefs = new SquirrelPreferences(); // Start with default
153+
//
154+
// darkThemePrefs.setMessagePanelMessageForeground(Color.green.getRGB());
155+
// darkThemePrefs.setMessagePanelMessageBackground(Color.white.getRGB());
156+
// darkThemePrefs.setMessagePanelMessageHistoryForeground(Color.black.getRGB());
157+
// darkThemePrefs.setMessagePanelMessageHistoryBackground(Color.white.getRGB());
158+
//
159+
// darkThemePrefs.setMessagePanelWarningForeground(Color.yellow.getRGB());
160+
// darkThemePrefs.setMessagePanelWarningBackground(Color.white.getRGB());
161+
// darkThemePrefs.setMessagePanelWarningHistoryForeground(Color.yellow.darker().darker().getRGB());
162+
// darkThemePrefs.setMessagePanelWarningHistoryBackground(Color.white.getRGB());
163+
//
164+
// loadData(darkThemePrefs);
165+
// applyChanges(Main.getApplication().getSquirrelPreferences());
166+
//}
167167
}

sql12/plugins/laf/src/net/sourceforge/squirrel_sql/plugins/laf/I18NStrings.properties

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
laf.lookAndFeel=Look and Feel:
3-
laf.lafWarning=Note: Controls may not be drawn correctly after changes in this panel until the application is restarted.
3+
laf.lafWarningRestart=Note: Any change here requires to restart SQuirreL!
44
laf.lf=L & F
55
laf.settings=Look and Feel settings
66
laf.jars=L & F jars:
@@ -31,4 +31,11 @@ laf.other=Other
3131

3232
laf.lafCriticalWarning=Also note: Some Look and Feels may cause performance or even functional problems. If you think you are seeing such problems switch to a Metal Look and Feel.
3333

34-
RadianceLookAndFeelController.radianceSkinLabel=Radiance Skin:
34+
RadianceLookAndFeelController.radianceSkinLabel=Radiance Skin:
35+
36+
LightDarkSwitchPanel.title=Light / Dark switch
37+
LightDarkSwitchPanel.description=When switching between light and dark Look and Feels you may adjust the SQL editor and other controls here.\n\
38+
Note: Recommended dark Look and Feels are FlatLaf Dark, Dracula as well as Radiance Graphite..., Raven, NightShade.
39+
40+
LightDarkSwitchPanel.light=Light
41+
LightDarkSwitchPanel.dark=Dark

sql12/plugins/laf/src/net/sourceforge/squirrel_sql/plugins/laf/LAFFontsTab.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public void applyChanges()
147147
*/
148148
public String getTitle()
149149
{
150-
return FontSelectionPanel.i18n.TAB_TITLE;
150+
return s_stringMgr.getString("laf.tabTitle");
151151
}
152152

153153
/**
@@ -157,27 +157,14 @@ public String getTitle()
157157
*/
158158
public String getHint()
159159
{
160-
return FontSelectionPanel.i18n.TAB_HINT;
160+
return s_stringMgr.getString("laf.tabHint");
161161
}
162162

163163
/**
164164
* "Fonts" panel to be displayed in the preferences dialog.
165165
*/
166166
private static final class FontSelectionPanel extends JPanel
167167
{
168-
/**
169-
* This interface defines locale specific strings. This should be
170-
* replaced with a property file.
171-
*/
172-
interface i18n
173-
{
174-
// i18n[laf.warning=Note: Changes may not take effect until the application is restarted.]
175-
String LAF_WARNING = s_stringMgr.getString("laf.warning");
176-
// i18n[laf.tabTitle=Fonts]
177-
String TAB_TITLE = s_stringMgr.getString("laf.tabTitle");
178-
// i18n[laf.tabHint=Fonts]
179-
String TAB_HINT = s_stringMgr.getString("laf.tabHint");
180-
}
181168

182169
/** Button to select font for menus. */
183170
private FontButton _menuFontBtn;
@@ -280,7 +267,7 @@ private void createUserInterface()
280267

281268
++gbc.gridy;
282269
gbc.gridwidth = GridBagConstraints.REMAINDER;
283-
add(new MultipleLineLabel(i18n.LAF_WARNING), gbc);
270+
add(new MultipleLineLabel(s_stringMgr.getString("laf.warning")), gbc);
284271
}
285272

286273
private JPanel createFontsPanel()

0 commit comments

Comments
 (0)