* 2nd reason: import progress has changed
* 3rd reason: import was canceled or failed in another way
*/
@Override
public void update(Observable o, Object arg) {
final ObserverNotification notification = (ObserverNotification) arg;
if (notification.getType() == NotificationType.done) {
mDialog.setImporting(false);
// set status bar text
final int size = ModelManager.getInstance().getAllModelElements().size();
MainStatusBar.getInstance().showMessage(
"OSM import successful. Map size: "
+String.valueOf(size)
+" elements",
10000
);
mDialog.getProgressDialog().setLabelText("Import complete!");
mDialog.getProgressDialog().setButtonText("Ok");
mDialog.getProgressDialog().setVisible(false);
mDialog.closeDialog();
} else if (notification.getType() == NotificationType.progress) {
mDialog.getProgressDialog().setProgressValue(
new Integer(notification.getObj1().toString())
);
} else if (notification.getType() == NotificationType.nothing) {
mDialog.getProgressDialog().setVisible(false);
mDialog.closeDialog();
} else if (notification.getType() == NotificationType.failed) {
mDialog.setImporting(false);
Logger.getLogger(this.getClass()).error("Import of OSM data failed!");
mDialog.getProgressDialog().setVisible(false);
mDialog.closeDialog();
JOptionPane.showMessageDialog(
mDialog.getParent(),
"Import of OSM data failed! "
+(String) notification.getObj1(),
"Import failed",
JOptionPane.ERROR_MESSAGE
);
} else {
log.error("Unknown event occured: " + notification.getType());
}
}