Changeset 14125 in josm for trunk/src/org
- Timestamp:
- 2018-08-11T19:01:26+02:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r14121 r14125 36 36 import org.openstreetmap.josm.io.NetworkManager; 37 37 import org.openstreetmap.josm.io.OnlineResource; 38 import org.openstreetmap.josm.spi.lifecycle.InitializationTask; 38 39 import org.openstreetmap.josm.spi.preferences.Config; 39 40 import org.openstreetmap.josm.spi.preferences.IUrls; 40 import org.openstreetmap.josm.tools.CheckParameterUtil;41 41 import org.openstreetmap.josm.tools.ImageProvider; 42 42 import org.openstreetmap.josm.tools.JosmRuntimeException; … … 87 87 */ 88 88 public static volatile PlatformHook platform; 89 90 private static volatile InitStatusListener initListener;91 92 /**93 * Initialization task listener.94 */95 public interface InitStatusListener {96 97 /**98 * Called when an initialization task updates its status.99 * @param event task name100 * @return new status101 */102 Object updateStatus(String event);103 104 /**105 * Called when an initialization task completes.106 * @param status final status107 */108 void finish(Object status);109 }110 111 /**112 * Sets initialization task listener.113 * @param listener initialization task listener114 */115 public static void setInitStatusListener(InitStatusListener listener) {116 CheckParameterUtil.ensureParameterNotNull(listener);117 initListener = listener;118 }119 89 120 90 /** … … 217 187 } 218 188 219 protected static final class InitializationTask implements Callable<Void> {220 221 private final String name;222 private final Runnable task;223 224 /**225 * Constructs a new {@code InitializationTask}.226 * @param name translated name to be displayed to user227 * @param task runnable initialization task228 */229 public InitializationTask(String name, Runnable task) {230 this.name = name;231 this.task = task;232 }233 234 @Override235 public Void call() {236 Object status = null;237 if (initListener != null) {238 status = initListener.updateStatus(name);239 }240 task.run();241 if (initListener != null) {242 initListener.finish(status);243 }244 return null;245 }246 }247 248 189 /** 249 190 * Replies the current selected OSM primitives, from a end-user point of view. -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r14121 r14125 161 161 import org.openstreetmap.josm.plugins.PluginHandler; 162 162 import org.openstreetmap.josm.plugins.PluginInformation; 163 import org.openstreetmap.josm.spi.lifecycle.InitStatusListener; 164 import org.openstreetmap.josm.spi.lifecycle.InitializationTask; 165 import org.openstreetmap.josm.spi.lifecycle.Lifecycle; 163 166 import org.openstreetmap.josm.spi.preferences.Config; 164 167 import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent; … … 318 321 String location = Config.getUrls().getJOSMWebsite() + "/proj/" + gridFileName; 319 322 // Try to load grid file 323 @SuppressWarnings("resource") 320 324 CachedFile cf = new CachedFile(location); 321 325 try { … … 667 671 } 668 672 673 /** 674 * Redirects the key inputs from {@code source} to main content pane. 675 * @param source source component from which key inputs are redirected 676 */ 669 677 public static void redirectToMainContentPane(JComponent source) { 670 678 RedirectInputMap.redirect(source, contentPanePrivate); … … 1045 1053 GuiHelper.runInEDT(() -> splash.setVisible(Config.getPref().getBoolean("draw.splashscreen", true))); 1046 1054 } 1047 Main.setInitStatusListener(new InitStatusListener() {1055 Lifecycle.setInitStatusListener(new InitStatusListener() { 1048 1056 1049 1057 @Override
Note:
See TracChangeset
for help on using the changeset viewer.