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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/tools/browser/filesystem/TGBrowserImpl.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.tools.browser.filesystem;
 
2
 
 
3
import java.io.File;
 
4
import java.util.ArrayList;
 
5
import java.util.List;
 
6
 
 
7
import org.herac.tuxguitar.gui.tools.browser.base.TGBrowser;
 
8
import org.herac.tuxguitar.gui.tools.browser.base.TGBrowserElement;
 
9
 
 
10
public class TGBrowserImpl extends TGBrowser{
 
11
        
 
12
        private File root;
 
13
        private TGBrowserElementImpl element;
 
14
        private TGBrowserDataImpl data;
 
15
        
 
16
        public TGBrowserImpl(TGBrowserDataImpl data){
 
17
                this.data = data;
 
18
        }
 
19
        
 
20
        public void open(){
 
21
                this.root = new File(this.data.getPath());
 
22
        }
 
23
        
 
24
        public void close(){
 
25
                this.root = null;
 
26
        }
 
27
        
 
28
        public void cdElement(TGBrowserElement element) {
 
29
                this.element = (TGBrowserElementImpl)element;
 
30
        }
 
31
        
 
32
        public void cdRoot() {
 
33
                this.element = null;
 
34
        }
 
35
        
 
36
        public void cdUp() {
 
37
                if(this.element != null){
 
38
                        this.element = this.element.getParent();
 
39
                }
 
40
        }
 
41
        
 
42
        public List listElements() {
 
43
                List elements = new ArrayList();
 
44
                File file = ((this.element != null)?this.element.getFile():this.root);
 
45
                if(file.exists() && file.isDirectory()){
 
46
                        File[] files = file.listFiles();
 
47
                        for(int i = 0; i < files.length;i ++){
 
48
                                elements.add(new TGBrowserElementImpl(this.element,files[i]));
 
49
                        }
 
50
                }
 
51
                return elements;
 
52
        }
 
53
        
 
54
}