Changeset 4840 in josm for trunk/src/org/openstreetmap/josm/gui/preferences
- Timestamp:
- 2012-01-21T23:04:50+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/preferences
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/DrawingPreference.java
r4767 r4840 17 17 18 18 import org.openstreetmap.josm.Main; 19 import org.openstreetmap.josm.actions.ExpertToggleAction; 20 import org.openstreetmap.josm.actions.ExpertToggleAction.ExpertModeChangeListener; 19 21 import org.openstreetmap.josm.tools.GBC; 20 22 21 public class DrawingPreference implements PreferenceSetting {23 public class DrawingPreference implements PreferenceSetting, ExpertModeChangeListener { 22 24 23 25 public static class Factory implements PreferenceSettingFactory { … … 37 39 38 40 // Options that affect performance 41 private JLabel performanceLabel = new JLabel(tr("Options that affect drawing performance")); 39 42 private JCheckBox useHighlighting = new JCheckBox(tr("Highlight target ways and nodes")); 40 43 private JCheckBox drawHelperLine = new JCheckBox(tr("Draw rubber-band helper line")); 41 44 private JCheckBox useAntialiasing = new JCheckBox(tr("Smooth map graphics (antialiasing)")); 42 45 private JCheckBox outlineOnly = new JCheckBox(tr("Draw only outlines of areas")); 43 46 44 47 public void addGui(PreferenceTabbedPane gui) { 45 48 gui.display.setPreferredSize(new Dimension(400,600)); … … 116 119 outlineOnly.setToolTipText(tr("This option suppresses the filling of areas, overriding anything specified in the selected style.")); 117 120 118 if (Main.pref.getBoolean("expert", false)) { 119 panel.add(new JLabel(tr("Options that affect drawing performance")),GBC.eop().insets(5,10,0,0)); 120 panel.add(useAntialiasing, GBC.eop().insets(20,5,0,0)); 121 panel.add(useHighlighting, GBC.eop().insets(20,0,0,0)); 122 panel.add(outlineOnly, GBC.eol().insets(20,0,0,5)); 123 } 124 121 panel.add(performanceLabel, GBC.eop().insets(5,10,0,0)); 122 panel.add(useAntialiasing, GBC.eop().insets(20,5,0,0)); 123 panel.add(useHighlighting, GBC.eop().insets(20,0,0,0)); 124 panel.add(outlineOnly, GBC.eol().insets(20,0,0,5)); 125 125 126 panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH)); 126 127 scrollpane = new JScrollPane(panel); 127 128 scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 )); 128 129 gui.displaycontent.addTab(tr("OSM Data"), scrollpane); 130 131 ExpertToggleAction.addExpertModeChangeListener(this, true); 132 } 133 134 @Override 135 public void expertChanged(boolean isExpert) { 136 performanceLabel.setVisible(isExpert); 137 useAntialiasing.setVisible(isExpert); 138 useHighlighting.setVisible(isExpert); 139 outlineOnly.setVisible(isExpert); 129 140 } 130 141 -
trunk/src/org/openstreetmap/josm/gui/preferences/LafPreference.java
r4828 r4840 21 21 22 22 import org.openstreetmap.josm.Main; 23 import org.openstreetmap.josm.actions.ExpertToggleAction; 24 import org.openstreetmap.josm.actions.ExpertToggleAction.ExpertModeChangeListener; 23 25 import org.openstreetmap.josm.tools.GBC; 24 26 25 public class LafPreference implements PreferenceSetting {27 public class LafPreference implements PreferenceSetting, ExpertModeChangeListener { 26 28 27 29 public static class Factory implements PreferenceSettingFactory { … … 40 42 private JCheckBox showLocalizedName = new JCheckBox(tr("Show localized name in selection lists")); 41 43 private JCheckBox modeless = new JCheckBox(tr("Modeless working (Potlatch style)")); 42 private JCheckBox expert = new JCheckBox(tr("Expert mode"));43 44 private JCheckBox dynamicButtons = new JCheckBox(tr("Dynamic buttons in side menus")); 44 45 … … 95 96 96 97 panel.add(showID, GBC.eop().insets(20, 0, 0, 0)); 97 if (Main.pref.getBoolean("expert", false)) { 98 panel.add(showLocalizedName, GBC.eop().insets(20, 0, 0, 0)); 99 panel.add(modeless, GBC.eop().insets(20, 0, 0, 0)); 100 } 98 panel.add(showLocalizedName, GBC.eop().insets(20, 0, 0, 0)); 99 panel.add(modeless, GBC.eop().insets(20, 0, 0, 0)); 101 100 102 101 dynamicButtons.setToolTipText(tr("Display buttons in right side menus only when mouse is inside the element")); 103 102 dynamicButtons.setSelected(Main.pref.getBoolean("dialog.dynamic.buttons", true)); 104 103 panel.add(dynamicButtons, GBC.eop().insets(20, 0, 0, 0)); 105 106 expert.setToolTipText(tr("The expert mode shows a lot of additional settings hidden from normal user"));107 expert.setSelected(Main.pref.getBoolean("expert", false));108 panel.add(expert, GBC.eop().insets(20, 0, 0, 0));109 104 110 105 panel.add(Box.createVerticalGlue(), GBC.eol().insets(0, 20, 0, 0)); … … 117 112 scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 )); 118 113 gui.displaycontent.addTab(tr("Look and Feel"), scrollpane); 114 115 ExpertToggleAction.addExpertModeChangeListener(this, true); 116 } 117 118 @Override 119 public void expertChanged(boolean isExpert) { 120 showLocalizedName.setVisible(isExpert); 121 modeless.setVisible(isExpert); 119 122 } 120 123 … … 125 128 Main.pref.put("osm-primitives.localize-name", showLocalizedName.isSelected()); 126 129 Main.pref.put("modeless", modeless.isSelected()); 127 if(Main.pref.put("expert", expert.isSelected()))128 mod = true;129 130 Main.pref.put("dialog.dynamic.buttons", dynamicButtons.isSelected()); 130 if(Main.pref.put("laf", ((LookAndFeelInfo)lafCombo.getSelectedItem()).getClassName())) 131 mod = true; 131 mod |= Main.pref.put("laf", ((LookAndFeelInfo)lafCombo.getSelectedItem()).getClassName()); 132 132 return mod; 133 133 } -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r4586 r4840 9 9 import java.awt.Dimension; 10 10 import java.awt.FlowLayout; 11 import java.awt.GridBagLayout; 11 12 import java.awt.Insets; 12 13 import java.awt.Toolkit; 13 14 import java.awt.event.ActionEvent; 15 import java.awt.event.ActionListener; 14 16 import java.awt.event.KeyEvent; 15 17 import java.awt.event.WindowAdapter; … … 18 20 import javax.swing.AbstractAction; 19 21 import javax.swing.BorderFactory; 22 import javax.swing.JCheckBox; 20 23 import javax.swing.JComponent; 21 24 import javax.swing.JDialog; … … 24 27 import javax.swing.KeyStroke; 25 28 29 import org.openstreetmap.josm.Main; 26 30 import org.openstreetmap.josm.gui.SideButton; 27 31 import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction; 28 32 import org.openstreetmap.josm.gui.help.HelpUtil; 29 33 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.ValidationListener; 34 import org.openstreetmap.josm.tools.GBC; 30 35 import org.openstreetmap.josm.tools.ImageProvider; 31 36 import org.openstreetmap.josm.tools.WindowGeometry; … … 37 42 38 43 protected JPanel buildActionPanel() { 39 JPanel pnl = new JPanel(new FlowLayout(FlowLayout.CENTER)); 40 pnl.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 41 pnl.add(new SideButton(new OKAction())); 42 pnl.add(new SideButton(new CancelAction())); 43 pnl.add(new SideButton(new ContextSensitiveHelpAction(HelpUtil.ht("/Action/Preferences")))); 44 JPanel pnl = new JPanel(new GridBagLayout()); 45 46 JCheckBox expert = new JCheckBox(tr("Expert mode")); 47 expert.setSelected(Main.main.menu.expert.isSelected()); 48 expert.addActionListener(new ActionListener() { 49 public void actionPerformed(ActionEvent e) { 50 Main.main.menu.expert.actionPerformed(null); 51 } 52 }); 53 54 JPanel btns = new JPanel(new FlowLayout(FlowLayout.CENTER)); 55 btns.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 56 btns.add(new SideButton(new OKAction())); 57 btns.add(new SideButton(new CancelAction())); 58 btns.add(new SideButton(new ContextSensitiveHelpAction(HelpUtil.ht("/Action/Preferences")))); 59 pnl.add(expert, GBC.std().insets(5,0,0,0)); 60 pnl.add(btns, GBC.std().fill(GBC.HORIZONTAL)); 44 61 return pnl; 45 62 } -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r4634 r4840 28 28 29 29 import org.openstreetmap.josm.Main; 30 import org.openstreetmap.josm.actions.ExpertToggleAction; 31 import org.openstreetmap.josm.actions.ExpertToggleAction.ExpertModeChangeListener; 30 32 import org.openstreetmap.josm.gui.preferences.advanced.AdvancedPreference; 31 33 import org.openstreetmap.josm.plugins.PluginDownloadTask; … … 42 44 * @author imi 43 45 */ 44 public class PreferenceTabbedPane extends JTabbedPane implements MouseWheelListener {46 public class PreferenceTabbedPane extends JTabbedPane implements MouseWheelListener, ExpertModeChangeListener { 45 47 /** 46 48 * Allows PreferenceSettings to do validation of entered values when ok was pressed. … … 56 58 } 57 59 60 private class TabData { 61 public String icon; 62 public JComponent tab; 63 public String toolTip; 64 public boolean isExpert; 65 } 66 58 67 // all created tabs 59 private final Map<String,Component> tabs = new HashMap<String,Component>();68 private final List<TabData> tabs = new ArrayList<TabData>(); 60 69 private final static Collection<PreferenceSettingFactory> settingsFactory = new LinkedList<PreferenceSettingFactory>(); 61 70 private final List<PreferenceSetting> settings = new ArrayList<PreferenceSetting>(); … … 94 103 public JPanel createPreferenceTab(String icon, String title, String desc) { 95 104 return createPreferenceTab(icon, title, desc, false); 105 } 106 107 public JPanel createPreferenceTab(String icon, String title, String desc, boolean inScrollPane) { 108 return createPreferenceTab(icon, title, desc, inScrollPane, false); 96 109 } 97 110 … … 107 120 * @return The created panel ready to add other controls. 108 121 */ 109 public JPanel createPreferenceTab(String icon, String title, String desc, boolean inScrollPane ) {122 public JPanel createPreferenceTab(String icon, String title, String desc, boolean inScrollPane, boolean isExpert) { 110 123 JPanel p = new JPanel(new GridBagLayout()); 111 124 p.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); … … 121 134 tab = sp; 122 135 } 123 tabs.put(icon,tab); 124 addTab(null, ImageProvider.get("preferences", icon), tab); 125 setToolTipTextAt(getTabCount()-1, "<html>"+desc+"</html>"); 136 TabData data = new TabData(); 137 data.icon = icon; 138 data.tab = tab; 139 data.isExpert = isExpert; 140 data.toolTip = "<html>"+desc+"</html>"; 141 tabs.add(data); 126 142 return p; 127 143 } 128 144 129 145 public void selectTabByName(String name) { 130 Component c = tabs.get(name); 131 if (c!=null) setSelectedComponent(c); 146 for (TabData data : tabs) { 147 if (data.icon.equals(name)) { 148 Component c = data.tab; 149 if (c != null) { 150 setSelectedComponent(c); 151 } 152 return; 153 } 154 } 132 155 } 133 156 … … 227 250 super(JTabbedPane.LEFT, JTabbedPane.SCROLL_TAB_LAYOUT); 228 251 super.addMouseWheelListener(this); 252 ExpertToggleAction.addExpertModeChangeListener(this); 229 253 } 230 254 … … 250 274 } 251 275 } 276 addGUITabs(false); 277 } 278 279 private void addGUITabs(boolean clear) { 280 boolean expert = Main.main.menu.expert.isSelected(); 281 Component sel = getSelectedComponent(); 282 if (clear) { 283 removeAll(); 284 } 285 for (TabData data : tabs) { 286 if (expert || !data.isExpert) { 287 addTab(null, ImageProvider.get("preferences", data.icon), data.tab, data.toolTip); 288 } 289 } 290 try { 291 setSelectedComponent(sel); 292 } catch (IllegalArgumentException e) {} 293 } 294 295 @Override 296 public void expertChanged(boolean isExpert) { 297 addGUITabs(true); 252 298 } 253 299 … … 288 334 PluginHandler.getPreferenceSetting(settingsFactory); 289 335 290 if(Main.pref.getBoolean("expert", false)) { 291 // always the last: advanced tab 292 settingsFactory.add(new AdvancedPreference.Factory()); 293 } 336 // always the last: advanced tab 337 settingsFactory.add(new AdvancedPreference.Factory()); 294 338 } 295 339 -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java
r4634 r4840 115 115 public void addGui(final PreferenceTabbedPane gui) { 116 116 JPanel p = gui.createPreferenceTab("advanced", tr("Advanced Preferences"), 117 tr("Setting Preference entries directly. Use with caution!"), false );117 tr("Setting Preference entries directly. Use with caution!"), false, true); 118 118 119 119 txtFilter = new JTextField();
Note:
See TracChangeset
for help on using the changeset viewer.