Search in sources :

Example 1 with PlasticTheme

use of com.jgoodies.looks.plastic.PlasticTheme in project adempiere by adempiere.

the class AdempierePLAF method setPLAF.

//  setPLAF
/**
	 *  Set PLAF and update Ini
	 *
	 *  @param plaf     ValueNamePair of the PLAF to be set
	 *  @param theme    Optional Theme name
	 *  @param upateIni     Update setting to INI
	 */
public static void setPLAF(ValueNamePair plaf, ValueNamePair theme, boolean updateIni) {
    if (plaf == null)
        return;
    log.config(plaf + (theme == null ? "" : (" - " + theme)));
    //	  Look & Feel
    Class<?> lafClass = null;
    try {
        lafClass = Class.forName(plaf.getValue());
    } catch (Exception e) {
        log.severe(e.getMessage());
        return;
    }
    if (updateIni) {
        Ini.setProperty(Ini.P_UI_LOOK, plaf.getName());
        //  Optional Theme
        Ini.setProperty(Ini.P_UI_THEME, "");
    }
    //  Default Theme
    boolean metal = MetalLookAndFeel.class.isAssignableFrom(lafClass);
    boolean adempiere = AdempiereLookAndFeel.class.isAssignableFrom(lafClass);
    boolean compiere = CompiereLookAndFeel.class.isAssignableFrom(lafClass);
    if (theme == null && metal) {
        if (compiere)
            theme = s_vp_compiereTheme;
        else if (adempiere)
            theme = s_vp_adempiereTheme;
        else
            theme = s_vp_metalTheme;
    }
    if (theme != null && metal && theme.getValue().length() > 0) {
        try {
            Class<?> c = Class.forName(theme.getValue());
            MetalTheme t = (MetalTheme) c.newInstance();
            if (compiere)
                CompiereLookAndFeel.setCurrentTheme(t);
            else if (adempiere && t instanceof PlasticTheme)
                AdempiereLookAndFeel.setCurrentTheme((PlasticTheme) t);
            else
                MetalLookAndFeel.setCurrentTheme(t);
            //
            if (updateIni)
                Ini.setProperty(Ini.P_UI_THEME, theme.getName());
        } catch (Exception e) {
            log.severe("Theme - " + e.getMessage());
        }
    }
    try {
        UIManager.setLookAndFeel((LookAndFeel) lafClass.newInstance());
    } catch (Exception e) {
        log.severe(e.getMessage());
    }
    log.config(plaf + " - " + theme);
//	printPLAFDefaults();
}
Also used : MetalTheme(javax.swing.plaf.metal.MetalTheme) PlasticTheme(com.jgoodies.looks.plastic.PlasticTheme)

Aggregations

PlasticTheme (com.jgoodies.looks.plastic.PlasticTheme)1 MetalTheme (javax.swing.plaf.metal.MetalTheme)1