- Timestamp:
- 2013-12-24T23:40:10+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/GettingStarted.java
r6296 r6525 25 25 import org.openstreetmap.josm.Main; 26 26 import org.openstreetmap.josm.data.Version; 27 import org.openstreetmap.josm.gui.preferences.server.ProxyPreference; 28 import org.openstreetmap.josm.gui.preferences.server.ProxyPreferenceListener; 27 29 import org.openstreetmap.josm.gui.widgets.JosmEditorPane; 28 30 import org.openstreetmap.josm.io.CacheCustomContent; … … 31 33 import org.openstreetmap.josm.tools.WikiReader; 32 34 33 public final class GettingStarted extends JPanel { 35 public final class GettingStarted extends JPanel implements ProxyPreferenceListener { 36 37 private final LinkGeneral lg; 34 38 private String content = ""; 39 private boolean contentInitialized = false; 40 35 41 private static final String STYLE = "<style type=\"text/css\">\n" 36 42 + "body {font-family: sans-serif; font-weight: bold; }\n" … … 113 119 public GettingStarted() { 114 120 super(new BorderLayout()); 115 final LinkGenerallg = new LinkGeneral("<html>" + STYLE + "<h1>" + "JOSM - " + tr("Java OpenStreetMap Editor")121 lg = new LinkGeneral("<html>" + STYLE + "<h1>" + "JOSM - " + tr("Java OpenStreetMap Editor") 116 122 + "</h1><h2 align=\"center\">" + tr("Downloading \"Message of the day\"") + "</h2></html>"); 117 123 // clear the build-in command ctrl+shift+O, because it is used as shortcut in JOSM … … 122 128 add(scroller, BorderLayout.CENTER); 123 129 130 getMOTD(); 131 132 new FileDrop(scroller); 133 } 134 135 private void getMOTD() { 124 136 // Asynchronously get MOTD to speed-up JOSM startup 125 137 Thread t = new Thread(new Runnable() { 126 138 @Override 127 139 public void run() { 128 if ( content.isEmpty()&& Main.pref.getBoolean("help.displaymotd", true)) {140 if (!contentInitialized && Main.pref.getBoolean("help.displaymotd", true)) { 129 141 try { 130 142 content = new MotdContent().updateIfRequiredString(); 143 contentInitialized = true; 144 ProxyPreference.removeProxyPreferenceListener(GettingStarted.this); 131 145 } catch (IOException ex) { 132 146 Main.warn(tr("Failed to read MOTD. Exception was: {0}", ex.toString())); 133 147 content = "<html>" + STYLE + "<h1>" + "JOSM - " + tr("Java OpenStreetMap Editor") 134 148 + "</h1>\n<h2 align=\"center\">(" + tr("Message of the day not available") + ")</h2></html>"; 149 // In case of MOTD not loaded because of proxy error, listen to preference changes to retry after update 150 ProxyPreference.addProxyPreferenceListener(GettingStarted.this); 135 151 } 136 152 } … … 146 162 t.setDaemon(true); 147 163 t.start(); 148 149 new FileDrop(scroller);150 164 } 151 165 … … 163 177 return sb.toString(); 164 178 } 179 180 @Override 181 public void proxyPreferenceChanged() { 182 getMOTD(); 183 } 165 184 } -
trunk/src/org/openstreetmap/josm/gui/preferences/ServerAccessPreference.java
r6523 r6525 45 45 * @return the scroll pane 46 46 */ 47 p rotectedJScrollPane wrapVerticallyScrollablePanel(VerticallyScrollablePanel panel) {47 public static JScrollPane wrapVerticallyScrollablePanel(VerticallyScrollablePanel panel) { 48 48 JScrollPane sp = new JScrollPane(panel); 49 49 sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); … … 109 109 gui.createPreferenceTab(this).add(buildContentPanel(), gc); 110 110 111 initFromPreferences();112 }113 114 /**115 * Initializes the configuration panel with values from the preferences116 */117 public void initFromPreferences() {118 111 pnlApiUrlPreferences.initFromPreferences(); 119 112 } -
trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreference.java
r6523 r6525 7 7 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 8 8 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 9 import org.openstreetmap.josm.gui.preferences.ServerAccessPreference; 9 10 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting; 10 11 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; … … 36 37 pnlAuthPreferences = new AuthenticationPreferencesPanel(); 37 38 gui.getServerPreference().addApiUrlChangeListener(pnlAuthPreferences); 38 gui.getServerPreference().addSubTab(this, tr("Authentication"), pnlAuthPreferences, 39 gui.getServerPreference().addSubTab(this, tr("Authentication"), 40 ServerAccessPreference.wrapVerticallyScrollablePanel(pnlAuthPreferences), 39 41 tr("Configure your identity and how to authenticate at the OSM server")); 40 42 } -
trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java
r6365 r6525 106 106 public AuthenticationPreferencesPanel() { 107 107 build(); 108 initFromPreferences(); 108 109 HelpUtil.setHelpContext(this, HelpUtil.ht("/Preferences/Connection#AuthenticationSettings")); 109 110 } -
trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreference.java
r6523 r6525 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.util.HashSet; 7 import java.util.Set; 8 6 9 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 7 10 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 8 11 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 12 import org.openstreetmap.josm.gui.preferences.ServerAccessPreference; 9 13 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting; 10 14 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; … … 26 30 } 27 31 28 ProxyPreferencesPanel pnlProxyPreferences; 32 private static Set<ProxyPreferenceListener> listeners = new HashSet<ProxyPreferenceListener>(); 33 34 private ProxyPreferencesPanel pnlProxyPreferences; 29 35 30 36 private ProxyPreference() { … … 35 41 public void addGui(PreferenceTabbedPane gui) { 36 42 pnlProxyPreferences = new ProxyPreferencesPanel(); 37 gui.getServerPreference().addSubTab(this, tr("Proxy settings"), pnlProxyPreferences, 43 gui.getServerPreference().addSubTab(this, tr("Proxy settings"), 44 ServerAccessPreference.wrapVerticallyScrollablePanel(pnlProxyPreferences), 38 45 tr("Configure whether to use a proxy server")); 39 46 } … … 42 49 public boolean ok() { 43 50 pnlProxyPreferences.saveToPreferences(); 51 for (ProxyPreferenceListener listener : listeners) { 52 listener.proxyPreferenceChanged(); 53 } 44 54 return false; 45 55 } … … 54 64 return gui.getServerPreference(); 55 65 } 66 67 /** 68 * Adds a new ProxyPreferenceListener. 69 * @param listener the listener to add 70 * @return {@code true} if the listener has been added, {@code false} otherwise 71 * @since 6525 72 */ 73 public static boolean addProxyPreferenceListener(ProxyPreferenceListener listener) { 74 if (listener != null) { 75 return listeners.add(listener); 76 } 77 return false; 78 } 79 80 /** 81 * Removes a ProxyPreferenceListener. 82 * @param listener the listener to remove 83 * @return {@code true} if the listener has been removed, {@code false} otherwise 84 * @since 6525 85 */ 86 public static boolean removeProxyPreferenceListener(ProxyPreferenceListener listener) { 87 if (listener != null) { 88 return listeners.remove(listener); 89 } 90 return false; 91 } 56 92 } -
trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreferencesPanel.java
r6340 r6525 360 360 } 361 361 362 /** 363 * Constructs a new {@code ProxyPreferencesPanel}. 364 */ 362 365 public ProxyPreferencesPanel() { 363 366 setLayout(new GridBagLayout());
Note:
See TracChangeset
for help on using the changeset viewer.