Changeset 2745 in josm for trunk/src/org
- Timestamp:
- 2010-01-06T20:34:54+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/preferences
- Files:
-
- 10 added
- 2 deleted
- 15 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/AdvancedPreference.java
r2512 r2745 46 46 protected JTextField txtFilter; 47 47 48 public void addGui(final Preference Dialoggui) {48 public void addGui(final PreferenceTabbedPane gui) { 49 49 JPanel p = gui.createPreferenceTab("advanced", tr("Advanced Preferences"), 50 50 tr("Setting Preference entries directly. Use with caution!"), false); … … 215 215 } 216 216 217 private void editPreference(final Preference Dialoggui, final JTable list) {217 private void editPreference(final PreferenceTabbedPane gui, final JTable list) { 218 218 if (list.getSelectedRowCount() != 1) { 219 219 JOptionPane.showMessageDialog( … … 240 240 } 241 241 242 private void removePreference(final Preference Dialoggui, final JTable list) {242 private void removePreference(final PreferenceTabbedPane gui, final JTable list) { 243 243 if (list.getSelectedRowCount() == 0) { 244 244 JOptionPane.showMessageDialog( … … 256 256 } 257 257 258 private void addPreference(final Preference Dialoggui) {258 private void addPreference(final PreferenceTabbedPane gui) { 259 259 JPanel p = new JPanel(new GridBagLayout()); 260 260 p.add(new JLabel(tr("Key")), GBC.std().insets(0,0,5,0)); -
trunk/src/org/openstreetmap/josm/gui/preferences/AudioPreference.java
r1742 r2745 48 48 private JTextField audioCalibration = new JTextField(8); 49 49 50 public void addGui(Preference Dialoggui) {50 public void addGui(PreferenceTabbedPane gui) { 51 51 // audioMenuVisible 52 52 audioMenuVisible.setSelected(! Main.pref.getBoolean("audio.menuinvisible")); -
trunk/src/org/openstreetmap/josm/gui/preferences/ColorPreference.java
r2675 r2745 146 146 } 147 147 148 public void addGui(final Preference Dialoggui) {148 public void addGui(final PreferenceTabbedPane gui) { 149 149 fixColorPrefixes(); 150 150 setColorModel(Main.pref.getAllColors()); -
trunk/src/org/openstreetmap/josm/gui/preferences/DrawingPreference.java
r2105 r2745 60 60 private JCheckBox useAntialiasing = new JCheckBox(tr("Smooth map graphics (antialiasing)")); 61 61 62 public void addGui(Preference Dialoggui) {62 public void addGui(PreferenceTabbedPane gui) { 63 63 gui.display.setPreferredSize(new Dimension(400,600)); 64 64 JPanel panel = new JPanel(new GridBagLayout()); -
trunk/src/org/openstreetmap/josm/gui/preferences/LafPreference.java
r2428 r2745 42 42 private JCheckBox modeless = new JCheckBox(tr("Modeless working (Potlatch style)")); 43 43 44 public void addGui(Preference Dialoggui) {44 public void addGui(PreferenceTabbedPane gui) { 45 45 lafCombo = new JComboBox(UIManager.getInstalledLookAndFeels()); 46 46 -
trunk/src/org/openstreetmap/josm/gui/preferences/LanguagePreference.java
r2711 r2745 48 48 private boolean translationsLoaded = false; 49 49 50 public void addGui(final Preference Dialoggui) {50 public void addGui(final PreferenceTabbedPane gui) { 51 51 model = new LanguageComboBoxModel(); 52 52 langCombo = new JComboBox(model); -
trunk/src/org/openstreetmap/josm/gui/preferences/MapPaintPreference.java
r2400 r2745 32 32 } 33 33 34 public void addGui(final Preference Dialoggui) {34 public void addGui(final PreferenceTabbedPane gui) { 35 35 enableDefault = new JCheckBox(tr("Enable built-in defaults"), 36 36 Main.pref.getBoolean("mappaint.style.enable-defaults", true)); -
trunk/src/org/openstreetmap/josm/gui/preferences/PluginPreference.java
r2152 r2745 40 40 private JPanel plugin; 41 41 private JPanel pluginPanel = new NoHorizontalScrollPanel(new GridBagLayout()); 42 private Preference Dialoggui;42 private PreferenceTabbedPane gui; 43 43 private JScrollPane pluginPane; 44 44 private PluginSelection selection = new PluginSelection(); 45 45 private JTextField txtFilter; 46 46 47 public void addGui(final Preference Dialoggui) {47 public void addGui(final PreferenceTabbedPane gui) { 48 48 this.gui = gui; 49 49 plugin = gui.createPreferenceTab("plugin", tr("Plugins"), tr("Configure available plugins."), false); -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r2641 r2745 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.preferences; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Font; 7 import java.awt.GridBagLayout; 8 import java.awt.ScrollPane; 9 import java.awt.event.MouseWheelEvent; 10 import java.awt.event.MouseWheelListener; 11 import java.util.ArrayList; 12 import java.util.Collection; 13 import java.util.Iterator; 14 import java.util.LinkedList; 15 import java.util.List; 16 import java.util.logging.Logger; 6 import java.awt.BorderLayout; 7 import java.awt.Component; 8 import java.awt.Container; 9 import java.awt.Dimension; 10 import java.awt.FlowLayout; 11 import java.awt.event.ActionEvent; 12 import java.awt.event.KeyEvent; 13 import java.awt.event.WindowAdapter; 14 import java.awt.event.WindowEvent; 17 15 16 import javax.swing.AbstractAction; 18 17 import javax.swing.BorderFactory; 19 18 import javax.swing.JComponent; 20 import javax.swing.J Label;19 import javax.swing.JDialog; 21 20 import javax.swing.JOptionPane; 22 21 import javax.swing.JPanel; 23 import javax.swing.JScrollPane; 24 import javax.swing.JTabbedPane; 22 import javax.swing.KeyStroke; 25 23 26 import org.openstreetmap.josm.Main; 27 import org.openstreetmap.josm.plugins.PluginHandler; 28 import org.openstreetmap.josm.tools.BugReportExceptionHandler; 29 import org.openstreetmap.josm.tools.GBC; 30 import org.openstreetmap.josm.tools.I18n; 24 import org.openstreetmap.josm.gui.SideButton; 25 import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction; 26 import org.openstreetmap.josm.gui.help.HelpUtil; 31 27 import org.openstreetmap.josm.tools.ImageProvider; 28 import org.openstreetmap.josm.tools.WindowGeometry; 32 29 33 /** 34 * The preference settings. 35 * 36 * @author imi 37 */ 38 public class PreferenceDialog extends JTabbedPane implements MouseWheelListener { 39 static private final Logger logger = Logger.getLogger(PreferenceDialog.class.getName()); 30 public class PreferenceDialog extends JDialog { 40 31 41 private final static Collection<PreferenceSettingFactory> settingsFactory = new LinkedList<PreferenceSettingFactory>();42 private final List<PreferenceSetting> settings = new ArrayList<PreferenceSetting>();32 private PreferenceTabbedPane tpPreferences; 33 private boolean canceled; 43 34 44 // some common tabs 45 public final JPanel display = createPreferenceTab("display", tr("Display Settings"), tr("Various settings that influence the visual representation of the whole program.")); 46 public final JPanel connection = createPreferenceTab("connection", I18n.tr("Connection Settings"), I18n.tr("Connection Settings for the OSM server."),false); 47 public final JPanel map = createPreferenceTab("map", I18n.tr("Map Settings"), I18n.tr("Settings for the map projection and data interpretation.")); 48 public final JPanel audio = createPreferenceTab("audio", I18n.tr("Audio Settings"), I18n.tr("Settings for the audio player and audio markers.")); 49 50 public final javax.swing.JTabbedPane displaycontent = new javax.swing.JTabbedPane(); 51 public final javax.swing.JTabbedPane mapcontent = new javax.swing.JTabbedPane(); 52 53 /** 54 * Construct a JPanel for the preference settings. Layout is GridBagLayout 55 * and a centered title label and the description are added. The panel 56 * will be shown inside a {@link ScrollPane} 57 * @param icon The name of the icon. 58 * @param title The title of this preference tab. 59 * @param desc A description in one sentence for this tab. Will be displayed 60 * italic under the title. 61 * @return The created panel ready to add other controls. 62 */ 63 public JPanel createPreferenceTab(String icon, String title, String desc) { 64 return createPreferenceTab(icon, title, desc, false); 35 protected JPanel buildActionPanel() { 36 JPanel pnl = new JPanel(new FlowLayout(FlowLayout.CENTER)); 37 pnl.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 38 pnl.add(new SideButton(new OKAction())); 39 pnl.add(new SideButton(new CancelAction())); 40 pnl.add(new SideButton(new ContextSensitiveHelpAction(HelpUtil.ht("/Action/Preferences")))); 41 return pnl; 65 42 } 66 43 67 /** 68 * Construct a JPanel for the preference settings. Layout is GridBagLayout 69 * and a centered title label and the description are added. 70 * @param icon The name of the icon. 71 * @param title The title of this preference tab. 72 * @param desc A description in one sentence for this tab. Will be displayed 73 * italic under the title. 74 * @param inScrollPane if <code>true</code> the added tab will show scroll bars 75 * if the panel content is larger than the available space 76 * @return The created panel ready to add other controls. 77 */ 78 public JPanel createPreferenceTab(String icon, String title, String desc, boolean inScrollPane) { 79 JPanel p = new JPanel(new GridBagLayout()); 80 p.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 81 p.add(new JLabel(title), GBC.eol().anchor(GBC.CENTER).insets(0,5,0,10)); 44 protected void build() { 45 Container c = getContentPane(); 46 c.setLayout(new BorderLayout()); 47 c.add(tpPreferences = new PreferenceTabbedPane(), BorderLayout.CENTER); 48 tpPreferences.buildGui(); 49 tpPreferences.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 50 c.add(buildActionPanel(), BorderLayout.SOUTH); 82 51 83 JLabel descLabel = new JLabel("<html>"+desc+"</html>"); 84 descLabel.setFont(descLabel.getFont().deriveFont(Font.ITALIC)); 85 p.add(descLabel, GBC.eol().insets(5,0,5,20).fill(GBC.HORIZONTAL)); 52 addWindowListener(new WindowEventHandler()); 86 53 87 JComponent tab = p; 88 if (inScrollPane) { 89 JScrollPane sp = new JScrollPane(p); 90 tab = sp; 91 } 92 addTab(null, ImageProvider.get("preferences", icon), tab); 93 setToolTipTextAt(getTabCount()-1, "<html>"+desc+"</html>"); 94 return p; 54 getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); 55 getRootPane().getActionMap().put("cancel", new CancelAction()); 56 HelpUtil.setHelpContext(getRootPane(), HelpUtil.ht("/Action/Preferences")); 95 57 } 96 58 97 public void ok() { 98 boolean requiresRestart = false; 99 for (PreferenceSetting setting : settings) 100 { 101 if(setting.ok()) { 102 requiresRestart = true; 103 } 104 } 105 if (requiresRestart) { 106 JOptionPane.showMessageDialog( 107 Main.parent, 108 tr("You have to restart JOSM for some settings to take effect."), 109 tr("Warning"), 110 JOptionPane.WARNING_MESSAGE 111 ); 112 } 113 Main.parent.repaint(); 59 public PreferenceDialog(Component parent) { 60 super(JOptionPane.getFrameForComponent(parent), tr("Preferences"), true /* modal */); 61 build(); 114 62 } 115 63 116 /** 117 * If the dialog is closed with Ok, the preferences will be stored to the preferences- 118 * file, otherwise no change of the file happens. 119 */ 120 public PreferenceDialog() { 121 super(JTabbedPane.LEFT, JTabbedPane.SCROLL_TAB_LAYOUT); 64 public boolean isCanceled() { 65 return canceled; 66 } 122 67 123 super.addMouseWheelListener(this); 68 protected void setCanceled(boolean canceled) { 69 this.canceled = canceled; 70 } 124 71 125 for (PreferenceSettingFactory factory:settingsFactory) { 126 // logger.info("creating settings: " + factory); 127 PreferenceSetting setting = factory.createPreferenceSetting(); 128 if (setting != null) { 129 settings.add(factory.createPreferenceSetting()); 130 } 72 @Override 73 public void setVisible(boolean visible) { 74 if (visible) { 75 new WindowGeometry( 76 getClass().getName() + ".geometry", 77 WindowGeometry.centerInWindow( 78 getParent(), 79 new Dimension(600,800) 80 ) 81 ).apply(this); 82 } else if (!visible && isShowing()){ 83 new WindowGeometry(this).remember(getClass().getName() + ".geometry"); 84 } 85 super.setVisible(visible); 86 } 87 88 class CancelAction extends AbstractAction { 89 public CancelAction() { 90 putValue(NAME, tr("Cancel")); 91 putValue(SMALL_ICON, ImageProvider.get("cancel")); 92 putValue(SHORT_DESCRIPTION, tr("Close the prefereces dialog and discard preference updates")); 131 93 } 132 94 133 display.add(displaycontent, GBC.eol().fill(GBC.BOTH)); 134 map.add(mapcontent, GBC.eol().fill(GBC.BOTH)); 135 for (Iterator<PreferenceSetting> it = settings.iterator(); it.hasNext();) { 136 try { 137 PreferenceSetting settings = it.next(); 138 //logger.info("adding gui: " + settings); 139 settings.addGui(this); 140 } catch (SecurityException e) { 141 it.remove(); 142 } catch (Throwable e) { 143 /* allow to change most settings even if e.g. a plugin fails */ 144 BugReportExceptionHandler.handleException(e); 145 } 95 public void cancel() { 96 setCanceled(true); 97 setVisible(false); 98 } 99 100 public void actionPerformed(ActionEvent evt) { 101 cancel(); 146 102 } 147 103 } 148 104 149 public List<PreferenceSetting> getSettings() { 150 return settings; 105 class OKAction extends AbstractAction { 106 public OKAction() { 107 putValue(NAME, tr("OK")); 108 putValue(SMALL_ICON, ImageProvider.get("ok")); 109 putValue(SHORT_DESCRIPTION, tr("Save the preferences and close the dialog")); 110 } 111 112 public void actionPerformed(ActionEvent evt) { 113 tpPreferences.savePreferences(); 114 setCanceled(false); 115 setVisible(false); 116 } 151 117 } 152 118 153 @SuppressWarnings("unchecked") 154 public <T> T getSetting(Class<? extends T> clazz) { 155 for (PreferenceSetting setting:settings) { 156 if (clazz.isAssignableFrom(setting.getClass())) 157 return (T)setting; 119 class WindowEventHandler extends WindowAdapter { 120 @Override 121 public void windowClosing(WindowEvent arg0) { 122 new CancelAction().cancel(); 158 123 } 159 return null;160 }161 162 static {163 // order is important!164 settingsFactory.add(new DrawingPreference.Factory());165 settingsFactory.add(new ColorPreference.Factory());166 settingsFactory.add(new LafPreference.Factory());167 settingsFactory.add(new LanguagePreference.Factory());168 settingsFactory.add(new ServerAccessPreference.Factory());169 settingsFactory.add(new FilePreferences.Factory());170 settingsFactory.add(new ProxyPreferences.Factory());171 settingsFactory.add(new ProjectionPreference.Factory());172 settingsFactory.add(new MapPaintPreference.Factory());173 settingsFactory.add(new TaggingPresetPreference.Factory());174 settingsFactory.add(new PluginPreference.Factory());175 settingsFactory.add(Main.toolbar);176 settingsFactory.add(new AudioPreference.Factory());177 settingsFactory.add(new ShortcutPreference.Factory());178 179 PluginHandler.getPreferenceSetting(settingsFactory);180 181 // always the last: advanced tab182 settingsFactory.add(new AdvancedPreference.Factory());183 }184 185 /**186 * This mouse wheel listener reacts when a scroll is carried out over the187 * tab strip and scrolls one tab/down or up, selecting it immediately.188 */189 public void mouseWheelMoved(MouseWheelEvent wev) {190 // Ensure the cursor is over the tab strip191 if(super.indexAtLocation(wev.getPoint().x, wev.getPoint().y) < 0)192 return;193 194 // Get currently selected tab195 int newTab = super.getSelectedIndex() + wev.getWheelRotation();196 197 // Ensure the new tab index is sound198 newTab = newTab < 0 ? 0 : newTab;199 newTab = newTab >= super.getTabCount() ? super.getTabCount() - 1 : newTab;200 201 // select new tab202 super.setSelectedIndex(newTab);203 124 } 204 125 } -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceSetting.java
r2512 r2745 7 7 * the current preferences. 8 8 */ 9 void addGui(Preference Dialoggui);9 void addGui(PreferenceTabbedPane gui); 10 10 11 11 /** -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r2741 r2745 36 36 * @author imi 37 37 */ 38 public class Preference Dialogextends JTabbedPane implements MouseWheelListener {39 static private final Logger logger = Logger.getLogger(Preference Dialog.class.getName());38 public class PreferenceTabbedPane extends JTabbedPane implements MouseWheelListener { 39 static private final Logger logger = Logger.getLogger(PreferenceTabbedPane.class.getName()); 40 40 41 41 private final static Collection<PreferenceSettingFactory> settingsFactory = new LinkedList<PreferenceSettingFactory>(); … … 79 79 JPanel p = new JPanel(new GridBagLayout()); 80 80 p.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 81 p.add(new JLabel(title), GBC.eol(). anchor(GBC.CENTER).insets(0,5,0,10));81 p.add(new JLabel(title), GBC.eol().insets(0,5,0,10).anchor(GBC.NORTHWEST)); 82 82 83 83 JLabel descLabel = new JLabel("<html>"+desc+"</html>"); … … 95 95 } 96 96 97 public void ok() {97 public void savePreferences() { 98 98 boolean requiresRestart = false; 99 99 for (PreferenceSetting setting : settings) … … 118 118 * file, otherwise no change of the file happens. 119 119 */ 120 public Preference Dialog() {120 public PreferenceTabbedPane() { 121 121 super(JTabbedPane.LEFT, JTabbedPane.SCROLL_TAB_LAYOUT); 122 123 122 super.addMouseWheelListener(this); 124 123 } 124 125 public void buildGui() { 125 126 for (PreferenceSettingFactory factory:settingsFactory) { 126 127 // logger.info("creating settings: " + factory); … … 167 168 settingsFactory.add(new LanguagePreference.Factory()); 168 169 settingsFactory.add(new ServerAccessPreference.Factory()); 169 settingsFactory.add(new FilePreferences.Factory());170 settingsFactory.add(new ProxyPreferences.Factory());171 170 settingsFactory.add(new ProjectionPreference.Factory()); 172 171 settingsFactory.add(new MapPaintPreference.Factory()); -
trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java
r2516 r2745 65 65 static private GBC projSubPrefPanelGBC = GBC.eol().fill(GBC.BOTH).insets(20,5,5,5); 66 66 67 public void addGui(Preference Dialoggui) {67 public void addGui(PreferenceTabbedPane gui) { 68 68 setupProjectionCombo(); 69 69 -
trunk/src/org/openstreetmap/josm/gui/preferences/ServerAccessPreference.java
r2650 r2745 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Font; 7 import java.net.PasswordAuthentication; 8 import java.net.Authenticator.RequestorType; 6 import java.awt.BorderLayout; 7 import java.awt.GridBagConstraints; 8 import java.awt.GridBagLayout; 9 import java.awt.Insets; 9 10 10 import javax.swing.J Label;11 import javax.swing.J PasswordField;12 import javax.swing.JT extField;11 import javax.swing.JPanel; 12 import javax.swing.JScrollPane; 13 import javax.swing.JTabbedPane; 13 14 14 import org.openstreetmap.josm. Main;15 import org.openstreetmap.josm. io.auth.CredentialsManager;16 import org.openstreetmap.josm. io.auth.CredentialsManagerException;17 import org.openstreetmap.josm. io.auth.CredentialsManagerFactory;18 import org.openstreetmap.josm. tools.GBC;19 15 import org.openstreetmap.josm.gui.help.HelpUtil; 16 import org.openstreetmap.josm.gui.preferences.server.AuthenticationPreferencesPanel; 17 import org.openstreetmap.josm.gui.preferences.server.BackupPreferencesPanel; 18 import org.openstreetmap.josm.gui.preferences.server.OsmApiUrlInputPanel; 19 import org.openstreetmap.josm.gui.preferences.server.ProxyPreferencesPanel; 20 import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel; 20 21 public class ServerAccessPreference implements PreferenceSetting { 21 22 … … 26 27 } 27 28 29 private OsmApiUrlInputPanel pnlApiUrlPreferences; 30 31 private JTabbedPane tpServerPreferences; 32 /** indicates whether to use the default OSM URL or not */ 33 /** panel for configuring authentication preferences */ 34 private AuthenticationPreferencesPanel pnlAuthPreferences; 35 /** panel for configuring proxy preferences */ 36 private ProxyPreferencesPanel pnlProxyPreferences; 37 /** panel for backup preferences */ 38 private BackupPreferencesPanel pnlBackupPreferences; 39 28 40 /** 29 * Editfield for the Base url to the REST API from OSM. 41 * Embeds a vertically scrollable panel in a {@see JScrollPane} 42 * @param panel the panel 43 * @return the scroll pane 30 44 */ 31 final private JTextField osmDataServerURL = new JTextField(20); 32 /** 33 * Editfield for the username to the OSM account. 34 */ 35 final private JTextField osmDataUsername = new JTextField(20); 36 /** 37 * Passwordfield for the userpassword of the REST API. 38 */ 39 final private JPasswordField osmDataPassword = new JPasswordField(20); 40 41 public void addGui(PreferenceDialog gui) { 42 CredentialsManager cm = CredentialsManagerFactory.getCredentialManager(); 43 String oldServerURL = Main.pref.get("osm-server.url", "http://api.openstreetmap.org/api"); 44 String oldUsername; 45 String oldPassword; 46 try { 47 PasswordAuthentication credentials = cm.lookup(RequestorType.SERVER); 48 oldUsername = (credentials == null || credentials.getUserName() == null) ? "" : credentials.getUserName(); 49 oldPassword = (credentials == null || credentials.getPassword() == null) ? "" : String.valueOf(credentials.getPassword()); 50 } catch(CredentialsManagerException e) { 51 e.printStackTrace(); 52 oldUsername = ""; 53 oldPassword = ""; 54 } 55 56 osmDataServerURL.setText(oldServerURL); 57 osmDataUsername.setText(oldUsername); 58 osmDataPassword.setText(oldPassword); 59 osmDataServerURL.setToolTipText(tr("The base URL for the OSM server (REST API)")); 60 osmDataUsername.setToolTipText(tr("Login name (e-mail) to the OSM account.")); 61 osmDataPassword.setToolTipText(tr("Login password to the OSM account. Leave blank to not store any password.")); 62 63 gui.connection.add(new JLabel(tr("Base Server URL")), GBC.std()); 64 gui.connection.add(osmDataServerURL, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5)); 65 gui.connection.add(new JLabel(tr("OSM username (e-mail)")), GBC.std()); 66 gui.connection.add(osmDataUsername, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5)); 67 gui.connection.add(new JLabel(tr("OSM password")), GBC.std()); 68 gui.connection.add(osmDataPassword, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,0)); 69 JLabel warning = new JLabel(tr("<html>" + 70 "WARNING: The password is stored in plain text in the preferences file.<br>" + 71 "The password is transferred in plain text to the server, encoded in the URL.<br>" + 72 "<b>Do not use a valuable Password.</b></html>")); 73 warning.setFont(warning.getFont().deriveFont(Font.ITALIC)); 74 gui.connection.add(warning, GBC.eop().fill(GBC.HORIZONTAL)); 45 protected JScrollPane wrapVerticallyScrollablePanel(VerticallyScrollablePanel panel) { 46 JScrollPane sp = new JScrollPane(panel); 47 sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 48 sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 49 return sp; 75 50 } 76 51 52 /** 53 * Builds the tabbed pane with the server preferences 54 * 55 * @return 56 */ 57 protected JPanel buildTabbedServerPreferences() { 58 JPanel pnl = new JPanel(new BorderLayout()); 59 60 tpServerPreferences = new JTabbedPane(); 61 pnlAuthPreferences = new AuthenticationPreferencesPanel(); 62 tpServerPreferences.add(wrapVerticallyScrollablePanel(pnlAuthPreferences)); 63 pnlProxyPreferences = new ProxyPreferencesPanel(); 64 tpServerPreferences.add(wrapVerticallyScrollablePanel(pnlProxyPreferences)); 65 pnlBackupPreferences = new BackupPreferencesPanel(); 66 tpServerPreferences.add(wrapVerticallyScrollablePanel(pnlBackupPreferences)); 67 68 tpServerPreferences.setTitleAt(0, tr("Authentication")); 69 tpServerPreferences.setTitleAt(1, tr("Proxy settings")); 70 tpServerPreferences.setTitleAt(2, tr("File backup")); 71 tpServerPreferences.setToolTipTextAt(0, tr("Configure your identity and how to authenticate at the OSM server")); 72 tpServerPreferences.setToolTipTextAt(1, tr("Configure whether to use a proxy server")); 73 tpServerPreferences.setToolTipTextAt(2, tr("Configure whether to create backup files")); 74 75 pnl.add(tpServerPreferences, BorderLayout.CENTER); 76 return pnl; 77 } 78 79 /** 80 * Builds the panel for entering the server access preferences 81 * 82 * @return 83 */ 84 protected JPanel buildContentPanel() { 85 JPanel pnl = new JPanel(new GridBagLayout()); 86 GridBagConstraints gc = new GridBagConstraints(); 87 88 // the checkbox for the default UL 89 gc.fill = GridBagConstraints.HORIZONTAL; 90 gc.anchor = GridBagConstraints.NORTHWEST; 91 gc.weightx = 1.0; 92 gc.insets = new Insets(0,0,0,0); 93 pnl.add(pnlApiUrlPreferences = new OsmApiUrlInputPanel(), gc); 94 95 // the remaining access properties 96 gc.gridy = 1; 97 gc.fill = GridBagConstraints.BOTH; 98 gc.weightx = 1.0; 99 gc.weighty = 1.0; 100 gc.insets = new Insets(10,0,3,3); 101 pnl.add(buildTabbedServerPreferences(), gc); 102 103 // let the AuthPreferencesPanel know when the API URL changes 104 // 105 pnlApiUrlPreferences.addPropertyChangeListener(pnlAuthPreferences); 106 107 HelpUtil.setHelpContext(pnl, HelpUtil.ht("/Preferences/Connection")); 108 return pnl; 109 } 110 111 public void addGui(PreferenceTabbedPane gui) { 112 GridBagConstraints gc = new GridBagConstraints(); 113 gc.fill = GridBagConstraints.BOTH; 114 gc.weightx = 1.0; 115 gc.weighty = 1.0; 116 gc.anchor = GridBagConstraints.NORTHWEST; 117 gui.connection.add(buildContentPanel(), gc); 118 119 initFromPreferences(); 120 } 121 122 /** 123 * Initializes the configuration panel with values from the preferences 124 */ 125 public void initFromPreferences() { 126 pnlApiUrlPreferences.initFromPreferences(); 127 pnlAuthPreferences.initFromPreferences(); 128 pnlProxyPreferences.initFromPreferences(); 129 pnlBackupPreferences.initFromPreferences(); 130 } 131 132 /** 133 * Saves the values to the preferences 134 */ 77 135 public boolean ok() { 78 CredentialsManager cm = CredentialsManagerFactory.getCredentialManager(); 79 Main.pref.put("osm-server.url", osmDataServerURL.getText()); 80 try { 81 cm.store(RequestorType.SERVER, new PasswordAuthentication( 82 osmDataUsername.getText(), 83 osmDataPassword.getPassword() 84 )); 85 } catch(CredentialsManagerException e) { 86 // FIXME: Message dialog with an error message? 87 e.printStackTrace(); 88 } 136 pnlApiUrlPreferences.saveToPreferences(); 137 pnlAuthPreferences.saveToPreferences(); 138 pnlProxyPreferences.saveToPreferences(); 139 pnlBackupPreferences.saveToPreferences(); 89 140 return false; 90 141 } -
trunk/src/org/openstreetmap/josm/gui/preferences/ShortcutPreference.java
r1742 r2745 20 20 } 21 21 22 public void addGui(Preference Dialoggui) {22 public void addGui(PreferenceTabbedPane gui) { 23 23 // icon source: http://www.iconfinder.net/index.php?q=key&page=icondetails&iconid=8553&size=128&q=key&s12=on&s16=on&s22=on&s32=on&s48=on&s64=on&s128=on 24 24 // icon licence: GPL -
trunk/src/org/openstreetmap/josm/gui/preferences/TaggingPresetPreference.java
r2400 r2745 36 36 private JCheckBox enableDefault; 37 37 38 public void addGui(final Preference Dialoggui) {38 public void addGui(final PreferenceTabbedPane gui) { 39 39 sortMenu = new JCheckBox(tr("Sort presets menu"), 40 40 Main.pref.getBoolean("taggingpreset.sortmenu", false)); -
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r2512 r2745 172 172 } 173 173 174 public void addGui(Preference Dialoggui) {174 public void addGui(PreferenceTabbedPane gui) { 175 175 actionsTree.setCellRenderer(new DefaultTreeCellRenderer() { 176 176 @Override
Note:
See TracChangeset
for help on using the changeset viewer.