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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/tools/browser/dialog/TGBrowserBar.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.dialog;
 
2
 
 
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;
 
9
 
 
10
public abstract class TGBrowserBar implements LanguageLoader{
 
11
        private TGBrowserDialog browser;
 
12
        
 
13
        public TGBrowserBar(TGBrowserDialog browser){
 
14
                this.browser = browser;
 
15
        }
 
16
        
 
17
        public abstract void init(Shell shell);
 
18
        
 
19
        public abstract void updateItems();
 
20
        
 
21
        public abstract void updateCollections(TGBrowserCollection selection);
 
22
        
 
23
        protected TGBrowserDialog getBrowser(){
 
24
                return this.browser;
 
25
        }
 
26
        
 
27
        protected void newCollection(String type){
 
28
                TGBrowserFactory factory = TGBrowserManager.instance().getFactory(type);
 
29
                if(factory != null){
 
30
                        TGBrowserData data = factory.dataDialog(getBrowser().getShell());
 
31
                        if(data != null){
 
32
                                openCollection(addCollection(factory, data, true));
 
33
                        }
 
34
                }
 
35
        }
 
36
        
 
37
        protected TGBrowserCollection addCollection(TGBrowserFactory factory,String data){
 
38
                return this.addCollection(factory,factory.parseData(data),false);
 
39
        }
 
40
        
 
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);
 
46
                if(reload){
 
47
                        getBrowser().updateCollections(collection);
 
48
                }
 
49
                return collection;
 
50
        }
 
51
        
 
52
        protected void openCollection(TGBrowserCollection collection){
 
53
                getBrowser().setCollection(collection);
 
54
                getBrowser().openCollection();
 
55
        }
 
56
        
 
57
        protected void removeCollection(TGBrowserCollection collection){
 
58
                getBrowser().removeCollection(collection);
 
59
        }
 
60
        
 
61
        protected void closeCollection(){
 
62
                getBrowser().closeCollection();
 
63
        }
 
64
        
 
65
}