Package giggler.ui.impl

Source Code of giggler.ui.impl.Frontend

package giggler.ui.impl;

import giggler.Configuration;
import giggler.Management;
import giggler.Plugin;
//import giggler.ui.swt.skin.themes.ThemeFactory;

import java.util.HashMap;
import java.util.Map;




public class Frontend
{
    private Map<String, PluginView> idToViewMap = null;
    private Map<String, Plugin> idToPluginMap = null;

    private Configurator configurator = null;
    private Management management = null;
    private TrayMenu trayMenu = null;

    static {
       
//      Skinner.setActive(false);
//        ThemeFactory.setTheme("GlossyShader");
    }
   
    public Frontend() {
       
        idToPluginMap = new HashMap<String, Plugin>();
        idToViewMap = new HashMap<String, PluginView>();
        trayMenu = new TrayMenu();
       
        trayMenu.register(new TrayMenu.Callback() {

            public void about() {
            }

            public void config(PluginView pluginView) {
               
                System.out.println("config <"+pluginView+">");
               
                configurator.config(pluginView);
            }

            public void exit() {
               
              management.shutdown();
            }
        });
    }

    public boolean available(Plugin plugin) {
       
//        if (plugin == this)
//            return false;
       
        PluginView pluginView = new PluginView(plugin);
       
        Plugin storedPlugin = idToPluginMap.get(pluginView.getId());
       
        if (storedPlugin != plugin) {
           
            if (storedPlugin == null) {
               
                idToPluginMap.put(pluginView.getId(), plugin);
                idToViewMap.put(pluginView.getId(), pluginView);
               
                configurator.add(pluginView);
                trayMenu.add(pluginView);
               
            } else {
               
                throw new IllegalPluginException("plugin '"+plugin.getName()+"' registered as v"+plugin.getVersion()+" and v"+storedPlugin.getVersion());
            }
        }
       
        return (pluginView.isConfigurable() || pluginView.hasPresentation());
    }

    public void retired(Plugin plugin) {
       
        Plugin _plugin = null;
       
        for (String pluginId : idToPluginMap.keySet()) {
        
            _plugin = idToPluginMap.get(pluginId);
           
            if (_plugin == plugin) {
               
                idToPluginMap.remove(pluginId);
               
                PluginView pluginView = idToViewMap.remove(pluginId);
               
                configurator.remove(pluginView);
                trayMenu.remove(pluginView);
               
                break;
            }
        }
    }

    public boolean shutdown() {

        return true;
    }

    public void setConfiguration(Configuration configuration) {
   
        configurator = new Configurator(configuration);
    }

  public void setManagement(Management management) {

    this.management = management;
  }
   
    // INNER CLASS //////////////////////////////////////////////////////////////////////////////////////
   
}
TOP

Related Classes of giggler.ui.impl.Frontend

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.