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