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();
}
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();
}
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);
}
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);
}
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() });
}
}
Aggregations