* Fixed theme selection bug

* Change AdempiereLookAndFeel to extend Plastic3D instead of Plastic
* Remove redundant Plastic look and feel from the supported list since AdempiereLookAndFeel extend Plastic
* Fixed AdempiereLookAndFeel can't use standard PlasticTheme bug
* Make flat toolbar the default
* Improved painting after changing of look and feel or theme. Alternatively, logout after change of theme.
This commit is contained in:
Heng Sin Low 2006-11-29 07:54:39 +00:00
parent 91cfbba120
commit 959114a466
7 changed files with 108 additions and 86 deletions

View File

@ -28,13 +28,13 @@ import javax.swing.plaf.basic.*;
public class AdempiereButtonListener extends BasicButtonListener
{
/**
* Compiere Button Listener
* Adempiere Button Listener
* @param b button
*/
public AdempiereButtonListener (AbstractButton b)
{
super (b);
} // CompiereButtonListener
} // AdempiereButtonListener
/**
* Install Keyboard Actions
@ -93,4 +93,4 @@ public class AdempiereButtonListener extends BasicButtonListener
}
} // updateMnemonicBindingX
} // CompiereButtonListener
} // AdempiereButtonListener

View File

@ -19,8 +19,6 @@ import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import javax.swing.plaf.metal.*;
import org.compiere.plaf.CompiereComboPopup;
/**
* Compiere ComboBox UI.
@ -74,8 +72,6 @@ public class AdempiereComboBoxUI extends com.jgoodies.looks.plastic.PlasticCombo
protected JButton createArrowButton()
{
JButton button = super.createArrowButton();
//button.setContentAreaFilled(false);
//button.setOpaque(false);
return button;
} // createArrowButton
@ -101,7 +97,7 @@ public class AdempiereComboBoxUI extends com.jgoodies.looks.plastic.PlasticCombo
*/
protected ComboPopup createPopup()
{
CompiereComboPopup newPopup = new CompiereComboPopup( comboBox );
AdempiereComboPopup newPopup = new AdempiereComboPopup( comboBox );
newPopup.getAccessibleContext().setAccessibleParent(comboBox);
return newPopup;
} // createPopup

View File

@ -0,0 +1,74 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.adempiere.plaf;
import javax.swing.*;
import javax.swing.plaf.basic.*;
import org.compiere.swing.*;
/**
* Adempiere Combo Popup - allows to prevent the display of the popup
*
* @author Jorg Janke
* @version $Id: AdempiereComboPopup.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $
*/
public class AdempiereComboPopup extends BasicComboPopup
{
/**
* Constructor
* @param combo
*/
public AdempiereComboPopup(JComboBox combo)
{
super(combo);
} // AdempiereComboPopup
/**
* Conditionally show the Popup.
* If the combo is a CComboBox/CField, the return value of the
* method displayPopup determines if the popup is actually displayed
* @see CComboBox#displayPopup()
* @see CField#displayPopup()
*/
public void show()
{
// Check ComboBox if popup should be displayed
if (comboBox instanceof CComboBox && !((CComboBox)comboBox).displayPopup())
return;
// Check Field if popup should be displayed
if (comboBox instanceof CField && !((CField)comboBox).displayPopup())
return;
super.show();
} // show
/**
* Inform CComboBox and CField that Popup was hidden
* @see CComboBox.hidingPopup
* @see CField.hidingPopup
*
public void hide()
{
super.hide();
// Inform ComboBox that popup was hidden
if (comboBox instanceof CComboBox)
(CComboBox)comboBox).hidingPopup();
else if (comboBox instanceof CComboBox)
(CComboBox)comboBox).hidingPopup();
} // hided
/**/
} // AdempiereComboPopup

View File

@ -22,7 +22,7 @@ import javax.swing.plaf.metal.*;
import sun.swing.*;
/**
* Compiere Label UI
* Adempiere Label UI
*
* @author Jorg Janke
* @version $Id: CompiereLabelUI.java,v 1.2 2005/12/05 02:38:28 jjanke Exp $
@ -30,7 +30,7 @@ import sun.swing.*;
public class AdempiereLabelUI extends MetalLabelUI
{
/** Singleton */
protected static AdempiereLabelUI compiereLabelUI = new AdempiereLabelUI();
protected static AdempiereLabelUI adempiereLabelUI = new AdempiereLabelUI();
/**
* Create UI
@ -39,7 +39,7 @@ public class AdempiereLabelUI extends MetalLabelUI
*/
public static AdempiereLabelUI createUI(JComponent c)
{
return compiereLabelUI;
return adempiereLabelUI;
} // createUI
/**
@ -150,4 +150,4 @@ public class AdempiereLabelUI extends MetalLabelUI
} // doPress
} // PressAction
} // CompiereLabelUI
} // AdempiereLabelUI

View File

@ -19,14 +19,13 @@ package org.adempiere.plaf;
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.metal.*;
import com.jgoodies.looks.plastic.PlasticLookAndFeel;
import com.jgoodies.looks.plastic.PlasticTheme;
/**
* Adempiere Look & Feel, based on JGoodies look and feel
*/
public class AdempiereLookAndFeel extends com.jgoodies.looks.plastic.PlasticLookAndFeel
public class AdempiereLookAndFeel extends com.jgoodies.looks.plastic.Plastic3DLookAndFeel
{
/**
* Constructor
@ -41,8 +40,8 @@ public class AdempiereLookAndFeel extends com.jgoodies.looks.plastic.PlasticLook
public static final String NAME = "Adempiere";
/** The Theme */
private static AdempiereTheme s_adempiereTheme = new org.adempiere.plaf.AdempiereTheme();
private static AdempiereTheme s_theme = s_adempiereTheme;
private static PlasticTheme s_adempiereTheme = new org.adempiere.plaf.AdempiereTheme();
private static PlasticTheme s_theme = s_adempiereTheme;
/** Paint Round Corners */
protected static boolean ROUND = false;
@ -98,26 +97,8 @@ public class AdempiereLookAndFeel extends com.jgoodies.looks.plastic.PlasticLook
//System.out.println("AdempiereLookAndFeel.initClassDefaults");
super.initClassDefaults( table);
// Overwrite
/*putDefault (table, "PanelUI");
putDefault (table, "ButtonUI");
putDefault (table, "ToggleButtonUI");
putDefault (table, "TabbedPaneUI");
putDefault (table, "TableHeaderUI");
putDefault (table, "RadioButtonUI");*/
//putDefault (table, "CheckBoxUI");
putDefault (table, "ComboBoxUI");
/*putDefault (table, "MenuUI");
putDefault (table, "MenuBarUI");
putDefault (table, "MenuItemUI");
putDefault (table, "CheckBoxMenuItemUI");
putDefault (table, "ToolBarUI");
putDefault (table, "RootPaneUI");
putDefault (table, "ViewportUI");
putDefault (table, "SplitPaneUI");
putDefault (table, "ScrollPaneUI");*/
putDefault (table, "LabelUI");
/*putDefault (table, "ToolTipUI");
putDefault (table, "TextAreaUI");*/
} // initClassDefaults
@ -170,39 +151,32 @@ public class AdempiereLookAndFeel extends com.jgoodies.looks.plastic.PlasticLook
} // initComponentDefaults
/**************************************************************************
* Create Default Thems
*/
protected void createDefaultTheme()
{
setCurrentTheme(s_theme);
} // createDefaultTheme
/**
* Set Current Theme
* @param theme metal theme
*/
public static void setCurrentTheme (org.adempiere.plaf.AdempiereTheme theme)
public static void setCurrentTheme (PlasticTheme theme)
{
if (theme != null)
if (theme != null) {
s_theme = theme;
PlasticLookAndFeel.setCurrentTheme(s_theme);
PlasticLookAndFeel.setCurrentTheme(s_theme);
}
} // setCurrentTheme
/**
* Get Current Theme
* @return Metal Theme
*/
public static AdempiereTheme getCurrentTheme()
public static PlasticTheme getCurrentTheme()
{
return s_theme;
} // getCurrentTheme
/**
* Get Compiere Theme
* Get default adempiere theme
* @return Metal Theme
*/
public static AdempiereTheme getAdempiereTheme()
public static PlasticTheme getDefaultTheme()
{
return s_adempiereTheme;
} // getCurrentTheme

View File

@ -22,7 +22,6 @@ import java.awt.Font;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.WindowEvent;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
@ -32,7 +31,6 @@ import java.util.ResourceBundle;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
@ -44,13 +42,11 @@ import org.compiere.plaf.CompiereLookAndFeel;
import org.compiere.plaf.CompiereThemeBlueMetal;
import org.compiere.plaf.CompiereThemeIce;
import org.compiere.swing.CButton;
import org.compiere.swing.CFrame;
import org.compiere.swing.ColorBlind;
import org.compiere.swing.ExtendedTheme;
import org.compiere.util.Ini;
import org.compiere.util.ValueNamePair;
import com.jgoodies.looks.plastic.PlasticLookAndFeel;
import com.jgoodies.looks.plastic.PlasticTheme;
/**
@ -286,7 +282,6 @@ public final class AdempierePLAF
//default theme
private static ValueNamePair s_vp_compiereTheme = null;
private static ValueNamePair s_vp_metalTheme = null;
private static ValueNamePair s_vp_plasticTheme = null;
//e-evolution vpj-cd 19102006
private static ValueNamePair s_vp_adempiereTheme = null;
//e-evolution vpj-cd 1910200sky
@ -305,21 +300,15 @@ public final class AdempierePLAF
try
{
Class c = Class.forName("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
Class.forName("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
vp = new ValueNamePair("org.adempiere.plaf.AdempiereLookAndFeel", org.adempiere.plaf.AdempiereLookAndFeel.NAME);
plafList.add(vp);
s_vp_adempiereTheme = new ValueNamePair("org.adempiere.plaf.AdempiereTheme", AdempiereThemeInnova.NAME);
plasticThemes.add (s_vp_adempiereTheme);
c = Class.forName("com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
vp = new ValueNamePair("com.jgoodies.looks.plastic.PlasticXPLookAndFeel", "Plastic");
plafList.add(vp);
MetalTheme theme = PlasticLookAndFeel.createMyDefaultTheme();
vp = new ValueNamePair(theme.getClass().getName(), theme.getName());
s_vp_plasticTheme = vp;
List installedThemes = PlasticLookAndFeel.getInstalledThemes();
List installedThemes = AdempiereLookAndFeel.getInstalledThemes();
for(Object t : installedThemes) {
theme = (MetalTheme)t;
MetalTheme theme = (MetalTheme)t;
vp = new ValueNamePair(theme.getClass().getName(), theme.getName());
plasticThemes.add(vp);
}
@ -397,7 +386,7 @@ public final class AdempierePLAF
public static ValueNamePair[] getThemes ()
{
LookAndFeel l = UIManager.getLookAndFeel();
if ( l instanceof PlasticLookAndFeel)
if ( l instanceof AdempiereLookAndFeel)
return s_plasticThemes;
else if ( l instanceof MetalLookAndFeel)
return s_metalThemes;
@ -480,7 +469,6 @@ public final class AdempierePLAF
// Default Theme
boolean metal = MetalLookAndFeel.class.isAssignableFrom(lafClass);
boolean plastic = PlasticLookAndFeel.class.isAssignableFrom(lafClass);
boolean adempiere = AdempiereLookAndFeel.class.isAssignableFrom(lafClass);
boolean compiere = CompiereLookAndFeel.class.isAssignableFrom(lafClass);
if (theme == null && metal)
@ -489,8 +477,6 @@ public final class AdempierePLAF
theme = s_vp_compiereTheme;
else if (adempiere)
theme = s_vp_adempiereTheme;
else if (plastic)
theme = s_vp_plasticTheme;
else
theme = s_vp_metalTheme;
}
@ -502,15 +488,10 @@ public final class AdempierePLAF
MetalTheme t = (MetalTheme)c.newInstance();
if (compiere)
CompiereLookAndFeel.setCurrentTheme(t);
else if (adempiere)
AdempiereLookAndFeel.setCurrentTheme(t);
else {
if (plastic && t instanceof PlasticTheme) {
PlasticLookAndFeel.setPlasticTheme((PlasticTheme)t);
} else {
MetalLookAndFeel.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());
@ -560,7 +541,7 @@ public final class AdempierePLAF
{
// Clean Theme Properties
AdempierePLAF.setPLAF ();
} // reset
} // reset
/**
* Print current UIDefaults
@ -647,15 +628,10 @@ public final class AdempierePLAF
{
if (laf instanceof CompiereLookAndFeel)
CompiereLookAndFeel.setCurrentTheme(theme);
else if (laf instanceof AdempiereLookAndFeel)
AdempiereLookAndFeel.setCurrentTheme(theme);
else {
if (laf instanceof PlasticLookAndFeel && theme instanceof PlasticTheme) {
PlasticLookAndFeel.setPlasticTheme((PlasticTheme)theme);
} else {
MetalLookAndFeel.setCurrentTheme(theme);
}
}
else if (laf instanceof AdempiereLookAndFeel && theme instanceof PlasticTheme)
AdempiereLookAndFeel.setCurrentTheme((PlasticTheme)theme);
else
MetalLookAndFeel.setCurrentTheme(theme);
}
/**************************************************************************

View File

@ -433,6 +433,8 @@ class PreviewPanel extends CPanel {
UIManager.setLookAndFeel(laf);
} catch (UnsupportedLookAndFeelException e) {
}
laf = null;
theme = null;
}
} else {
//draw captured preview image