Skip to content

Commit 3637416

Browse files
committed
Bug fix: Look and Feel Plugin: Cleaned up L&F Preferences UI.
1 parent 71722d5 commit 3637416

File tree

10 files changed

+140
-196
lines changed

10 files changed

+140
-196
lines changed

sql12/core/doc/changes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ Table cell data popup now offers find, Xml/Json-reformatting and export function
122122

123123
Bug fixes:
124124

125+
Look and Feel Plugin: Cleaned up L&F Preferences UI.
126+
125127
#1532 MS Excel export: Fixed NoSuchMethodError
126128

127129
SQL result tab header marks:

sql12/core/src/net/sourceforge/squirrel_sql/fw/gui/OutputLabel.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
* License along with this library; if not, write to the Free Software
1818
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919
*/
20-
import java.awt.Dimension;
2120

2221
import javax.swing.JLabel;
2322
/**
@@ -28,17 +27,6 @@
2827
*/
2928
public class OutputLabel extends JLabel
3029
{
31-
/** Default preferred width. */
32-
public static final int PREF_WIDTH = 200;
33-
34-
/**
35-
* Default ctor.
36-
*/
37-
public OutputLabel()
38-
{
39-
super();
40-
commonCtor();
41-
}
4230

4331
/**
4432
* Ctor specifying text.
@@ -48,7 +36,6 @@ public OutputLabel()
4836
public OutputLabel(String text)
4937
{
5038
super(text);
51-
commonCtor();
5239
setToolTipText(text);
5340
}
5441

@@ -62,14 +49,4 @@ public void setText(String text)
6249
super.setText(text);
6350
setToolTipText(text);
6451
}
65-
66-
/**
67-
* Common ctor code.
68-
*/
69-
private void commonCtor()
70-
{
71-
Dimension ps = getPreferredSize();
72-
ps.width = PREF_WIDTH;
73-
setPreferredSize(ps);
74-
}
7552
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,4 @@ 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-
SubstanceLookAndFeelController.substanceSkinLabel=Substance Skin:RadianceLookAndFeelController.radianceSkinLabel=Radiance Skin:
35-
36-
RadianceLookAndFeelController.radianceSkinLabel=Radiance Skin:RadianceLookAndFeelController.radianceSkinLabel=Radiance Skin:
34+
RadianceLookAndFeelController.radianceSkinLabel=Radiance Skin:

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

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.sourceforge.squirrel_sql.plugins.laf;
22

3+
import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
34
import net.sourceforge.squirrel_sql.fw.gui.MultipleLineLabel;
45
import net.sourceforge.squirrel_sql.fw.util.StringManager;
56
import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
@@ -10,7 +11,7 @@
1011
import javax.swing.JCheckBox;
1112
import javax.swing.JLabel;
1213
import javax.swing.JPanel;
13-
import javax.swing.SwingConstants;
14+
import javax.swing.JTextField;
1415
import javax.swing.UIManager;
1516
import java.awt.Color;
1617
import java.awt.GridBagConstraints;
@@ -29,29 +30,6 @@ final class LAFPreferencesPanel extends JPanel
2930

3031
private static ILogger s_log = LoggerController.createLogger(LAFPreferencesPanel.class);
3132

32-
/**
33-
* This interface defines locale specific strings. This should be
34-
* replaced with a property file.
35-
*/
36-
interface LAFPreferencesPanelI18n
37-
{
38-
StringManager s_stringMgr = StringManagerFactory.getStringManager(LAFPreferencesPanelI18n.class);
39-
40-
// i18n[laf.lookAndFeel=Look and Feel:]
41-
String LOOK_AND_FEEL = s_stringMgr.getString("laf.lookAndFeel");
42-
// i18n[laf.lafWarning=Note: Controls may not be drawn correctly after changes in this panel until the application is restarted.]
43-
String LAF_WARNING = s_stringMgr.getString("laf.lafWarning");
44-
// i18n[laf.lf=L & F]
45-
String TAB_TITLE = s_stringMgr.getString("laf.lf");
46-
// i18n[laf.settings=Look and Feel settings]
47-
String TAB_HINT = s_stringMgr.getString("laf.settings");
48-
// i18n[laf.jars=L & F jars:]
49-
String LAF_LOC = s_stringMgr.getString("laf.jars");
50-
// i18n[laf.lafPerformanceWarning=Also note: Some Look and Feels may cause performance problems.
51-
// If you think your selected Look and Feel slows down SQuirreL switch to a Metal or Plastic Look and Feel.]
52-
String LAF_CRITICAL_WARNING = s_stringMgr.getString("laf.lafCriticalWarning");
53-
}
54-
5533
private LookAndFeelComboBox _lafCmb = new LookAndFeelComboBox();
5634
private JCheckBox _allowSetBorder = new JCheckBox(s_stringMgr.getString("laf.allowsetborder"));
5735

@@ -77,8 +55,6 @@ interface LAFPreferencesPanelI18n
7755
*/
7856
private BaseLAFPreferencesPanelComponent _curLAFConfigComp;
7957

80-
81-
8258
LAFPreferencesPanel(LAFPlugin plugin, LAFRegister lafRegister)
8359
{
8460
super(new GridBagLayout());
@@ -146,10 +122,10 @@ private void createUserInterface()
146122
add(_lafPnl, gbc);
147123

148124
gbc = new GridBagConstraints(0,1,1,1,0,0,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4),0,0);
149-
add(new MultipleLineLabel(LAFPreferencesPanelI18n.LAF_WARNING), gbc);
125+
add(new MultipleLineLabel(s_stringMgr.getString("laf.lafWarning")), gbc);
150126

151127
gbc = new GridBagConstraints(0,2,1,1,0,0,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4),0,0);
152-
MultipleLineLabel enforedWarningLabel = new MultipleLineLabel(LAFPreferencesPanelI18n.LAF_CRITICAL_WARNING);
128+
MultipleLineLabel enforedWarningLabel = new MultipleLineLabel(s_stringMgr.getString("laf.lafCriticalWarning"));
153129
enforedWarningLabel.setForeground(Color.red);
154130
add(enforedWarningLabel, gbc);
155131

@@ -165,22 +141,26 @@ private JPanel createLookAndFeelPanel()
165141
GridBagConstraints gbc = new GridBagConstraints();
166142

167143
gbc = new GridBagConstraints(0,0,1,1,0,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 4, 4, 4),0,0);
168-
ret.add(new JLabel(LAFPreferencesPanelI18n.LOOK_AND_FEEL, SwingConstants.RIGHT), gbc);
144+
ret.add(new JLabel(s_stringMgr.getString("laf.lookAndFeel")), gbc);
169145

170146
gbc = new GridBagConstraints(1,0,1,1,0,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 4, 4, 4),0,0);
171147
ret.add(_lafCmb, gbc);
172148

173149

174150
gbc = new GridBagConstraints(0,1,1,1,0,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 4, 4, 4),0,0);
175-
ret.add(new JLabel(LAFPreferencesPanelI18n.LAF_LOC, SwingConstants.RIGHT), gbc);
151+
ret.add(new JLabel(s_stringMgr.getString("laf.jars")), gbc);
176152

177-
gbc = new GridBagConstraints(1,1,1,1,1,0,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4),0,0);
178-
ret.add(new MultipleLineLabel(_plugin.getLookAndFeelFolder().getAbsolutePath()), gbc);
153+
gbc = new GridBagConstraints(1,1,1,1,0,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 4, 4, 4),0,0);
154+
ret.add(GUIUtils.styleTextFieldToCopyableLabel(new JTextField(_plugin.getLookAndFeelFolder().getAbsolutePath())), gbc);
179155

180156

181-
gbc = new GridBagConstraints(0,2,2,1,0,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 4, 4),0,0);
157+
gbc = new GridBagConstraints(0,2,GridBagConstraints.REMAINDER, 1,0,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 4, 4),0,0);
158+
//_configHolderPnl.setBorder(BorderFactory.createLineBorder(Color.red));
182159
ret.add(_configHolderPnl, gbc);
183160

161+
gbc = new GridBagConstraints(1,3,GridBagConstraints.REMAINDER, 1,1,1,GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0),0,0);
162+
ret.add(new JPanel(), gbc);
163+
184164
return ret;
185165
}
186166

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void applyChanges()
122122
*/
123123
public String getTitle()
124124
{
125-
return LAFPreferencesPanel.LAFPreferencesPanelI18n.TAB_TITLE;
125+
return s_stringMgr.getString("laf.lf");
126126
}
127127

128128
/**
@@ -132,7 +132,6 @@ public String getTitle()
132132
*/
133133
public String getHint()
134134
{
135-
return LAFPreferencesPanel.LAFPreferencesPanelI18n.TAB_HINT;
135+
return s_stringMgr.getString("laf.settings");
136136
}
137-
138137
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ public BaseLAFPreferencesPanelComponent getPreferencesComponent() {
142142

143143
private static final class RadianceSkinPrefsPanel extends BaseLAFPreferencesPanelComponent {
144144

145-
interface SkinPrefsPanelI18n {
146-
// i18n[RadianceLookAndFeelController.radianceSkinLabel=Radiance Skin:]
147-
String THEME_PACK = s_stringMgr.getString("RadianceLookAndFeelController.radianceSkinLabel");
148-
}
149-
150145
private RadianceLookAndFeelController _ctrl;
151146

152147
private JComboBox _skinCmb = new JComboBox();
@@ -165,7 +160,7 @@ private void createUserInterface() {
165160

166161
gbc.gridx = 0;
167162
gbc.gridy = 0;
168-
add(new JLabel(SkinPrefsPanelI18n.THEME_PACK, SwingConstants.RIGHT), gbc);
163+
add(new JLabel(s_stringMgr.getString("RadianceLookAndFeelController.radianceSkinLabel"), SwingConstants.RIGHT), gbc);
169164

170165
++gbc.gridx;
171166
add(_skinCmb, gbc);

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

Lines changed: 3 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@
1919
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2020
*/
2121

22-
import net.sourceforge.squirrel_sql.fw.gui.DirectoryListComboBox;
23-
import net.sourceforge.squirrel_sql.fw.gui.OutputLabel;
24-
import net.sourceforge.squirrel_sql.fw.id.IHasIdentifier;
25-
import net.sourceforge.squirrel_sql.fw.id.IIdentifier;
26-
import net.sourceforge.squirrel_sql.fw.id.IntegerIdentifier;
2722
import net.sourceforge.squirrel_sql.fw.util.DuplicateObjectException;
28-
import net.sourceforge.squirrel_sql.fw.util.FileExtensionFilter;
2923
import net.sourceforge.squirrel_sql.fw.util.FileWrapper;
3024
import net.sourceforge.squirrel_sql.fw.util.FileWrapperFactory;
3125
import net.sourceforge.squirrel_sql.fw.util.FileWrapperFactoryImpl;
@@ -36,12 +30,7 @@
3630
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
3731
import net.sourceforge.squirrel_sql.fw.xml.XMLObjectCache;
3832

39-
import javax.swing.JLabel;
4033
import javax.swing.LookAndFeel;
41-
import javax.swing.SwingConstants;
42-
import java.awt.GridBagConstraints;
43-
import java.awt.GridBagLayout;
44-
import java.awt.Insets;
4534
import java.io.File;
4635
import java.io.IOException;
4736
import java.lang.reflect.Method;
@@ -54,8 +43,7 @@
5443
*/
5544
public class SkinLookAndFeelController extends DefaultLookAndFeelController
5645
{
57-
private static final StringManager s_stringMgr =
58-
StringManagerFactory.getStringManager(SkinLookAndFeelController.class);
46+
private static final StringManager s_stringMgr = StringManagerFactory.getStringManager(SkinLookAndFeelController.class);
5947

6048
/** Logger for this class. */
6149
private static final ILogger s_log = LoggerController.createLogger(SkinLookAndFeelController.class);
@@ -170,120 +158,8 @@ public void setFileWrapperFactory(FileWrapperFactory fileWrapperFactory)
170158
this.fileWrapperFactory = fileWrapperFactory;
171159
}
172160

173-
private static final class SkinPrefsPanel extends BaseLAFPreferencesPanelComponent
161+
public SkinPreferences getSkinPreferences()
174162
{
175-
176-
/**
177-
* This interface defines locale specific strings. This should be replaced with a property file.
178-
*/
179-
interface SkinPrefsPanelI18n
180-
{
181-
// i18n[laf.skinThemPack=Theme Pack:]
182-
String THEME_PACK = s_stringMgr.getString("laf.skinThemPack");
183-
184-
// i18n[laf.skinThemePackDir=Theme Pack Directory:]
185-
String THEMEPACK_LOC = s_stringMgr.getString("laf.skinThemePackDir");
186-
}
187-
188-
private SkinLookAndFeelController _ctrl;
189-
190-
private DirectoryListComboBox _themePackCmb = new DirectoryListComboBox();
191-
192-
SkinPrefsPanel(SkinLookAndFeelController ctrl)
193-
{
194-
super(new GridBagLayout());
195-
_ctrl = ctrl;
196-
createUserInterface();
197-
}
198-
199-
private void createUserInterface()
200-
{
201-
final GridBagConstraints gbc = new GridBagConstraints();
202-
gbc.anchor = GridBagConstraints.WEST;
203-
gbc.fill = GridBagConstraints.HORIZONTAL;
204-
gbc.insets = new Insets(4, 4, 4, 4);
205-
206-
gbc.gridx = 0;
207-
gbc.gridy = 0;
208-
add(new JLabel(SkinPrefsPanelI18n.THEME_PACK, SwingConstants.RIGHT), gbc);
209-
210-
++gbc.gridx;
211-
add(_themePackCmb, gbc);
212-
213-
gbc.gridx = 0;
214-
++gbc.gridy;
215-
add(new JLabel(SkinPrefsPanelI18n.THEMEPACK_LOC, SwingConstants.RIGHT), gbc);
216-
217-
++gbc.gridx;
218-
final String themePackDir = _ctrl._prefs.getThemePackDirectory();
219-
add(new OutputLabel(themePackDir), gbc);
220-
}
221-
222-
/**
223-
* @see BaseLAFPreferencesPanelComponent#loadPreferencesPanel()
224-
*/
225-
public void loadPreferencesPanel()
226-
{
227-
super.loadPreferencesPanel();
228-
final String themePackDir = _ctrl._prefs.getThemePackDirectory();
229-
// i18n[laf.jarZip=JAR/Zip files]
230-
final FileExtensionFilter filter = new FileExtensionFilter(s_stringMgr.getString("laf.jarZip"), new String[] { ".jar", ".zip" });
231-
_themePackCmb.load(new File(themePackDir), filter);
232-
_themePackCmb.setSelectedItem(_ctrl._prefs.getThemePackName());
233-
if (_themePackCmb.getSelectedIndex() == -1 && _themePackCmb.getModel().getSize() > 0)
234-
{
235-
_themePackCmb.setSelectedIndex(0);
236-
}
237-
}
238-
239-
/**
240-
* @see BaseLAFPreferencesPanelComponent#applyChanges()
241-
*/
242-
public boolean applyChanges()
243-
{
244-
super.applyChanges();
245-
_ctrl._prefs.setThemePackName((String) _themePackCmb.getSelectedItem());
246-
247-
// Force the LAF to be set even if Skin is the current one. This
248-
// allows a change in theme to take affect.
249-
return true;
250-
}
251-
}
252-
253-
public static final class SkinPreferences implements IHasIdentifier
254-
{
255-
private String _themePackDir;
256-
257-
private String _themePackName;
258-
259-
private IntegerIdentifier _id = new IntegerIdentifier(1);
260-
261-
public String getThemePackDirectory()
262-
{
263-
return _themePackDir;
264-
}
265-
266-
public void setThemePackDirectory(String value)
267-
{
268-
_themePackDir = value;
269-
}
270-
271-
public String getThemePackName()
272-
{
273-
return _themePackName;
274-
}
275-
276-
public void setThemePackName(String value)
277-
{
278-
_themePackName = value;
279-
}
280-
281-
/**
282-
* @return The unique identifier for this object.
283-
*/
284-
public IIdentifier getIdentifier()
285-
{
286-
return _id;
287-
}
163+
return _prefs;
288164
}
289165
}

0 commit comments

Comments
 (0)