X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fsettings%2FSetDisplaySettings.java;h=fd15a5097399cacd20ff8640954746889c045504;hp=63286c5e86dcddce24736afe427a4bfc410bcb97;hb=HEAD;hpb=2302358503c38817e19f6e529f6c9e530aac0e86 diff --git a/src/tim/prune/function/settings/SetDisplaySettings.java b/src/tim/prune/function/settings/SetDisplaySettings.java index 63286c5..0a9efd9 100644 --- a/src/tim/prune/function/settings/SetDisplaySettings.java +++ b/src/tim/prune/function/settings/SetDisplaySettings.java @@ -93,8 +93,12 @@ public class SetDisplaySettings extends GenericFunction private JCheckBox _antialiasCheckbox = null; private JComboBox _wpIconCombobox = null; private JRadioButton[] _sizeRadioButtons = null; + private JRadioButton[] _windowStyleRadios = null; private JButton _okButton = null; + private static final String STYLEKEY_NIMBUS = "javax.swing.plaf.nimbus.NimbusLookAndFeel"; + private static final String STYLEKEY_GTK = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; + /** * Constructor @@ -176,6 +180,28 @@ public class SetDisplaySettings extends GenericFunction waypointsPanel.setAlignmentX(Component.CENTER_ALIGNMENT); midPanel.add(waypointsPanel); + // Panel for window style + JPanel windowStylePanel = new JPanel(); + windowStylePanel.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), BorderFactory.createEmptyBorder(3, 3, 3, 3)) + ); + windowStylePanel.setLayout(new FlowLayout(FlowLayout.CENTER)); + windowStylePanel.add(new JLabel(I18nManager.getText("dialog.displaysettings.windowstyle"))); + windowStylePanel.add(Box.createHorizontalStrut(10)); + ButtonGroup styleGroup = new ButtonGroup(); + final String[] styleKeys = {"default", "nimbus", "gtk"}; + _windowStyleRadios = new JRadioButton[3]; + for (int i=0; i<3; i++) + { + _windowStyleRadios[i] = new JRadioButton( + I18nManager.getText("dialog.displaysettings.windowstyle." + styleKeys[i])); + styleGroup.add(_windowStyleRadios[i]); + if (i != 2 || platformHasPlaf(STYLEKEY_GTK)) + { + windowStylePanel.add(_windowStyleRadios[i]); + } + } + midPanel.add(windowStylePanel); mainPanel.add(midPanel, BorderLayout.CENTER); // button panel at bottom @@ -201,6 +227,19 @@ public class SetDisplaySettings extends GenericFunction return mainPanel; } + /** + * @return true if the specified style name is available on this platform + */ + private static boolean platformHasPlaf(String styleName) + { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) + { + if (info.getClassName().equals(styleName)) { + return true; + } + } + return false; + } /** * Show window @@ -221,6 +260,7 @@ public class SetDisplaySettings extends GenericFunction _antialiasCheckbox.setSelected(Config.getConfigBoolean(Config.KEY_ANTIALIAS)); _wpIconCombobox.setSelectedIndex(Config.getConfigInt(Config.KEY_WAYPOINT_ICONS)); selectIconSizeRadio(Config.getConfigInt(Config.KEY_WAYPOINT_ICON_SIZE)); + selectWindowStyleRadio(Config.getConfigString(Config.KEY_WINDOW_STYLE)); _dialog.setVisible(true); } @@ -240,6 +280,24 @@ public class SetDisplaySettings extends GenericFunction } } + /** + * Select the corresponding radio button according to the selected style + * @param inValue style string saved in Config + */ + private void selectWindowStyleRadio(String inValue) + { + int selectedRadio = 0; + if (inValue != null && inValue.equals(STYLEKEY_NIMBUS)) + { + selectedRadio = 1; + } + else if (inValue != null && inValue.equals(STYLEKEY_GTK) && _windowStyleRadios[2] != null) + { + selectedRadio = 2; + } + _windowStyleRadios[selectedRadio].setSelected(true); + } + /** * @return numeric value of selected icon size according to radio buttons */ @@ -255,6 +313,20 @@ public class SetDisplaySettings extends GenericFunction return 1; // default is medium } + /** + * @return the style string according to the selected radio button + */ + private String getSelectedStyleString() + { + if (_windowStyleRadios[1].isSelected()) { + return STYLEKEY_NIMBUS; + } + if (_windowStyleRadios[2] != null && _windowStyleRadios[2].isSelected()) { + return STYLEKEY_GTK; + } + return null; + } + /** * Save settings and close */ @@ -267,6 +339,7 @@ public class SetDisplaySettings extends GenericFunction Config.setConfigBoolean(Config.KEY_ANTIALIAS, _antialiasCheckbox.isSelected()); Config.setConfigInt(Config.KEY_WAYPOINT_ICONS, _wpIconCombobox.getSelectedIndex()); Config.setConfigInt(Config.KEY_WAYPOINT_ICON_SIZE, getSelectedIconSize()); + Config.setConfigString(Config.KEY_WINDOW_STYLE, getSelectedStyleString()); // refresh display UpdateMessageBroker.informSubscribers(DataSubscriber.MAPSERVER_CHANGED); _dialog.dispose();