model.loadingStarted();
final GuidesSet guidesSet = getModel().getGuidesSet();
// Load data into model
IPersistenceManager manager = PersistenceManagerConfig.getManager();
manager.loadGuidesSet(guidesSet);
// Connect persistence listeners
ChangesMonitor changesMonitor = new ChangesMonitor(guidesSet, manager);
domainEventsListener.addDomainListener(changesMonitor);
// Copy guides and preferences from installer model if it is present
if (installationModel != null)
{
GuidesSet installerSet = installationModel.getGuidesSet();
int count = installerSet.getGuidesCount();
for (int i = 0; i < count; i++)
{
guidesSet.add(installerSet.getGuideAt(i));
}
// Copy preferences
Preferences appPrefs = Application.getUserPreferences();
installationModel.storePreferences(appPrefs);
restoreModelPreferencesAndUpdate(model, appPrefs);
}
// If database was reset we need to show recovery options
if (manager.isDatabaseReset())
{
DatabaseRecoverer.performRecovery(model, ApplicationLauncher.getBackupsPath());
}
initMaxViewsAndClickthroughs(guidesSet);
startLoadingUsedTags(guidesSet);
if (dockIconUnreadMonitor != null) dockIconUnreadMonitor.update();
model.loadingFinished();
// Perform sync-on-startup only if the database was OK
if (!manager.isDatabaseReset())
{
// check if it's time for full sync on startup
SyncFull syncFull = new SyncFull(model);
if (syncFull.isSyncTime()) SyncFullAction.getInstance().doSync(null);
}