1 /*
2  * aTunes
3  * Copyright (C) Alex Aranda, Sylvain Gaudard and contributors
4  *
5  * See http://www.atunes.org/wiki/index.php?title=Contributing for information about contributors
6  *
7  * http://www.atunes.org
8  * http://sourceforge.net/projects/atunes
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  */
20 
21 package net.sourceforge.atunes.kernel.modules.favorites;
22 
23 import net.sourceforge.atunes.kernel.AbstractStateRetrieveTask;
24 import net.sourceforge.atunes.model.IBeanFactory;
25 import net.sourceforge.atunes.model.IFavorites;
26 import net.sourceforge.atunes.model.INavigationHandler;
27 import net.sourceforge.atunes.model.INavigationView;
28 import net.sourceforge.atunes.model.IPlayListHandler;
29 import net.sourceforge.atunes.model.IStateService;
30 
31 /**
32  * Reads favorites
33  *
34  * @author alex
35  *
36  */
37 public class FavoritesInitializationTask extends AbstractStateRetrieveTask {
38 
39 	private IFavorites favorites;
40 
41 	@Override
retrieveData(final IStateService stateService, final IBeanFactory beanFactory)42 	public void retrieveData(final IStateService stateService,
43 			final IBeanFactory beanFactory) {
44 		this.favorites = stateService.retrieveFavoritesCache();
45 	}
46 
47 	@Override
setData(final IBeanFactory beanFactory)48 	public void setData(final IBeanFactory beanFactory) {
49 		if (this.favorites != null) {
50 			beanFactory.getBean(FavoritesHandler.class).setFavorites(
51 					this.favorites);
52 			// Update navigator
53 			beanFactory.getBean(INavigationHandler.class).refreshView(
54 					beanFactory.getBean("favoritesNavigationView",
55 							INavigationView.class));
56 			// Update playlist
57 			beanFactory.getBean(IPlayListHandler.class).refreshPlayList();
58 		}
59 	}
60 }
61