package org.simantics.maps.server.ui;
import java.util.Optional;
+import java.util.function.Consumer;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
public class TileserverMapnikStartJob extends Job {
private static final Logger LOGGER = LoggerFactory.getLogger(TileserverMapnikStartJob.class);
+ private Consumer<IStatus> callback;
- public TileserverMapnikStartJob() {
+ public TileserverMapnikStartJob(Consumer<IStatus> callback) {
super("Tileserver start job");
+ this.callback = callback;
}
@Override
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask("Starting tileserver", 100);
+ IStatus status = Status.OK_STATUS;
try {
StartListener startListener = new StartListener(monitor);
TileserverMapnikInstance.get().start(Optional.of(startListener));
if (startListener.module != null || startListener.returnValue != 0)
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not install " + String.valueOf(startListener.module) + " with returnValue " + startListener.returnValue);
- return Status.OK_STATUS;
+ status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not install " + String.valueOf(startListener.module) + " with returnValue " + startListener.returnValue);
} catch (Exception e) {
LOGGER.error("Could not start tileserver-mapnik", e);
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not start tileserver-mapnik: " + e.getMessage());
+ status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not start tileserver-mapnik: " + e.getMessage());
}
+ callback.accept(status);
+ return status;
}
private class StartListener implements TileserverStartListener {