Search in sources :

Example 1 with MetalTheme

use of javax.swing.plaf.metal.MetalTheme in project adempiere by adempiere.

the class Preference method cmd_save.

//	load
/**
	 *	Save Settings
	 */
private void cmd_save() {
    log.config("");
    //  UI
    //	AutoCommit
    Ini.setProperty(Ini.P_A_COMMIT, (autoCommit.isSelected()));
    Env.setAutoCommit(Env.getCtx(), autoCommit.isSelected());
    Ini.setProperty(Ini.P_A_NEW, (autoNew.isSelected()));
    Env.setAutoNew(Env.getCtx(), autoNew.isSelected());
    //	AdempiereSys
    Ini.setProperty(Ini.P_ADEMPIERESYS, adempiereSys.isSelected());
    //	LogMigrationScript
    Ini.setProperty(Ini.P_LOGMIGRATIONSCRIPT, logMigrationScript.isSelected());
    if (MSystem.isSwingRememberPasswordAllowed()) {
        //	AutoLogin
        Ini.setProperty(Ini.P_A_LOGIN, (autoLogin.isSelected()));
        //	Save Password
        Ini.setProperty(Ini.P_STORE_PWD, (storePassword.isSelected()));
    } else {
        Ini.setProperty(Ini.P_A_LOGIN, false);
        Ini.setProperty(Ini.P_STORE_PWD, false);
    }
    //	Show Acct Tab
    Ini.setProperty(Ini.P_SHOW_ACCT, (showAcct.isSelected()));
    Env.setContext(Env.getCtx(), "#ShowAcct", (showAcct.isSelected()));
    //	Show Trl Tab
    Ini.setProperty(Ini.P_SHOW_TRL, (showTrl.isSelected()));
    Env.setContext(Env.getCtx(), "#ShowTrl", (showTrl.isSelected()));
    //	Show Advanced Tab
    Ini.setProperty(Ini.P_SHOW_ADVANCED, (showAdvanced.isSelected()));
    Env.setContext(Env.getCtx(), "#ShowAdvanced", (showAdvanced.isSelected()));
    //  ConnectionProfile
    ValueNamePair ppNew = (ValueNamePair) connectionProfile.getSelectedItem();
    String cpNew = ppNew.getValue();
    String cpOld = CConnection.get().getConnectionProfile();
    CConnection.get().setConnectionProfile(cpNew);
    if (!cpNew.equals(cpOld) && (cpNew.equals(CConnection.PROFILE_WAN) || cpOld.equals(CConnection.PROFILE_WAN)))
        ADialog.info(0, this, "ConnectionProfileChange");
    Ini.setProperty(Ini.P_CACHE_WINDOW, cacheWindow.isSelected());
    //  Print Preview
    Ini.setProperty(Ini.P_PRINTPREVIEW, (printPreview.isSelected()));
    //  Validate Connection on Startup
    Ini.setProperty(Ini.P_VALIDATE_CONNECTION_ON_STARTUP, (validateConnectionOnStartup.isSelected()));
    //  Single Instance per Window
    Ini.setProperty(Ini.P_SINGLE_INSTANCE_PER_WINDOW, (singleInstancePerWindow.isSelected()));
    //  Open Window Maximized
    Ini.setProperty(Ini.P_OPEN_WINDOW_MAXIMIZED, (openWindowMaximized.isSelected()));
    //	TraceLevel/File
    Level level = (Level) traceLevel.getSelectedItem();
    CLogMgt.setLevel(level);
    Ini.setProperty(Ini.P_TRACELEVEL, level.getName());
    Ini.setProperty(Ini.P_TRACEFILE, traceFile.isSelected());
    //  Printer
    String printer = (String) fPrinter.getSelectedItem();
    Env.setContext(Env.getCtx(), "#Printer", printer);
    Ini.setProperty(Ini.P_PRINTER, printer);
    //  Date (remove seconds)
    java.sql.Timestamp ts = (java.sql.Timestamp) fDate.getValue();
    if (ts != null)
        Env.setContext(Env.getCtx(), "#Date", ts);
    // Charset
    Charset charset = (Charset) fCharset.getSelectedItem();
    Ini.setProperty(Ini.P_CHARSET, charset.name());
    //UI
    ValueNamePair laf = plafEditor.getSelectedLook();
    ValueNamePair theme = plafEditor.getSelectedTheme();
    if (laf != null) {
        String clazz = laf.getValue();
        String currentLaf = UIManager.getLookAndFeel().getClass().getName();
        if (clazz != null && clazz.length() > 0 && !currentLaf.equals(clazz)) {
            //laf changed
            AdempierePLAF.setPLAF(laf, theme, true);
            AEnv.updateUI();
        } else {
            if (UIManager.getLookAndFeel() instanceof MetalLookAndFeel) {
                MetalTheme currentTheme = MetalLookAndFeel.getCurrentTheme();
                String themeClass = currentTheme.getClass().getName();
                String sTheme = theme.getValue();
                if (sTheme != null && sTheme.length() > 0 && !sTheme.equals(themeClass)) {
                    ValueNamePair plaf = new ValueNamePair(UIManager.getLookAndFeel().getClass().getName(), UIManager.getLookAndFeel().getName());
                    AdempierePLAF.setPLAF(plaf, theme, true);
                    AEnv.updateUI();
                }
            }
        }
    }
    Ini.saveProperties(Ini.isClient());
    dispose();
}
Also used : MetalTheme(javax.swing.plaf.metal.MetalTheme) Charset(java.nio.charset.Charset) Level(java.util.logging.Level) ValueNamePair(org.compiere.util.ValueNamePair) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel)

Example 2 with MetalTheme

use of javax.swing.plaf.metal.MetalTheme 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)

Example 3 with MetalTheme

use of javax.swing.plaf.metal.MetalTheme in project adempiere by adempiere.

the class PreviewPanel method setLFSelection.

/**
	 *  Update the look list and theme list to show the current selection
	 */
private void setLFSelection() {
    m_setting = true;
    //  Search for PLAF
    ValueNamePair plaf = null;
    LookAndFeel lookFeel = UIManager.getLookAndFeel();
    String look = lookFeel.getClass().getName();
    for (int i = 0; i < AdempierePLAF.getPLAFs().length; i++) {
        ValueNamePair vp = AdempierePLAF.getPLAFs()[i];
        if (vp.getValue().equals(look)) {
            plaf = vp;
            break;
        }
    }
    if (plaf != null)
        lookList.setSelectedValue(plaf, true);
    //  Search for Theme
    MetalTheme metalTheme = null;
    ValueNamePair theme = null;
    boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel;
    themeList.setModel(new DefaultComboBoxModel(AdempierePLAF.getThemes()));
    if (metal) {
        theme = null;
        AppContext context = AppContext.getAppContext();
        metalTheme = (MetalTheme) context.get("currentMetalTheme");
        if (metalTheme != null) {
            String lookTheme = metalTheme.getName();
            for (int i = 0; i < AdempierePLAF.getThemes().length; i++) {
                ValueNamePair vp = AdempierePLAF.getThemes()[i];
                if (vp.getName().equals(lookTheme)) {
                    theme = vp;
                    break;
                }
            }
        }
        if (theme != null)
            themeList.setSelectedValue(theme, true);
    }
    m_setting = false;
    log.info(lookFeel + " - " + metalTheme);
}
Also used : MetalTheme(javax.swing.plaf.metal.MetalTheme) AppContext(sun.awt.AppContext) ValueNamePair(org.compiere.util.ValueNamePair) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) LookAndFeel(javax.swing.LookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel)

Example 4 with MetalTheme

use of javax.swing.plaf.metal.MetalTheme in project jdk8u_jdk by JetBrains.

the class MetalworksFrame method buildMenus.

protected void buildMenus() {
    menuBar = new JMenuBar();
    menuBar.setOpaque(true);
    JMenu file = buildFileMenu();
    JMenu edit = buildEditMenu();
    JMenu views = buildViewsMenu();
    JMenu speed = buildSpeedMenu();
    JMenu help = buildHelpMenu();
    // load a theme from a text file
    MetalTheme myTheme = null;
    try {
        InputStream istream = getClass().getResourceAsStream("/resources/MyTheme.theme");
        myTheme = new PropertiesMetalTheme(istream);
    } catch (NullPointerException e) {
        System.out.println(e);
    }
    // build an array of themes
    MetalTheme[] themes = { new OceanTheme(), new DefaultMetalTheme(), new GreenMetalTheme(), new AquaMetalTheme(), new KhakiMetalTheme(), new DemoMetalTheme(), new ContrastMetalTheme(), new BigContrastMetalTheme(), myTheme };
    // put the themes in a menu
    JMenu themeMenu = new MetalThemeMenu("Theme", themes);
    menuBar.add(file);
    menuBar.add(edit);
    menuBar.add(views);
    menuBar.add(themeMenu);
    menuBar.add(speed);
    menuBar.add(help);
    setJMenuBar(menuBar);
}
Also used : InputStream(java.io.InputStream) DefaultMetalTheme(javax.swing.plaf.metal.DefaultMetalTheme) OceanTheme(javax.swing.plaf.metal.OceanTheme) DefaultMetalTheme(javax.swing.plaf.metal.DefaultMetalTheme) MetalTheme(javax.swing.plaf.metal.MetalTheme) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 5 with MetalTheme

use of javax.swing.plaf.metal.MetalTheme in project jgnash by ccavanaugh.

the class ThemeManager method setTheme.

private static void setTheme(final String theme) {
    try {
        Class<?> themeClass = Class.forName(theme);
        MetalTheme themeObject = (MetalTheme) themeClass.newInstance();
        MetalLookAndFeel.setCurrentTheme(themeObject);
    } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
        Logger.getLogger(ThemeManager.class.getName()).log(Level.SEVERE, "Could not install theme: {0}\n{1}", new Object[] { theme, e.toString() });
    }
}
Also used : MetalTheme(javax.swing.plaf.metal.MetalTheme)

Aggregations

MetalTheme (javax.swing.plaf.metal.MetalTheme)10 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)5 ValueNamePair (org.compiere.util.ValueNamePair)5 LookAndFeel (javax.swing.LookAndFeel)4 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2 JMenu (javax.swing.JMenu)2 AppContext (sun.awt.AppContext)2 PlasticTheme (com.jgoodies.looks.plastic.PlasticTheme)1 InputStream (java.io.InputStream)1 Charset (java.nio.charset.Charset)1 Level (java.util.logging.Level)1 Preferences (java.util.prefs.Preferences)1 ButtonGroup (javax.swing.ButtonGroup)1 JMenuBar (javax.swing.JMenuBar)1 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)1 DefaultMetalTheme (javax.swing.plaf.metal.DefaultMetalTheme)1 OceanTheme (javax.swing.plaf.metal.OceanTheme)1 CompiereLookAndFeel (org.compiere.plaf.CompiereLookAndFeel)1