TGCommunitySingleton.java :  » Music » TuxGuitar-1.2 » org » herac » tuxguitar » community » Java Open Source

Java Open Source » Music » TuxGuitar 1.2 
TuxGuitar 1.2 » org » herac » tuxguitar » community » TGCommunitySingleton.java
package org.herac.tuxguitar.community;

import org.herac.tuxguitar.community.auth.TGCommunityAuth;
import org.herac.tuxguitar.gui.system.config.TGConfigManager;
import org.herac.tuxguitar.gui.system.plugins.TGPluginConfigManager;

public class TGCommunitySingleton {
  
  private static TGCommunitySingleton instance;
  
  private TGConfigManager config;
  private TGCommunityAuth auth;
  
  private TGCommunitySingleton(){
    this.auth = new TGCommunityAuth();
  }
  
  public static TGCommunitySingleton getInstance() {
    synchronized ( TGCommunitySingleton.class ) {
      if( instance == null ){
        instance = new TGCommunitySingleton();
      }
    }
    return instance;
  }
  
  public TGConfigManager getConfig(){
    if(this.config == null){ 
      this.config = new TGPluginConfigManager("tuxguitar-community");
      this.config.init();
    }
    return this.config;
  }
  
  public void loadSettings(){
    TGConfigManager config = getConfig();
    this.auth.load( config );
  }
  
  public void saveSettings(){
    TGConfigManager config = getConfig();
    this.auth.save( config );
    config.save();
  }
  
  public TGCommunityAuth getAuth(){
    return this.auth;
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.