~ubuntu-branches/ubuntu/oneiric/tuxguitar/oneiric

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/system/plugins/base/TGPluginList.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mto: (5.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20080619003030-h719szrhsngou7c6
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.herac.tuxguitar.gui.system.plugins.base;
 
2
 
 
3
import java.util.Iterator;
 
4
import java.util.List;
 
5
 
 
6
import org.herac.tuxguitar.gui.system.plugins.TGPlugin;
 
7
import org.herac.tuxguitar.gui.system.plugins.TGPluginException;
 
8
 
 
9
public abstract class TGPluginList extends TGPluginAdapter{
 
10
        
 
11
        private boolean enabled;
 
12
        private List plugins;
 
13
        
 
14
        public TGPluginList(){
 
15
                super();
 
16
        }
 
17
        
 
18
        public void init() throws TGPluginException {
 
19
                Iterator it = getIterator();
 
20
                while(it.hasNext()){
 
21
                        TGPlugin plugin = (TGPlugin)it.next();
 
22
                        plugin.init();
 
23
                }
 
24
        }
 
25
        
 
26
        public void close() throws TGPluginException {
 
27
                Iterator it = getIterator();
 
28
                while(it.hasNext()){
 
29
                        TGPlugin plugin = (TGPlugin)it.next();
 
30
                        plugin.close();
 
31
                }
 
32
        }
 
33
        
 
34
        public void setEnabled(boolean enabled) throws TGPluginException {
 
35
                this.enabled = enabled;
 
36
                Iterator it = getIterator();
 
37
                while(it.hasNext()){
 
38
                        TGPlugin plugin = (TGPlugin)it.next();
 
39
                        plugin.setEnabled(this.enabled);
 
40
                }
 
41
        }
 
42
        
 
43
        public boolean isEnabled() {
 
44
                return this.enabled;
 
45
        }
 
46
        
 
47
        private Iterator getIterator(){
 
48
                if(this.plugins == null){
 
49
                        this.plugins = getPlugins();
 
50
                }
 
51
                return this.plugins.iterator();
 
52
        }
 
53
        
 
54
        protected abstract List getPlugins();
 
55
}