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.actions;
22 
23 import java.util.List;
24 
25 import net.sourceforge.atunes.model.IAudioObject;
26 import net.sourceforge.atunes.model.IChangeTagsProcess;
27 import net.sourceforge.atunes.model.ILocalAudioObject;
28 import net.sourceforge.atunes.model.IProcessFactory;
29 import net.sourceforge.atunes.model.ITreeNode;
30 import net.sourceforge.atunes.utils.I18nUtils;
31 
32 /**
33  * Removes tags of audio objects
34  *
35  * @author alex
36  *
37  */
38 public class ClearTagNavigatorAction extends
39 	AbstractActionOverSelectedObjects<ILocalAudioObject> {
40 
41     private static final long serialVersionUID = 4476719536754930347L;
42 
43     private IProcessFactory processFactory;
44 
45     /**
46      * @param processFactory
47      */
setProcessFactory(final IProcessFactory processFactory)48     public void setProcessFactory(final IProcessFactory processFactory) {
49 	this.processFactory = processFactory;
50     }
51 
52     /**
53      * Default constructor
54      */
ClearTagNavigatorAction()55     public ClearTagNavigatorAction() {
56 	super(I18nUtils.getString("CLEAR_TAG"));
57     }
58 
59     @Override
executeAction(final List<ILocalAudioObject> objects)60     protected void executeAction(final List<ILocalAudioObject> objects) {
61 	IChangeTagsProcess process = (IChangeTagsProcess) processFactory
62 		.getProcessByName("clearTagsProcess");
63 	process.setFilesToChange(objects);
64 	process.execute();
65     }
66 
67     @Override
isEnabledForNavigationTreeSelection( final boolean rootSelected, final List<ITreeNode> selection)68     public boolean isEnabledForNavigationTreeSelection(
69 	    final boolean rootSelected, final List<ITreeNode> selection) {
70 	return !rootSelected && !selection.isEmpty();
71     }
72 
73     @Override
isEnabledForNavigationTableSelection( final List<IAudioObject> selection)74     public boolean isEnabledForNavigationTableSelection(
75 	    final List<IAudioObject> selection) {
76 	return !selection.isEmpty();
77     }
78 }
79