1
package org.herac.tuxguitar.gui.tools.browser.dialog;
3
import org.eclipse.swt.widgets.Shell;
4
import org.herac.tuxguitar.gui.system.language.LanguageLoader;
5
import org.herac.tuxguitar.gui.tools.browser.TGBrowserCollection;
6
import org.herac.tuxguitar.gui.tools.browser.TGBrowserManager;
7
import org.herac.tuxguitar.gui.tools.browser.base.TGBrowserData;
8
import org.herac.tuxguitar.gui.tools.browser.base.TGBrowserFactory;
10
public abstract class TGBrowserBar implements LanguageLoader{
11
private TGBrowserDialog browser;
13
public TGBrowserBar(TGBrowserDialog browser){
14
this.browser = browser;
17
public abstract void init(Shell shell);
19
public abstract void updateItems();
21
public abstract void updateCollections(TGBrowserCollection selection);
23
protected TGBrowserDialog getBrowser(){
27
protected void newCollection(String type){
28
TGBrowserFactory factory = TGBrowserManager.instance().getFactory(type);
30
TGBrowserData data = factory.dataDialog(getBrowser().getShell());
32
openCollection(addCollection(factory, data, true));
37
protected TGBrowserCollection addCollection(TGBrowserFactory factory,String data){
38
return this.addCollection(factory,factory.parseData(data),false);
41
protected TGBrowserCollection addCollection(TGBrowserFactory factory,TGBrowserData data,boolean reload){
42
TGBrowserCollection collection = new TGBrowserCollection();
43
collection.setType(factory.getType());
44
collection.setData(data);
45
TGBrowserManager.instance().addCollection(collection);
47
getBrowser().updateCollections(collection);
52
protected void openCollection(TGBrowserCollection collection){
53
getBrowser().setCollection(collection);
54
getBrowser().openCollection();
57
protected void removeCollection(TGBrowserCollection collection){
58
getBrowser().removeCollection(collection);
61
protected void closeCollection(){
62
getBrowser().closeCollection();