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.process;
22 
23 import java.util.List;
24 
25 import net.sourceforge.atunes.model.IAudioObject;
26 import net.sourceforge.atunes.model.IPlayListHandler;
27 
28 class AddToPlayListRunnable implements Runnable {
29 
30 	private List<IAudioObject> songsLoaded;
31 
32 	private IPlayListHandler playListHandler;
33 
34 	private String playListName;
35 
36 	private boolean replacePlayList;
37 
38 	/**
39 	 * @param songsLoaded
40 	 * @param playListHandler
41 	 * @param playListName
42 	 * @param replacePlayList
43 	 */
AddToPlayListRunnable(List<IAudioObject> songsLoaded, IPlayListHandler playListHandler, String playListName, boolean replacePlayList)44 	public AddToPlayListRunnable(List<IAudioObject> songsLoaded,
45 			IPlayListHandler playListHandler, String playListName,
46 			boolean replacePlayList) {
47 		this.songsLoaded = songsLoaded;
48 		this.playListHandler = playListHandler;
49 		this.playListName = playListName;
50 		this.replacePlayList = replacePlayList;
51 	}
52 
53 	@Override
run()54 	public void run() {
55 		if (songsLoaded.size() >= 1) {
56 			if (this.replacePlayList) {
57 				playListHandler.clearPlayList();
58 				playListHandler.addToVisiblePlayList(songsLoaded);
59 				playListHandler.renameCurrentVisiblePlayList(playListName);
60 			} else {
61 				playListHandler.newPlayList(playListName, songsLoaded);
62 			}
63 		}
64 	}
65 }