diff --git a/src/org/openstreetmap/josm/Main.java b/src/org/openstreetmap/josm/Main.java
index 46b1c57..aff5e0d 100644
|
a
|
b
|
import java.net.URISyntaxException;
|
| 21 | 21 | import java.util.ArrayList; |
| 22 | 22 | import java.util.Collection; |
| 23 | 23 | import java.util.Iterator; |
| | 24 | import java.util.LinkedList; |
| 24 | 25 | import java.util.List; |
| 25 | 26 | import java.util.Map; |
| 26 | 27 | import java.util.StringTokenizer; |
| … |
… |
abstract public class Main {
|
| 221 | 222 | } |
| 222 | 223 | } |
| 223 | 224 | |
| | 225 | private static InitStatusListener initListener = null; |
| | 226 | |
| | 227 | public static interface InitStatusListener { |
| | 228 | |
| | 229 | void updateStatus(String event); |
| | 230 | } |
| | 231 | |
| | 232 | public static void setInitStatusListener(InitStatusListener listener) { |
| | 233 | initListener = listener; |
| | 234 | } |
| | 235 | |
| 224 | 236 | public Main() { |
| 225 | 237 | main = this; |
| 226 | 238 | isOpenjdk = System.getProperty("java.vm.name").toUpperCase().indexOf("OPENJDK") != -1; |
| | 239 | |
| | 240 | if (initListener != null) |
| | 241 | initListener.updateStatus(tr("Executing platform startup hook")); |
| 227 | 242 | platform.startupHook(); |
| 228 | 243 | |
| 229 | 244 | // We try to establish an API connection early, so that any API |
| 230 | 245 | // capabilities are already known to the editor instance. However |
| 231 | 246 | // if it goes wrong that's not critical at this stage. |
| | 247 | if (initListener != null) |
| | 248 | initListener.updateStatus(tr("Initializing OSM API")); |
| 232 | 249 | try { |
| 233 | 250 | OsmApi.getOsmApi().initialize(null, true); |
| 234 | 251 | } catch (Exception x) { |
| 235 | 252 | // ignore any exception here. |
| 236 | 253 | } |
| 237 | 254 | |
| | 255 | if (initListener != null) |
| | 256 | initListener.updateStatus(tr("Building main menu")); |
| 238 | 257 | contentPanePrivate.add(panel, BorderLayout.CENTER); |
| 239 | 258 | panel.add(gettingStarted, BorderLayout.CENTER); |
| 240 | 259 | menu = new MainMenu(); |
| … |
… |
abstract public class Main {
|
| 247 | 266 | registerActionShortcut(menu.help, Shortcut.registerShortcut("system:help", tr("Help"), |
| 248 | 267 | KeyEvent.VK_F1, Shortcut.GROUP_DIRECT)); |
| 249 | 268 | |
| | 269 | if (initListener != null) |
| | 270 | initListener.updateStatus(tr("Initializing presets")); |
| 250 | 271 | TaggingPresetPreference.initialize(); |
| | 272 | |
| | 273 | if (initListener != null) |
| | 274 | initListener.updateStatus(tr("Initializing map styles")); |
| 251 | 275 | MapPaintPreference.initialize(); |
| | 276 | |
| | 277 | if (initListener != null) |
| | 278 | initListener.updateStatus(tr("Loading imagery preferences")); |
| 252 | 279 | ImageryPreference.initialize(); |
| 253 | 280 | |
| | 281 | if (initListener != null) |
| | 282 | initListener.updateStatus(tr("Initializing validator")); |
| 254 | 283 | validator = new OsmValidator(); |
| 255 | 284 | MapView.addLayerChangeListener(validator); |
| 256 | 285 | |
| … |
… |
abstract public class Main {
|
| 263 | 292 | }); |
| 264 | 293 | FeatureAdapter.registerTranslationAdapter(I18n.getTranslationAdapter()); |
| 265 | 294 | |
| | 295 | if (initListener != null) |
| | 296 | initListener.updateStatus(tr("Updating user interface")); |
| | 297 | |
| 266 | 298 | toolbar.refreshToolbarControl(); |
| 267 | 299 | |
| 268 | 300 | toolbar.control.updateUI(); |
diff --git a/src/org/openstreetmap/josm/gui/MainApplication.java b/src/org/openstreetmap/josm/gui/MainApplication.java
index b5c9555..b833872 100644
|
a
|
b
|
public class MainApplication extends Main {
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | SplashScreen splash = new SplashScreen(); |
| 212 | | ProgressMonitor monitor = splash.getProgressMonitor(); |
| | 212 | final ProgressMonitor monitor = splash.getProgressMonitor(); |
| 213 | 213 | monitor.beginTask(tr("Initializing")); |
| 214 | | monitor.setTicksCount(7); |
| 215 | 214 | splash.setVisible(Main.pref.getBoolean("draw.splashscreen", true)); |
| | 215 | Main.setInitStatusListener(new InitStatusListener() { |
| | 216 | |
| | 217 | @Override |
| | 218 | public void updateStatus(String event) { |
| | 219 | monitor.indeterminateSubTask(event); |
| | 220 | } |
| | 221 | }); |
| 216 | 222 | |
| 217 | 223 | List<PluginInformation> pluginsToLoad = PluginHandler.buildListOfPluginsToLoad(splash,monitor.createSubTaskMonitor(1, false)); |
| 218 | 224 | if (!pluginsToLoad.isEmpty() && PluginHandler.checkAndConfirmPluginUpdate(splash)) { |
| 219 | | monitor.subTask(tr("Updating plugins...")); |
| | 225 | monitor.subTask(tr("Updating plugins")); |
| 220 | 226 | pluginsToLoad = PluginHandler.updatePlugins(splash,pluginsToLoad, monitor.createSubTaskMonitor(1, false)); |
| 221 | 227 | } |
| 222 | | monitor.worked(1); |
| 223 | 228 | |
| 224 | | monitor.subTask(tr("Installing updated plugins")); |
| | 229 | monitor.indeterminateSubTask(tr("Installing updated plugins")); |
| 225 | 230 | PluginHandler.installDownloadedPlugins(true); |
| 226 | | monitor.worked(1); |
| 227 | 231 | |
| 228 | | monitor.subTask(tr("Loading early plugins")); |
| | 232 | monitor.indeterminateSubTask(tr("Loading early plugins")); |
| 229 | 233 | PluginHandler.loadEarlyPlugins(splash,pluginsToLoad, monitor.createSubTaskMonitor(1, false)); |
| 230 | | monitor.worked(1); |
| 231 | 234 | |
| 232 | | monitor.subTask(tr("Setting defaults")); |
| | 235 | monitor.indeterminateSubTask(tr("Setting defaults")); |
| 233 | 236 | preConstructorInit(args); |
| 234 | 237 | removeObsoletePreferences(); |
| 235 | | monitor.worked(1); |
| 236 | 238 | |
| 237 | 239 | monitor.indeterminateSubTask(tr("Creating main GUI")); |
| 238 | 240 | JFrame mainFrame = new JFrame(tr("Java OpenStreetMap Editor")); |
| 239 | 241 | Main.parent = mainFrame; |
| 240 | 242 | Main.addListener(); |
| 241 | 243 | final Main main = new MainApplication(mainFrame); |
| 242 | | monitor.worked(1); |
| 243 | 244 | |
| 244 | | monitor.subTask(tr("Loading plugins")); |
| | 245 | monitor.indeterminateSubTask(tr("Loading plugins")); |
| 245 | 246 | PluginHandler.loadLatePlugins(splash,pluginsToLoad, monitor.createSubTaskMonitor(1, false)); |
| 246 | | monitor.worked(1); |
| 247 | 247 | toolbar.refreshToolbarControl(); |
| 248 | 248 | splash.setVisible(false); |
| 249 | 249 | splash.dispose(); |
diff --git a/src/org/openstreetmap/josm/gui/SplashScreen.java b/src/org/openstreetmap/josm/gui/SplashScreen.java
index 4ca46e5..7637e19 100644
|
a
|
b
|
import java.awt.Insets;
|
| 12 | 12 | import java.awt.event.MouseAdapter; |
| 13 | 13 | import java.awt.event.MouseEvent; |
| 14 | 14 | |
| | 15 | import java.util.Arrays; |
| | 16 | import java.util.LinkedList; |
| 15 | 17 | import javax.swing.JFrame; |
| 16 | 18 | import javax.swing.JLabel; |
| 17 | 19 | import javax.swing.JPanel; |
| … |
… |
public class SplashScreen extends JFrame {
|
| 132 | 134 | public Dimension getPreferredSize() { |
| 133 | 135 | Dimension d = super.getPreferredSize(); |
| 134 | 136 | if(d.width < 600) d.width = 600; |
| | 137 | d.height *= MAX_NUMBER_OF_MESSAGES; |
| 135 | 138 | return d; |
| 136 | 139 | } |
| 137 | 140 | }, gc); |
| … |
… |
public class SplashScreen extends JFrame {
|
| 166 | 169 | repaint(); |
| 167 | 170 | } |
| 168 | 171 | |
| | 172 | private static final int MAX_NUMBER_OF_MESSAGES = 3; |
| | 173 | private LinkedList<String> messages = new LinkedList<String>(Arrays.asList(" ", " ", " ")); //update when changing MAX_NUMBER_OF_MESSAGES |
| | 174 | private long time = System.currentTimeMillis(); |
| | 175 | |
| | 176 | /** |
| | 177 | * Stores and displays the {@code MAX_NUMBER_OF_MESSAGES} most recent |
| | 178 | * task titles together with their execution time. |
| | 179 | */ |
| 169 | 180 | public void setTaskTitle(String taskTitle) { |
| 170 | | lblTaskTitle.setText(taskTitle); |
| | 181 | |
| | 182 | while (messages.size() >= MAX_NUMBER_OF_MESSAGES) { |
| | 183 | messages.removeFirst(); |
| | 184 | } |
| | 185 | if (!taskTitle.isEmpty()) { |
| | 186 | long now = System.currentTimeMillis(); |
| | 187 | messages.add(tr("{0} ({1} ms)", taskTitle, Long.toString(now - time))); |
| | 188 | time = now; |
| | 189 | } |
| | 190 | String html = ""; |
| | 191 | int i = 0; |
| | 192 | for (String m : messages) { |
| | 193 | html += "<p class=\"entry" + (++i) + "\">" + m + "</p>"; |
| | 194 | } |
| | 195 | |
| | 196 | lblTaskTitle.setText("<html><style>" |
| | 197 | + ".entry1{color:#CCCCCC;}" |
| | 198 | + ".entry2{color:#999999;}" |
| | 199 | + ".entry3{color:#000000;}</style>" + html + "</html>"); //update when changing MAX_NUMBER_OF_MESSAGES |
| 171 | 200 | repaint(); |
| 172 | 201 | } |
| 173 | 202 | |