package org.twopm.laf;

import java.util.prefs.Preferences;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.metal.MetalLookAndFeel;
import static javax.swing.plaf.metal.MetalLookAndFeel.getCurrentTheme;
import static javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme;
import org.openide.util.NbPreferences;

/**
 * @author Edward M. Kagan <pagan@tabor.one>
 */
public class TitanLookAndFeel  extends MetalLookAndFeel {
    
    public static boolean self_install ()
    {
        UIManager.LookAndFeelInfo[] installedLookAndFeels = UIManager.getInstalledLookAndFeels();
        for (UIManager.LookAndFeelInfo lafi : installedLookAndFeels)
        {
            String laf_name = "[twopm!] Titan";  //NOI18N
            if (lafi.getName().equals(laf_name))
            {
                System.out.println("LAF Persist - no install.");
                return false;
            }
        }
        System.out.print("NO LAF - installing... ");
        UIManager.installLookAndFeel(new UIManager.LookAndFeelInfo("[twopm!] Titan" , TitanLookAndFeel.class.getName()) ); //NOI18N
        System.out.println("OK");
        
        System.out.print("Applying LAf... ");
        Preferences prefs = NbPreferences.root().node( "laf" ); //NOI18N
        prefs.put( "laf", TitanLookAndFeel.class.getName() ); //NOI18N
        System.out.println("OK");
        return true;
    }

    @Override
    public String getName() {
        return "[twopm!] Titan";  //NOI18N
    }

    @Override
    protected void createDefaultTheme() {
        super.createDefaultTheme();
        if( !(getCurrentTheme() instanceof TitanTheme) )
            setCurrentTheme( new TitanTheme() );
    }

    @Override
    public UIDefaults getDefaults() {
        UIDefaults defaults = super.getDefaults();
        return defaults;
    }

    @Override
    public void initialize() {
        super.initialize();
    }
    
}
