~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/TGInputStreamPlugin.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 org.herac.tuxguitar.io.base.TGFileFormatManager;
 
4
import org.herac.tuxguitar.io.base.TGInputStreamBase;
 
5
 
 
6
public abstract class TGInputStreamPlugin extends TGPluginAdapter{
 
7
        
 
8
        private boolean loaded;
 
9
        private TGInputStreamBase stream;
 
10
        
 
11
        protected abstract TGInputStreamBase getInputStream();
 
12
        
 
13
        public void init(){
 
14
                this.stream = getInputStream();
 
15
        }
 
16
        
 
17
        public void close(){
 
18
                this.removePlugin();
 
19
        }
 
20
        
 
21
        protected void addPlugin(){
 
22
                if(!this.loaded){
 
23
                        TGFileFormatManager.instance().addInputStream(this.stream);
 
24
                        this.loaded = true;
 
25
                }
 
26
        }
 
27
        
 
28
        protected void removePlugin(){
 
29
                if(this.loaded){
 
30
                        TGFileFormatManager.instance().removeInputStream(this.stream);
 
31
                        this.loaded = false;
 
32
                }
 
33
        }
 
34
        
 
35
        public void setEnabled(boolean enabled) {
 
36
                if(enabled){
 
37
                        addPlugin();
 
38
                }else{
 
39
                        removePlugin();
 
40
                }
 
41
        }
 
42
        
 
43
}