From b830c022cd1043f048b92c696b0ffc5326a51bae Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Mon, 27 Nov 2006 08:02:27 +0000 Subject: [PATCH] * New look and feel and theme selection UI. The old editor is still there but not used. * Make compiere swing components works better under window and plastic look and feel. * Rename org.compiere.plaf.Adempiere*UI classes back to org.compiere.plaf.Compiere*UI. This is to make a clean separation between the new AdempiereLookAndFeel and the old CompiereLookAndFeel. Any class used by AdempiereLookAndFeel should goes into the org.adempiere.plaf package instead. As part of the exercise, AdempierePLAF is moved from org.compiere.plaf to org.adempiere.plaf * Fixed some bug related UI painting issue after switching of look and feel. It is still not perfect but much better. * Added a logout icon. Feel free to replace this if you have a better one. Please email me or post into the SF Developer forum is I break anything. Also, I haven't tested the new code under Linux yet and some localization work to be done. --- .../org/adempiere/plaf/AdempiereColor.java | 1268 ----------------- .../adempiere/plaf/AdempiereColorBlind.java | 286 ---- .../adempiere/plaf/AdempiereComboBoxUI.java | 10 +- .../adempiere/plaf/AdempiereLookAndFeel.java | 53 +- .../plaf/AdempierePLAF.java | 389 ++--- .../org/adempiere/plaf/AdempiereTheme.java | 295 +--- .../plaf/AdempiereThemeInnova.java | 2 +- .../plaf/PLAFEditor.java} | 128 +- .../org/adempiere/plaf/PLAFEditorPanel.java | 445 ++++++ ...tener.java => CompiereButtonListener.java} | 4 +- ...ereButtonUI.java => CompiereButtonUI.java} | 10 +- ...I.java => CompiereCheckBoxMenuItemUI.java} | 4 +- ...heckBoxUI.java => CompiereCheckBoxUI.java} | 6 +- ...AdempiereColor.java => CompiereColor.java} | 120 +- ...omboBoxUI.java => CompiereComboBoxUI.java} | 6 +- ...omboPopup.java => CompiereComboPopup.java} | 4 +- ...piereLabelUI.java => CompiereLabelUI.java} | 6 +- .../compiere/plaf/CompiereLookAndFeel.java | 35 +- ...eMenuBarUI.java => CompiereMenuBarUI.java} | 6 +- ...enuItemUI.java => CompiereMenuItemUI.java} | 8 +- ...empiereMenuUI.java => CompiereMenuUI.java} | 4 +- ...pierePanelUI.java => CompierePanelUI.java} | 53 +- ...ttonUI.java => CompiereRadioButtonUI.java} | 4 +- ...ootPaneUI.java => CompiereRootPaneUI.java} | 2 +- ...lPaneUI.java => CompiereScrollPaneUI.java} | 4 +- ...der.java => CompiereSplitPaneDivider.java} | 4 +- ...itPaneUI.java => CompiereSplitPaneUI.java} | 6 +- ...dPaneUI.java => CompiereTabbedPaneUI.java} | 40 +- ...aderUI.java => CompiereTableHeaderUI.java} | 12 +- ...extAreaUI.java => CompiereTextAreaUI.java} | 6 +- .../src/org/compiere/plaf/CompiereTheme.java | 304 +--- .../compiere/plaf/CompiereThemeBlueMetal.java | 4 +- ...meEditor.java => CompiereThemeEditor.java} | 7 +- ...tonUI.java => CompiereToggleButtonUI.java} | 8 +- ...eToolBarUI.java => CompiereToolBarUI.java} | 4 +- ...eToolTipUI.java => CompiereToolTipUI.java} | 4 +- ...AdempiereUtils.java => CompiereUtils.java} | 19 +- ...iewportUI.java => CompiereViewportUI.java} | 4 +- looks/src/org/compiere/plaf/PlafRes.java | 4 +- looks/src/org/compiere/swing/CButton.java | 27 +- looks/src/org/compiere/swing/CCheckBox.java | 6 +- looks/src/org/compiere/swing/CComboBox.java | 24 +- looks/src/org/compiere/swing/CDialog.java | 1 - looks/src/org/compiere/swing/CField.java | 2 +- looks/src/org/compiere/swing/CFrame.java | 1 - looks/src/org/compiere/swing/CLabel.java | 3 - looks/src/org/compiere/swing/CPanel.java | 26 +- looks/src/org/compiere/swing/CPassword.java | 4 +- looks/src/org/compiere/swing/CScrollPane.java | 12 +- looks/src/org/compiere/swing/CTabbedPane.java | 35 +- looks/src/org/compiere/swing/CTable.java | 10 + looks/src/org/compiere/swing/CTextArea.java | 3 +- looks/src/org/compiere/swing/CTextField.java | 3 +- looks/src/org/compiere/swing/CTextPane.java | 3 +- .../src/org/compiere/swing/CToggleButton.java | 26 +- .../compiere/{plaf => swing}/ColorBlind.java | 2 +- .../ColorEditor.java} | 67 +- .../src/org/compiere/swing/ExtendedTheme.java | 30 + .../compiere/{plaf => swing}/FontChooser.java | 4 +- looks/src/org/compiere/swing/ThemeUtils.java | 220 +++ looks/src/org/compiere/util/Ini.java | 11 +- looks/src/org/compiere/util/IniDialog.java | 1 + looks/src/org/compiere/util/MiniBrowser.java | 3 +- looks/swing.properties | 2 +- 64 files changed, 1314 insertions(+), 2790 deletions(-) delete mode 100755 looks/src/org/adempiere/plaf/AdempiereColor.java delete mode 100755 looks/src/org/adempiere/plaf/AdempiereColorBlind.java rename looks/src/org/{compiere => adempiere}/plaf/AdempierePLAF.java (60%) rename looks/src/org/{compiere => adempiere}/plaf/AdempiereThemeInnova.java (96%) rename looks/src/org/{compiere/plaf/AdempierePLAFEditor.java => adempiere/plaf/PLAFEditor.java} (80%) create mode 100644 looks/src/org/adempiere/plaf/PLAFEditorPanel.java rename looks/src/org/compiere/plaf/{AdempiereButtonListener.java => CompiereButtonListener.java} (94%) rename looks/src/org/compiere/plaf/{AdempiereButtonUI.java => CompiereButtonUI.java} (89%) rename looks/src/org/compiere/plaf/{AdempiereCheckBoxMenuItemUI.java => CompiereCheckBoxMenuItemUI.java} (92%) rename looks/src/org/compiere/plaf/{AdempiereCheckBoxUI.java => CompiereCheckBoxUI.java} (90%) rename looks/src/org/compiere/plaf/{AdempiereColor.java => CompiereColor.java} (85%) rename looks/src/org/compiere/plaf/{AdempiereComboBoxUI.java => CompiereComboBoxUI.java} (92%) rename looks/src/org/compiere/plaf/{AdempiereComboPopup.java => CompiereComboPopup.java} (93%) rename looks/src/org/compiere/plaf/{AdempiereLabelUI.java => CompiereLabelUI.java} (92%) rename looks/src/org/compiere/plaf/{AdempiereMenuBarUI.java => CompiereMenuBarUI.java} (90%) rename looks/src/org/compiere/plaf/{AdempiereMenuItemUI.java => CompiereMenuItemUI.java} (89%) rename looks/src/org/compiere/plaf/{AdempiereMenuUI.java => CompiereMenuUI.java} (93%) rename looks/src/org/compiere/plaf/{AdempierePanelUI.java => CompierePanelUI.java} (75%) rename looks/src/org/compiere/plaf/{AdempiereRadioButtonUI.java => CompiereRadioButtonUI.java} (90%) rename looks/src/org/compiere/plaf/{AdempiereRootPaneUI.java => CompiereRootPaneUI.java} (94%) rename looks/src/org/compiere/plaf/{AdempiereScrollPaneUI.java => CompiereScrollPaneUI.java} (92%) rename looks/src/org/compiere/plaf/{AdempiereSplitPaneDivider.java => CompiereSplitPaneDivider.java} (92%) rename looks/src/org/compiere/plaf/{AdempiereSplitPaneUI.java => CompiereSplitPaneUI.java} (91%) rename looks/src/org/compiere/plaf/{AdempiereTabbedPaneUI.java => CompiereTabbedPaneUI.java} (93%) rename looks/src/org/compiere/plaf/{AdempiereTableHeaderUI.java => CompiereTableHeaderUI.java} (87%) rename looks/src/org/compiere/plaf/{AdempiereTextAreaUI.java => CompiereTextAreaUI.java} (93%) rename looks/src/org/compiere/plaf/{AdempiereThemeEditor.java => CompiereThemeEditor.java} (96%) rename looks/src/org/compiere/plaf/{AdempiereToggleButtonUI.java => CompiereToggleButtonUI.java} (89%) rename looks/src/org/compiere/plaf/{AdempiereToolBarUI.java => CompiereToolBarUI.java} (93%) rename looks/src/org/compiere/plaf/{AdempiereToolTipUI.java => CompiereToolTipUI.java} (93%) rename looks/src/org/compiere/plaf/{AdempiereUtils.java => CompiereUtils.java} (93%) rename looks/src/org/compiere/plaf/{AdempiereViewportUI.java => CompiereViewportUI.java} (93%) rename looks/src/org/compiere/{plaf => swing}/ColorBlind.java (96%) rename looks/src/org/compiere/{plaf/AdempiereColorEditor.java => swing/ColorEditor.java} (89%) create mode 100644 looks/src/org/compiere/swing/ExtendedTheme.java rename looks/src/org/compiere/{plaf => swing}/FontChooser.java (96%) create mode 100644 looks/src/org/compiere/swing/ThemeUtils.java diff --git a/looks/src/org/adempiere/plaf/AdempiereColor.java b/looks/src/org/adempiere/plaf/AdempiereColor.java deleted file mode 100755 index 09d3de16ea..0000000000 --- a/looks/src/org/adempiere/plaf/AdempiereColor.java +++ /dev/null @@ -1,1268 +0,0 @@ -/****************************************************************************** - * The contents of this file are subject to the Compiere License Version 1.1 - * ("License"); You may not use this file except in compliance with the License - * You may obtain a copy of the License at http://www.compiere.org/license.html - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for - * the specific language governing rights and limitations under the License. - * The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial - * Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke - * are Copyright (C) 1999-2005 Jorg Janke. - * All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved. - * Contributor(s): ______________________________________. - *****************************************************************************/ -package org.adempiere.plaf; - -import java.awt.*; -import java.awt.image.*; -import java.io.*; -import java.net.*; -import java.util.*; -import java.util.logging.*; -import javax.swing.*; -import javax.swing.plaf.*; -import org.compiere.util.*; -import org.compiere.plaf.*; - -/** - * Compiere Background Color - * - * @author Jorg Janke - * @version $Id: CompiereColor.java,v 1.24 2005/10/21 15:44:12 jjanke Exp $ - */ -public class AdempiereColor implements Serializable -{ - /** Background type Flat */ - public static final String TYPE_FLAT = "F"; - /** Background type Gradient */ - public static final String TYPE_GRADIENT = "G"; - /** Background type Lines */ - public static final String TYPE_LINES = "L"; - /** Background type Texture */ - public static final String TYPE_TEXTURE = "T"; - - /** Names */ - private static ResourceBundle s_res = ResourceBundle.getBundle("org.compiere.plaf.PlafRes"); - - /** Type Values */ - public static final String[] TYPE_VALUES = new String[] { - TYPE_FLAT, TYPE_GRADIENT, TYPE_LINES, TYPE_TEXTURE - }; - /** Type Names */ - public static final String[] TYPE_NAMES = new String[] { - s_res.getString("BackColType_Flat"), - s_res.getString("BackColType_Gradient"), - s_res.getString("BackColType_Lines"), - s_res.getString("BackColType_Texture") - }; - /** Types */ - public static final ValueNamePair[] TYPES = new ValueNamePair[] { - new ValueNamePair(TYPE_VALUES[0], TYPE_NAMES[0]), - new ValueNamePair(TYPE_VALUES[1], TYPE_NAMES[1]), - new ValueNamePair(TYPE_VALUES[2], TYPE_NAMES[2]), - new ValueNamePair(TYPE_VALUES[3], TYPE_NAMES[3]) - }; - - /** Gradient Starting Values */ - public static final int[] GRADIENT_SP_VALUES = new int[] { - SwingConstants.NORTH, SwingConstants.NORTH_EAST, - SwingConstants.EAST, SwingConstants.SOUTH_EAST, - SwingConstants.SOUTH, SwingConstants.SOUTH_WEST, - SwingConstants.WEST, SwingConstants.NORTH_WEST - }; - /** Gradient Starting Names */ - public static final String[] GRADIENT_SP_NAMES = new String[] { - "North", "North-East", - "East", "South-East", - "South", "South-West", - "West", "North-West" - }; - /** Gradient Starting Point */ - public static final KeyNamePair[] GRADIENT_SP = new KeyNamePair[] { - new KeyNamePair(GRADIENT_SP_VALUES[0], GRADIENT_SP_NAMES[0]), - new KeyNamePair(GRADIENT_SP_VALUES[1], GRADIENT_SP_NAMES[1]), - new KeyNamePair(GRADIENT_SP_VALUES[2], GRADIENT_SP_NAMES[2]), - new KeyNamePair(GRADIENT_SP_VALUES[3], GRADIENT_SP_NAMES[3]), - new KeyNamePair(GRADIENT_SP_VALUES[4], GRADIENT_SP_NAMES[4]), - new KeyNamePair(GRADIENT_SP_VALUES[5], GRADIENT_SP_NAMES[5]), - new KeyNamePair(GRADIENT_SP_VALUES[6], GRADIENT_SP_NAMES[6]), - new KeyNamePair(GRADIENT_SP_VALUES[7], GRADIENT_SP_NAMES[7]) - }; - /** Exception text */ - private static final String EXCEPTION_TEXT = "Arguments cannot be NULL"; - - - /************************************************************************** - * Set Background of Component to default color - * @param c component - */ - /* - public static void setBackground (JComponent c) - { - setBackground (c, CompierePanelUI.getDefaultBackground()); - } // setBackground - */ - /** - * Set Background of Component - * @param c Component - * @param cc Color - */ - public static void setBackground (JComponent c, AdempiereColor cc) - { - c.putClientProperty(AdempierePLAF.BACKGROUND, cc); - } // setBackground - - /** - * Get Background Color of component - * @param c JComponent - * @return Color - */ - public static AdempiereColor getBackground (JComponent c) - { - AdempiereColor bg = null; - try - { - bg = (AdempiereColor)c.getClientProperty(AdempierePLAF.BACKGROUND); - } - catch (Exception e) - { - log.severe("ClientProperty: " + e.getMessage()); - } - return bg; - } // getBackground - - /** - * Set Background of Window Content Pane to default color - * @param win window - */ - /* - public static void setBackground (Window win) - { - setBackground (win, CompierePanelUI.getDefaultBackground()); - } // setBackground - */ - /** - * Set Background of Window Content Pane - * @param win window - * @param cc compiere color - */ - public static void setBackground (Window win, AdempiereColor cc) - { - if (win instanceof JDialog) - { - ((JPanel)((JDialog)win).getContentPane()).putClientProperty(AdempierePLAF.BACKGROUND, cc); - // ((JPanel)((JDialog)win).getContentPane()).setName("contentPane"); - } - else if (win instanceof JFrame) - { - ((JPanel)((JFrame)win).getContentPane()).putClientProperty(AdempierePLAF.BACKGROUND, cc); - // ((JPanel)((JFrame)win).getContentPane()).setName("contentPane"); - } - else if (win instanceof JWindow) - { - ((JPanel)((JWindow)win).getContentPane()).putClientProperty(AdempierePLAF.BACKGROUND, cc); - // ((JPanel)((JWindow)win).getContentPane()).setName("contentPane"); - } - } // setBackground - - /** - * Set Default Background - * @param bg Background Color - * @see CompierePanelUI#setDefaultBackground - */ - /* - public static void setDefaultBackground (AdempiereColor bg) - { - CompierePanelUI.setDefaultBackground(bg); - } // setDefaultBackground - */ - - /** - * Get Default Background - * @return Background - * @see CompierePanelUI#getDefaultBackground - */ - /* - public static AdempiereColor getDefaultBackground() - { - return CompierePanelUI.getDefaultBackground(); - } // getDefaultBackground - - /** - * - * Set Default Background - * @param setDefault if true, the background will be set to the default color - * @see CompierePanelUI#setSetDefault - */ - public static void setSetDefault (boolean setDefault) - { - AdempierePanelUI.setSetDefault(setDefault); - } // setSetDefault - - /** - * Is the Default Background set by default - * @return true if default background is set - * @see AdempierePanelUI#isSetDefault - */ - public static boolean isSetDefault() - { - return AdempierePanelUI.isSetDefault(); - } // isSetDefault - - /** - * Parse attributes and return CompiereColor - * @param attributes attributes - * @return CompiereColor - */ - public static AdempiereColor parse (String attributes) - { - AdempiereColor cc = new AdempiereColor (); - try - { - if (attributes != null && attributes.length() > 0) - cc.parseAttributres (attributes); - } - catch (Exception e) - { - log.severe("(" + attributes + ") - " + e.toString()); - } - return cc; - } // parse - - - /************************************************************************* - * Create Gradient Background Color (Window System Color - White) - */ - public AdempiereColor() - { - this (TYPE_GRADIENT); - } // CompiereColor - - /** - * Create Default Background Colors of Type - * @param type Background type (see constants TYPE_*) - */ - public AdempiereColor (String type) - { - if (type == null) - new java.lang.IllegalArgumentException (EXCEPTION_TEXT); - if (type.equals(TYPE_FLAT) || type.equals(TYPE_GRADIENT) - || type.equals(TYPE_TEXTURE) || type.equals(TYPE_LINES)) - { - m_type = type; - } - else - new java.lang.IllegalArgumentException ("Invalid Type"); - } // CompiereColor - - /** - * Create Flat Background Color - * @param bg background - */ - public AdempiereColor (Color bg) - { - this (bg, true); - } // CompiereColor - - /** - * Create Background Color - * @param bg Color - * @param flat if true create Flat color otherwise Gradient color with white lower color - */ - public AdempiereColor (Color bg, boolean flat) - { - if (bg == null) - new java.lang.IllegalArgumentException (EXCEPTION_TEXT); - m_type = flat ? TYPE_FLAT : TYPE_GRADIENT; - m_primaryColor = bg; - } // CompiereColor - - /** - * Set Background to Gradient colors - * @param upperColor upper Color - * @param lowerColor lower Color - * @param startPoint Starting point - e.g. SOUTH_WEST see SwingConstants, default NORTH_WEST - * @param repeatDistance X/Y Distance to repeat gradient in points - 0 no repeats - */ - public AdempiereColor (Color upperColor, Color lowerColor, int startPoint, int repeatDistance) - { - if (upperColor == null || lowerColor == null) - new java.lang.IllegalArgumentException (EXCEPTION_TEXT); - m_type = TYPE_GRADIENT; - m_primaryColor = upperColor; - m_secondaryColor = lowerColor; - m_startPoint = startPoint; - m_repeatDistance = repeatDistance; - } // CompiereColor - - /** - * Set Background to Gradient colors. - * Starting in the north, repeat after 100 pt - * @param upperColor upper color - * @param lowerColor lower color - */ - public AdempiereColor (Color upperColor, Color lowerColor) - { - this (upperColor, lowerColor, SwingConstants.NORTH_WEST, 100); - } // CompiereColor - - /** - * Set Background to Texture - * - * @param textureURL URL to a *.gif or *.jpg graphic file - * @param taint Color to taint the texture (use white for not tainting it) - * @param compositeAlpha Value from 0(no) to 1(full) taining - */ - public AdempiereColor (URL textureURL, Color taint, float compositeAlpha) - { - if (textureURL == null || taint == null) - new java.lang.IllegalArgumentException (EXCEPTION_TEXT); - m_type = TYPE_TEXTURE; - m_textureURL = textureURL; - m_primaryColor = taint; - m_compositeAlpha = compositeAlpha; - } // CompiereColor - - /** - * Set Background to Texture - * - * @param textureURL URL to a *.gif or *.jpg graphic file - * @param taint Color to taint the texture (use white for not tainting it) - * @param compositeAlpha Tainting value from 0 (no - FullGraph) to 1 (full - NoGraph) - */ - public AdempiereColor (String textureURL, Color taint, float compositeAlpha) - { - if (textureURL == null || taint == null) - new java.lang.IllegalArgumentException (EXCEPTION_TEXT); - m_type = TYPE_TEXTURE; - setTextureURL(textureURL); - m_primaryColor = taint; - m_compositeAlpha = compositeAlpha; - } // CompiereColor - - /** - * Set Background to Lines - * - * @param lineColor line color - * @param backColor background color - * @param lineWidth Stroke width in point - * @param lineDistance Distance between lines in points - */ - public AdempiereColor (Color lineColor, Color backColor, float lineWidth, int lineDistance) - { - if (lineColor == null || backColor == null) - new java.lang.IllegalArgumentException (EXCEPTION_TEXT); - m_type = TYPE_LINES; - m_primaryColor = backColor; - m_secondaryColor = lineColor; - m_lineWidth = lineWidth; - m_lineDistance = lineDistance; - } // CompiereColor - - /** - * Copy Color - * @param cc color - */ - public AdempiereColor (AdempiereColor cc) - { - if (cc == null) - return; - setColor(cc); - } // CompiereColor - - /*************************************************************************/ - - /** Type - Default: Gradient */ - private String m_type = TYPE_GRADIENT; - - /** Primary Color - Default Panel back */ - private Color m_primaryColor = UIManager.getColor("Panel.background"); - /** Secondary Color - Default: gray-white */ - private Color m_secondaryColor = new Color (245, 245, 245); - - /** Texture Graph URL */ - private URL m_textureURL = null; - /** Texture Graph */ - private BufferedImage m_image = null; - /** Texture Alpha - Default: 0.7 */ - private float m_compositeAlpha = 0.7f; - - /** Line Width - Default: 1 */ - private float m_lineWidth = 1.0f; - /** Line Distance - Default: 5 */ - private int m_lineDistance = 5; - - /** Gradient Starting point - Default: NORTH_WEST */ - private int m_startPoint = SwingConstants.NORTH_WEST; - /** Gradient repeat distance in points - Default: 100 */ - private int m_repeatDistance = 100; - - /** Background */ - private ColorBackground m_back = null; - /** 3D Look */ - private boolean m_3d = true; - - /** Diry marker for repaining Background */ - private boolean m_dirty = true; - /** Logger */ - private static Logger log = Logger.getLogger(AdempiereColor.class.getName()); - - /************************************************************************** - * Get BackgroundType (Flat, Gradient, Lines, Texture) - * @return Background Type (see TYPE_* constants) - */ - public String getType() - { - return m_type; - } // getType - - /** - * Flat Background Type (default) - * @return true if Flat background - */ - public boolean isFlat() - { - return TYPE_FLAT.equals(getType()); - } // isFlat - - /** - * Gradient Background Type - * @return true if Gradient background - */ - public boolean isGradient() - { - return TYPE_GRADIENT.equals(getType()); - } // isGradient - - /** - * Line Background Type - * @return true if Line background - */ - public boolean isLine() - { - return TYPE_LINES.equals(getType()); - } // isLine - - /** - * Texture Background Type - * @return true if Texture background - */ - public boolean isTexture() - { - return TYPE_TEXTURE.equals(getType()); - } // isTexture - - - /************************ - * Get Flat Color - * @return Primary Color - */ - public Color getFlatColor() - { - return m_primaryColor; - } // getFlatColor - - /** - * Set Flat Color - * @param color flat color - */ - public void setFlatColor(Color color) - { - if (!isFlat() || color == null) - return; - m_primaryColor = color; - m_dirty = true; - } // getFlatColor - - - /************************ - * Gradient Upper Color - * @return Color or null - */ - public Color getGradientUpperColor() - { - if (!isGradient()) - return null; - return m_primaryColor; - } // getGradientUpperColor - - /** - * Gradient Upper Color - * @param color upper color - */ - public void setGradientUpperColor(Color color) - { - if (!isGradient() || color == null) - return; - m_primaryColor = color; - m_dirty = true; - } // getGradientUpperColor - - /** - * Gradient Lower Color - * @return Color or null - */ - public Color getGradientLowerColor() - { - if (!isGradient()) - return null; - return m_secondaryColor; - } // getGradientLowerColor - - /** - * Gradient Lower Color - * @param color lower color - */ - public void setGradientLowerColor(Color color) - { - if (!isGradient() || color == null) - return; - m_secondaryColor = color; - m_dirty = true; - } // setGradientLowerColor - - /** - * Gradient Starting Point - * @return starting point - e.g. NORTH - or 0 - * @see SwingConstants - */ - public int getGradientStartPoint () - { - if (!isGradient()) - return 0; - return m_startPoint; - } // getGradientStartPoint - - /** - * Gradient Starting Point - * @param startPoint starting point - e.g. NORTH - * @see SwingConstants - */ - public void setGradientStartPoint (int startPoint) - { - if (!isGradient()) - return; - m_startPoint = startPoint; - m_dirty = true; - } // setGradientStartPoint - - /** - * Gradient Repeat Distance in point - * @return Repeat Distance - or 0 - */ - public int getGradientRepeatDistance () - { - if (!isGradient()) - return 0; - return m_repeatDistance; - } // getGradientRepeatDistance - - /** - * Gradient Repeat Distance. - * Zero stands for no repeats - * @param repeatDistance repeat gradient after point x+repeat / y+repeat (depending on direction) - */ - public void setGradientRepeatDistance (int repeatDistance) - { - if (!isGradient()) - return; - m_repeatDistance = repeatDistance; - m_dirty = true; - } // setGradientRepeatDistance - - /** - * Gradient Repeat Distance. - * Zero stands for no repeats - * @param repeatDistanceString repeat gradient after point x+repeat / y+repeat (depending on direction) - */ - public void setGradientRepeatDistance (String repeatDistanceString) - { - if (!isGradient()) - return; - try - { - setGradientRepeatDistance(Integer.parseInt(repeatDistanceString)); - } - catch (Exception e) - { - log.severe("Parsing=" - + repeatDistanceString + " - " + e.getMessage()); - } - } // setGradientRepeatDistance - - - /************************ - * Texture Url - * @return URL (if not found, org.compiere.plaf.background.jpg is used) - */ - public URL getTextureURL() - { - if (!isTexture()) - return null; - if (m_textureURL == null) - m_textureURL = AdempiereColor.class.getResource("Compiere200x100.gif"); - return m_textureURL; - } // getTextureURL - - /** - * Get Texture Image based on Texture URL - * @return Image - */ - public BufferedImage getTextureImage() - { - if (m_image == null) - { - URL url = getTextureURL(); - m_image = AdempiereUtils.loadBufferedImage(url, BufferedImage.TYPE_INT_ARGB_PRE); - } - return m_image; - } // getTextureImage - - /** - * Texture Url - * @param url URL to graphic file (jpg) - */ - public void setTextureURL(URL url) - { - if (!isTexture() || url == null) - return; - m_textureURL = url; - m_image = null; - m_dirty = true; - } // setTextureURL - - /** - * Texture Url - * @param urlString URL to graphic file (jpg) - */ - public void setTextureURL(String urlString) - { - if (!isTexture() || urlString == null) - return; - try - { - setTextureURL (new URL(urlString)); - } - catch (Exception e) - { - log.severe("Parsing URL=" - + urlString + " - " + e.getMessage()); - } - } // setTextureURL - - /** - * Texture Taint Color - * @return Color or null - */ - public Color getTextureTaintColor() - { - if (!isTexture()) - return null; - return m_primaryColor; - } // getTextureTaintColor - - /** - * Texture Taint Color - * @param color taint color - */ - public void setTextureTaintColor(Color color) - { - if (!isTexture() || color == null) - return; - m_primaryColor = color; - m_dirty = true; - } // setTextureTaintColor - - /** - * Texture Composite Alpha - * @return Composite Ampha or 0f - */ - public float getTextureCompositeAlpha() - { - if (!isTexture()) - return 0f; - return m_compositeAlpha; - } // getTextureCompositeAlpha - - /** - * Texture Composite Alpha - * @param alpha alpha value - */ - public void setTextureCompositeAlpha(float alpha) - { - if (!isTexture()) - return; - m_compositeAlpha = alpha; - m_dirty = true; - } // setTextureCompositeAlpha - - /** - * Texture Composite Alpha - * @param alphaString String to be parsed - */ - public void setTextureCompositeAlpha(String alphaString) - { - if (!isTexture() || alphaString == null) - return; - try - { - setTextureCompositeAlpha(Float.parseFloat(alphaString)); - } - catch (Exception e) - { - log.severe("Parsing=" - + alphaString + " - " + e.getMessage()); - } - } // setTextureCompositeAlpha - - - /************************ - * Line Color - * @return Color or null - */ - public Color getLineColor() - { - if (!isLine()) - return null; - return m_secondaryColor; - } // getLineColor - - /** - * Line Color - * @param color line color - */ - public void setLineColor(Color color) - { - if (!isLine() || color == null) - return; - m_secondaryColor = color; - m_dirty = true; - } // setLineColor - - /** - * Line Background Color - * @return Color or null - */ - public Color getLineBackColor() - { - if (!isLine()) - return null; - return m_primaryColor; - } // getLineBackColor - - /** - * Line Background Color - * @param color background color - */ - public void setLineBackColor(Color color) - { - if (!isLine() || color == null) - return; - m_primaryColor = color; - m_dirty = true; - } // setLineBackColor - - /** - * Background Line Width - * @return width or 0f - */ - public float getLineWidth() - { - if (!isLine()) - return 0f; - return m_lineWidth; - } // getLineWidth - - /** - * Background Line Width - * @param width line width - */ - public void setLineWidth(float width) - { - if (!isLine()) - return; - m_lineWidth = width; - m_dirty = true; - } // setLineWidth - - /** - * Background Line Width - * @param widthString line width - */ - public void setLineWidth(String widthString) - { - if (!isLine() || widthString == null) - return; - try - { - setLineWidth(Float.parseFloat(widthString)); - } - catch (Exception e) - { - log.severe("Parsing=" - + widthString + " - " + e.getMessage()); - } - } // setLineWidth - - /** - * Background Line distance in pt - * @return distance or 0 - */ - public int getLineDistance() - { - if (!isLine()) - return 0; - return m_lineDistance; - } // getLineDistance - - /** - * Background Line distance in pt - * @param distance line distance - */ - public void setLineDistance(int distance) - { - if (!isLine()) - return; - m_lineDistance = distance; - m_dirty = true; - } // setLineDistance - - /** - * Background Line distance in pt - * @param distanceString line distance - */ - public void setLineDistance(String distanceString) - { - if (!isLine()) - return; - try - { - setLineDistance(Integer.parseInt(distanceString)); - } - catch (Exception e) - { - log.severe("Parsing=" - + distanceString + " - " + e.getMessage()); - } - } // setLineDistance - - /** - * Set Prinary Color - * @param color primary color - */ - protected void setPrimaryColor (Color color) - { - if (color != null) - m_primaryColor = color; - } // setPrimaryColor - - /** - * Set CompiereColor from CompiereColor - * @param cc CompiereColor - */ - public void setColor (AdempiereColor cc) - { - if (cc == null) - return; - m_type = cc.getType(); - // - if (cc.isFlat()) - m_primaryColor = cc.getFlatColor(); - else if (cc.isGradient()) - { - m_primaryColor = cc.getGradientUpperColor(); - m_secondaryColor = cc.getGradientLowerColor(); - m_startPoint = cc.getGradientStartPoint(); - m_repeatDistance = cc.getGradientRepeatDistance(); - } - else if (cc.isTexture()) - { - setTextureURL(cc.getTextureURL()); - m_primaryColor = cc.getTextureTaintColor(); - m_compositeAlpha = cc.getTextureCompositeAlpha(); - } - else if (cc.isLine()) - { - m_primaryColor = cc.getLineBackColor(); - m_secondaryColor = cc.getLineColor(); - m_lineWidth = cc.getLineWidth(); - m_lineDistance = cc.getLineDistance(); - } - else - log.severe("Invalid Color"); - // - m_dirty = true; - } // setColor - - - /************************************************************************** - * Fill with CompiereColor Background - * @param g the Graphics context in which to paint - * @param c the component being painted - */ - public void paint (Graphics g, JComponent c) - { - getColorBackground(c).paint (g, c); - } // paint - - /** - * Fill with Compiere Background - * @param g graphics - * @param c component - * @param x x pos - * @param y y pos - * @param w with - * @param h height - */ - public void paintRect (Graphics g, JComponent c, int x, int y, int w, int h) - { - getColorBackground(c).paintRect (g,c, x,y, w,h); - } // paintRect - - /** - * Get Background - * @param c Componenr - * @return Background - */ - private ColorBackground getColorBackground (JComponent c) - { - if (m_back == null) - { - Rectangle bounds = c.getBounds(); - Container container = c.getParent(); - while (container != null) - { - bounds = container.getBounds(bounds); - container = container.getParent(); - } - m_back = new ColorBackground (bounds); - } - return m_back; - } // getBackground - - - /************************************************************************** - * String representation - * @return string representation - */ - public String toString() - { - StringBuffer sb = new StringBuffer ("CompiereColor["); - if (isFlat()) - sb.append("Flat") - .append(" ").append(AdempiereTheme.getColorAsString(getFlatColor())); - else if (isGradient()) - sb.append("Gradient") - .append(" Upper=").append(AdempiereTheme.getColorAsString(getGradientUpperColor())) - .append(",Lower=").append(AdempiereTheme.getColorAsString(getGradientLowerColor())) - .append(",Start=").append(getGradientStartPoint()) - .append(",RDistance=").append(getGradientRepeatDistance()); - else if (isLine()) - sb.append("Line") - .append(" Color=").append(AdempiereTheme.getColorAsString(getLineColor())) - .append(",BackColor=").append(AdempiereTheme.getColorAsString(getLineBackColor())) - .append(",Width=").append(getLineWidth()) - .append(",Distance=").append(getLineDistance()); - else if (isTexture()) - sb.append("Texture") - .append(" GraphURL=").append(getTextureURL()) - .append(",Taint=").append(AdempiereTheme.getColorAsString(getTextureTaintColor())) - .append(",Alpha=").append(getTextureCompositeAlpha()); - sb.append("]"); - return sb.toString(); - } // toString - - /** - * Parse String Representation and set Attributes - * @param str parse string - */ - private void parseAttributres (String str) - { - if (str.indexOf("[Flat ") != -1) - { - m_type = TYPE_FLAT; - m_primaryColor = AdempiereTheme.parseColor(str, - new ColorUIResource(m_primaryColor)); - } - else if (str.indexOf("[Gradient ") != -1) - { - m_type = TYPE_GRADIENT; - m_primaryColor = AdempiereTheme.parseColor(str.substring(str.indexOf(" Upper=")+7, str.indexOf(",Lower=")), - new ColorUIResource(m_primaryColor)); - m_secondaryColor = AdempiereTheme.parseColor(str.substring(str.indexOf(",Lower=")+7, str.indexOf(",Start=")), - new ColorUIResource(m_secondaryColor)); - m_startPoint = Integer.parseInt(str.substring(str.indexOf(",Start=")+7, str.indexOf(",RDistance="))); - setGradientRepeatDistance(str.substring(str.indexOf(",RDistance=")+11, str.lastIndexOf("]"))); - } - else if (str.indexOf("[Line ") != -1) - { - m_type = TYPE_LINES; - m_primaryColor =AdempiereTheme.parseColor(str.substring(str.indexOf(" Color=")+7, str.indexOf(",BackColor=")), - new ColorUIResource(m_primaryColor)); - m_secondaryColor = AdempiereTheme.parseColor(str.substring(str.indexOf(",BackColor=")+11, str.indexOf(",Width=")), - new ColorUIResource(m_secondaryColor)); - setLineWidth(str.substring(str.indexOf(",Width=")+7, str.indexOf(",Distance="))); - setLineDistance(str.substring(str.indexOf(",Distance=")+10, str.lastIndexOf("]"))); - } - else if (str.indexOf("[Texture ") != -1) - { - m_type = TYPE_TEXTURE; - setTextureURL (str.substring(str.indexOf(" GraphURL=")+10, str.indexOf(",Taint="))); - m_primaryColor = AdempiereTheme.parseColor(str.substring(str.indexOf(",Taint=")+7, str.indexOf(",Alpha=")), - new ColorUIResource(m_primaryColor)); - setTextureCompositeAlpha (str.substring(str.indexOf(",Alpha=")+7, str.lastIndexOf("]"))); - } - } // parseString - - /** - * Does the background needs to be redone - * @return true if there were changes - */ - boolean isDirty() - { - return m_dirty; - } // isDirty - - /** - * Set Dirty - * @param dirty if true, the background will be re-painted - */ - void setDirty (boolean dirty) - { - m_dirty = dirty; - } // setDirty - - -/****************************************************************************** - * Background contains a Buffered Image with the background. - * The initial size is determined by the constructor. - * It is resized if required when painting. - *
- * The Buffered image is a 8-bit RGBA color components packed into integer pixels. - * The image has a DirectColorModel with alpha. The color data in this image - * is considered to be premultiplied with alpha - */ -public class ColorBackground -{ - /** - * Create Color Background - * @param bounds Rectangle to fit in - */ - public ColorBackground (Rectangle bounds) - { - createColorBackground (bounds); - fillColorBackground (); - } // Background - - private int m_height = 200; - private int m_width = 200; - private BufferedImage m_backImage; - private int m_colorBlind = AdempiereColorBlind.getColorType(); - - /** - * Create Color Background - * @param bounds Rectangle to fit in - */ - private void createColorBackground (Rectangle bounds) - { - m_height = Math.max(bounds.y + bounds.height, m_height); - m_width = Math.max(bounds.x + bounds.width, m_width); - m_backImage = new BufferedImage (m_width, m_height, BufferedImage.TYPE_INT_ARGB_PRE); - } // create Background - - - /** - * Fill Background with Color - */ - public void fillColorBackground () - { - Graphics2D g2D = m_backImage.createGraphics(); - - if (isGradient()) - { - Point start = null; - Point end = null; - int r = 1; // repeats - switch (m_startPoint) - { - case SwingConstants.NORTH_WEST: - start = new Point (0, 0); - if (m_repeatDistance > 0) - end = new Point (m_repeatDistance, m_repeatDistance); - // end = new Point (Math.min(m_repeatDistance, m_width), Math.min(m_repeatDistance, height)); - else - end = new Point (m_width/r, m_height/r); - break; - case SwingConstants.WEST: - start = new Point (0, m_height/2); - if (m_repeatDistance > 0) - end = new Point (m_repeatDistance, m_height/2); - // end = new Point (Math.min(m_repeatDistance, m_width), m_height/2); - else - end = new Point (m_width/r, m_height/2); - break; - case SwingConstants.SOUTH_WEST: - start = new Point (0, m_height); - if (m_repeatDistance > 0) - end = new Point (m_repeatDistance, m_height-m_repeatDistance); - // end = new Point (Math.min(m_width, m_repeatDistance), Math.max(0, m_height-m_repeatDistance)); - else - end = new Point (m_width/r, m_height-(m_height/r)); - break; - case SwingConstants.SOUTH: - start = new Point (0, m_height); - if (m_repeatDistance > 0) - end = new Point (0, m_height-m_repeatDistance); - // end = new Point (0, Math.max(0, m_height-m_repeatDistance)); - else - end = new Point (0, m_height-(m_height/r)); - break; - case SwingConstants.SOUTH_EAST: - start = new Point (m_width, m_height); - if (m_repeatDistance > 0) - end = new Point (m_width-m_repeatDistance, m_height-m_repeatDistance); - // end = new Point (Math.min(0, m_width-m_repeatDistance), Math.max(0, m_height-m_repeatDistance)); - else - end = new Point (m_width-(m_width/r), m_height-(m_height/r)); - break; - case SwingConstants.EAST: - start = new Point (m_width, m_height/2); - if (m_repeatDistance > 0) - end = new Point (m_width-m_repeatDistance, m_height/2); - // end = new Point (Math.min(0, m_width-m_repeatDistance), m_height/2); - else - end = new Point (m_width-(m_width/r), m_height/2); - break; - case SwingConstants.NORTH_EAST: - start = new Point (m_width, 0); - if (m_repeatDistance > 0) - end = new Point (m_width-m_repeatDistance, m_repeatDistance); - // end = new Point (Math.min(0, m_width-m_repeatDistance), Math.min(m_height, m_repeatDistance)); - else - end = new Point (m_width-(m_width/r), m_height/r); - break; - default: - case SwingConstants.NORTH: - start = new Point (0, 0); - if (m_repeatDistance > 0) - end = new Point (0, m_repeatDistance); - // end = new Point (0, Math.min(m_height, m_repeatDistance)); - else - end = new Point (0, m_height/r); - } - GradientPaint paint = new GradientPaint( - start, - AdempiereColorBlind.getDichromatColor(getGradientUpperColor()), - end, - AdempiereColorBlind.getDichromatColor(getGradientLowerColor()), - true); // cyclic - g2D.setPaint(paint); - g2D.fillRect(0, 0, m_width, m_height); - } - else if (isTexture()) - { - BufferedImage image = getTextureImage(); - if (image == null) - { - g2D.setPaint(AdempiereColorBlind.getDichromatColor(getFlatColor())); - g2D.fillRect(0, 0, m_width, m_height); - } - else - { - Rectangle anchor = new Rectangle (0,0, image.getWidth(), image.getHeight()); - TexturePaint texture = new TexturePaint (image, anchor); - g2D.setPaint(texture); - g2D.fillRect(0, 0, m_width, m_height); - g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getTextureCompositeAlpha())); - g2D.setPaint(AdempiereColorBlind.getDichromatColor(getTextureTaintColor())); - g2D.fillRect(0, 0, m_width, m_height); - } - } - else if (isLine()) - { - // Background - g2D.setPaint(AdempiereColorBlind.getDichromatColor(getLineBackColor())); - g2D.fillRect(0, 0, m_width, m_height); - // Lines - g2D.setPaint(AdempiereColorBlind.getDichromatColor(getLineColor())); - g2D.setStroke(new BasicStroke(getLineWidth())); - for (int y = 0; y < m_height; y += getLineDistance()) - g2D.drawLine(0, y, m_width, y); - } - else // flat - { - g2D.setPaint(AdempiereColorBlind.getDichromatColor(getFlatColor())); - g2D.fillRect(0, 0, m_width, m_height); - } - setDirty (false); - } // fillBackground - - /** - * Paint/copy background to component - * @param g graphics - * @param c component - */ - public void paint (Graphics g, JComponent c) - { - Rectangle bounds = c.getBounds(); - check (bounds); - // - int h = c.getHeight(); - int w = c.getWidth(); - // Copy Background - g.drawImage (m_backImage, - 0, 0, // destination start point - w, h, // destination end point - bounds.x, bounds.y, // source start - bounds.x+w, bounds.y+h, // source end - c); - } // paint - - /** - * Paint/copy background to component rectangle - * @param g graphics - * @param c compnent - * @param x x pos - * @param y y pos - * @param w width - * @param h height - */ - public void paintRect (Graphics g, JComponent c, int x, int y, int w, int h) - { - Rectangle bounds = c.getBounds(); - check (bounds); - // Copy Background - g.drawImage (m_backImage, - x, y, // destination start point - x+w, h+y, // destination end point - x, y, // source start - x+w, y+h, // source end - c); - } // paint - - /** - * Check size of background and repaint if required - * @param bounds Bounds of component - */ - private void check (Rectangle bounds) - { - // Re-Create, if Color Type changed - if (AdempiereColorBlind.getColorType() != m_colorBlind) - { - m_colorBlind = AdempiereColorBlind.getColorType(); - setDirty(true); - } - // we need to create new background - if ((m_height < (bounds.y + bounds.height)) - || (m_width < (bounds.x + bounds.width))) - { - createColorBackground (bounds); - fillColorBackground(); - } - else if (isDirty()) - fillColorBackground(); - } // check - -} // ColorBackground - -} // CompiereColor diff --git a/looks/src/org/adempiere/plaf/AdempiereColorBlind.java b/looks/src/org/adempiere/plaf/AdempiereColorBlind.java deleted file mode 100755 index e6bf0c8e37..0000000000 --- a/looks/src/org/adempiere/plaf/AdempiereColorBlind.java +++ /dev/null @@ -1,286 +0,0 @@ -/****************************************************************************** - * The contents of this file are subject to the Compiere License Version 1.1 - * ("License"); You may not use this file except in compliance with the License - * You may obtain a copy of the License at http://www.compiere.org/license.html - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for - * the specific language governing rights and limitations under the License. - * The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial - * Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke - * are Copyright (C) 1999-2005 Jorg Janke. - * All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved. - * Contributor(s): ______________________________________. - *****************************************************************************/ -package org.adempiere.plaf; - -import java.awt.Color; -import java.util.logging.*; - -import javax.swing.plaf.ColorUIResource; - -/** - * Color Blind Utilities. - * These utilities help to show how color blind/challenged see colors. - * - * Created by Thomas Wolfmaier. - * Copyright (C) 1999-2005 HCIRN. - * All rights reserved. - * @see HCIRN - * - * @author Thomas Wolfmaier - * @version $Id: ColorBlind.java,v 1.8 2005/10/14 00:42:52 jjanke Exp $ - */ -public class AdempiereColorBlind -{ - /** Color Blindness Type - 0=none */ - public static final String[] COLORBLIND_TYPE = - {"", "Protanopia", "Deuteranopia", "Tritanopia"}; - - public static final int NORMAL = 0; - public static final int PROTANOPIA = 1; - public static final int DEUTERANOPIA = 2; - public static final int TRITANOPIA = 3; - - /*************************************************************************/ - - private static final double[][] confusionPoints = - { {0.735, 0.265}, - {1.140, -0.140}, - {0.171, -0.003} - }; - private static final double[][][] colorAxes = - { {{0.115807, 0.073581}, {0.471899, 0.527051}}, - {{0.102776, 0.102864}, {0.505845, 0.493211}}, - {{0.045391, 0.294976}, {0.665764, 0.334011}} - }; - private static final double[][] RGBtoXYZMatrix = - { {0.430574, 0.341550, 0.178325}, - {0.222015, 0.706655, 0.071330}, - {0.020183, 0.129553, 0.939180} - }; - private static final double[][] XYZtoRGBMatrix = - { { 3.063218, -1.393325, -0.475802}, - {-0.969243, 1.875966, 0.041555}, - { 0.067871, -0.228834, 1.069251} - }; - private static final double[] whitePoint = - { 0.312713, 0.329016, 0.358271 - }; - private static final double gamma = 2.2; - - /** Color Blind Type */ - private static int s_colorType = NORMAL; - - /** Logger */ - private static Logger log = Logger.getLogger(AdempiereColorBlind.class.getName()); - - - /** - * Set Color Type for Color Blind view - * @param colorType (0 = none) - */ - public static void setColorType (int colorType) - { - if (colorType > 0 && colorType < 4) - s_colorType = colorType; - else - s_colorType = 0; - if (s_colorType != 0) - log.config(COLORBLIND_TYPE[colorType]); - } // setColorType - - /** - * Get Color Type for Color Blind view - * @return colorType (0 = none) - */ - public static int getColorType () - { - return s_colorType; - } // getColorType - - - /************************************************************************** - * Convert "normal" color to Dichromat Color based on set color type - * @param color Java Color object containing values for RGB - * @return Dichromat Color - */ - public static ColorUIResource getDichromatColorUIResource (ColorUIResource color) - { - if (s_colorType == NORMAL) - return color; - return new ColorUIResource(getDichromatColorUIResource (color, s_colorType)); - } // convertToDichromatColorUIResource - - /** - * Convert "normal" color to Dichromat Color - * @param color Java Color object containing values for RGB - * @param colorType PROTANOPIA = 1, DEUTERANOPIA = 2 or TRITANOPIA = 3 as declared above - * @return Dichromat Color - */ - public static Color getDichromatColorUIResource (ColorUIResource color, int colorType) - { - if (s_colorType == NORMAL) - return color; - return new ColorUIResource(getDichromatColor (color, s_colorType)); - } // convertToDichromatColorUIResource - - /** - * Convert "normal" color to Dichromat Color based on set color type - * @param color Java Color object containing values for RGB - * @return Dichromat Color - */ - public static Color getDichromatColor (Color color) - { - if (s_colorType == NORMAL) - return color; - return getDichromatColor (color, s_colorType); - } // convertToDichromatColor - - /** - * Convert "normal" color to Dichromat Color - * @param color Java Color object containing values for RGB - * @param colorType PROTANOPIA = 1, DEUTERANOPIA = 2 or TRITANOPIA = 3 as declared above - * @return Dichromat Color - */ - public static Color getDichromatColor (Color color, int colorType) - { - // check type & return if not valid - int type = 0; - if (colorType > 0 && colorType < 4) - type = colorType; - // No conversion or no color - if (type == 0 || color == null) - return color; - type--; // correct to zero based - - // Return white & black - not converted - if (color.equals(Color.black) || color.equals(Color.white)) - return color; - - double red = color.getRed(); - double green = color.getGreen(); - double blue = color.getBlue(); - - // System.out.println("Red: " + red + " Green: " + green + " Blue: " + blue); - - double X = RGBtoXYZMatrix[0][0] * Math.pow(red / 255.0, gamma) + - RGBtoXYZMatrix[0][1] * Math.pow(green / 255.0, gamma) + - RGBtoXYZMatrix[0][2] * Math.pow(blue / 255.0, gamma); - double Y = RGBtoXYZMatrix[1][0] * Math.pow(red / 255.0, gamma) + - RGBtoXYZMatrix[1][1] * Math.pow(green / 255.0, gamma) + - RGBtoXYZMatrix[1][2] * Math.pow(blue / 255.0, gamma); - double Z = RGBtoXYZMatrix[2][0] * Math.pow(red / 255.0, gamma) + - RGBtoXYZMatrix[2][1] * Math.pow(green / 255.0, gamma) + - RGBtoXYZMatrix[2][2] * Math.pow(blue / 255.0, gamma); - - // System.out.println("X: " + X + " Y: " + Y + " Z: " + Z); - - double x = 0.0; - double y = 0.0; - - if ((X + Y + Z) != 0.0) - { - x = X / (X + Y + Z); - y = Y / (X + Y + Z); - } - - // System.out.println("x: " + x + " y: " + y + " Y: " + Y); - - double Yn = Y; - double Xn = (whitePoint[0] * Yn) / whitePoint[1]; - double Zn = (whitePoint[2] * Yn) / whitePoint[1]; - - double xc = confusionPoints[type][0]; - double yc = confusionPoints[type][1]; - - double x1 = colorAxes[type][0][0]; - double y1 = colorAxes[type][0][1]; - double x2 = colorAxes[type][1][0]; - double y2 = colorAxes[type][1][1]; - - double ap = (y2 - y1) / (x2 - x1); - double bp = y1 - (x1 * ap); - - // System.out.println("ap: " + ap + " bp: " + bp); - - double a; - if (x < xc) - a = (yc - y) / (xc - x); - else - a = (y - yc) / (x - xc); - - double b = y - (x * a); - - // System.out.println("a: " + a + " b: " + b); - - x = (bp - b) / (a - ap); - y = a * x + b; - - // System.out.println("x: " + x + " y: " + y); - - X = 0.0; - Z = 0.0; - if (y != 0) - { - X = x * (Y / y); - Z = (1 - x - y) * (Y / y); - } - - // System.out.println("X: " + X + " Y: " + Y + " Z: " + Z); - - red = XYZtoRGBMatrix[0][0] * X + - XYZtoRGBMatrix[0][1] * Y + - XYZtoRGBMatrix[0][2] * Z; - green = XYZtoRGBMatrix[1][0] * X + - XYZtoRGBMatrix[1][1] * Y + - XYZtoRGBMatrix[1][2] * Z; - blue = XYZtoRGBMatrix[2][0] * X + - XYZtoRGBMatrix[2][1] * Y + - XYZtoRGBMatrix[2][2] * Z; - - // System.out.println("Red: " + red + " Green: " + green + " Blue: " + blue); - - double reddiff = XYZtoRGBMatrix[0][0] * (Xn - X) + - XYZtoRGBMatrix[0][1] * (Yn - Y) + - XYZtoRGBMatrix[0][2] * (Zn - Z); - double greendiff = XYZtoRGBMatrix[1][0] * (Xn - X) + - XYZtoRGBMatrix[1][1] * (Yn - Y) + - XYZtoRGBMatrix[1][2] * (Zn - Z); - double bluediff = XYZtoRGBMatrix[2][0] * (Xn - X) + - XYZtoRGBMatrix[2][1] * (Yn - Y) + - XYZtoRGBMatrix[2][2] * (Zn - Z); - - double cr = ((red < 0.0 ? 0.0 : 1.0) - red) / reddiff; - double cg = ((green < 0.0 ? 0.0 : 1.0) - green) / greendiff; - double cb = ((blue < 0.0 ? 0.0 : 1.0) - blue) / bluediff; - - // System.out.println("cr: " + cr + " cg: " + cg + " cb: " + cb); - - double c1 = (cr < 0 || cr > 1) ? 0 : cr; - double c2 = (cg < 0 || cg > 1) ? 0 : cg; - double c3 = (cb < 0 || cb > 1) ? 0 : cb; - double c = Math.max(c1, Math.max(c2, c3)); - - // System.out.println("c: " + c); - - red = red + c * reddiff; - green = green + c * greendiff; - blue = blue + c * bluediff; - - // System.out.println("Red: " + red + " Green: " + green + " Blue: " + blue); - - red = Math.pow(red, 1.0 / gamma); - green = Math.pow(green, 1.0 / gamma); - blue = Math.pow(blue, 1.0 / gamma); - - // System.out.println("Red: " + red + " Green: " + green + " Blue: " + blue); - // System.out.println("Red: " + red * 255.0 + " Green: " + green * 255.0 + " Blue: " + blue * 255.0); - - Color retValue = new Color((float)red, (float)green, (float)blue); - log.fine("Color " + color.getRed() + "-" + color.getGreen() + "-" + color.getBlue() - + " -> " + retValue.getRed() + "-" + retValue.getGreen() + "-" + retValue.getBlue() + " <- " + COLORBLIND_TYPE[colorType]); - - return retValue; - } // convertToDichromatColor - -} // ColorBlind diff --git a/looks/src/org/adempiere/plaf/AdempiereComboBoxUI.java b/looks/src/org/adempiere/plaf/AdempiereComboBoxUI.java index 652ef55b74..2c0f9ed203 100755 --- a/looks/src/org/adempiere/plaf/AdempiereComboBoxUI.java +++ b/looks/src/org/adempiere/plaf/AdempiereComboBoxUI.java @@ -19,7 +19,7 @@ import javax.swing.plaf.*; import javax.swing.plaf.basic.*; import javax.swing.plaf.metal.*; -import org.compiere.plaf.AdempiereComboPopup; +import org.compiere.plaf.CompiereComboPopup; /** @@ -55,7 +55,7 @@ public class AdempiereComboBoxUI extends com.jgoodies.looks.plastic.PlasticCombo { MouseListener[] ml = c.getMouseListeners(); super.installUI(c); - c.setOpaque(false); + //c.setOpaque(false); // for (int i = 0; i < ml.length; i++) { @@ -74,8 +74,8 @@ public class AdempiereComboBoxUI extends com.jgoodies.looks.plastic.PlasticCombo protected JButton createArrowButton() { JButton button = super.createArrowButton(); - button.setContentAreaFilled(false); - button.setOpaque(false); + //button.setContentAreaFilled(false); + //button.setOpaque(false); return button; } // createArrowButton @@ -101,7 +101,7 @@ public class AdempiereComboBoxUI extends com.jgoodies.looks.plastic.PlasticCombo */ protected ComboPopup createPopup() { - AdempiereComboPopup newPopup = new AdempiereComboPopup( comboBox ); + CompiereComboPopup newPopup = new CompiereComboPopup( comboBox ); newPopup.getAccessibleContext().setAccessibleParent(comboBox); return newPopup; } // createPopup diff --git a/looks/src/org/adempiere/plaf/AdempiereLookAndFeel.java b/looks/src/org/adempiere/plaf/AdempiereLookAndFeel.java index 4fb4c896c4..350d6f2c33 100755 --- a/looks/src/org/adempiere/plaf/AdempiereLookAndFeel.java +++ b/looks/src/org/adempiere/plaf/AdempiereLookAndFeel.java @@ -1,15 +1,18 @@ /****************************************************************************** - * The contents of this file are subject to the Compiere License Version 1.1 - * ("License"); You may not use this file except in compliance with the License - * You may obtain a copy of the License at http://www.compiere.org/license.html - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for - * the specific language governing rights and limitations under the License. - * The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial - * Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke - * are Copyright (C) 1999-2005 Jorg Janke. - * All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved. - * Contributor(s): ______________________________________. + * 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; @@ -18,18 +21,10 @@ import java.awt.*; import javax.swing.*; import javax.swing.plaf.metal.*; +import com.jgoodies.looks.plastic.PlasticLookAndFeel; + /** - * Compiere Look & Feel. - * We wanted a nice UI not the battleship gray based stuff. - * I guess a matter of taste. - * - * : - * UIManager.setLookAndFeel(new com.compiere.plaf.CompiereLookAndFeel()); - * // or UIManager.setLookAndFeel("com.compiere.plaf.CompiereLookAndFeel"); - * - * - * @author Jorg Janke - * @version $Id: CompiereLookAndFeel.java,v 1.19 2005/12/05 02:38:28 jjanke Exp $ + * Adempiere Look & Feel, based on JGoodies look and feel */ public class AdempiereLookAndFeel extends com.jgoodies.looks.plastic.PlasticLookAndFeel { @@ -86,10 +81,7 @@ public class AdempiereLookAndFeel extends com.jgoodies.looks.plastic.PlasticLook */ public UIDefaults getDefaults() { - // System.out.println("CompiereLookAndFeel.getDefaults"); - // Theme already created/set - //MetalLookAndFeel.setCurrentTheme(s_theme); - com.jgoodies.looks.plastic.PlasticLookAndFeel.setCurrentTheme(s_theme); + //com.jgoodies.looks.plastic.PlasticLookAndFeel.setCurrentTheme(s_theme); UIDefaults defaults = super.getDefaults(); // calls init..Defaults return defaults; } // getDefaults @@ -153,11 +145,7 @@ public class AdempiereLookAndFeel extends com.jgoodies.looks.plastic.PlasticLook */ protected void initSystemColorDefaults (UIDefaults table) { - // System.out.println("CompiereLookAndFeel.initSystemColorDefaults"); super.initSystemColorDefaults( table); - - // we made the color a bit darker - // table.put("textHighlight", CompiereUtils.getTranslucentColor(getTextHighlightColor(), 128)); } // initSystemColorDefaults /** @@ -166,7 +154,6 @@ public class AdempiereLookAndFeel extends com.jgoodies.looks.plastic.PlasticLook */ protected void initComponentDefaults (UIDefaults table) { - // System.out.println("CompiereLookAndFeel.initComponentDefaults"); super.initComponentDefaults( table); // ComboBox defaults @@ -199,7 +186,7 @@ public class AdempiereLookAndFeel extends com.jgoodies.looks.plastic.PlasticLook { if (theme != null) s_theme = theme; - MetalLookAndFeel.setCurrentTheme(s_theme); + PlasticLookAndFeel.setCurrentTheme(s_theme); } // setCurrentTheme /** @@ -244,4 +231,4 @@ public class AdempiereLookAndFeel extends com.jgoodies.looks.plastic.PlasticLook super.provideErrorFeedback (component); } // provideErrorFeedback -} // CompiereLookAndFeel +} // AdempiereLookAndFeel diff --git a/looks/src/org/compiere/plaf/AdempierePLAF.java b/looks/src/org/adempiere/plaf/AdempierePLAF.java similarity index 60% rename from looks/src/org/compiere/plaf/AdempierePLAF.java rename to looks/src/org/adempiere/plaf/AdempierePLAF.java index 4d72e0ebd0..14341883f1 100644 --- a/looks/src/org/compiere/plaf/AdempierePLAF.java +++ b/looks/src/org/adempiere/plaf/AdempierePLAF.java @@ -14,18 +14,44 @@ * 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.compiere.plaf; +package org.adempiere.plaf; -import java.awt.*; -import java.awt.event.*; -import java.lang.reflect.*; -import java.util.*; -import java.util.logging.*; -import javax.swing.*; -import javax.swing.plaf.metal.*; -//import org.compiere.process.OrgOwnership; -import org.compiere.swing.*; -import org.compiere.util.*; +import java.awt.Color; +import java.awt.Dimension; +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; +import java.util.Arrays; +import java.util.List; +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; +import javax.swing.UIManager; +import javax.swing.plaf.metal.MetalLookAndFeel; +import javax.swing.plaf.metal.MetalTheme; + +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; /** * Variable Pluggable Look And Feel. @@ -33,18 +59,12 @@ import org.compiere.util.*; * * @author Jorg Janke * @version $Id: AdempierePLAF.java,v 1.3 2006/07/30 00:52:23 jjanke Exp $ + * + * @author Low Heng Sin + * @version 2006-11-27 */ public final class AdempierePLAF { - /** Version tag */ - public static final String VERSION = "R1.4.0"; - /** Key of Client Property to paint in AdempiereColor */ - public static final String BACKGROUND = "AdempiereBackground"; - /** Key of Client Property for Rectangle Items - if exists, the standard background is used */ - public static final String BACKGROUND_FILL = "AdempiereBackgroundFill"; - /** Key of Client Property for CPanel */ - public static final String TABLEVEL = "AdempiereTabLevel"; - /** Logger */ private static Logger log = Logger.getLogger(AdempierePLAF.class.getName()); @@ -62,30 +82,40 @@ public final class AdempierePLAF } // getFieldBackground_Normal /** - * Return Error field background (AdempiereTheme) + * Return Error field background * @return Color */ public static Color getFieldBackground_Error() { - return ColorBlind.getDichromatColor(AdempiereThemeInnova.error); + Color c = UIManager.getColor(ExtendedTheme.ERROR_BG_KEY); + if (c == null) + c = ExtendedTheme.DEFAULT_ERROR_BG; + return ColorBlind.getDichromatColor(c); } // getFieldBackground_Error /** - * Return Mandatory field background color (AdempiereTheme) + * Return Mandatory field background color * @return Color */ public static Color getFieldBackground_Mandatory() { - return ColorBlind.getDichromatColor(AdempiereThemeInnova.mandatory); + Color c = UIManager.getColor(ExtendedTheme.MANDATORY_BG_KEY); + if (c == null) + c = ExtendedTheme.DEFAULT_MANDATORY_BG; + return ColorBlind.getDichromatColor(c); } // getFieldBackground_Mandatory /** - * Return Inactive field background color (AdempiereTheme) + * Return Inactive field background color * @return Color */ public static Color getFieldBackground_Inactive() { - return ColorBlind.getDichromatColor(AdempiereThemeInnova.inactive); + Color c = UIManager.getColor(ExtendedTheme.INACTIVE_BG_KEY); + if ( c != null ) + return ColorBlind.getDichromatColor(c); + else + return getFieldBackground_Normal(); } // getFieldBackground_Inactive /** @@ -105,7 +135,10 @@ public final class AdempierePLAF */ public static Color getInfoBackground() { - return ColorBlind.getDichromatColor(AdempiereThemeInnova.info); + Color c = UIManager.getColor(ExtendedTheme.INFO_BG_KEY); + if (c == null) + c = UIManager.getColor("info"); + return ColorBlind.getDichromatColor(c); } // getInfoBackground @@ -127,7 +160,7 @@ public final class AdempierePLAF */ public static Color getTextColor_OK() { - return ColorBlind.getDichromatColor(AdempiereThemeInnova.txt_ok); + return getTextColor_Normal(); } // getText_OK /** @@ -136,7 +169,10 @@ public final class AdempierePLAF */ public static Color getTextColor_Issue() { - return ColorBlind.getDichromatColor(AdempiereThemeInnova.txt_error); + Color c = UIManager.getColor(ExtendedTheme.ERROR_FG_KEY); + if (c == null) + c = ExtendedTheme.DEFAULT_ERROR_FG; + return ColorBlind.getDichromatColor(c); } // getText_Issue /** @@ -155,7 +191,7 @@ public final class AdempierePLAF */ public static Color getPrimary1() { - return ColorBlind.getDichromatColor(AdempiereThemeInnova.primary1); + return ColorBlind.getDichromatColor(MetalLookAndFeel.getCurrentTheme().getPrimaryControlDarkShadow()); } /** * Get Primary2 @@ -163,7 +199,7 @@ public final class AdempierePLAF */ public static Color getPrimary2() { - return ColorBlind.getDichromatColor(AdempiereThemeInnova.primary2); + return ColorBlind.getDichromatColor(MetalLookAndFeel.getCurrentTheme().getPrimaryControlShadow()); } /** * Get Primary3 @@ -171,7 +207,7 @@ public final class AdempierePLAF */ public static Color getPrimary3() { - return ColorBlind.getDichromatColor(AdempiereThemeInnova.primary3); + return ColorBlind.getDichromatColor(MetalLookAndFeel.getCurrentTheme().getPrimaryControl()); } /** * Get Secondary 1 @@ -179,7 +215,7 @@ public final class AdempierePLAF */ public static Color getSecondary1() { - return ColorBlind.getDichromatColor(AdempiereThemeInnova.secondary1); + return ColorBlind.getDichromatColor(MetalLookAndFeel.getCurrentTheme().getControlDarkShadow()); } /** * Get Secondary 2 @@ -187,7 +223,7 @@ public final class AdempierePLAF */ public static Color getSecondary2() { - return ColorBlind.getDichromatColor(AdempiereThemeInnova.secondary2); + return ColorBlind.getDichromatColor(MetalLookAndFeel.getCurrentTheme().getControlShadow()); } /** * Get Secondary 3 @@ -195,20 +231,19 @@ public final class AdempierePLAF */ public static Color getSecondary3() { - return ColorBlind.getDichromatColor(AdempiereThemeInnova.secondary3); + return ColorBlind.getDichromatColor(MetalLookAndFeel.getCurrentTheme().getControl()); } /****** Fonts ************************************************************/ /** - * Get Header Font (window/label font) + * Get Header Font (window title font) * @return font */ public static Font getFont_Header() { - return CompiereTheme.windowFont; - // return UIManager.getFont("Label.font"); + return MetalLookAndFeel.getWindowTitleFont(); } // getFont_Header /** @@ -217,8 +252,7 @@ public final class AdempierePLAF */ public static Font getFont_Field() { - return CompiereTheme.userFont; - // return UIManager.getFont("TextField.font"); + return UIManager.getFont("TextField.font"); } // getFont_Field /** @@ -227,8 +261,7 @@ public final class AdempierePLAF */ public static Font getFont_Label() { - return CompiereTheme.controlFont; - // return UIManager.getFont("Label.font"); + return UIManager.getFont("Label.font"); } // setFont_Label /** @@ -237,7 +270,7 @@ public final class AdempierePLAF */ public static Font getFont_Small() { - return CompiereTheme.smallFont; + return MetalLookAndFeel.getSubTextFont(); } // setFont_Small /****** Available L&F ****************************************************/ @@ -247,20 +280,17 @@ public final class AdempierePLAF /** Default PLAF */ private static ValueNamePair s_defaultPLAF = null; /** Availablle Themes */ - private static ValueNamePair[] s_themes = null; + private static ValueNamePair[] s_metalThemes = null; + private static ValueNamePair[] s_plasticThemes = null; - private static ValueNamePair s_vp_adempiereTheme = null; + //default theme + private static ValueNamePair s_vp_compiereTheme = null; private static ValueNamePair s_vp_metalTheme = null; - private static ValueNamePair s_vp_kunststoffTheme = null; + private static ValueNamePair s_vp_plasticTheme = null; //e-evolution vpj-cd 19102006 - private static ValueNamePair s_vp_jgoodiesTheme = null; + private static ValueNamePair s_vp_adempiereTheme = null; //e-evolution vpj-cd 1910200sky - /** PLAF class list - com.sun.java.swing.plaf.windows.WindowsLookAndFeel - com.sun.java.swing.plaf.motif.MotifLookAndFeel - javax.swing.plaf.metal.MetalLookAndFeel - /** * Static Initializer. * - Fill available PLAFs and Themes @@ -270,55 +300,50 @@ public final class AdempierePLAF ArrayList plafList = new ArrayList(); //e-evolution vpj-cd 19102006 ValueNamePair vp = null; - ArrayList themeList = new ArrayList(); + ArrayList metalThemes = new ArrayList(); + ArrayList plasticThemes = new ArrayList(); try { - Class c = Class.forName("com.jgoodies.looks.plastic.PlasticLookAndFeel"); + Class c = Class.forName("com.jgoodies.looks.plastic.Plastic3DLookAndFeel"); vp = new ValueNamePair("org.adempiere.plaf.AdempiereLookAndFeel", org.adempiere.plaf.AdempiereLookAndFeel.NAME); plafList.add(vp); - s_vp_jgoodiesTheme = new ValueNamePair("org.compiere.plaf.AdempiereTheme", AdempiereThemeInnova.NAME); - themeList.add (s_vp_jgoodiesTheme); + 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(); + for(Object t : installedThemes) { + theme = (MetalTheme)t; + vp = new ValueNamePair(theme.getClass().getName(), theme.getName()); + plasticThemes.add(vp); + } } catch (Exception e) { - // log.severe("Kuststoff not found"); + log.severe("Plastic look and feel not found"); } //e-evolution vpj-cd 19102006 - //vpj-cd ValueNamePair vp = new ValueNamePair("org.compiere.plaf.CompiereLookAndFeel", CompiereLookAndFeel.NAME); vp = new ValueNamePair("org.compiere.plaf.CompiereLookAndFeel", CompiereLookAndFeel.NAME); plafList.add (vp); - // Themes - //vpj-cd ArrayList themeList = new ArrayList(); - s_vp_adempiereTheme = new ValueNamePair("org.compiere.plaf.CompiereThemeBlueMetal", CompiereThemeBlueMetal.NAME); - themeList.add (s_vp_adempiereTheme); - themeList.add (new ValueNamePair("org.compiere.plaf.CompiereThemeIce", CompiereThemeIce.NAME)); - // Metal - s_vp_metalTheme = new ValueNamePair("javax.swing.plaf.metal.DefaultMetalTheme", "Steel"); - themeList.add (s_vp_metalTheme); - themeList.add (new ValueNamePair("javax.swing.plaf.metal.OceanTheme", "Ocean")); -// themeList.add (new ValueNamePair("javax.swing.plaf.metal.MetalHighContrastTheme", "Java High Contrast")); - // - themeList.add (new ValueNamePair("org.compiere.plaf.AquaTheme", "Aqua")); - themeList.add (new ValueNamePair("org.compiere.plaf.CharcoalTheme", "Charcoal")); - themeList.add (new ValueNamePair("org.compiere.plaf.ContrastTheme", "Contrast")); - themeList.add (new ValueNamePair("org.compiere.plaf.EmeraldTheme", "Emerald")); - themeList.add (new ValueNamePair("org.compiere.plaf.RubyTheme", "Ruby")); - - // Discover and Install - Kuststoff - try - { - Class c = Class.forName("com.incors.plaf.kunststoff.KunststoffLookAndFeel"); - vp = new ValueNamePair("com.incors.plaf.kunststoff.KunststoffLookAndFeel", "Kunststoff"); - plafList.add(vp); - vp = new ValueNamePair("com.incors.plaf.kunststoff.KunststoffTheme", "Kuststoff"); - themeList.add(vp); - s_vp_kunststoffTheme = vp; - } - catch (Exception e) - { - // log.severe("Kuststoff not found"); - } + s_vp_compiereTheme = new ValueNamePair("org.compiere.plaf.CompiereThemeBlueMetal", CompiereThemeBlueMetal.NAME); + metalThemes.add (s_vp_compiereTheme); + metalThemes.add (new ValueNamePair("org.compiere.plaf.CompiereThemeIce", CompiereThemeIce.NAME)); + + //Metal + s_vp_metalTheme = new ValueNamePair("javax.swing.plaf.metal.OceanTheme", "Ocean"); + metalThemes.add (s_vp_metalTheme); + metalThemes.add (new ValueNamePair("javax.swing.plaf.metal.DefaultMetalTheme", "Steel")); + metalThemes.add (new ValueNamePair("org.compiere.plaf.AquaTheme", "Aqua")); + metalThemes.add (new ValueNamePair("org.compiere.plaf.CharcoalTheme", "Charcoal")); + metalThemes.add (new ValueNamePair("org.compiere.plaf.ContrastTheme", "Contrast")); + metalThemes.add (new ValueNamePair("org.compiere.plaf.EmeraldTheme", "Emerald")); + metalThemes.add (new ValueNamePair("org.compiere.plaf.RubyTheme", "Ruby")); // Install discovered PLAFs for (int i = 0; i < plafList.size(); i++) @@ -334,10 +359,7 @@ public final class AdempierePLAF { vp = new ValueNamePair (lfInfo[i].getClassName(), lfInfo[i].getName()); plafList.add(vp); - //begin vpj-cd e-evolution 26 oct 2006 - //if (lfInfo[i].getName().equals(CompiereLookAndFeel.NAME)) if (lfInfo[i].getName().equals(org.adempiere.plaf.AdempiereLookAndFeel.NAME)) - //end vpj-cd e-evolution 26 oct 2006 { s_defaultPLAF = vp; log.finest(vp.getName() + " (default)"); @@ -349,8 +371,11 @@ public final class AdempierePLAF plafList.toArray(s_looks); // Fill Available Themes - s_themes = new ValueNamePair[themeList.size()]; - themeList.toArray(s_themes); + s_metalThemes = new ValueNamePair[metalThemes.size()]; + metalThemes.toArray(s_metalThemes); + + s_plasticThemes = new ValueNamePair[plasticThemes.size()]; + plasticThemes.toArray(s_plasticThemes); // // printPLAFDefaults(); } // static Initializer @@ -366,22 +391,24 @@ public final class AdempierePLAF } // getPLAFs /** - * Get the list of available Metal Themes if the current L&F is a Metal L&F + * Get the list of available Metal or Plastic Themes. * @return Array of Strings with Names of Metal Themes */ public static ValueNamePair[] getThemes () { - if (UIManager.getLookAndFeel() instanceof MetalLookAndFeel) - return s_themes; + LookAndFeel l = UIManager.getLookAndFeel(); + if ( l instanceof PlasticLookAndFeel) + return s_plasticThemes; + else if ( l instanceof MetalLookAndFeel) + return s_metalThemes; return new ValueNamePair[0]; } // getThemes /************************************************************************** * Set PLAF based on Ini Properties - * @param win Optional Window */ - public static void setPLAF (Window win) + public static void setPLAF () { String look = Ini.getProperty(Ini.P_UI_LOOK); String lookTheme = Ini.getProperty(Ini.P_UI_THEME); @@ -397,16 +424,28 @@ public final class AdempierePLAF } // Search for Theme ValueNamePair theme = null; - for (int i = 0; i < s_themes.length; i++) + for (int i = 0; i < s_metalThemes.length; i++) { - if (s_themes[i].getName().equals(lookTheme)) + if (s_metalThemes[i].getName().equals(lookTheme)) { - theme = s_themes[i]; + theme = s_metalThemes[i]; break; } } + + if (theme == null) + { + for (int i = 0; i < s_plasticThemes.length; i++) + { + if (s_plasticThemes[i].getName().equals(lookTheme)) + { + theme = s_plasticThemes[i]; + break; + } + } + } // Set PLAF - setPLAF (plaf == null ? s_defaultPLAF : plaf, theme, win); + setPLAF (plaf == null ? s_defaultPLAF : plaf, theme, true); } // setPLAF /** @@ -414,66 +453,81 @@ public final class AdempierePLAF * * @param plaf ValueNamePair of the PLAF to be set * @param theme Optional Theme name - * @param win Optional Window + * @param upateIni Update setting to INI */ - public static void setPLAF (ValueNamePair plaf, ValueNamePair theme, Window win) + public static void setPLAF (ValueNamePair plaf, ValueNamePair theme, boolean updateIni) { if (plaf == null) return; log.config(plaf + (theme == null ? "" : (" - " + theme))); - // Look & Feel - try - { - UIManager.setLookAndFeel(plaf.getValue()); + // Look & Feel + Class lafClass = null; + try { + lafClass = Class.forName(plaf.getValue()); } catch (Exception e) { log.severe(e.getMessage()); + return; } - LookAndFeel laf = UIManager.getLookAndFeel(); - Ini.setProperty(Ini.P_UI_LOOK, plaf.getName()); - - // Optional Theme - Ini.setProperty(Ini.P_UI_THEME, ""); + + if ( updateIni ) { + Ini.setProperty(Ini.P_UI_LOOK, plaf.getName()); + // Optional Theme + Ini.setProperty(Ini.P_UI_THEME, ""); + } + // Default Theme - if (theme == null && laf instanceof MetalLookAndFeel) + 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) { - String className = laf.getClass().getName(); - if (className.equals("javax.swing.plaf.metal.MetalLookAndFeel")) - theme = s_vp_metalTheme; - else if (className.equals("org.compiere.plaf.CompiereLookAndFeel")) + if (compiere) + theme = s_vp_compiereTheme; + else if (adempiere) theme = s_vp_adempiereTheme; - else if (className.equals("com.incors.plaf.kunststoff.KunststoffLookAndFeel")) - theme = s_vp_kunststoffTheme; - //e-evolution vpj-cd - else if (className.equals("org.adempiere.plaf.AdempiereLookAndFeel")) - theme = s_vp_jgoodiesTheme; - //e-evolution vpj-cd + else if (plastic) + theme = s_vp_plasticTheme; + else + theme = s_vp_metalTheme; } - if (theme != null && laf instanceof MetalLookAndFeel && theme.getValue().length() > 0) + if (theme != null && metal && theme.getValue().length() > 0) { try { Class c = Class.forName(theme.getValue()); MetalTheme t = (MetalTheme)c.newInstance(); - if (t instanceof CompiereTheme) - AdempiereThemeInnova.load(); - if (laf instanceof CompiereLookAndFeel) + if (compiere) CompiereLookAndFeel.setCurrentTheme(t); - else - MetalLookAndFeel.setCurrentTheme(t); + else if (adempiere) + AdempiereLookAndFeel.setCurrentTheme(t); + else { + if (plastic && t instanceof PlasticTheme) { + PlasticLookAndFeel.setPlasticTheme((PlasticTheme)t); + } else { + MetalLookAndFeel.setCurrentTheme(t); + } + } // - boolean flat = Ini.isPropertyBool(Ini.P_UI_FLAT); - CompiereTheme.setTheme(t, flat); // copies it if not AdempiereTheme - Ini.setProperty(Ini.P_UI_THEME, theme.getName()); + if (updateIni) + Ini.setProperty(Ini.P_UI_THEME, theme.getName()); } catch (Exception e) { log.severe("Theme - " + e.getMessage()); } } - updateUI (win); + try + { + UIManager.setLookAndFeel((LookAndFeel)lafClass.newInstance()); + } + catch (Exception e) + { + log.severe(e.getMessage()); + } log.config(plaf + " - " + theme); // printPLAFDefaults(); } // setPLAF @@ -501,13 +555,11 @@ public final class AdempierePLAF /** * Reset PLAF Settings - * @param win Window to be reset */ - public static void reset (Window win) + public static void reset () { // Clean Theme Properties - AdempiereThemeInnova.reset (); // sets properties - AdempierePLAF.setPLAF (win); + AdempierePLAF.setPLAF (); } // reset /** @@ -538,7 +590,7 @@ public final class AdempierePLAF */ public static boolean isActive() { - return UIManager.getLookAndFeel() instanceof CompiereLookAndFeel; + return UIManager.getLookAndFeel() instanceof AdempiereLookAndFeel; } // isActive /*************************************************************************/ @@ -585,9 +637,29 @@ public final class AdempierePLAF window.setVisible(true); } // showCenterScreen + /** + * Invoke the correct method to set current metal based theme. + * Supported look and feel are Metal, Plastic and Compiere. + * @param laf Metal based look and feel + * @param theme Metal based theme + */ + public static void setCurrentMetalTheme(MetalLookAndFeel laf, MetalTheme theme) + { + 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); + } + } + } /************************************************************************** - * Start Class With Adempiere Look or Adempiere PLAF Editor + * Start Class With Adempiere Look * @param args first parameter is class to start, if none start PLAF Editor */ public static void main (String[] args) @@ -604,12 +676,10 @@ public final class AdempierePLAF // set the defined PLAF Ini.loadProperties (true); - AdempiereThemeInnova.load (); - setPLAF (null); + setPLAF (); // if (args.length == 0) { - AdempierePLAFFrame frame = new AdempierePLAFFrame(); return; } @@ -663,34 +733,3 @@ public final class AdempierePLAF } // main } // AdempierePLAF - -/** - * Frame to display Editor - */ -class AdempierePLAFFrame extends CFrame -{ - /** - * Frame to display Editor - */ - public AdempierePLAFFrame() - { - super("AdempierePLAF"); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - setIconImage(Toolkit.getDefaultToolkit().getImage(AdempierePLAF.class.getResource("icons/CL16.gif"))); - AdempierePLAF.showCenterScreen(this); - } // AdempierePLAFFrame - - /** - * Show Editor - * @param e event - */ - protected void processWindowEvent (WindowEvent e) - { - super.processWindowEvent(e); - if (e.getID() == WindowEvent.WINDOW_OPENED) - { - AdempierePLAFEditor ed = new AdempierePLAFEditor(this, true); - dispose(); - } - } // processWindowEvents -} // AdempierePLAFFrame diff --git a/looks/src/org/adempiere/plaf/AdempiereTheme.java b/looks/src/org/adempiere/plaf/AdempiereTheme.java index 2657993568..f9f477fea1 100755 --- a/looks/src/org/adempiere/plaf/AdempiereTheme.java +++ b/looks/src/org/adempiere/plaf/AdempiereTheme.java @@ -11,6 +11,8 @@ import javax.swing.plaf.ColorUIResource; import javax.swing.plaf.FontUIResource; //import org.compiere.plaf.ColorBlind; +import org.compiere.swing.ColorBlind; +import org.compiere.swing.ExtendedTheme; import org.compiere.util.Ini; import com.jgoodies.looks.plastic.PlasticScrollBarUI; @@ -25,7 +27,7 @@ import com.jgoodies.looks.plastic.theme.*; * @author vpj-cd * @version $Revision: 1.0 $ */ -public class AdempiereTheme extends com.jgoodies.looks.plastic.theme.DesertBluer { +public class AdempiereTheme extends com.jgoodies.looks.plastic.PlasticTheme { /** @@ -55,47 +57,6 @@ public class AdempiereTheme extends com.jgoodies.looks.plastic.theme.DesertBluer s_theme = new org.adempiere.plaf.AdempiereTheme(); } - /** - * Set Theme to current Metal Theme and copy it - */ - public static void setTheme () - { - log.fine(""); - org.adempiere.plaf.AdempiereTheme copyFrom = new org.adempiere.plaf.AdempiereTheme(); - boolean flat = Ini.isPropertyBool(Ini.P_UI_FLAT); - setTheme (copyFrom, flat); - } // setTheme - - /** - * Set Theme to current Metal Theme and copy it - * @param copyFrom theme - * @param flat flat colors - */ - public static void setTheme (org.adempiere.plaf.AdempiereTheme copyFrom, boolean flat) - { - if (copyFrom == null || copyFrom instanceof org.adempiere.plaf.AdempiereTheme) - return; - log.fine(copyFrom.getName() + " - Flat=" + flat); - // May not be correct, if Themes overwrites default methods - primary1 = copyFrom.getPrimaryControlDarkShadow(); - primary2 = copyFrom.getPrimaryControlShadow(); - primary3 = copyFrom.getPrimaryControl(); - secondary1 = copyFrom.getControlDarkShadow(); - secondary2 = copyFrom.getControlShadow(); - secondary3 = copyFrom.getControl(); - org.compiere.plaf.AdempierePanelUI.setDefaultBackground(new org.compiere.plaf.AdempiereColor(secondary3, flat)); - white = copyFrom.getPrimaryControlHighlight(); - black = copyFrom.getPrimaryControlInfo(); - // - controlFont = copyFrom.getControlTextFont(); - systemFont = copyFrom.getSystemTextFont(); - userFont = copyFrom.getUserTextFont(); - smallFont = copyFrom.getSubTextFont(); - menuFont = copyFrom.getMenuTextFont(); - windowFont = copyFrom.getWindowTitleFont(); - } // setTheme - - //------------------------------------------------- /** Theme Name */ protected static String s_name = "Adempiere Theme"; @@ -173,15 +134,15 @@ public class AdempiereTheme extends com.jgoodies.looks.plastic.theme.DesertBluer */ public ColorUIResource getPrimary1() { - return AdempiereColorBlind.getDichromatColorUIResource(primary1); + return ColorBlind.getDichromatColorUIResource(primary1); } public ColorUIResource getPrimary2() { - return AdempiereColorBlind.getDichromatColorUIResource(primary2); + return ColorBlind.getDichromatColorUIResource(primary2); } public ColorUIResource getPrimary3() { - return AdempiereColorBlind.getDichromatColorUIResource(primary3); + return ColorBlind.getDichromatColorUIResource(primary3); } /** @@ -190,32 +151,32 @@ public class AdempiereTheme extends com.jgoodies.looks.plastic.theme.DesertBluer */ public ColorUIResource getSecondary0() { - return AdempiereColorBlind.getDichromatColorUIResource(secondary0); + return ColorBlind.getDichromatColorUIResource(secondary0); } public ColorUIResource getSecondary1() { - return AdempiereColorBlind.getDichromatColorUIResource(secondary1); + return ColorBlind.getDichromatColorUIResource(secondary1); } public ColorUIResource getSecondary2() { - return AdempiereColorBlind.getDichromatColorUIResource(secondary2); + return ColorBlind.getDichromatColorUIResource(secondary2); } public ColorUIResource getSecondary3() { - return AdempiereColorBlind.getDichromatColorUIResource(secondary3); + return ColorBlind.getDichromatColorUIResource(secondary3); } public ColorUIResource getSecondary4() { - return AdempiereColorBlind.getDichromatColorUIResource(secondary4); + return ColorBlind.getDichromatColorUIResource(secondary4); } public ColorUIResource getBlack() { - return AdempiereColorBlind.getDichromatColorUIResource(black); + return ColorBlind.getDichromatColorUIResource(black); } public ColorUIResource getWhite() { - return AdempiereColorBlind.getDichromatColorUIResource(white); + return ColorBlind.getDichromatColorUIResource(white); } /** @@ -350,65 +311,6 @@ public class AdempiereTheme extends com.jgoodies.looks.plastic.theme.DesertBluer } public FontUIResource getSubTextFont() {return _getSubTextFont();} - // Static property info - - private static final String P_Primary1 = "#ColorPrimary1"; - private static final String P_Primary2 = "#ColorPrimary2"; - private static final String P_Primary3 = "#ColorPrimary3"; - private static final String P_Secondary1 = "#ColorSecondary1"; - private static final String P_Secondary2 = "#ColorSecondary2"; - private static final String P_Secondary3 = "#ColorSecondary3"; - private static final String P_Black = "#ColorBlack"; - private static final String P_White = "#ColorWhite"; - private static final String P_Error = "#ColorError"; - private static final String P_Info = "#ColorInfo"; - private static final String P_Mandatory = "#ColorMandatory"; - private static final String P_Inactive = "#ColorInactive"; - private static final String P_Txt_OK = "#ColorTextOK"; - private static final String P_Txt_Error = "#ColorTextError"; - // - private static final String P_Control = "#FontControl"; - private static final String P_System = "#FontSystem"; - private static final String P_User = "#FontUser"; - private static final String P_Small = "#FontSmall"; - private static final String P_Window = "#FontWindow"; - private static final String P_Menu = "#FontMenu"; - /** Background Color */ - protected static final String P_AdempiereColor = "#AdempiereColor"; - - /** - * Save information in Properties - */ - public static void save () - { - //log.config(AdempiereColor.getDefaultBackground().toString()); - // - Ini.setProperty(P_Primary1, getColorAsString(primary1)); - Ini.setProperty(P_Primary2, getColorAsString(primary2)); - Ini.setProperty(P_Primary3, getColorAsString(primary3)); - Ini.setProperty(P_Secondary1, getColorAsString(secondary1)); - Ini.setProperty(P_Secondary2, getColorAsString(secondary2)); - Ini.setProperty(P_Secondary3, getColorAsString(secondary3)); - Ini.setProperty(P_Error, getColorAsString(error)); - Ini.setProperty(P_Info, getColorAsString(info)); - Ini.setProperty(P_Mandatory, getColorAsString(mandatory)); - Ini.setProperty(P_Inactive, getColorAsString(inactive)); - Ini.setProperty(P_White, getColorAsString(white)); - Ini.setProperty(P_Black, getColorAsString(black)); - Ini.setProperty(P_Txt_OK, getColorAsString(txt_ok)); - Ini.setProperty(P_Txt_Error, getColorAsString(txt_error)); - // - Ini.setProperty(P_Control, ((Font)controlFont).toString()); - Ini.setProperty(P_System, ((Font)systemFont).toString()); - Ini.setProperty(P_User, ((Font)userFont).toString()); - Ini.setProperty(P_Small, ((Font)smallFont).toString()); - Ini.setProperty(P_Window, ((Font)windowFont).toString()); - Ini.setProperty(P_Menu, ((Font)menuFont).toString()); - // - //AdempiereColor cc = org.adempiere.plaf.AdempiereColor.getDefaultBackground(); - //Ini.setProperty(P_CompiereColor, cc.toString()); - } // save - /** * Parses Color into String representation. * Required as SystemColors and Alpha Colors have different formats @@ -430,169 +332,12 @@ public class AdempiereTheme extends com.jgoodies.looks.plastic.theme.DesertBluer } // getColorAsString /** - * Load Properties from Ini - */ - public static void load () - { - primary1 = parseColor (Ini.getProperty(P_Primary1), primary1); - primary2 = parseColor (Ini.getProperty(P_Primary2), primary2); - primary3 = parseColor (Ini.getProperty(P_Primary3), primary3); - secondary1 = parseColor (Ini.getProperty(P_Secondary1), secondary1); - secondary2 = parseColor (Ini.getProperty(P_Secondary2), secondary2); - secondary3 = parseColor (Ini.getProperty(P_Secondary3), secondary3); - error = parseColor(Ini.getProperty(P_Error), error); - info = parseColor(Ini.getProperty(P_Info), info); - mandatory = parseColor(Ini.getProperty(P_Mandatory), mandatory); - inactive = parseColor(Ini.getProperty(P_Inactive), inactive); - white = parseColor(Ini.getProperty(P_White), white); - black = parseColor(Ini.getProperty(P_Black), black); - txt_ok = parseColor(Ini.getProperty(P_Txt_OK), txt_ok); - txt_error = parseColor(Ini.getProperty(P_Txt_Error), txt_error); - // - controlFont = parseFont(Ini.getProperty(P_Control), controlFont); - systemFont = parseFont(Ini.getProperty(P_System), systemFont); - userFont = parseFont(Ini.getProperty(P_User), userFont); - smallFont = parseFont(Ini.getProperty(P_Small), smallFont); - windowFont = parseFont(Ini.getProperty(P_Window), windowFont); - menuFont = parseFont(Ini.getProperty(P_Menu), menuFont); - // - //AdempiereColor cc = AdempiereColor.parse(Ini.getProperty(P_AdempiereColor)); - //AdempiereColor.setDefaultBackground(cc); - } // load - - /** * Set Default Colors */ public void setDefault() { } // setDefault - /** - * Reset Info in Properties - */ - public static void reset () - { -/** - Ini.remove (P_Primary1); - Ini.remove (P_Primary2); - Ini.remove (P_Primary3); - Ini.remove (P_Secondary1); - Ini.remove (P_Secondary2); - Ini.remove (P_Secondary3); - Ini.remove (P_Error); - Ini.remove (P_Info); - Ini.remove (P_Mandatory); - Ini.remove (P_Inactive); - Ini.remove (P_White); - Ini.remove (P_Black); - Ini.remove (P_Txt_OK); - Ini.remove (P_Txt_Error); - // - Ini.remove (P_Control); - Ini.remove (P_System); - Ini.remove (P_User); - Ini.remove (P_Small); - Ini.remove (P_Window); - Ini.remove (P_Menu); - // CompiereColor - Ini.remove(P_CompiereColor); -**/ - // Initialize - Ini.setProperty(Ini.P_UI_LOOK, org.adempiere.plaf.AdempiereLookAndFeel.NAME); - Ini.setProperty(Ini.P_UI_THEME, s_name); - // - if (s_theme != null) - s_theme.setDefault(); - - // Background - // CompiereColor cc = new CompiereColor(SystemColor.control); // flat Windows 212-208-200 - // CompiereColor cc = new CompiereColor(secondary3); // flat Metal 204-204-204 - //AdempiereColor cc = new AdempiereColor(secondary3, false); - //AdempiereColor.setDefaultBackground (cc); - // - save(); // save properties - } // reset - - /** - * Parse Color. - *

- * Color - [r=102,g=102,b=153,a=0] - * - * @param information string information to be parsed - * @param stdColor color used if info cannot parsed - * @return color - * @see #getColorAsString - */ - protected static ColorUIResource parseColor (String information, ColorUIResource stdColor) - { - if (information == null - || information.length() == 0 - || information.trim().length() == 0) - return stdColor; - // System.out.print("ParseColor=" + info); - try - { - int r = Integer.parseInt(information.substring(information.indexOf("r=")+2, information.indexOf(",g="))); - int g = Integer.parseInt(information.substring(information.indexOf("g=")+2, information.indexOf(",b="))); - int b = 0; - int a = 255; - if (information.indexOf("a=") == -1) - b = Integer.parseInt(information.substring(information.indexOf("b=")+2, information.indexOf("]"))); - else - { - b = Integer.parseInt(information.substring(information.indexOf("b=")+2, information.indexOf(",a="))); - a = Integer.parseInt(information.substring(information.indexOf("a=")+2, information.indexOf("]"))); - } - ColorUIResource retValue = new ColorUIResource(new Color(r, g, b, a)); - // System.out.println(" - " + retValue.toString()); - return retValue; - } - catch (Exception e) - { - log.config(information + " - cannot parse: " + e.toString()); - } - return stdColor; - } // parseColor - - /** - * Parse Font - *

- * javax.swing.plaf.FontUIResource[family=dialog.bold,name=Dialog,style=bold,size=12] - * - * @param information string information to be parsed - * @param stdFont font used if info cannot be parsed - * @return font - */ - private static FontUIResource parseFont(String information, FontUIResource stdFont) - { - if (information == null - || information.length() == 0 - || information.trim().length() == 0) - return stdFont; - // System.out.print("ParseFont=" + info); - try - { - String name = information.substring(information.indexOf("name=")+5, information.indexOf(",style=")); - String s = information.substring(information.indexOf("style=")+6, information.indexOf(",size=")); - int style = Font.PLAIN; - if (s.equals("bold")) - style = Font.BOLD; - else if (s.equals("italic")) - style = Font.ITALIC; - else if (s.equals("bolditalic")) - style = Font.BOLD | Font.ITALIC; - int size = Integer.parseInt(information.substring(information.indexOf(",size=")+6, information.lastIndexOf("]"))); - FontUIResource retValue = new FontUIResource(name,style,size); - // System.out.println(" - " + retValue.toString()); - return retValue; - } - catch (Exception e) - { - log.config(information + " - cannot parse: " + e.toString()); - } - return stdFont; - } // parseFont - //----------------------------------------------------- @@ -630,9 +375,17 @@ public class AdempiereTheme extends com.jgoodies.looks.plastic.theme.DesertBluer PlasticScrollBarUI.MAX_BUMPS_WIDTH_KEY, new Integer(30), //"TabbedPane.selected", getWhite(), "TabbedPane.selectHighlight", new ColorUIResource(231, 218, 188), - }; - + ExtendedTheme.ERROR_BG_KEY, + error, + ExtendedTheme.ERROR_FG_KEY, + txt_error, + ExtendedTheme.INACTIVE_BG_KEY, + inactive, + ExtendedTheme.INFO_BG_KEY, + info, + ExtendedTheme.MANDATORY_BG_KEY, + mandatory + }; table.putDefaults(uiDefaults); } - } diff --git a/looks/src/org/compiere/plaf/AdempiereThemeInnova.java b/looks/src/org/adempiere/plaf/AdempiereThemeInnova.java similarity index 96% rename from looks/src/org/compiere/plaf/AdempiereThemeInnova.java rename to looks/src/org/adempiere/plaf/AdempiereThemeInnova.java index 5dcec2db4a..d3b28ebba7 100644 --- a/looks/src/org/compiere/plaf/AdempiereThemeInnova.java +++ b/looks/src/org/adempiere/plaf/AdempiereThemeInnova.java @@ -14,7 +14,7 @@ * 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.compiere.plaf; +package org.adempiere.plaf; import java.awt.*; import javax.swing.plaf.*; diff --git a/looks/src/org/compiere/plaf/AdempierePLAFEditor.java b/looks/src/org/adempiere/plaf/PLAFEditor.java similarity index 80% rename from looks/src/org/compiere/plaf/AdempierePLAFEditor.java rename to looks/src/org/adempiere/plaf/PLAFEditor.java index 2885e41e32..08eda25409 100644 --- a/looks/src/org/compiere/plaf/AdempierePLAFEditor.java +++ b/looks/src/org/adempiere/plaf/PLAFEditor.java @@ -14,7 +14,7 @@ * 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.compiere.plaf; +package org.adempiere.plaf; import java.awt.*; import java.awt.event.*; @@ -23,8 +23,13 @@ import java.util.logging.*; import javax.swing.*; import javax.swing.border.*; import javax.swing.plaf.metal.*; + +import org.compiere.plaf.CompiereColor; +import org.compiere.plaf.CompiereLookAndFeel; +import org.compiere.plaf.CompiereThemeEditor; import org.compiere.swing.*; import org.compiere.util.*; + import sun.awt.*; /** @@ -35,53 +40,53 @@ import sun.awt.*; * @author Jorg Janke * @version $Id: AdempierePLAFEditor.java,v 1.3 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempierePLAFEditor extends JDialog +public class PLAFEditor extends JDialog implements ActionListener { /** * Default Constructor * Don't Show Example */ - public AdempierePLAFEditor() + public PLAFEditor() { super(); init(false); - } // AdempierePLAFEditor + } // PLAFEditor /** * Constructor * @param showExample if true, show Example */ - public AdempierePLAFEditor (boolean showExample) + public PLAFEditor (boolean showExample) { super(); - init(showExample); - } // AdempierePLAFEditor + init(true); + } // PLAFEditor /** * Modal Dialog Constructor * @param owner * @param showExample if true, show Example */ - public AdempierePLAFEditor(Dialog owner, boolean showExample) + public PLAFEditor(Dialog owner, boolean showExample) { super(owner, "", true); - init(showExample); - } // AdempierePLAFEditor + init(true); + } // PLAFEditor /** * Modal Frame Constructor * @param owner * @param showExample if true, show Example */ - public AdempierePLAFEditor(Frame owner, boolean showExample) + public PLAFEditor(Frame owner, boolean showExample) { super(owner, "", true); - init(showExample); - } // AdempierePLAFEditor + init(true); + } // PLAFEditor /** Logger */ - private static Logger log = Logger.getLogger(AdempierePLAFEditor.class.getName()); + private static Logger log = Logger.getLogger(PLAFEditor.class.getName()); /************************************************************************** @@ -105,7 +110,6 @@ public class AdempierePLAFEditor extends JDialog { log.log(Level.SEVERE, "", e); } - // AdempiereUtils.setNotBuffered(this); } // PLAFEditor /** Diable Theme Field */ @@ -135,13 +139,9 @@ public class AdempierePLAFEditor extends JDialog private CComboBox lfField = new CComboBox(AdempierePLAF.getPLAFs()); private CLabel themeLabel = new CLabel(); private CComboBox themeField = new CComboBox(AdempierePLAF.getThemes()); - private CButton cButton = new CButton(); private FlowLayout southLayout = new FlowLayout(); private CButton rButton = new CButton(); - private CButton bSetColor = new CButton(); - private CCheckBox cDefault = new CCheckBox(); private CComboBox blindField = new CComboBox(ColorBlind.COLORBLIND_TYPE); - private CCheckBox flatField = new CCheckBox(); private CLabel blindLabel = new CLabel(); private BorderLayout mainLayout = new BorderLayout(); // @@ -168,10 +168,10 @@ public class AdempierePLAFEditor extends JDialog private JScrollPane jScrollPane2 = new JScrollPane(); private JTable jTable1 = new JTable(s_data, s_columns); private GridBagLayout gridBagLayout1 = new GridBagLayout(); - private CPanel jPanelFlat = new CPanel(new AdempiereColor(new Color(255,205,255), true)); - private CPanel jPanelGradient = new CPanel(new AdempiereColor(new Color(233,210,210), new Color(217,210,233))); - private CPanel jPanelTexture = new CPanel(new AdempiereColor(AdempiereColor.class.getResource("vincent.jpg"), Color.lightGray, 0.7f)); - private CPanel jPanelLines = new CPanel(new AdempiereColor(new Color(178,181,205), new Color(193,193,205), 1.0f, 5)); + private CPanel jPanelFlat = new CPanel(new CompiereColor(new Color(255,205,255), true)); + private CPanel jPanelGradient = new CPanel(new CompiereColor(new Color(233,210,210), new Color(217,210,233))); + private CPanel jPanelTexture = new CPanel(new CompiereColor(CompiereColor.class.getResource("vincent.jpg"), Color.lightGray, 0.7f)); + private CPanel jPanelLines = new CPanel(new CompiereColor(new Color(178,181,205), new Color(193,193,205), 1.0f, 5)); private JButton jButtonFlat = new JButton(); private CButton jButtonGardient = new CButton(); private JButton jButtonTexture = new JButton(); @@ -200,7 +200,7 @@ public class AdempierePLAFEditor extends JDialog private void jbInit() throws Exception { this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - this.setTitle(s_res.getString("LookAndFeelEditor") + " " + AdempierePLAF.VERSION); + this.setTitle(s_res.getString("LookAndFeelEditor")); mainPanel.setLayout(mainLayout); mainLayout.setHgap(5); mainLayout.setVgap(5); @@ -216,25 +216,15 @@ public class AdempierePLAFEditor extends JDialog jPanelTexture.setToolTipText("Indented Level 2"); jPanelLines.setToolTipText("Indented Level 1"); this.getContentPane().add(mainPanel, BorderLayout.CENTER); - AdempiereColor.setBackground(this); // lfLabel.setText(s_res.getString("LookAndFeel")); lfField.addActionListener(this); themeLabel.setText(s_res.getString("Theme")); themeField.addActionListener(this); - cButton.setText(s_res.getString("EditAdempiereTheme")); - cButton.addActionListener(this); rButton.setText(s_res.getString("Reset")); rButton.addActionListener(this); - cDefault.setText(s_res.getString("SetDefault")); - cDefault.addActionListener(this); - bSetColor.setText(s_res.getString("SetDefaultColor")); - bSetColor.addActionListener(this); blindLabel.setText(s_res.getString("ColorBlind")); blindField.addActionListener(this); - flatField.setText(s_res.getString("FlatColor")); - flatField.setSelected(Ini.isPropertyBool(Ini.P_UI_FLAT)); - flatField.addActionListener(this); // bOK.addActionListener(this); bCancel.addActionListener(this); @@ -282,16 +272,8 @@ public class AdempierePLAFEditor extends JDialog ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); northPanel.add(themeField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); - northPanel.add(cButton, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); northPanel.add(rButton, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - northPanel.add(bSetColor, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); - northPanel.add(cDefault, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - northPanel.add(flatField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 12), 0, 0)); northPanel.add(blindLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); northPanel.add(blindField, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0 @@ -366,7 +348,7 @@ public class AdempierePLAFEditor extends JDialog */ private void dynInit() { - // setLFSelection(); + setLFSelection(); // jPanelGradient.setTabLevel(1); jPanelTexture.setTabLevel(2); @@ -383,7 +365,6 @@ public class AdempierePLAFEditor extends JDialog jButtonTexture.addActionListener(this); jButtonLines.addActionListener(this); // - AdempierePLAF.setPLAF(this); } // dynInit /** @@ -451,7 +432,6 @@ public class AdempierePLAFEditor extends JDialog // OK - Save & Finish if (e.getSource() == bOK) { - CompiereTheme.save(); Ini.saveProperties(true); dispose(); } @@ -470,58 +450,28 @@ public class AdempierePLAFEditor extends JDialog { m_setting = true; // disable Theme setting // set new theme - AdempierePLAF.setPLAF((ValueNamePair)lfField.getSelectedItem(), null, this); + AdempierePLAF.setPLAF((ValueNamePair)lfField.getSelectedItem(), null, true); + AdempierePLAF.updateUI(this); setLFSelection(); - setBackgroundToTheme(); - AdempierePLAF.setPLAF(this); // twice ?? m_setting = false; // enable Theme setting } // Theme Field Changed else if (e.getSource() == themeField && !m_setting) { Ini.setProperty(Ini.P_UI_THEME, themeField.getSelectedItem().toString()); - AdempierePLAF.setPLAF((ValueNamePair)lfField.getSelectedItem(), (ValueNamePair)themeField.getSelectedItem(), this); - CompiereTheme.setTheme(); // copy Theme - setBackgroundToTheme(); - AdempierePLAF.setPLAF(this); // twice (??) - } - - // Start Adempiere Theme Editor - else if (e.getSource() == cButton) - { - new AdempiereThemeEditor(this); - setBackgroundToTheme(); + AdempierePLAF.setPLAF((ValueNamePair)lfField.getSelectedItem(), (ValueNamePair)themeField.getSelectedItem(),true); + AdempierePLAF.updateUI(this); } // Reset PLAFs else if (e.getSource() == rButton) { - AdempierePLAF.reset(this); + AdempierePLAF.reset(); + AdempierePLAF.updateUI(this); setLFSelection(); ColorBlind.setColorType(ColorBlind.NORMAL); - AdempierePLAF.setPLAF(this); // twice ?? } - // Set Default Background Color - else if (e.getSource() == bSetColor) - { - AdempiereColor cc = AdempiereColorEditor.showDialog(this, AdempierePanelUI.getDefaultBackground()); - AdempierePanelUI.setDefaultBackground(cc); - AdempierePLAF.updateUI(this); - Ini.setProperty(CompiereTheme.P_AdempiereColor, cc.toString()); - } - // Set Background as Default - else if (e.getSource() == cDefault) - { - AdempierePanelUI.setSetDefault(cDefault.isSelected()); - AdempierePLAF.updateUI(this); - } - // Flat - else if (e.getSource() == flatField) - { - Ini.setProperty(Ini.P_UI_FLAT, flatField.isSelected()); - setBackgroundToTheme(); - } // ColorBlind else if (e.getSource() == blindField) { @@ -542,7 +492,6 @@ public class AdempierePLAFEditor extends JDialog } ColorBlind.setColorType(sel); AdempierePLAF.updateUI(this); - AdempierePLAF.setPLAF(this); // twice (??) } } @@ -585,7 +534,6 @@ public class AdempierePLAFEditor extends JDialog themeField.setEnabled(metal); themeLabel.setEnabled(metal); boolean adempiere = UIManager.getLookAndFeel() instanceof CompiereLookAndFeel; - flatField.setEnabled(adempiere); // ColorBlind - only with Adempiere L&F & Theme boolean enableBlind = adempiere @@ -600,20 +548,6 @@ public class AdempierePLAFEditor extends JDialog setCursor(Cursor.getDefaultCursor()); } // actionPerformed - /** - * Set AdempiereColor Background to Theme Background - */ - private void setBackgroundToTheme() - { - // Not flat for Adempiere L&F - boolean flat = Ini.isPropertyBool(Ini.P_UI_FLAT); - AdempiereColor cc = new AdempiereColor(CompiereTheme.secondary3, flat); - AdempierePanelUI.setDefaultBackground(cc); - Ini.setProperty(CompiereTheme.P_AdempiereColor, cc.toString()); - AdempierePLAF.updateUI(this); - } // setBackgroundToTheme - - /** * Dispose * Exit, if there is no real owning parent (not modal) - shortcut diff --git a/looks/src/org/adempiere/plaf/PLAFEditorPanel.java b/looks/src/org/adempiere/plaf/PLAFEditorPanel.java new file mode 100644 index 0000000000..acbf0cd4d2 --- /dev/null +++ b/looks/src/org/adempiere/plaf/PLAFEditorPanel.java @@ -0,0 +1,445 @@ +/****************************************************************************** + * 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 java.awt.BorderLayout; +import java.awt.Cursor; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.event.FocusAdapter; +import java.awt.event.KeyAdapter; +import java.awt.event.MouseAdapter; +import java.awt.image.BufferedImage; +import java.util.ResourceBundle; +import java.util.logging.Logger; + +import javax.swing.BorderFactory; +import javax.swing.BoxLayout; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JRadioButton; +import javax.swing.JRootPane; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTable; +import javax.swing.JTree; +import javax.swing.LookAndFeel; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.plaf.SplitPaneUI; +import javax.swing.plaf.basic.BasicSplitPaneUI; +import javax.swing.plaf.metal.MetalLookAndFeel; +import javax.swing.plaf.metal.MetalTheme; + +import org.compiere.swing.CButton; +import org.compiere.swing.CCheckBox; +import org.compiere.swing.CComboBox; +import org.compiere.swing.CLabel; +import org.compiere.swing.CPanel; +import org.compiere.swing.CTabbedPane; +import org.compiere.swing.CTextField; +import org.compiere.util.ValueNamePair; + +import sun.awt.AppContext; + +/** + * Look and feel selection panel. + * @author Low Heng Sin + * @version 2006-11-27 + */ +public class PLAFEditorPanel extends CPanel { + /** Logger */ + private static Logger log = Logger.getLogger(PLAFEditor.class.getName()); + + static ResourceBundle s_res = ResourceBundle.getBundle("org.compiere.plaf.PlafRes"); + static Object[] s_columns = new Object[] {"-0-", "-1-"}; + static Object[][] s_data = new Object[][] { + {"-00-", "-01-"}, + {"-10-", "-11-"}, + {"-20-", "-21-"}, + {"-30-", "-31-"}, + {"-O0-", "-O1-"}, + {"-l0-", "-l1-"}}; + + private PreviewPanel previewPanel = new PreviewPanel(); + private JList lookList = new JList(AdempierePLAF.getPLAFs()); + private JList themeList = new JList(); + + /** + * Instance variable to disable list event handling when updating list with value + * from UIManager + */ + private boolean m_setting; + + //preview components + private CTextField error = new CTextField(s_res.getString("Error")); + private CTextField mandatory = new CTextField(s_res.getString("Mandatory")); + CButton button = new CButton("Button"); + CPanel tabPage1 = new CPanel(); + + public PLAFEditorPanel() { + init(); + } + + private void init() { + setupUI(); + setupPreview(); + setLFSelection(); + } + + /** + * Create and layout UI components + */ + private void setupUI() { + this.setLayout(new BorderLayout()); + + //splitpane for the selection and preview panel + JSplitPane splitPane = new JSplitPane(); + splitPane.setBorder(BorderFactory.createEmptyBorder()); + splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); + add(splitPane, BorderLayout.CENTER); + + CPanel selectionPanel = new CPanel(); + CPanel previewPart = new CPanel(); + + splitPane.setTopComponent(selectionPanel); + splitPane.setBottomComponent(previewPart); + splitPane.setDividerLocation(0.50); + splitPane.setDividerSize(0); + //disable divider + SplitPaneUI splitPaneUI = splitPane.getUI(); + if (splitPaneUI instanceof BasicSplitPaneUI) { + ((BasicSplitPaneUI)splitPaneUI).getDivider().setEnabled(false); + } + + //setup look and theme selection component + selectionPanel.setLayout(new GridBagLayout()); + CLabel label = new CLabel(s_res.getString("LookAndFeel")); + label.setForeground(AdempierePLAF.getPrimary1()); + label.setFont(label.getFont().deriveFont(Font.BOLD)); + selectionPanel.add(label, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, + GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); + label = new CLabel(s_res.getString("Theme")); + label.setForeground(AdempierePLAF.getPrimary1()); + label.setFont(label.getFont().deriveFont(Font.BOLD)); + selectionPanel.add(label, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, + GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); + + lookList.setVisibleRowCount(12); + JScrollPane scrollPane = new JScrollPane(lookList); + scrollPane.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getSecondary1(), 1)); + selectionPanel.add(scrollPane, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, + GridBagConstraints.NORTHWEST, GridBagConstraints.VERTICAL, new Insets(0, 5, 2, 2), 100, 0)); + + themeList.setVisibleRowCount(12); + scrollPane = new JScrollPane(themeList); + scrollPane.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getSecondary1(), 1)); + selectionPanel.add(scrollPane, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, + GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 2, 2, 5), 0, 0)); + + previewPart.setBorder(BorderFactory.createEmptyBorder()); + previewPart.setLayout(new GridBagLayout()); + label = new CLabel(s_res.getString("Preview")); + label.setForeground(AdempierePLAF.getPrimary1()); + label.setFont(label.getFont().deriveFont(Font.BOLD)); + previewPart.add(label, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, + GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); + previewPart.add(previewPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, + GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0)); + + lookList.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent e) { + lookAndFeelSelectionChanged(e); + } + + }); + themeList.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent e) { + themeSelectionChanged(e); + } + + }); + } + + protected void themeSelectionChanged(ListSelectionEvent e) { + if (m_setting) return; + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + ValueNamePair laf = (ValueNamePair)lookList.getSelectedValue(); + ValueNamePair theme = (ValueNamePair)themeList.getSelectedValue(); + LookAndFeel currentLaf = UIManager.getLookAndFeel(); + MetalTheme currentTheme = MetalLookAndFeel.getCurrentTheme(); + AdempierePLAF.setPLAF(laf, theme, false); + previewPanel.refresh(currentLaf,currentTheme); + SwingUtilities.updateComponentTreeUI(previewPanel); + updatePreviewComponents(); + setLFSelection(); + setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + this.repaint(); + } + + /** + * Handle look and feel selection changed + * @param e + */ + protected void lookAndFeelSelectionChanged(ListSelectionEvent e) { + if (m_setting) return; + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + ValueNamePair laf = (ValueNamePair)lookList.getSelectedValue(); + LookAndFeel currentLaf = UIManager.getLookAndFeel(); + MetalTheme currentTheme = MetalLookAndFeel.getCurrentTheme(); + AdempierePLAF.setPLAF(laf, null, false); + previewPanel.refresh(currentLaf,currentTheme); + SwingUtilities.updateComponentTreeUI(previewPanel); + updatePreviewComponents(); + setLFSelection(); + setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + this.repaint(); + } + + private void updatePreviewComponents() { + error.setBackground(true); + mandatory.setMandatory(true); + button.setOpaque(true); + tabPage1.setOpaque(false); + } + + /** + * Create the preview UI components + */ + private void setupPreview() { + JRootPane rootPane = new JRootPane(); + previewPanel.setLayout(new BorderLayout()); + previewPanel.add(rootPane, BorderLayout.CENTER); + previewPanel.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getSecondary1(), 1)); + GridLayout gridLayout = new GridLayout(1, 3); + gridLayout.setHgap(4); + rootPane.getContentPane().setLayout(gridLayout); + rootPane.setGlassPane(new GlassPane()); + rootPane.getGlassPane().setVisible(true); + CPanel column1 = new CPanel(); + rootPane.getContentPane().add(column1); + CPanel column2 = new CPanel(); + rootPane.getContentPane().add(column2); + CPanel column3 = new CPanel(); + rootPane.getContentPane().add(column3); + + column1.setLayout(new GridBagLayout()); + JTree jtree = new JTree(); + jtree.setFocusable(false); + jtree.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getSecondary1(), 1)); + column1.add(jtree, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, + GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5,5,2,2),0,0)); + CTextField normal = new CTextField("Text Field"); + normal.setFocusable(false); + column1.add(normal, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, + GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,5,5,2),0,0)); + error.setBackground(true); + error.setFocusable(false); + column1.add(error, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, + GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,2,5,2),0,0)); + + column2.setLayout(new GridBagLayout()); + JTable jtable = new JTable(s_data, s_columns); + JScrollPane scrollPane = new JScrollPane(jtable); + jtable.setFocusable(false); + scrollPane.setPreferredSize(jtable.getPreferredSize()); + column2.add(scrollPane, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, + GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5,2,2,2),0,0)); + mandatory.setMandatory(true); + mandatory.setFocusable(false); + column2.add(mandatory, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, + GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,2,5,2),0,0)); + CTextField inactive = new CTextField(s_res.getString("Inactive")); + inactive.setEnabled(false); + column2.add(inactive, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, + GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,2,5,2),0,0)); + + column3.setLayout(new GridBagLayout()); + CTabbedPane tab = new CTabbedPane(); + column3.add(tab, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, + GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5,2,2,5),0,0)); + CComboBox editable = new CComboBox(new Object[]{"Editable"}); + editable.setEditable(true); + editable.setFocusable(false); + column3.add(editable, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, + GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,2,5,2),0,0)); + CComboBox choice = new CComboBox(new Object[]{"Choice"}); + choice.setEditable(false); + choice.setFocusable(false); + column3.add(choice, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, + GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,2,5,5),0,0)); + + tabPage1.setLayout(new BoxLayout(tabPage1, BoxLayout.Y_AXIS)); + JRadioButton radio = new JRadioButton("Radio"); + radio.setSelected(true); + radio.setMargin(new Insets(5,5,5,5)); + radio.setFocusable(false); + radio.setOpaque(false); + tabPage1.add(radio); + CCheckBox checkBox = new CCheckBox("Checkbox"); + checkBox.setSelected(true); + checkBox.setMargin(new Insets(5,5,5,5)); + checkBox.setFocusable(false); + tabPage1.add(checkBox); + CLabel label = new CLabel("Label"); + label.setHorizontalAlignment(JLabel.LEFT); + label.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); + tabPage1.add(label); + button.setMargin(new Insets(5,5,5,5)); + button.setFocusable(false); + tabPage1.add(button); + tab.add(tabPage1, "tab1"); + tab.add(new CPanel(), "tab2"); + } + + /** + * 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); + } // setLFSelection + + /** + * Get look and feel selected by user + * @return selected look and feel + */ + public ValueNamePair getSelectedLook() { + return (ValueNamePair)lookList.getSelectedValue(); + } + + /** + * Get theme selected by user + * @return selected theme + */ + public ValueNamePair getSelectedTheme() { + return (ValueNamePair)themeList.getSelectedValue(); + } +} + +/** + * Glass pane to block input and mouse event from the preview components + * @author Low Heng Sin + */ +class GlassPane extends JComponent { + GlassPane() { + addMouseListener(new MouseAdapter() {}); + addKeyListener(new KeyAdapter() {}); + addFocusListener(new FocusAdapter() {}); + } +} + +/** + * A custom panel, only repaint when look and feel or theme changed. + * @author Low Heng Sin + */ +class PreviewPanel extends CPanel { + private boolean capture = true; + private LookAndFeel laf = null; + private MetalTheme theme = null; + private BufferedImage image; + + @Override + public void paint(Graphics g) { + if (capture) { + //capture preview image + image = (BufferedImage)createImage(this.getWidth(),this.getHeight()); + super.paint(image.createGraphics()); + g.drawImage(image, 0, 0, null); + capture = false; + if (laf != null) { + //reset to origianl setting + if (laf instanceof MetalLookAndFeel) + AdempierePLAF.setCurrentMetalTheme((MetalLookAndFeel)laf, theme); + try { + UIManager.setLookAndFeel(laf); + } catch (UnsupportedLookAndFeelException e) { + } + } + } else { + //draw preview image + if (image != null) + g.drawImage(image, 0, 0, null); + } + } + + /** + * Refresh look and feel preview, reset to original setting after + * refresh. + * @param currentLaf Current Look and feel + * @param currentTheme Current Theme + */ + public void refresh(LookAndFeel currentLaf, MetalTheme currentTheme) { + this.laf = currentLaf; + this.theme = currentTheme; + capture = true; + } +} \ No newline at end of file diff --git a/looks/src/org/compiere/plaf/AdempiereButtonListener.java b/looks/src/org/compiere/plaf/CompiereButtonListener.java similarity index 94% rename from looks/src/org/compiere/plaf/AdempiereButtonListener.java rename to looks/src/org/compiere/plaf/CompiereButtonListener.java index daade5c4c5..fdc220db89 100644 --- a/looks/src/org/compiere/plaf/AdempiereButtonListener.java +++ b/looks/src/org/compiere/plaf/CompiereButtonListener.java @@ -28,13 +28,13 @@ import javax.swing.plaf.basic.*; * @author Jorg Janke * @version $Id: AdempiereButtonListener.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereButtonListener extends BasicButtonListener +public class CompiereButtonListener extends BasicButtonListener { /** * Adempiere Button Listener * @param b button */ - public AdempiereButtonListener (AbstractButton b) + public CompiereButtonListener (AbstractButton b) { super (b); } // AdempiereButtonListener diff --git a/looks/src/org/compiere/plaf/AdempiereButtonUI.java b/looks/src/org/compiere/plaf/CompiereButtonUI.java similarity index 89% rename from looks/src/org/compiere/plaf/AdempiereButtonUI.java rename to looks/src/org/compiere/plaf/CompiereButtonUI.java index 141b07b175..2109dbb939 100644 --- a/looks/src/org/compiere/plaf/AdempiereButtonUI.java +++ b/looks/src/org/compiere/plaf/CompiereButtonUI.java @@ -28,7 +28,7 @@ import javax.swing.plaf.metal.*; * @author Jorg Janke * @version $Id: AdempiereButtonUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereButtonUI extends MetalButtonUI +public class CompiereButtonUI extends MetalButtonUI { /** * Static Create UI @@ -41,7 +41,7 @@ public class AdempiereButtonUI extends MetalButtonUI } // createUI /** UI shared */ - private static AdempiereButtonUI s_buttonUI = new AdempiereButtonUI(); + private static CompiereButtonUI s_buttonUI = new CompiereButtonUI(); /************************************************************************** @@ -73,7 +73,7 @@ public class AdempiereButtonUI extends MetalButtonUI { // System.out.println(c.getClass() + " ** " + ((JButton)c).getText() + " ** " + c.isOpaque()); if (c.isOpaque()) - AdempiereUtils.fillRectange((Graphics2D)g, c, CompiereLookAndFeel.ROUND); + CompiereUtils.fillRectange((Graphics2D)g, c, CompiereLookAndFeel.ROUND); paint (g, c); } // update @@ -90,7 +90,7 @@ public class AdempiereButtonUI extends MetalButtonUI boolean in = model.isPressed() || model.isSelected(); // if (b.isBorderPainted()) - AdempiereUtils.paint3Deffect((Graphics2D)g, c, CompiereLookAndFeel.ROUND, !in); + CompiereUtils.paint3Deffect((Graphics2D)g, c, CompiereLookAndFeel.ROUND, !in); } // paint /** @@ -126,7 +126,7 @@ public class AdempiereButtonUI extends MetalButtonUI */ protected BasicButtonListener createButtonListener (AbstractButton b) { - return new AdempiereButtonListener(b); + return new CompiereButtonListener(b); } // createButtonListener } // AdempiereButtonUI diff --git a/looks/src/org/compiere/plaf/AdempiereCheckBoxMenuItemUI.java b/looks/src/org/compiere/plaf/CompiereCheckBoxMenuItemUI.java similarity index 92% rename from looks/src/org/compiere/plaf/AdempiereCheckBoxMenuItemUI.java rename to looks/src/org/compiere/plaf/CompiereCheckBoxMenuItemUI.java index 9315c9e741..570255797d 100644 --- a/looks/src/org/compiere/plaf/AdempiereCheckBoxMenuItemUI.java +++ b/looks/src/org/compiere/plaf/CompiereCheckBoxMenuItemUI.java @@ -26,7 +26,7 @@ import javax.swing.plaf.basic.*; * @author Jorg Janke * @version $Id: AdempiereCheckBoxMenuItemUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI +public class CompiereCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI { /** * Create own instance @@ -35,7 +35,7 @@ public class AdempiereCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI */ public static ComponentUI createUI(JComponent c) { - return new AdempiereMenuItemUI(); + return new CompiereMenuItemUI(); } // createUI /** diff --git a/looks/src/org/compiere/plaf/AdempiereCheckBoxUI.java b/looks/src/org/compiere/plaf/CompiereCheckBoxUI.java similarity index 90% rename from looks/src/org/compiere/plaf/AdempiereCheckBoxUI.java rename to looks/src/org/compiere/plaf/CompiereCheckBoxUI.java index f39e6595b7..e155355995 100644 --- a/looks/src/org/compiere/plaf/AdempiereCheckBoxUI.java +++ b/looks/src/org/compiere/plaf/CompiereCheckBoxUI.java @@ -28,7 +28,7 @@ import javax.swing.plaf.metal.MetalCheckBoxUI; * @author Jorg Janke * @version $Id: AdempiereCheckBoxUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereCheckBoxUI extends MetalCheckBoxUI +public class CompiereCheckBoxUI extends MetalCheckBoxUI { /** * Create UI @@ -41,7 +41,7 @@ public class AdempiereCheckBoxUI extends MetalCheckBoxUI } // createUI /** UI shared */ - private static AdempiereCheckBoxUI s_checkBoxUI = new AdempiereCheckBoxUI(); + private static CompiereCheckBoxUI s_checkBoxUI = new CompiereCheckBoxUI(); /************************************************************************** @@ -61,7 +61,7 @@ public class AdempiereCheckBoxUI extends MetalCheckBoxUI */ protected BasicButtonListener createButtonListener (AbstractButton b) { - return new AdempiereButtonListener(b); + return new CompiereButtonListener(b); } // createButtonListener } // AdempiereCheckBoxUI diff --git a/looks/src/org/compiere/plaf/AdempiereColor.java b/looks/src/org/compiere/plaf/CompiereColor.java similarity index 85% rename from looks/src/org/compiere/plaf/AdempiereColor.java rename to looks/src/org/compiere/plaf/CompiereColor.java index 5236e0ac23..ff35fe6117 100644 --- a/looks/src/org/compiere/plaf/AdempiereColor.java +++ b/looks/src/org/compiere/plaf/CompiereColor.java @@ -24,6 +24,10 @@ import java.util.*; import java.util.logging.*; import javax.swing.*; import javax.swing.plaf.*; + +import org.adempiere.plaf.AdempierePLAF; +import org.compiere.swing.ColorBlind; +import org.compiere.swing.ThemeUtils; import org.compiere.util.*; /** @@ -32,7 +36,7 @@ import org.compiere.util.*; * @author Jorg Janke * @version $Id: AdempiereColor.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereColor implements Serializable +public class CompiereColor implements Serializable { /** Background type Flat */ public static final String TYPE_FLAT = "F"; @@ -100,7 +104,7 @@ public class AdempiereColor implements Serializable */ public static void setBackground (JComponent c) { - setBackground (c, AdempierePanelUI.getDefaultBackground()); + setBackground (c, new CompiereColor(AdempierePLAF.getFormBackground())); } // setBackground /** @@ -108,9 +112,9 @@ public class AdempiereColor implements Serializable * @param c Component * @param cc Color */ - public static void setBackground (JComponent c, AdempiereColor cc) + public static void setBackground (JComponent c, CompiereColor cc) { - c.putClientProperty(AdempierePLAF.BACKGROUND, cc); + c.putClientProperty(CompiereLookAndFeel.BACKGROUND, cc); } // setBackground /** @@ -118,12 +122,12 @@ public class AdempiereColor implements Serializable * @param c JComponent * @return Color */ - public static AdempiereColor getBackground (JComponent c) + public static CompiereColor getBackground (JComponent c) { - AdempiereColor bg = null; + CompiereColor bg = null; try { - bg = (AdempiereColor)c.getClientProperty(AdempierePLAF.BACKGROUND); + bg = (CompiereColor)c.getClientProperty(CompiereLookAndFeel.BACKGROUND); } catch (Exception e) { @@ -138,7 +142,7 @@ public class AdempiereColor implements Serializable */ public static void setBackground (Window win) { - setBackground (win, AdempierePanelUI.getDefaultBackground()); + setBackground (win, new CompiereColor(AdempierePLAF.getFormBackground())); } // setBackground /** @@ -146,73 +150,43 @@ public class AdempiereColor implements Serializable * @param win window * @param cc adempiere color */ - public static void setBackground (Window win, AdempiereColor cc) + public static void setBackground (Window win, CompiereColor cc) { if (win instanceof JDialog) { - ((JPanel)((JDialog)win).getContentPane()).putClientProperty(AdempierePLAF.BACKGROUND, cc); + ((JPanel)((JDialog)win).getContentPane()).putClientProperty(CompiereLookAndFeel.BACKGROUND, cc); // ((JPanel)((JDialog)win).getContentPane()).setName("contentPane"); } else if (win instanceof JFrame) { - ((JPanel)((JFrame)win).getContentPane()).putClientProperty(AdempierePLAF.BACKGROUND, cc); + ((JPanel)((JFrame)win).getContentPane()).putClientProperty(CompiereLookAndFeel.BACKGROUND, cc); // ((JPanel)((JFrame)win).getContentPane()).setName("contentPane"); } else if (win instanceof JWindow) { - ((JPanel)((JWindow)win).getContentPane()).putClientProperty(AdempierePLAF.BACKGROUND, cc); + ((JPanel)((JWindow)win).getContentPane()).putClientProperty(CompiereLookAndFeel.BACKGROUND, cc); // ((JPanel)((JWindow)win).getContentPane()).setName("contentPane"); } } // setBackground - /** - * Set Default Background - * @param bg Background Color - * @see AdempierePanelUI#setDefaultBackground - */ - public static void setDefaultBackground (AdempiereColor bg) - { - AdempierePanelUI.setDefaultBackground(bg); - } // setDefaultBackground - /** * Get Default Background * @return Background - * @see AdempierePanelUI#getDefaultBackground + * @see CompierePanelUI#getDefaultBackground */ - public static AdempiereColor getDefaultBackground() + public static CompiereColor getDefaultBackground() { - return AdempierePanelUI.getDefaultBackground(); + return new CompiereColor(AdempierePLAF.getFormBackground()); } // getDefaultBackground - /** - * Set Default Background - * @param setDefault if true, the background will be set to the default color - * @see AdempierePanelUI#setSetDefault - */ - public static void setSetDefault (boolean setDefault) - { - AdempierePanelUI.setSetDefault(setDefault); - } // setSetDefault - - /** - * Is the Default Background set by default - * @return true if default background is set - * @see AdempierePanelUI#isSetDefault - */ - public static boolean isSetDefault() - { - return AdempierePanelUI.isSetDefault(); - } // isSetDefault - /** * Parse attributes and return AdempiereColor * @param attributes attributes * @return AdempiereColor */ - public static AdempiereColor parse (String attributes) + public static CompiereColor parse (String attributes) { - AdempiereColor cc = new AdempiereColor (); + CompiereColor cc = new CompiereColor (); try { if (attributes != null && attributes.length() > 0) @@ -229,7 +203,7 @@ public class AdempiereColor implements Serializable /************************************************************************* * Create Gradient Background Color (Window System Color - White) */ - public AdempiereColor() + public CompiereColor() { this (TYPE_GRADIENT); } // AdempiereColor @@ -238,7 +212,7 @@ public class AdempiereColor implements Serializable * Create Default Background Colors of Type * @param type Background type (see constants TYPE_*) */ - public AdempiereColor (String type) + public CompiereColor (String type) { if (type == null) new java.lang.IllegalArgumentException (EXCEPTION_TEXT); @@ -255,7 +229,7 @@ public class AdempiereColor implements Serializable * Create Flat Background Color * @param bg background */ - public AdempiereColor (Color bg) + public CompiereColor (Color bg) { this (bg, true); } // AdempiereColor @@ -265,7 +239,7 @@ public class AdempiereColor implements Serializable * @param bg Color * @param flat if true create Flat color otherwise Gradient color with white lower color */ - public AdempiereColor (Color bg, boolean flat) + public CompiereColor (Color bg, boolean flat) { if (bg == null) new java.lang.IllegalArgumentException (EXCEPTION_TEXT); @@ -280,7 +254,7 @@ public class AdempiereColor implements Serializable * @param startPoint Starting point - e.g. SOUTH_WEST see SwingConstants, default NORTH_WEST * @param repeatDistance X/Y Distance to repeat gradient in points - 0 no repeats */ - public AdempiereColor (Color upperColor, Color lowerColor, int startPoint, int repeatDistance) + public CompiereColor (Color upperColor, Color lowerColor, int startPoint, int repeatDistance) { if (upperColor == null || lowerColor == null) new java.lang.IllegalArgumentException (EXCEPTION_TEXT); @@ -297,7 +271,7 @@ public class AdempiereColor implements Serializable * @param upperColor upper color * @param lowerColor lower color */ - public AdempiereColor (Color upperColor, Color lowerColor) + public CompiereColor (Color upperColor, Color lowerColor) { this (upperColor, lowerColor, SwingConstants.NORTH_WEST, 100); } // AdempiereColor @@ -309,7 +283,7 @@ public class AdempiereColor implements Serializable * @param taint Color to taint the texture (use white for not tainting it) * @param compositeAlpha Value from 0(no) to 1(full) taining */ - public AdempiereColor (URL textureURL, Color taint, float compositeAlpha) + public CompiereColor (URL textureURL, Color taint, float compositeAlpha) { if (textureURL == null || taint == null) new java.lang.IllegalArgumentException (EXCEPTION_TEXT); @@ -326,7 +300,7 @@ public class AdempiereColor implements Serializable * @param taint Color to taint the texture (use white for not tainting it) * @param compositeAlpha Tainting value from 0 (no - FullGraph) to 1 (full - NoGraph) */ - public AdempiereColor (String textureURL, Color taint, float compositeAlpha) + public CompiereColor (String textureURL, Color taint, float compositeAlpha) { if (textureURL == null || taint == null) new java.lang.IllegalArgumentException (EXCEPTION_TEXT); @@ -344,7 +318,7 @@ public class AdempiereColor implements Serializable * @param lineWidth Stroke width in point * @param lineDistance Distance between lines in points */ - public AdempiereColor (Color lineColor, Color backColor, float lineWidth, int lineDistance) + public CompiereColor (Color lineColor, Color backColor, float lineWidth, int lineDistance) { if (lineColor == null || backColor == null) new java.lang.IllegalArgumentException (EXCEPTION_TEXT); @@ -359,7 +333,7 @@ public class AdempiereColor implements Serializable * Copy Color * @param cc color */ - public AdempiereColor (AdempiereColor cc) + public CompiereColor (CompiereColor cc) { if (cc == null) return; @@ -401,7 +375,7 @@ public class AdempiereColor implements Serializable /** Diry marker for repaining Background */ private boolean m_dirty = true; /** Logger */ - private static Logger log = Logger.getLogger(AdempiereColor.class.getName()); + private static Logger log = Logger.getLogger(CompiereColor.class.getName()); /************************************************************************** * Get BackgroundType (Flat, Gradient, Lines, Texture) @@ -596,7 +570,7 @@ public class AdempiereColor implements Serializable if (!isTexture()) return null; if (m_textureURL == null) - m_textureURL = AdempiereColor.class.getResource("Adempiere00x100.gif"); + m_textureURL = CompiereColor.class.getResource("Adempiere00x100.gif"); return m_textureURL; } // getTextureURL @@ -609,7 +583,7 @@ public class AdempiereColor implements Serializable if (m_image == null) { URL url = getTextureURL(); - m_image = AdempiereUtils.loadBufferedImage(url, BufferedImage.TYPE_INT_ARGB_PRE); + m_image = CompiereUtils.loadBufferedImage(url, BufferedImage.TYPE_INT_ARGB_PRE); } return m_image; } // getTextureImage @@ -856,7 +830,7 @@ public class AdempiereColor implements Serializable * Set AdempiereColor from AdempiereColor * @param cc AdempiereColor */ - public void setColor (AdempiereColor cc) + public void setColor (CompiereColor cc) { if (cc == null) return; @@ -946,23 +920,23 @@ public class AdempiereColor implements Serializable StringBuffer sb = new StringBuffer ("AdempiereColor["); if (isFlat()) sb.append("Flat") - .append(" ").append(CompiereTheme.getColorAsString(getFlatColor())); + .append(" ").append(ThemeUtils.getColorAsString(getFlatColor())); else if (isGradient()) sb.append("Gradient") - .append(" Upper=").append(CompiereTheme.getColorAsString(getGradientUpperColor())) - .append(",Lower=").append(CompiereTheme.getColorAsString(getGradientLowerColor())) + .append(" Upper=").append(ThemeUtils.getColorAsString(getGradientUpperColor())) + .append(",Lower=").append(ThemeUtils.getColorAsString(getGradientLowerColor())) .append(",Start=").append(getGradientStartPoint()) .append(",RDistance=").append(getGradientRepeatDistance()); else if (isLine()) sb.append("Line") - .append(" Color=").append(CompiereTheme.getColorAsString(getLineColor())) - .append(",BackColor=").append(CompiereTheme.getColorAsString(getLineBackColor())) + .append(" Color=").append(ThemeUtils.getColorAsString(getLineColor())) + .append(",BackColor=").append(ThemeUtils.getColorAsString(getLineBackColor())) .append(",Width=").append(getLineWidth()) .append(",Distance=").append(getLineDistance()); else if (isTexture()) sb.append("Texture") .append(" GraphURL=").append(getTextureURL()) - .append(",Taint=").append(CompiereTheme.getColorAsString(getTextureTaintColor())) + .append(",Taint=").append(ThemeUtils.getColorAsString(getTextureTaintColor())) .append(",Alpha=").append(getTextureCompositeAlpha()); sb.append("]"); return sb.toString(); @@ -977,15 +951,15 @@ public class AdempiereColor implements Serializable if (str.indexOf("[Flat ") != -1) { m_type = TYPE_FLAT; - m_primaryColor = CompiereTheme.parseColor(str, + m_primaryColor = ThemeUtils.parseColor(str, new ColorUIResource(m_primaryColor)); } else if (str.indexOf("[Gradient ") != -1) { m_type = TYPE_GRADIENT; - m_primaryColor = CompiereTheme.parseColor(str.substring(str.indexOf(" Upper=")+7, str.indexOf(",Lower=")), + m_primaryColor = ThemeUtils.parseColor(str.substring(str.indexOf(" Upper=")+7, str.indexOf(",Lower=")), new ColorUIResource(m_primaryColor)); - m_secondaryColor = CompiereTheme.parseColor(str.substring(str.indexOf(",Lower=")+7, str.indexOf(",Start=")), + m_secondaryColor = ThemeUtils.parseColor(str.substring(str.indexOf(",Lower=")+7, str.indexOf(",Start=")), new ColorUIResource(m_secondaryColor)); m_startPoint = Integer.parseInt(str.substring(str.indexOf(",Start=")+7, str.indexOf(",RDistance="))); setGradientRepeatDistance(str.substring(str.indexOf(",RDistance=")+11, str.lastIndexOf("]"))); @@ -993,9 +967,9 @@ public class AdempiereColor implements Serializable else if (str.indexOf("[Line ") != -1) { m_type = TYPE_LINES; - m_primaryColor = CompiereTheme.parseColor(str.substring(str.indexOf(" Color=")+7, str.indexOf(",BackColor=")), + m_primaryColor = ThemeUtils.parseColor(str.substring(str.indexOf(" Color=")+7, str.indexOf(",BackColor=")), new ColorUIResource(m_primaryColor)); - m_secondaryColor = CompiereTheme.parseColor(str.substring(str.indexOf(",BackColor=")+11, str.indexOf(",Width=")), + m_secondaryColor = ThemeUtils.parseColor(str.substring(str.indexOf(",BackColor=")+11, str.indexOf(",Width=")), new ColorUIResource(m_secondaryColor)); setLineWidth(str.substring(str.indexOf(",Width=")+7, str.indexOf(",Distance="))); setLineDistance(str.substring(str.indexOf(",Distance=")+10, str.lastIndexOf("]"))); @@ -1004,7 +978,7 @@ public class AdempiereColor implements Serializable { m_type = TYPE_TEXTURE; setTextureURL (str.substring(str.indexOf(" GraphURL=")+10, str.indexOf(",Taint="))); - m_primaryColor = CompiereTheme.parseColor(str.substring(str.indexOf(",Taint=")+7, str.indexOf(",Alpha=")), + m_primaryColor = ThemeUtils.parseColor(str.substring(str.indexOf(",Taint=")+7, str.indexOf(",Alpha=")), new ColorUIResource(m_primaryColor)); setTextureCompositeAlpha (str.substring(str.indexOf(",Alpha=")+7, str.lastIndexOf("]"))); } diff --git a/looks/src/org/compiere/plaf/AdempiereComboBoxUI.java b/looks/src/org/compiere/plaf/CompiereComboBoxUI.java similarity index 92% rename from looks/src/org/compiere/plaf/AdempiereComboBoxUI.java rename to looks/src/org/compiere/plaf/CompiereComboBoxUI.java index d5f1b842e9..57e64879e1 100644 --- a/looks/src/org/compiere/plaf/AdempiereComboBoxUI.java +++ b/looks/src/org/compiere/plaf/CompiereComboBoxUI.java @@ -30,7 +30,7 @@ import javax.swing.plaf.metal.*; * @author Jorg Janke * @version $Id: AdempiereComboBoxUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereComboBoxUI extends MetalComboBoxUI +public class CompiereComboBoxUI extends MetalComboBoxUI { /** * Create UI @@ -39,7 +39,7 @@ public class AdempiereComboBoxUI extends MetalComboBoxUI */ public static ComponentUI createUI(JComponent c) { - return new AdempiereComboBoxUI(); + return new CompiereComboBoxUI(); } // CreateUI /*************************************************************************/ @@ -102,7 +102,7 @@ public class AdempiereComboBoxUI extends MetalComboBoxUI */ protected ComboPopup createPopup() { - AdempiereComboPopup newPopup = new AdempiereComboPopup( comboBox ); + CompiereComboPopup newPopup = new CompiereComboPopup( comboBox ); newPopup.getAccessibleContext().setAccessibleParent(comboBox); return newPopup; } // createPopup diff --git a/looks/src/org/compiere/plaf/AdempiereComboPopup.java b/looks/src/org/compiere/plaf/CompiereComboPopup.java similarity index 93% rename from looks/src/org/compiere/plaf/AdempiereComboPopup.java rename to looks/src/org/compiere/plaf/CompiereComboPopup.java index 637b4fd8ff..49621d0c3a 100644 --- a/looks/src/org/compiere/plaf/AdempiereComboPopup.java +++ b/looks/src/org/compiere/plaf/CompiereComboPopup.java @@ -26,13 +26,13 @@ import org.compiere.swing.*; * @author Jorg Janke * @version $Id: AdempiereComboPopup.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereComboPopup extends BasicComboPopup +public class CompiereComboPopup extends BasicComboPopup { /** * Constructor * @param combo */ - public AdempiereComboPopup(JComboBox combo) + public CompiereComboPopup(JComboBox combo) { super(combo); } // AdempiereComboPopup diff --git a/looks/src/org/compiere/plaf/AdempiereLabelUI.java b/looks/src/org/compiere/plaf/CompiereLabelUI.java similarity index 92% rename from looks/src/org/compiere/plaf/AdempiereLabelUI.java rename to looks/src/org/compiere/plaf/CompiereLabelUI.java index 3b7c3e7d60..cf844413aa 100644 --- a/looks/src/org/compiere/plaf/AdempiereLabelUI.java +++ b/looks/src/org/compiere/plaf/CompiereLabelUI.java @@ -30,17 +30,17 @@ import sun.swing.*; * @author Jorg Janke * @version $Id: AdempiereLabelUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereLabelUI extends MetalLabelUI +public class CompiereLabelUI extends MetalLabelUI { /** Singleton */ - protected static AdempiereLabelUI adempiereLabelUI = new AdempiereLabelUI(); + protected static CompiereLabelUI adempiereLabelUI = new CompiereLabelUI(); /** * Create UI * @param c component * @return singleton */ - public static AdempiereLabelUI createUI(JComponent c) + public static CompiereLabelUI createUI(JComponent c) { return adempiereLabelUI; } // createUI diff --git a/looks/src/org/compiere/plaf/CompiereLookAndFeel.java b/looks/src/org/compiere/plaf/CompiereLookAndFeel.java index 90e56d8206..c5ce52a437 100644 --- a/looks/src/org/compiere/plaf/CompiereLookAndFeel.java +++ b/looks/src/org/compiere/plaf/CompiereLookAndFeel.java @@ -22,7 +22,7 @@ import javax.swing.*; import javax.swing.plaf.metal.*; /** - * Adempiere Look & Feel. + * Compiere Look & Feel. * We wanted a nice UI not the battleship gray based stuff. * I guess a matter of taste. * @@ -49,12 +49,22 @@ public class CompiereLookAndFeel extends MetalLookAndFeel public static final String NAME = "Compiere"; /** The Theme */ - private static CompiereTheme s_adempiereTheme = new CompiereThemeBlueMetal(); - private static MetalTheme s_theme = s_adempiereTheme; + private static CompiereTheme s_compiereTheme = new CompiereThemeBlueMetal(); + private static MetalTheme s_theme = s_compiereTheme; /** Paint Round Corners */ protected static boolean ROUND = false; - + + /** Key of Client Property to paint in CompiereColor */ + public static final String BACKGROUND = "CompiereBackground"; + /** Key of Client Property for Rectangle Items - if exists, the standard background is used */ + public static final String BACKGROUND_FILL = "CompiereBackgroundFill"; + /** Key of Client Property for CPanel */ + public static final String TABLEVEL = "CompiereTabLevel"; + + /** Version tag */ + public static final String VERSION = "R1.4.0"; + /** * The Name * @return Name @@ -79,7 +89,7 @@ public class CompiereLookAndFeel extends MetalLookAndFeel */ public String getDescription() { - return "Adempiere Look & Feel - (c) 2001-2005 Jorg Janke"; + return "Compiere Look & Feel - (c) 2001-2005 Jorg Janke"; } // getDescription @@ -89,7 +99,6 @@ public class CompiereLookAndFeel extends MetalLookAndFeel */ public UIDefaults getDefaults() { - // System.out.println("AdempiereLookAndFeel.getDefaults"); // Theme already created/set MetalLookAndFeel.setCurrentTheme(s_theme); UIDefaults defaults = super.getDefaults(); // calls init..Defaults @@ -105,7 +114,6 @@ public class CompiereLookAndFeel extends MetalLookAndFeel */ protected void initClassDefaults(UIDefaults table) { - // System.out.println("AdempiereLookAndFeel.initClassDefaults"); super.initClassDefaults( table); // Overwrite putDefault (table, "PanelUI"); @@ -140,7 +148,7 @@ public class CompiereLookAndFeel extends MetalLookAndFeel { try { - String className = "org.compiere.plaf.Adempiere" + uiKey; + String className = "org.compiere.plaf.Compiere" + uiKey; table.put(uiKey, className); } catch (Exception ex) @@ -155,11 +163,7 @@ public class CompiereLookAndFeel extends MetalLookAndFeel */ protected void initSystemColorDefaults (UIDefaults table) { - // System.out.println("AdempiereLookAndFeel.initSystemColorDefaults"); super.initSystemColorDefaults( table); - - // we made the color a bit darker - // table.put("textHighlight", AdempiereUtils.getTranslucentColor(getTextHighlightColor(), 128)); } // initSystemColorDefaults /** @@ -168,7 +172,6 @@ public class CompiereLookAndFeel extends MetalLookAndFeel */ protected void initComponentDefaults (UIDefaults table) { - // System.out.println("AdempiereLookAndFeel.initComponentDefaults"); super.initComponentDefaults( table); // ComboBox defaults @@ -207,12 +210,12 @@ public class CompiereLookAndFeel extends MetalLookAndFeel } // getCurrentTheme /** - * Get Adempiere Theme + * Get Compiere Theme * @return Metal Theme */ - public static CompiereTheme getAdempiereTheme() + public static CompiereTheme getCompiereTheme() { - return s_adempiereTheme; + return s_compiereTheme; } // getCurrentTheme /** diff --git a/looks/src/org/compiere/plaf/AdempiereMenuBarUI.java b/looks/src/org/compiere/plaf/CompiereMenuBarUI.java similarity index 90% rename from looks/src/org/compiere/plaf/AdempiereMenuBarUI.java rename to looks/src/org/compiere/plaf/CompiereMenuBarUI.java index 1da07ed041..d3929a80c7 100644 --- a/looks/src/org/compiere/plaf/AdempiereMenuBarUI.java +++ b/looks/src/org/compiere/plaf/CompiereMenuBarUI.java @@ -28,7 +28,7 @@ import javax.swing.plaf.metal.*; * @author Jorg Janke * @version $Id: AdempiereMenuBarUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereMenuBarUI extends MetalMenuBarUI +public class CompiereMenuBarUI extends MetalMenuBarUI { /** * Create own instance @@ -37,7 +37,7 @@ public class AdempiereMenuBarUI extends MetalMenuBarUI */ public static ComponentUI createUI (JComponent x) { - return new AdempiereMenuBarUI(); + return new CompiereMenuBarUI(); } // createUI /** @@ -60,7 +60,7 @@ public class AdempiereMenuBarUI extends MetalMenuBarUI if (c.isOpaque()) { // Get AdempiereColor - AdempiereColor bg = AdempiereColor.getDefaultBackground(); + CompiereColor bg = CompiereColor.getDefaultBackground(); bg.paint (g, c); } else diff --git a/looks/src/org/compiere/plaf/AdempiereMenuItemUI.java b/looks/src/org/compiere/plaf/CompiereMenuItemUI.java similarity index 89% rename from looks/src/org/compiere/plaf/AdempiereMenuItemUI.java rename to looks/src/org/compiere/plaf/CompiereMenuItemUI.java index 57a7220e0c..5a665e8f82 100644 --- a/looks/src/org/compiere/plaf/AdempiereMenuItemUI.java +++ b/looks/src/org/compiere/plaf/CompiereMenuItemUI.java @@ -27,7 +27,7 @@ import javax.swing.plaf.basic.*; * @author Jorg Janke * @version $Id: AdempiereMenuItemUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereMenuItemUI extends BasicMenuItemUI +public class CompiereMenuItemUI extends BasicMenuItemUI { /** * Create own instance @@ -36,7 +36,7 @@ public class AdempiereMenuItemUI extends BasicMenuItemUI */ public static ComponentUI createUI(JComponent c) { - return new AdempiereMenuItemUI(); + return new CompiereMenuItemUI(); } // createUI /** @@ -58,7 +58,7 @@ public class AdempiereMenuItemUI extends BasicMenuItemUI { if (c.isOpaque()) { - AdempiereColor bg = AdempiereColor.getDefaultBackground(); + CompiereColor bg = CompiereColor.getDefaultBackground(); bg.paint (g, c); // // g.setColor(c.getBackground()); @@ -80,7 +80,7 @@ public class AdempiereMenuItemUI extends BasicMenuItemUI super.paintBackground (g, menuItem, bgColor); else { - AdempiereColor bg = AdempiereColor.getDefaultBackground(); + CompiereColor bg = CompiereColor.getDefaultBackground(); bg.paint (g, menuItem); } } // paintBackground diff --git a/looks/src/org/compiere/plaf/AdempiereMenuUI.java b/looks/src/org/compiere/plaf/CompiereMenuUI.java similarity index 93% rename from looks/src/org/compiere/plaf/AdempiereMenuUI.java rename to looks/src/org/compiere/plaf/CompiereMenuUI.java index cbf8fe6950..87b93545a1 100644 --- a/looks/src/org/compiere/plaf/AdempiereMenuUI.java +++ b/looks/src/org/compiere/plaf/CompiereMenuUI.java @@ -27,7 +27,7 @@ import javax.swing.plaf.basic.BasicMenuUI; * @author Jorg Janke * @version $Id: AdempiereMenuUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereMenuUI extends BasicMenuUI +public class CompiereMenuUI extends BasicMenuUI { /** * Create own instance @@ -36,7 +36,7 @@ public class AdempiereMenuUI extends BasicMenuUI */ public static ComponentUI createUI(JComponent x) { - return new AdempiereMenuUI(); + return new CompiereMenuUI(); } // createUI /** diff --git a/looks/src/org/compiere/plaf/AdempierePanelUI.java b/looks/src/org/compiere/plaf/CompierePanelUI.java similarity index 75% rename from looks/src/org/compiere/plaf/AdempierePanelUI.java rename to looks/src/org/compiere/plaf/CompierePanelUI.java index 074088f981..60b537de41 100644 --- a/looks/src/org/compiere/plaf/AdempierePanelUI.java +++ b/looks/src/org/compiere/plaf/CompierePanelUI.java @@ -21,6 +21,8 @@ import javax.swing.*; import javax.swing.plaf.*; import javax.swing.plaf.basic.*; +import org.adempiere.plaf.AdempierePLAF; + /** * Panel UI. * The default properties can be set via @@ -37,7 +39,7 @@ import javax.swing.plaf.basic.*; * @author Jorg Janke * @version $Id: AdempierePanelUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempierePanelUI extends BasicPanelUI +public class CompierePanelUI extends BasicPanelUI { /** * Static Create UI @@ -51,7 +53,7 @@ public class AdempierePanelUI extends BasicPanelUI } // createUI /** UI */ - private static AdempierePanelUI s_panelUI = new AdempierePanelUI(); + private static CompierePanelUI s_panelUI = new CompierePanelUI(); /************************************************************************** @@ -104,10 +106,10 @@ public class AdempierePanelUI extends BasicPanelUI // System.out.print(" - Background: "); // Get AdempiereColor - AdempiereColor bg = null; + CompiereColor bg = null; try { - bg = (AdempiereColor)c.getClientProperty(AdempierePLAF.BACKGROUND); + bg = (CompiereColor)c.getClientProperty(CompiereLookAndFeel.BACKGROUND); } catch (Exception e) { @@ -130,48 +132,5 @@ public class AdempierePanelUI extends BasicPanelUI /*************************************************************************/ - /** Default Background */ - private static AdempiereColor s_default = new AdempiereColor(); - /** Set Background to default setting */ - private static boolean s_setDefault = false; - - - /** - * Set Default Background - * @param bg Background Color - */ - public static void setDefaultBackground (AdempiereColor bg) - { - if (bg == null) - return; - s_default.setColor(bg); - } // setBackground - - /** - * Get Default Background - * @return Background - */ - public static AdempiereColor getDefaultBackground() - { - return s_default; - } // getBackground - - /** - * Set Default Background - * @param setDefault if true, the background will be set to the default color - */ - public static void setSetDefault (boolean setDefault) - { - s_setDefault = setDefault; - } // setSetDefault - - /** - * Is the Default Background set by default - * @return true if default background is set - */ - public static boolean isSetDefault() - { - return s_setDefault; - } // isSetDefault } // AdempierePanel diff --git a/looks/src/org/compiere/plaf/AdempiereRadioButtonUI.java b/looks/src/org/compiere/plaf/CompiereRadioButtonUI.java similarity index 90% rename from looks/src/org/compiere/plaf/AdempiereRadioButtonUI.java rename to looks/src/org/compiere/plaf/CompiereRadioButtonUI.java index 38fdae696c..c9198dbbe4 100644 --- a/looks/src/org/compiere/plaf/AdempiereRadioButtonUI.java +++ b/looks/src/org/compiere/plaf/CompiereRadioButtonUI.java @@ -26,7 +26,7 @@ import javax.swing.plaf.metal.*; * @author Jorg Janke * @version $Id: AdempiereRadioButtonUI.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ */ -public class AdempiereRadioButtonUI extends MetalRadioButtonUI +public class CompiereRadioButtonUI extends MetalRadioButtonUI { /** * Create UI @@ -39,7 +39,7 @@ public class AdempiereRadioButtonUI extends MetalRadioButtonUI } // createUI /** UI */ - private static final AdempiereRadioButtonUI s_radioButtonUI = new AdempiereRadioButtonUI(); + private static final CompiereRadioButtonUI s_radioButtonUI = new CompiereRadioButtonUI(); /************************************************************************** diff --git a/looks/src/org/compiere/plaf/AdempiereRootPaneUI.java b/looks/src/org/compiere/plaf/CompiereRootPaneUI.java similarity index 94% rename from looks/src/org/compiere/plaf/AdempiereRootPaneUI.java rename to looks/src/org/compiere/plaf/CompiereRootPaneUI.java index bba7b073e6..0835a26cbe 100644 --- a/looks/src/org/compiere/plaf/AdempiereRootPaneUI.java +++ b/looks/src/org/compiere/plaf/CompiereRootPaneUI.java @@ -24,7 +24,7 @@ import javax.swing.plaf.metal.MetalRootPaneUI; * @author Jorg Janke * @version $Id: AdempiereRootPaneUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereRootPaneUI extends MetalRootPaneUI +public class CompiereRootPaneUI extends MetalRootPaneUI { /** * MetalTitlePane does the Layout & Painting of the Window including System MenuBar diff --git a/looks/src/org/compiere/plaf/AdempiereScrollPaneUI.java b/looks/src/org/compiere/plaf/CompiereScrollPaneUI.java similarity index 92% rename from looks/src/org/compiere/plaf/AdempiereScrollPaneUI.java rename to looks/src/org/compiere/plaf/CompiereScrollPaneUI.java index 6b5a619907..1e9ebc33b4 100644 --- a/looks/src/org/compiere/plaf/AdempiereScrollPaneUI.java +++ b/looks/src/org/compiere/plaf/CompiereScrollPaneUI.java @@ -26,7 +26,7 @@ import javax.swing.plaf.metal.*; * @author Jorg Janke * @version $Id: AdempiereScrollPaneUI.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ */ -public class AdempiereScrollPaneUI extends MetalScrollPaneUI +public class CompiereScrollPaneUI extends MetalScrollPaneUI { /** * Create UI (not shared) @@ -35,7 +35,7 @@ public class AdempiereScrollPaneUI extends MetalScrollPaneUI */ public static ComponentUI createUI(JComponent x) { - return new AdempiereScrollPaneUI(); + return new CompiereScrollPaneUI(); } // createUI /** diff --git a/looks/src/org/compiere/plaf/AdempiereSplitPaneDivider.java b/looks/src/org/compiere/plaf/CompiereSplitPaneDivider.java similarity index 92% rename from looks/src/org/compiere/plaf/AdempiereSplitPaneDivider.java rename to looks/src/org/compiere/plaf/CompiereSplitPaneDivider.java index 6ef6f38f96..f15cfd4e5e 100644 --- a/looks/src/org/compiere/plaf/AdempiereSplitPaneDivider.java +++ b/looks/src/org/compiere/plaf/CompiereSplitPaneDivider.java @@ -25,13 +25,13 @@ import javax.swing.plaf.basic.*; * @author Jorg Janke * @version $Id: AdempiereSplitPaneDivider.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -class AdempiereSplitPaneDivider extends BasicSplitPaneDivider +class CompiereSplitPaneDivider extends BasicSplitPaneDivider { /** * Constructor * @param ui */ - public AdempiereSplitPaneDivider (BasicSplitPaneUI ui) + public CompiereSplitPaneDivider (BasicSplitPaneUI ui) { super (ui); // BasicBorders$SplitPaneDividerBorder - ignored set after constructor diff --git a/looks/src/org/compiere/plaf/AdempiereSplitPaneUI.java b/looks/src/org/compiere/plaf/CompiereSplitPaneUI.java similarity index 91% rename from looks/src/org/compiere/plaf/AdempiereSplitPaneUI.java rename to looks/src/org/compiere/plaf/CompiereSplitPaneUI.java index db50024d39..0410672185 100644 --- a/looks/src/org/compiere/plaf/AdempiereSplitPaneUI.java +++ b/looks/src/org/compiere/plaf/CompiereSplitPaneUI.java @@ -27,7 +27,7 @@ import javax.swing.plaf.basic.*; * @author Jorg Janke * @version $Id: AdempiereSplitPaneUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereSplitPaneUI extends BasicSplitPaneUI +public class CompiereSplitPaneUI extends BasicSplitPaneUI { /** * Creates a new MetalSplitPaneUI instance @@ -36,7 +36,7 @@ public class AdempiereSplitPaneUI extends BasicSplitPaneUI */ public static ComponentUI createUI (JComponent x) { - return new AdempiereSplitPaneUI(); + return new CompiereSplitPaneUI(); } // createUI /** @@ -45,7 +45,7 @@ public class AdempiereSplitPaneUI extends BasicSplitPaneUI */ public BasicSplitPaneDivider createDefaultDivider() { - return new AdempiereSplitPaneDivider (this); + return new CompiereSplitPaneDivider (this); } /** diff --git a/looks/src/org/compiere/plaf/AdempiereTabbedPaneUI.java b/looks/src/org/compiere/plaf/CompiereTabbedPaneUI.java similarity index 93% rename from looks/src/org/compiere/plaf/AdempiereTabbedPaneUI.java rename to looks/src/org/compiere/plaf/CompiereTabbedPaneUI.java index de81523b13..40540e8470 100644 --- a/looks/src/org/compiere/plaf/AdempiereTabbedPaneUI.java +++ b/looks/src/org/compiere/plaf/CompiereTabbedPaneUI.java @@ -22,15 +22,17 @@ import javax.swing.plaf.*; import javax.swing.plaf.basic.*; import javax.swing.plaf.metal.*; +import org.adempiere.plaf.AdempierePLAF; + /** * Same implementation detail as in AdempierePanelUI. * Additional handling of dwawing tabs. - * @see AdempierePanelUI + * @see CompierePanelUI * * @author Jorg Janke * @version $Id: AdempiereTabbedPaneUI.java,v 1.3 2006/07/30 00:52:23 jjanke Exp $ */ -public class AdempiereTabbedPaneUI extends MetalTabbedPaneUI +public class CompiereTabbedPaneUI extends MetalTabbedPaneUI { /** * Static Create UI @@ -39,7 +41,7 @@ public class AdempiereTabbedPaneUI extends MetalTabbedPaneUI */ public static ComponentUI createUI(JComponent c) { - return new AdempiereTabbedPaneUI(); + return new CompiereTabbedPaneUI(); } // createUI /** @@ -82,7 +84,7 @@ public class AdempiereTabbedPaneUI extends MetalTabbedPaneUI // System.out.println("Tab: Bounds=" + c.getBounds() + " - " + c.getClass().getName()); if (c.isOpaque()) - AdempierePanelUI.updateIt (g, c); // tabAreaBackground + CompierePanelUI.updateIt (g, c); // tabAreaBackground paint (g, c); } // update @@ -172,13 +174,13 @@ public class AdempiereTabbedPaneUI extends MetalTabbedPaneUI Component comp = tabPane.getComponentAt(tabIndex); // System.out.println("Tab " + tabIndex + " Comp=" + comp.getName() + " " + comp.getClass().getName() + " x=" + x + ", y=" + y + ", w=" +w + ", h=" + h); g2D.setPaint(comp.getBackground()); - AdempiereColor bg = AdempiereColor.getDefaultBackground(); + CompiereColor bg = CompiereColor.getDefaultBackground(); if (comp instanceof JPanel) { JPanel jp = (JPanel)comp; try { - bg = (AdempiereColor)jp.getClientProperty(AdempierePLAF.BACKGROUND); + bg = (CompiereColor)jp.getClientProperty(CompiereLookAndFeel.BACKGROUND); } catch (Exception e) { @@ -188,7 +190,7 @@ public class AdempiereTabbedPaneUI extends MetalTabbedPaneUI if (bg == null) // No Background { - if (AdempiereUtils.isLeftToRight(tabPane)) + if (CompiereUtils.isLeftToRight(tabPane)) { switch (tabPlacement) { @@ -236,7 +238,7 @@ public class AdempiereTabbedPaneUI extends MetalTabbedPaneUI } else // we have a background { - if (AdempiereUtils.isLeftToRight(tabPane)) + if (CompiereUtils.isLeftToRight(tabPane)) { switch (tabPlacement) { @@ -298,8 +300,8 @@ public class AdempiereTabbedPaneUI extends MetalTabbedPaneUI new int[] {y, y, y+6, y+(h/2), y+(h/2) }, 5); // lighter GradientPaint paint = new GradientPaint ( - x, y, AdempiereUtils.COL_1TOP, - x, y+(h/2), AdempiereUtils.COL_1END); + x, y, CompiereUtils.COL_1TOP, + x, y+(h/2), CompiereUtils.COL_1END); g2D.setPaint(paint); g2D.fill(top); } @@ -314,8 +316,8 @@ public class AdempiereTabbedPaneUI extends MetalTabbedPaneUI new int[] {y+(h/2), y+(h/2), y+h, y+h, y+h-6 }, 5); // darker GradientPaint paint = new GradientPaint ( - x, y+(h/2), AdempiereUtils.COL_2TOP, - x, y+h, AdempiereUtils.COL_2END); + x, y+(h/2), CompiereUtils.COL_2TOP, + x, y+h, CompiereUtils.COL_2END); g2D.setPaint(paint); g2D.fill(end); } @@ -367,11 +369,11 @@ public class AdempiereTabbedPaneUI extends MetalTabbedPaneUI if (comp != null && comp instanceof JComponent) { JComponent jc = (JComponent)comp; - AdempiereColor bg = null; + CompiereColor bg = null; try { if (jc != null) - bg = (AdempiereColor)jc.getClientProperty(AdempierePLAF.BACKGROUND); + bg = (CompiereColor)jc.getClientProperty(CompiereLookAndFeel.BACKGROUND); } catch (Exception e) { @@ -379,8 +381,8 @@ public class AdempiereTabbedPaneUI extends MetalTabbedPaneUI } if (bg == null) { - bg = new AdempiereColor(jc.getBackground()); - jc.putClientProperty(AdempierePLAF.BACKGROUND, bg); + bg = new CompiereColor(jc.getBackground()); + jc.putClientProperty(CompiereLookAndFeel.BACKGROUND, bg); } bg.paintRect(g, jc, x,y, w,h); } @@ -444,7 +446,7 @@ public class AdempiereTabbedPaneUI extends MetalTabbedPaneUI protected void paintContentBorderBottomEdge (Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { - boolean leftToRight = AdempiereUtils.isLeftToRight(tabPane); + boolean leftToRight = CompiereUtils.isLeftToRight(tabPane); int bottom = y + h - 1; int right = x + w - 1; Rectangle selRect = selectedIndex < 0 ? null : getTabBounds(selectedIndex, calcRect); @@ -566,7 +568,7 @@ public class AdempiereTabbedPaneUI extends MetalTabbedPaneUI int currentRun = getRunForTab( tabPane.getTabCount(), tabIndex ); int lastIndex = lastTabInRun( tabPane.getTabCount(), currentRun ); int firstIndex = tabRuns[ currentRun ]; - boolean leftToRight = AdempiereUtils.isLeftToRight(tabPane); + boolean leftToRight = CompiereUtils.isLeftToRight(tabPane); int bottom = h - 1; int right = w - 1; @@ -1021,7 +1023,7 @@ public class AdempiereTabbedPaneUI extends MetalTabbedPaneUI JComponent jc = (JComponent)comp; try { - Integer ll = (Integer)jc.getClientProperty(AdempierePLAF.TABLEVEL); + Integer ll = (Integer)jc.getClientProperty(CompiereLookAndFeel.TABLEVEL); if (ll != null) level = ll.intValue(); } diff --git a/looks/src/org/compiere/plaf/AdempiereTableHeaderUI.java b/looks/src/org/compiere/plaf/CompiereTableHeaderUI.java similarity index 87% rename from looks/src/org/compiere/plaf/AdempiereTableHeaderUI.java rename to looks/src/org/compiere/plaf/CompiereTableHeaderUI.java index 8d4d61ab52..1c65d1785c 100644 --- a/looks/src/org/compiere/plaf/AdempiereTableHeaderUI.java +++ b/looks/src/org/compiere/plaf/CompiereTableHeaderUI.java @@ -30,7 +30,7 @@ import javax.swing.plaf.basic.BasicTableHeaderUI; * @author Jorg Janke * @version $Id: AdempiereTableHeaderUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereTableHeaderUI extends BasicTableHeaderUI +public class CompiereTableHeaderUI extends BasicTableHeaderUI { /** * Static Create UI @@ -39,7 +39,7 @@ public class AdempiereTableHeaderUI extends BasicTableHeaderUI */ public static ComponentUI createUI(JComponent c) { - return new AdempiereTableHeaderUI(); + return new CompiereTableHeaderUI(); } // createUI @@ -52,8 +52,8 @@ public class AdempiereTableHeaderUI extends BasicTableHeaderUI super.installUI(c); // TableHeader is in JViewpoiunt, which is Opaque // When UI created, TableHeader not added to viewpoint - c.setOpaque(true); - c.putClientProperty(AdempierePLAF.BACKGROUND_FILL, "Y"); + //c.setOpaque(true); + //c.putClientProperty(AdempierePLAF.BACKGROUND_FILL, "Y"); } // installUI @@ -76,7 +76,7 @@ public class AdempiereTableHeaderUI extends BasicTableHeaderUI { // AdempiereUtils.printParents (c); // Parent is JViewpoint if (c.isOpaque()) // flat - AdempiereUtils.fillRectange((Graphics2D)g, c, CompiereLookAndFeel.ROUND); + CompiereUtils.fillRectange((Graphics2D)g, c, CompiereLookAndFeel.ROUND); // paint (g, c); } // update @@ -89,7 +89,7 @@ public class AdempiereTableHeaderUI extends BasicTableHeaderUI public void paint(Graphics g, JComponent c) { super.paint( g, c); - AdempiereUtils.paint3Deffect((Graphics2D)g, c, CompiereLookAndFeel.ROUND, true); + CompiereUtils.paint3Deffect((Graphics2D)g, c, CompiereLookAndFeel.ROUND, true); } // paint } // AdempiereTableHeader diff --git a/looks/src/org/compiere/plaf/AdempiereTextAreaUI.java b/looks/src/org/compiere/plaf/CompiereTextAreaUI.java similarity index 93% rename from looks/src/org/compiere/plaf/AdempiereTextAreaUI.java rename to looks/src/org/compiere/plaf/CompiereTextAreaUI.java index e5aad468c0..25a3e3c26a 100644 --- a/looks/src/org/compiere/plaf/AdempiereTextAreaUI.java +++ b/looks/src/org/compiere/plaf/CompiereTextAreaUI.java @@ -26,7 +26,7 @@ import javax.swing.plaf.basic.*; import javax.swing.text.*; -public class AdempiereTextAreaUI extends BasicTextAreaUI +public class CompiereTextAreaUI extends BasicTextAreaUI { /** * Creates a UI for a JTextArea. @@ -37,14 +37,14 @@ public class AdempiereTextAreaUI extends BasicTextAreaUI */ public static ComponentUI createUI(JComponent ta) { - return new AdempiereTextAreaUI(ta); + return new CompiereTextAreaUI(ta); } /** * Constructor * @param ta text area */ - public AdempiereTextAreaUI (JComponent ta) + public CompiereTextAreaUI (JComponent ta) { if (ta instanceof JTextComponent) m_editor = (JTextComponent)ta; diff --git a/looks/src/org/compiere/plaf/CompiereTheme.java b/looks/src/org/compiere/plaf/CompiereTheme.java index 70c8d4c1c9..73eef28db1 100644 --- a/looks/src/org/compiere/plaf/CompiereTheme.java +++ b/looks/src/org/compiere/plaf/CompiereTheme.java @@ -18,13 +18,19 @@ package org.compiere.plaf; import java.awt.*; import java.util.logging.*; + +import javax.swing.UIDefaults; import javax.swing.plaf.*; import javax.swing.plaf.metal.*; + +import org.compiere.swing.ColorBlind; +import org.compiere.swing.ExtendedTheme; import org.compiere.util.*; + import sun.awt.*; /** - * Adempiere User definable Theme (if used in Metal L&F). + * Compiere User definable Theme (if used in Metal L&F). * In other Environments, it provides UI extensions (e.g. Error Color) * * @author Jorg Janke @@ -135,49 +141,6 @@ public class CompiereTheme extends MetalTheme public static final int FONT_SIZE = 12; - /** - * Set Theme to current Metal Theme and copy it - */ - public static void setTheme () - { - log.fine(""); - AppContext context = AppContext.getAppContext(); - MetalTheme copyFrom = (MetalTheme)context.get("currentMetalTheme"); - boolean flat = Ini.isPropertyBool(Ini.P_UI_FLAT); - setTheme (copyFrom, flat); - } // setTheme - - /** - * Set Theme to current Metal Theme and copy it - * @param copyFrom theme - * @param flat flat colors - */ - public static void setTheme (MetalTheme copyFrom, boolean flat) - { - if (copyFrom == null || copyFrom instanceof CompiereTheme) - return; - log.fine(copyFrom.getName() + " - Flat=" + flat); - // May not be correct, if Themes overwrites default methods - primary1 = copyFrom.getPrimaryControlDarkShadow(); - primary2 = copyFrom.getPrimaryControlShadow(); - primary3 = copyFrom.getPrimaryControl(); - secondary1 = copyFrom.getControlDarkShadow(); - secondary2 = copyFrom.getControlShadow(); - secondary3 = copyFrom.getControl(); - AdempierePanelUI.setDefaultBackground(new AdempiereColor(secondary3, flat)); - white = copyFrom.getPrimaryControlHighlight(); - black = copyFrom.getPrimaryControlInfo(); - // - controlFont = copyFrom.getControlTextFont(); - systemFont = copyFrom.getSystemTextFont(); - userFont = copyFrom.getUserTextFont(); - smallFont = copyFrom.getSubTextFont(); - menuFont = copyFrom.getMenuTextFont(); - windowFont = copyFrom.getWindowTitleFont(); - } // setTheme - - - /************************************************************************** * Get Primary 1 (blue in default Metal Theme) * @return color @@ -361,241 +324,22 @@ public class CompiereTheme extends MetalTheme } public FontUIResource getSubTextFont() {return _getSubTextFont();} - // Static property info - - private static final String P_Primary1 = "#ColorPrimary1"; - private static final String P_Primary2 = "#ColorPrimary2"; - private static final String P_Primary3 = "#ColorPrimary3"; - private static final String P_Secondary1 = "#ColorSecondary1"; - private static final String P_Secondary2 = "#ColorSecondary2"; - private static final String P_Secondary3 = "#ColorSecondary3"; - private static final String P_Black = "#ColorBlack"; - private static final String P_White = "#ColorWhite"; - private static final String P_Error = "#ColorError"; - private static final String P_Info = "#ColorInfo"; - private static final String P_Mandatory = "#ColorMandatory"; - private static final String P_Inactive = "#ColorInactive"; - private static final String P_Txt_OK = "#ColorTextOK"; - private static final String P_Txt_Error = "#ColorTextError"; - // - private static final String P_Control = "#FontControl"; - private static final String P_System = "#FontSystem"; - private static final String P_User = "#FontUser"; - private static final String P_Small = "#FontSmall"; - private static final String P_Window = "#FontWindow"; - private static final String P_Menu = "#FontMenu"; - /** Background Color */ - protected static final String P_AdempiereColor = "#AdempiereColor"; - - /** - * Save information in Properties - */ - public static void save () - { - log.config(AdempiereColor.getDefaultBackground().toString()); - // - Ini.setProperty(P_Primary1, getColorAsString(primary1)); - Ini.setProperty(P_Primary2, getColorAsString(primary2)); - Ini.setProperty(P_Primary3, getColorAsString(primary3)); - Ini.setProperty(P_Secondary1, getColorAsString(secondary1)); - Ini.setProperty(P_Secondary2, getColorAsString(secondary2)); - Ini.setProperty(P_Secondary3, getColorAsString(secondary3)); - Ini.setProperty(P_Error, getColorAsString(error)); - Ini.setProperty(P_Info, getColorAsString(info)); - Ini.setProperty(P_Mandatory, getColorAsString(mandatory)); - Ini.setProperty(P_Inactive, getColorAsString(inactive)); - Ini.setProperty(P_White, getColorAsString(white)); - Ini.setProperty(P_Black, getColorAsString(black)); - Ini.setProperty(P_Txt_OK, getColorAsString(txt_ok)); - Ini.setProperty(P_Txt_Error, getColorAsString(txt_error)); - // - Ini.setProperty(P_Control, ((Font)controlFont).toString()); - Ini.setProperty(P_System, ((Font)systemFont).toString()); - Ini.setProperty(P_User, ((Font)userFont).toString()); - Ini.setProperty(P_Small, ((Font)smallFont).toString()); - Ini.setProperty(P_Window, ((Font)windowFont).toString()); - Ini.setProperty(P_Menu, ((Font)menuFont).toString()); - // - AdempiereColor cc = AdempiereColor.getDefaultBackground(); - Ini.setProperty(P_AdempiereColor, cc.toString()); - } // save - - - /** - * Parses Color into String representation. - * Required as SystemColors and Alpha Colors have different formats - * @param c Color - * @return [r=102,g=102,b=153,a=255] - * @see #parseColor - */ - public static String getColorAsString (Color c) - { - if (c == null) - c = SystemColor.control; - StringBuffer sb = new StringBuffer("[r=").append(c.getRed()) - .append(",g=").append(c.getGreen()) - .append(",b=").append(c.getBlue()) - .append(",a=").append(c.getAlpha()) - .append("]"); - // System.out.println(sb.toString()); - return sb.toString(); - } // getColorAsString - - /** - * Load Properties from Ini - */ - public static void load () - { - primary1 = parseColor (Ini.getProperty(P_Primary1), primary1); - primary2 = parseColor (Ini.getProperty(P_Primary2), primary2); - primary3 = parseColor (Ini.getProperty(P_Primary3), primary3); - secondary1 = parseColor (Ini.getProperty(P_Secondary1), secondary1); - secondary2 = parseColor (Ini.getProperty(P_Secondary2), secondary2); - secondary3 = parseColor (Ini.getProperty(P_Secondary3), secondary3); - error = parseColor(Ini.getProperty(P_Error), error); - info = parseColor(Ini.getProperty(P_Info), info); - mandatory = parseColor(Ini.getProperty(P_Mandatory), mandatory); - inactive = parseColor(Ini.getProperty(P_Inactive), inactive); - white = parseColor(Ini.getProperty(P_White), white); - black = parseColor(Ini.getProperty(P_Black), black); - txt_ok = parseColor(Ini.getProperty(P_Txt_OK), txt_ok); - txt_error = parseColor(Ini.getProperty(P_Txt_Error), txt_error); - // - controlFont = parseFont(Ini.getProperty(P_Control), controlFont); - systemFont = parseFont(Ini.getProperty(P_System), systemFont); - userFont = parseFont(Ini.getProperty(P_User), userFont); - smallFont = parseFont(Ini.getProperty(P_Small), smallFont); - windowFont = parseFont(Ini.getProperty(P_Window), windowFont); - menuFont = parseFont(Ini.getProperty(P_Menu), menuFont); - // - AdempiereColor cc = AdempiereColor.parse(Ini.getProperty(P_AdempiereColor)); - AdempiereColor.setDefaultBackground(cc); - } // load - - /** - * Reset Info in Properties - */ - public static void reset () - { -/** - Ini.remove (P_Primary1); - Ini.remove (P_Primary2); - Ini.remove (P_Primary3); - Ini.remove (P_Secondary1); - Ini.remove (P_Secondary2); - Ini.remove (P_Secondary3); - Ini.remove (P_Error); - Ini.remove (P_Info); - Ini.remove (P_Mandatory); - Ini.remove (P_Inactive); - Ini.remove (P_White); - Ini.remove (P_Black); - Ini.remove (P_Txt_OK); - Ini.remove (P_Txt_Error); - // - Ini.remove (P_Control); - Ini.remove (P_System); - Ini.remove (P_User); - Ini.remove (P_Small); - Ini.remove (P_Window); - Ini.remove (P_Menu); - // AdempiereColor - Ini.remove(P_AdempiereColor); -**/ - // Initialize - Ini.setProperty(Ini.P_UI_LOOK, CompiereLookAndFeel.NAME); - Ini.setProperty(Ini.P_UI_THEME, s_name); - // - if (s_theme != null) - s_theme.setDefault(); - - // Background - // AdempiereColor cc = new AdempiereColor(SystemColor.control); // flat Windows 212-208-200 - // AdempiereColor cc = new AdempiereColor(secondary3); // flat Metal 204-204-204 - AdempiereColor cc = new AdempiereColor(secondary3, false); - AdempiereColor.setDefaultBackground (cc); - // - save(); // save properties - } // reset - - /** - * Parse Color. - *

- * Color - [r=102,g=102,b=153,a=0] - * - * @param information string information to be parsed - * @param stdColor color used if info cannot parsed - * @return color - * @see #getColorAsString - */ - protected static ColorUIResource parseColor (String information, ColorUIResource stdColor) - { - if (information == null - || information.length() == 0 - || information.trim().length() == 0) - return stdColor; - // System.out.print("ParseColor=" + info); - try + @Override + public void addCustomEntriesToTable(UIDefaults table) { + super.addCustomEntriesToTable(table); + Object[] defaults = { - int r = Integer.parseInt(information.substring(information.indexOf("r=")+2, information.indexOf(",g="))); - int g = Integer.parseInt(information.substring(information.indexOf("g=")+2, information.indexOf(",b="))); - int b = 0; - int a = 255; - if (information.indexOf("a=") == -1) - b = Integer.parseInt(information.substring(information.indexOf("b=")+2, information.indexOf("]"))); - else - { - b = Integer.parseInt(information.substring(information.indexOf("b=")+2, information.indexOf(",a="))); - a = Integer.parseInt(information.substring(information.indexOf("a=")+2, information.indexOf("]"))); - } - ColorUIResource retValue = new ColorUIResource(new Color(r, g, b, a)); - // System.out.println(" - " + retValue.toString()); - return retValue; - } - catch (Exception e) - { - log.config(information + " - cannot parse: " + e.toString()); - } - return stdColor; - } // parseColor - - /** - * Parse Font - *

- * javax.swing.plaf.FontUIResource[family=dialog.bold,name=Dialog,style=bold,size=12] - * - * @param information string information to be parsed - * @param stdFont font used if info cannot be parsed - * @return font - */ - private static FontUIResource parseFont(String information, FontUIResource stdFont) - { - if (information == null - || information.length() == 0 - || information.trim().length() == 0) - return stdFont; - // System.out.print("ParseFont=" + info); - try - { - String name = information.substring(information.indexOf("name=")+5, information.indexOf(",style=")); - String s = information.substring(information.indexOf("style=")+6, information.indexOf(",size=")); - int style = Font.PLAIN; - if (s.equals("bold")) - style = Font.BOLD; - else if (s.equals("italic")) - style = Font.ITALIC; - else if (s.equals("bolditalic")) - style = Font.BOLD | Font.ITALIC; - int size = Integer.parseInt(information.substring(information.indexOf(",size=")+6, information.lastIndexOf("]"))); - FontUIResource retValue = new FontUIResource(name,style,size); - // System.out.println(" - " + retValue.toString()); - return retValue; - } - catch (Exception e) - { - log.config(information + " - cannot parse: " + e.toString()); - } - return stdFont; - } // parseFont - + ExtendedTheme.ERROR_BG_KEY, + error, + ExtendedTheme.ERROR_FG_KEY, + txt_error, + ExtendedTheme.INACTIVE_BG_KEY, + inactive, + ExtendedTheme.INFO_BG_KEY, + info, + ExtendedTheme.MANDATORY_BG_KEY, + mandatory + }; + table.putDefaults(defaults); + } } // AdempiereTheme diff --git a/looks/src/org/compiere/plaf/CompiereThemeBlueMetal.java b/looks/src/org/compiere/plaf/CompiereThemeBlueMetal.java index c1d3e8cb18..ec94d7704f 100644 --- a/looks/src/org/compiere/plaf/CompiereThemeBlueMetal.java +++ b/looks/src/org/compiere/plaf/CompiereThemeBlueMetal.java @@ -17,6 +17,8 @@ package org.compiere.plaf; import java.awt.*; + +import javax.swing.UIDefaults; import javax.swing.plaf.*; /** @@ -96,5 +98,5 @@ public class CompiereThemeBlueMetal extends CompiereTheme menuFont = null; _getMenuTextFont(); } // setDefault - + } // AdempiereThemeBlueMetal diff --git a/looks/src/org/compiere/plaf/AdempiereThemeEditor.java b/looks/src/org/compiere/plaf/CompiereThemeEditor.java similarity index 96% rename from looks/src/org/compiere/plaf/AdempiereThemeEditor.java rename to looks/src/org/compiere/plaf/CompiereThemeEditor.java index dbf6317f09..e7d9addc4e 100644 --- a/looks/src/org/compiere/plaf/AdempiereThemeEditor.java +++ b/looks/src/org/compiere/plaf/CompiereThemeEditor.java @@ -25,6 +25,7 @@ import javax.swing.border.*; import javax.swing.plaf.*; import javax.swing.plaf.metal.*; +import org.adempiere.plaf.AdempierePLAF; import org.compiere.swing.*; /** @@ -35,14 +36,14 @@ import org.compiere.swing.*; * @author Jorg Janke * @version $Id: AdempiereThemeEditor.java,v 1.3 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereThemeEditor extends CDialog +public class CompiereThemeEditor extends CDialog implements ActionListener { /** * Constructor * @param owner Frame owner */ - public AdempiereThemeEditor (JDialog owner) + public CompiereThemeEditor (JDialog owner) { super(owner, s_res.getString("AdempiereThemeEditor"), true); try @@ -291,7 +292,7 @@ public class AdempiereThemeEditor extends CDialog // Confirm if (e.getSource() == bOK) { - CompiereTheme.save(); + //CompiereTheme.save(); dispose(); return; } diff --git a/looks/src/org/compiere/plaf/AdempiereToggleButtonUI.java b/looks/src/org/compiere/plaf/CompiereToggleButtonUI.java similarity index 89% rename from looks/src/org/compiere/plaf/AdempiereToggleButtonUI.java rename to looks/src/org/compiere/plaf/CompiereToggleButtonUI.java index e846d8685e..1f24e4c3cc 100644 --- a/looks/src/org/compiere/plaf/AdempiereToggleButtonUI.java +++ b/looks/src/org/compiere/plaf/CompiereToggleButtonUI.java @@ -27,7 +27,7 @@ import javax.swing.plaf.metal.*; * @author Jorg Janke * @version $Id: AdempiereToggleButtonUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereToggleButtonUI extends MetalToggleButtonUI +public class CompiereToggleButtonUI extends MetalToggleButtonUI { /** * Static Create UI @@ -40,7 +40,7 @@ public class AdempiereToggleButtonUI extends MetalToggleButtonUI } // createUI /** UI shared */ - private static AdempiereToggleButtonUI s_toggleButtonUI = new AdempiereToggleButtonUI(); + private static CompiereToggleButtonUI s_toggleButtonUI = new CompiereToggleButtonUI(); /************************************************************************** @@ -72,7 +72,7 @@ public class AdempiereToggleButtonUI extends MetalToggleButtonUI { if (c.isOpaque()) // flat background // AdempiereColor.getDefaultBackground().paint(g, c); - AdempiereUtils.fillRectange((Graphics2D)g, c, CompiereLookAndFeel.ROUND); + CompiereUtils.fillRectange((Graphics2D)g, c, CompiereLookAndFeel.ROUND); paint (g, c); } // update @@ -88,7 +88,7 @@ public class AdempiereToggleButtonUI extends MetalToggleButtonUI ButtonModel model = b.getModel(); boolean in = model.isPressed() || model.isSelected(); // - AdempiereUtils.paint3Deffect((Graphics2D)g, c, CompiereLookAndFeel.ROUND, !in); + CompiereUtils.paint3Deffect((Graphics2D)g, c, CompiereLookAndFeel.ROUND, !in); } // paint /** diff --git a/looks/src/org/compiere/plaf/AdempiereToolBarUI.java b/looks/src/org/compiere/plaf/CompiereToolBarUI.java similarity index 93% rename from looks/src/org/compiere/plaf/AdempiereToolBarUI.java rename to looks/src/org/compiere/plaf/CompiereToolBarUI.java index 50f47ff30e..74a713469a 100644 --- a/looks/src/org/compiere/plaf/AdempiereToolBarUI.java +++ b/looks/src/org/compiere/plaf/CompiereToolBarUI.java @@ -26,7 +26,7 @@ import javax.swing.plaf.metal.*; * @author Jorg Janke * @version $Id: AdempiereToolBarUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereToolBarUI extends MetalToolBarUI +public class CompiereToolBarUI extends MetalToolBarUI { /** * Create UI (own instance) @@ -35,7 +35,7 @@ public class AdempiereToolBarUI extends MetalToolBarUI */ public static ComponentUI createUI (JComponent c) { - return new AdempiereToolBarUI(); + return new CompiereToolBarUI(); } // createUI diff --git a/looks/src/org/compiere/plaf/AdempiereToolTipUI.java b/looks/src/org/compiere/plaf/CompiereToolTipUI.java similarity index 93% rename from looks/src/org/compiere/plaf/AdempiereToolTipUI.java rename to looks/src/org/compiere/plaf/CompiereToolTipUI.java index 83722b5c44..0488ca4825 100644 --- a/looks/src/org/compiere/plaf/AdempiereToolTipUI.java +++ b/looks/src/org/compiere/plaf/CompiereToolTipUI.java @@ -29,7 +29,7 @@ import javax.swing.plaf.metal.*; * @author Jorg Janke * @version $Id: AdempiereToolTipUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereToolTipUI extends MetalToolTipUI +public class CompiereToolTipUI extends MetalToolTipUI { public static ComponentUI createUI(JComponent c) @@ -37,7 +37,7 @@ public class AdempiereToolTipUI extends MetalToolTipUI return sharedInstance; } - static AdempiereToolTipUI sharedInstance = new AdempiereToolTipUI(); + static CompiereToolTipUI sharedInstance = new CompiereToolTipUI(); private JToolTip tip; diff --git a/looks/src/org/compiere/plaf/AdempiereUtils.java b/looks/src/org/compiere/plaf/CompiereUtils.java similarity index 93% rename from looks/src/org/compiere/plaf/AdempiereUtils.java rename to looks/src/org/compiere/plaf/CompiereUtils.java index fd30b68dc6..2f1423893e 100644 --- a/looks/src/org/compiere/plaf/AdempiereUtils.java +++ b/looks/src/org/compiere/plaf/CompiereUtils.java @@ -23,6 +23,9 @@ import java.io.*; import java.net.*; import java.util.logging.*; import javax.swing.*; + +import org.adempiere.plaf.AdempierePLAF; + import com.sun.image.codec.jpeg.*; /** @@ -31,11 +34,11 @@ import com.sun.image.codec.jpeg.*; * @author Jorg Janke * @version $Id: AdempiereUtils.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ */ -public class AdempiereUtils +public class CompiereUtils { /** Logger */ - private static Logger log = Logger.getLogger(AdempiereUtils.class.getName()); + private static Logger log = Logger.getLogger(CompiereUtils.class.getName()); /** * Fill Background with Color. @@ -48,18 +51,18 @@ public class AdempiereUtils public static void fillRectange(Graphics2D g2D, JComponent c, boolean round) { // Paint in AdempiereColor? - AdempiereColor cc = null; - boolean stdCC = c.getClientProperty(AdempierePLAF.BACKGROUND_FILL) != null; + CompiereColor cc = null; + boolean stdCC = c.getClientProperty(CompiereLookAndFeel.BACKGROUND_FILL) != null; try { - cc = (AdempiereColor)c.getClientProperty(AdempierePLAF.BACKGROUND); + cc = (CompiereColor)c.getClientProperty(CompiereLookAndFeel.BACKGROUND); } catch (Exception e) { stdCC = true; } if (stdCC) - cc = AdempiereColor.getDefaultBackground(); + cc = CompiereColor.getDefaultBackground(); // Paint AdempiereColor if (cc != null) @@ -455,7 +458,7 @@ public class AdempiereUtils c.setName("C" + String.valueOf(s_no++)); System.out.print(c.getName()); System.out.print(" - " + c.getClass().getName()); - System.out.println (" ** " + c.isOpaque() + " bg=" + (c.getClientProperty(AdempierePLAF.BACKGROUND) != null)); + System.out.println (" ** " + c.isOpaque() + " bg=" + (c.getClientProperty(CompiereLookAndFeel.BACKGROUND) != null)); // Container container = c.getParent(); while (container != null) @@ -463,7 +466,7 @@ public class AdempiereUtils System.out.print (" - " + container.getName() + " " + container.getClass().getName() + " ** " + container.isOpaque()); if (container instanceof JComponent) - System.out.print (" bg=" + (((JComponent)container).getClientProperty(AdempierePLAF.BACKGROUND) != null)); + System.out.print (" bg=" + (((JComponent)container).getClientProperty(CompiereLookAndFeel.BACKGROUND) != null)); System.out.println (); container = container.getParent(); } diff --git a/looks/src/org/compiere/plaf/AdempiereViewportUI.java b/looks/src/org/compiere/plaf/CompiereViewportUI.java similarity index 93% rename from looks/src/org/compiere/plaf/AdempiereViewportUI.java rename to looks/src/org/compiere/plaf/CompiereViewportUI.java index 2a8dbed456..db23dffa16 100644 --- a/looks/src/org/compiere/plaf/AdempiereViewportUI.java +++ b/looks/src/org/compiere/plaf/CompiereViewportUI.java @@ -27,7 +27,7 @@ import javax.swing.plaf.basic.BasicViewportUI; * @author Jorg Janke * @version $Id: AdempiereViewportUI.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ */ -public class AdempiereViewportUI extends BasicViewportUI +public class CompiereViewportUI extends BasicViewportUI { /** Shared UI object */ private static ViewportUI viewportUI; @@ -40,7 +40,7 @@ public class AdempiereViewportUI extends BasicViewportUI public static ComponentUI createUI (JComponent c) { if (viewportUI == null) - viewportUI = new AdempiereViewportUI(); + viewportUI = new CompiereViewportUI(); return viewportUI; } // createUI diff --git a/looks/src/org/compiere/plaf/PlafRes.java b/looks/src/org/compiere/plaf/PlafRes.java index 7f4617afd5..4cb571f5f2 100644 --- a/looks/src/org/compiere/plaf/PlafRes.java +++ b/looks/src/org/compiere/plaf/PlafRes.java @@ -117,7 +117,9 @@ public class PlafRes extends ListResourceBundle { "LineBackColor", "Background Color" }, { "LineWidth", "Line Width" }, { "LineDistance", "Line Distance" }, - { "FlatColor", "Flat Color" } + { "FlatColor", "Flat Color" }, + { "UITheme", "User Interface Theme" }, + { "Preview", "Preview" } }; /** diff --git a/looks/src/org/compiere/swing/CButton.java b/looks/src/org/compiere/swing/CButton.java index 739a00e221..0145a2cc78 100644 --- a/looks/src/org/compiere/swing/CButton.java +++ b/looks/src/org/compiere/swing/CButton.java @@ -18,6 +18,8 @@ package org.compiere.swing; import java.awt.*; import javax.swing.*; + +import org.adempiere.plaf.AdempierePLAF; import org.compiere.plaf.*; import org.compiere.util.*; @@ -68,8 +70,6 @@ public class CButton extends JButton implements CEditor public CButton (Action a) { super (a); - setContentAreaFilled(false); - setOpaque(false); } // CButton /** @@ -81,11 +81,6 @@ public class CButton extends JButton implements CEditor public CButton(String text, Icon icon) { super (text, icon); - setContentAreaFilled(false); - setOpaque(false); - // - setFont(AdempierePLAF.getFont_Label()); - setForeground(AdempierePLAF.getTextColor_Label()); } // CButton @@ -99,12 +94,7 @@ public class CButton extends JButton implements CEditor if (bg.equals(getBackground())) return; super.setBackground (bg); - // ignore calls from javax.swing.LookAndFeel.installColors(LookAndFeel.java:61) - if (!Trace.getCallerClass(1).startsWith("javax")) - { - setOpaque(true); - setContentAreaFilled(true); - } + setBackgroundColor(new CompiereColor(bg)); this.repaint(); } // setBackground @@ -128,12 +118,11 @@ public class CButton extends JButton implements CEditor * Set Background * @param bg AdempiereColor for Background, if null set standard background */ - public void setBackgroundColor (AdempiereColor bg) + public void setBackgroundColor (CompiereColor bg) { if (bg == null) - bg = AdempiereColor.getDefaultBackground(); - setOpaque(true); - putClientProperty(AdempierePLAF.BACKGROUND, bg); + bg = new CompiereColor(AdempierePLAF.getFormBackground()); + putClientProperty(CompiereLookAndFeel.BACKGROUND, bg); super.setBackground (bg.getFlatColor()); this.repaint(); } // setBackground @@ -142,11 +131,11 @@ public class CButton extends JButton implements CEditor * Get Background * @return Color for Background */ - public AdempiereColor getBackgroundColor () + public CompiereColor getBackgroundColor () { try { - return (AdempiereColor)getClientProperty(AdempierePLAF.BACKGROUND); + return (CompiereColor)getClientProperty(CompiereLookAndFeel.BACKGROUND); } catch (Exception e) { diff --git a/looks/src/org/compiere/swing/CCheckBox.java b/looks/src/org/compiere/swing/CCheckBox.java index 0f2ad113ce..24646bac32 100644 --- a/looks/src/org/compiere/swing/CCheckBox.java +++ b/looks/src/org/compiere/swing/CCheckBox.java @@ -22,7 +22,7 @@ import javax.swing.Action; import javax.swing.Icon; import javax.swing.JCheckBox; -import org.compiere.plaf.AdempierePLAF; +import org.adempiere.plaf.AdempierePLAF; /** * Adempiere CheckBox @@ -135,8 +135,8 @@ public class CCheckBox extends JCheckBox implements CEditor */ private void init() { - setFont(AdempierePLAF.getFont_Label()); - setForeground(AdempierePLAF.getTextColor_Label()); + //Default to transparent, works better under windows look and feel + setOpaque(false); } // init /*************************************************************************/ diff --git a/looks/src/org/compiere/swing/CComboBox.java b/looks/src/org/compiere/swing/CComboBox.java index 91a3d89af2..4e5bb5cee1 100644 --- a/looks/src/org/compiere/swing/CComboBox.java +++ b/looks/src/org/compiere/swing/CComboBox.java @@ -21,6 +21,8 @@ import java.awt.event.*; import java.util.*; import javax.swing.*; import javax.swing.plaf.*; + +import org.adempiere.plaf.AdempierePLAF; import org.compiere.plaf.*; import org.compiere.util.*; @@ -132,10 +134,6 @@ public class CComboBox extends JComboBox */ private void init() { - // overwrite - otherwise Label Font - setFont(AdempierePLAF.getFont_Field()); - setForeground(AdempierePLAF.getTextColor_Normal()); - setBackground(false); FIELD_HIGHT = getPreferredSize().height; } // init @@ -151,8 +149,8 @@ public class CComboBox extends JComboBox */ public void setIcon (Icon defaultIcon) { - if (getUI() instanceof AdempiereComboBoxUI) - ((AdempiereComboBoxUI)getUI()).setIcon(defaultIcon); + if (getUI() instanceof CompiereComboBoxUI) + ((CompiereComboBoxUI)getUI()).setIcon(defaultIcon); m_icon = defaultIcon; } // setIcon @@ -163,8 +161,8 @@ public class CComboBox extends JComboBox public void setUI (ComboBoxUI ui) { super.setUI(ui); - if (m_icon != null && ui instanceof AdempiereComboBoxUI) - ((AdempiereComboBoxUI)getUI()).setIcon(m_icon); + if (m_icon != null && ui instanceof CompiereComboBoxUI) + ((CompiereComboBoxUI)getUI()).setIcon(m_icon); } // setUI /** @@ -283,16 +281,16 @@ public class CComboBox extends JComboBox * Add Mouse Listener - 1-4-0 Bug. * Bug in 1.4.0 Metal: arrowButton gets Mouse Events, so add the JComboBox * MouseListeners to the arrowButton - No context menu if right-click - * @see AdempiereComboBoxUI#installUI(JComponent) + * @see CompiereComboBoxUI#installUI(JComponent) * @param ml */ public void addMouseListener (MouseListener ml) { super.addMouseListener(ml); // ignore calls from javax.swing.plaf.basic.BasicComboBoxUI.installListeners(BasicComboBoxUI.java:271) - if (getUI() instanceof AdempiereComboBoxUI && !Trace.getCallerClass(1).startsWith("javax")) + if (getUI() instanceof CompiereComboBoxUI && !Trace.getCallerClass(1).startsWith("javax")) { - JButton b = ((AdempiereComboBoxUI)getUI()).getArrowButton(); + JButton b = ((CompiereComboBoxUI)getUI()).getArrowButton(); if (b != null) b.addMouseListener(ml); } @@ -313,9 +311,9 @@ public class CComboBox extends JComboBox public void removeMouseListener (MouseListener ml) { super.removeMouseListener(ml); - if (getUI() instanceof AdempiereComboBoxUI) + if (getUI() instanceof CompiereComboBoxUI) { - JButton b = ((AdempiereComboBoxUI)getUI()).getArrowButton(); + JButton b = ((CompiereComboBoxUI)getUI()).getArrowButton(); if (b != null) b.removeMouseListener(ml); } diff --git a/looks/src/org/compiere/swing/CDialog.java b/looks/src/org/compiere/swing/CDialog.java index 5804a35264..dd3a478f9e 100644 --- a/looks/src/org/compiere/swing/CDialog.java +++ b/looks/src/org/compiere/swing/CDialog.java @@ -152,7 +152,6 @@ public class CDialog extends JDialog protected void dialogInit() { super.dialogInit(); - AdempiereColor.setBackground(this); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setTitle(getTitle()); // remove Mn // diff --git a/looks/src/org/compiere/swing/CField.java b/looks/src/org/compiere/swing/CField.java index 0562712b3f..39d6a8ee70 100644 --- a/looks/src/org/compiere/swing/CField.java +++ b/looks/src/org/compiere/swing/CField.java @@ -35,7 +35,7 @@ import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.plaf.TextUI; -import org.compiere.plaf.AdempierePLAF; +import org.adempiere.plaf.AdempierePLAF; /** * Adempiere Colored Field with external popup editor. diff --git a/looks/src/org/compiere/swing/CFrame.java b/looks/src/org/compiere/swing/CFrame.java index b565a08293..1dff8a2c1a 100644 --- a/looks/src/org/compiere/swing/CFrame.java +++ b/looks/src/org/compiere/swing/CFrame.java @@ -76,7 +76,6 @@ public class CFrame extends JFrame protected void frameInit () { super.frameInit (); - AdempiereColor.setBackground(this); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // Container c = getContentPane(); diff --git a/looks/src/org/compiere/swing/CLabel.java b/looks/src/org/compiere/swing/CLabel.java index e917dbaa19..acaa279f30 100644 --- a/looks/src/org/compiere/swing/CLabel.java +++ b/looks/src/org/compiere/swing/CLabel.java @@ -174,9 +174,6 @@ public class CLabel extends JLabel setOpaque(false); if (getToolTipText() == null) // force Tool Tip setToolTipText(getText()); - // - setForeground(AdempierePLAF.getTextColor_Label()); - setFont(AdempierePLAF.getFont_Label()); } // init diff --git a/looks/src/org/compiere/swing/CPanel.java b/looks/src/org/compiere/swing/CPanel.java index d747b8fe88..cac704ee6d 100644 --- a/looks/src/org/compiere/swing/CPanel.java +++ b/looks/src/org/compiere/swing/CPanel.java @@ -18,6 +18,8 @@ package org.compiere.swing; import java.awt.*; import javax.swing.*; + +import org.adempiere.plaf.AdempierePLAF; import org.compiere.plaf.*; import org.compiere.util.*; @@ -79,7 +81,7 @@ public class CPanel extends JPanel * Creates a new CPanel with a double buffer and a flow layout. * @param bc Initial Background Color */ - public CPanel(AdempiereColor bc) + public CPanel(CompiereColor bc) { this (); init(); @@ -107,20 +109,20 @@ public class CPanel extends JPanel return; super.setBackground (bg); // ignore calls from javax.swing.LookAndFeel.installColors(LookAndFeel.java:61) - if (!Trace.getCallerClass(1).startsWith("javax")) - setBackgroundColor (new AdempiereColor(bg)); + //if (!Trace.getCallerClass(1).startsWith("javax")) + setBackgroundColor (new CompiereColor(bg)); } // setBackground /** * Set Background * @param bg AdempiereColor for Background, if null set standard background */ - public void setBackgroundColor (AdempiereColor bg) + public void setBackgroundColor (CompiereColor bg) { if (bg == null) - bg = AdempierePanelUI.getDefaultBackground(); + bg = new CompiereColor(AdempierePLAF.getFormBackground()); setOpaque(true); // not transparent - putClientProperty(AdempierePLAF.BACKGROUND, bg); + putClientProperty(CompiereLookAndFeel.BACKGROUND, bg); super.setBackground (bg.getFlatColor()); } // setBackground @@ -128,11 +130,11 @@ public class CPanel extends JPanel * Get Background * @return Color for Background */ - public AdempiereColor getBackgroundColor () + public CompiereColor getBackgroundColor () { try { - return (AdempiereColor)getClientProperty(AdempierePLAF.BACKGROUND); + return (CompiereColor)getClientProperty(CompiereLookAndFeel.BACKGROUND); } catch (Exception e) { @@ -152,9 +154,9 @@ public class CPanel extends JPanel public void setTabLevel (int level) { if (level == 0) - putClientProperty(AdempierePLAF.TABLEVEL, null); + putClientProperty(CompiereLookAndFeel.TABLEVEL, null); else - putClientProperty(AdempierePLAF.TABLEVEL, new Integer(level)); + putClientProperty(CompiereLookAndFeel.TABLEVEL, new Integer(level)); } // setTabLevel /** @@ -165,7 +167,7 @@ public class CPanel extends JPanel { try { - Integer ll = (Integer)getClientProperty(AdempierePLAF.TABLEVEL); + Integer ll = (Integer)getClientProperty(CompiereLookAndFeel.TABLEVEL); if (ll != null) return ll.intValue(); } @@ -185,7 +187,7 @@ public class CPanel extends JPanel { StringBuffer sb = new StringBuffer ("CPanel ["); sb.append(super.toString()); - AdempiereColor bg = getBackgroundColor(); + CompiereColor bg = getBackgroundColor(); if (bg != null) sb.append(bg.toString()); sb.append("]"); diff --git a/looks/src/org/compiere/swing/CPassword.java b/looks/src/org/compiere/swing/CPassword.java index 5e4b9257a8..9ba5a487c1 100644 --- a/looks/src/org/compiere/swing/CPassword.java +++ b/looks/src/org/compiere/swing/CPassword.java @@ -21,7 +21,7 @@ import java.awt.Color; import javax.swing.JPasswordField; import javax.swing.text.Document; -import org.compiere.plaf.AdempierePLAF; +import org.adempiere.plaf.AdempierePLAF; /** * Password Field @@ -107,8 +107,6 @@ public class CPassword extends JPasswordField implements CEditor */ private void init() { - setFont(AdempierePLAF.getFont_Field()); - setForeground(AdempierePLAF.getTextColor_Normal()); } // init /*************************************************************************/ diff --git a/looks/src/org/compiere/swing/CScrollPane.java b/looks/src/org/compiere/swing/CScrollPane.java index 96ca3ac25b..0f1f6df1c4 100644 --- a/looks/src/org/compiere/swing/CScrollPane.java +++ b/looks/src/org/compiere/swing/CScrollPane.java @@ -20,6 +20,7 @@ import java.awt.*; import javax.swing.*; +import org.adempiere.plaf.AdempierePLAF; import org.compiere.plaf.*; /** @@ -67,7 +68,6 @@ public class CScrollPane extends JScrollPane public CScrollPane (Component view, int vsbPolicy, int hsbPolicy) { super (view, vsbPolicy, hsbPolicy); - setBackgroundColor(null); setOpaque(false); getViewport().setOpaque(false); } // CScollPane @@ -77,15 +77,11 @@ public class CScrollPane extends JScrollPane * Set Background * @param bg AdempiereColor for Background, if null set standard background */ - public void setBackgroundColor (AdempiereColor bg) + public void setBackgroundColor (CompiereColor bg) { if (bg == null) - bg = AdempierePanelUI.getDefaultBackground(); - putClientProperty(AdempierePLAF.BACKGROUND, bg); - // super.setBackground(bg.getFlatColor()); - // getViewport().putClientProperty(AdempierePLAF.BACKGROUND, bg); - // getViewport().setBackground(bg.getFlatColor()); - // getViewport().setOpaque(true); + bg = new CompiereColor(AdempierePLAF.getFormBackground()); + putClientProperty(CompiereLookAndFeel.BACKGROUND, bg); } // setBackground } // CScollPane diff --git a/looks/src/org/compiere/swing/CTabbedPane.java b/looks/src/org/compiere/swing/CTabbedPane.java index 5a06572dd4..8695404ac4 100644 --- a/looks/src/org/compiere/swing/CTabbedPane.java +++ b/looks/src/org/compiere/swing/CTabbedPane.java @@ -22,9 +22,10 @@ import java.util.*; import javax.swing.*; -import org.compiere.plaf.AdempiereColor; -import org.compiere.plaf.AdempierePLAF; -import org.compiere.plaf.AdempierePanelUI; +import org.adempiere.plaf.AdempierePLAF; +import org.compiere.plaf.CompiereColor; +import org.compiere.plaf.CompiereLookAndFeel; +import org.compiere.plaf.CompierePanelUI; import org.compiere.util.Trace; import sun.swing.*; @@ -84,7 +85,7 @@ public class CTabbedPane extends JTabbedPane * Creates an empty TabbedPane with a defaults and Color * @param bg Color */ - public CTabbedPane (AdempiereColor bg) + public CTabbedPane (CompiereColor bg) { super(); init(); @@ -96,9 +97,6 @@ public class CTabbedPane extends JTabbedPane */ private void init() { - setOpaque(false); - setFont(AdempierePLAF.getFont_Label()); - setForeground(AdempierePLAF.getTextColor_Label()); } // init @@ -111,9 +109,7 @@ public class CTabbedPane extends JTabbedPane if (bg.equals(getBackground())) return; super.setBackground (bg); - // ignore calls from javax.swing.LookAndFeel.installColors(LookAndFeel.java:61) - if (!Trace.getCallerClass(1).startsWith("javax")) - setBackgroundColor (new AdempiereColor(bg)); + setBackgroundColor (new CompiereColor(bg)); } // setBackground /** @@ -128,12 +124,11 @@ public class CTabbedPane extends JTabbedPane * Set Background * @param bg AdempiereColor for Background, if null set standard background */ - public void setBackgroundColor (AdempiereColor bg) + public void setBackgroundColor (CompiereColor bg) { if (bg == null) - bg = AdempierePanelUI.getDefaultBackground(); - setOpaque(true); - putClientProperty(AdempierePLAF.BACKGROUND, bg); + bg = new CompiereColor(AdempierePLAF.getFormBackground()); + putClientProperty(CompiereLookAndFeel.BACKGROUND, bg); super.setBackground (bg.getFlatColor()); // repaint(); @@ -143,11 +138,11 @@ public class CTabbedPane extends JTabbedPane * Get Background * @return Color for Background */ - public AdempiereColor getBackgroundColor () + public CompiereColor getBackgroundColor () { try { - return (AdempiereColor)getClientProperty(AdempierePLAF.BACKGROUND); + return (CompiereColor)getClientProperty(CompiereLookAndFeel.BACKGROUND); } catch (Exception e) { @@ -195,10 +190,10 @@ public class CTabbedPane extends JTabbedPane if (component instanceof JPanel) { JPanel p = (JPanel)component; - if (p.getClientProperty(AdempierePLAF.BACKGROUND) == null) + if (p.getClientProperty(CompiereLookAndFeel.BACKGROUND) == null) { - AdempiereColor.setBackground(p); - p.setOpaque(true); + //AdempiereColor.setBackground(p); + //p.setOpaque(true); } } // Set first @@ -328,7 +323,7 @@ public class CTabbedPane extends JTabbedPane { StringBuffer sb = new StringBuffer ("CTabbedPane ["); sb.append(super.toString()); - AdempiereColor bg = getBackgroundColor(); + CompiereColor bg = getBackgroundColor(); if (bg != null) sb.append(bg.toString()); sb.append("]"); diff --git a/looks/src/org/compiere/swing/CTable.java b/looks/src/org/compiere/swing/CTable.java index e9db376cdb..ed628d76e8 100644 --- a/looks/src/org/compiere/swing/CTable.java +++ b/looks/src/org/compiere/swing/CTable.java @@ -45,6 +45,8 @@ public class CTable extends JTable setAutoResizeMode(JTable.AUTO_RESIZE_OFF); getTableHeader().addMouseListener(new CTableMouseListener()); setSurrendersFocusOnKeystroke(true); + //Default row height too narrow + setRowHeight(getFont().getSize() + 8); } // CTable /** Last model index sorted */ @@ -301,4 +303,12 @@ public class CTable extends JTable } } // CTableMouseListener + + @Override + public void setFont(Font font) { + super.setFont(font); + //Update row height + setRowHeight(getFont().getSize() + 8); + } + } // CTable diff --git a/looks/src/org/compiere/swing/CTextArea.java b/looks/src/org/compiere/swing/CTextArea.java index 36836c2bd3..f7d5f9df53 100644 --- a/looks/src/org/compiere/swing/CTextArea.java +++ b/looks/src/org/compiere/swing/CTextArea.java @@ -23,6 +23,7 @@ import java.awt.im.*; import javax.swing.*; import javax.swing.text.*; +import org.adempiere.plaf.AdempierePLAF; import org.compiere.plaf.*; /** @@ -125,8 +126,6 @@ public class CTextArea extends JScrollPane m_textArea = textArea; super.setOpaque(false); super.getViewport().setOpaque(false); - m_textArea.setFont(AdempierePLAF.getFont_Field()); - m_textArea.setForeground(AdempierePLAF.getTextColor_Normal()); m_textArea.setLineWrap(true); m_textArea.setWrapStyleWord(true); // Overwrite default Tab diff --git a/looks/src/org/compiere/swing/CTextField.java b/looks/src/org/compiere/swing/CTextField.java index 9e18caee65..ddd0cb917b 100644 --- a/looks/src/org/compiere/swing/CTextField.java +++ b/looks/src/org/compiere/swing/CTextField.java @@ -22,6 +22,7 @@ import java.awt.event.*; import javax.swing.*; import javax.swing.text.*; +import org.adempiere.plaf.AdempierePLAF; import org.compiere.plaf.*; /** @@ -117,8 +118,6 @@ public class CTextField extends JTextField */ private void init() { - setFont(AdempierePLAF.getFont_Field()); - setForeground(AdempierePLAF.getTextColor_Normal()); setBackground (false); // Minimum Size Dimension size = getPreferredSize(); diff --git a/looks/src/org/compiere/swing/CTextPane.java b/looks/src/org/compiere/swing/CTextPane.java index d2fd84f9f6..99700a2893 100644 --- a/looks/src/org/compiere/swing/CTextPane.java +++ b/looks/src/org/compiere/swing/CTextPane.java @@ -23,6 +23,7 @@ import java.awt.im.*; import javax.swing.*; import javax.swing.text.*; +import org.adempiere.plaf.AdempierePLAF; import org.compiere.plaf.*; /** @@ -63,8 +64,6 @@ public class CTextPane extends JScrollPane super.setOpaque(false); super.getViewport().setOpaque(false); m_textPane.setContentType("text/html"); - m_textPane.setFont(AdempierePLAF.getFont_Field()); - m_textPane.setForeground(AdempierePLAF.getTextColor_Normal()); } // CTextPane private JTextPane m_textPane = null; diff --git a/looks/src/org/compiere/swing/CToggleButton.java b/looks/src/org/compiere/swing/CToggleButton.java index 1097e1803d..2e596c1544 100644 --- a/looks/src/org/compiere/swing/CToggleButton.java +++ b/looks/src/org/compiere/swing/CToggleButton.java @@ -22,8 +22,9 @@ import javax.swing.Action; import javax.swing.Icon; import javax.swing.JToggleButton; -import org.compiere.plaf.AdempiereColor; -import org.compiere.plaf.AdempierePLAF; +import org.adempiere.plaf.AdempierePLAF; +import org.compiere.plaf.CompiereColor; +import org.compiere.plaf.CompiereLookAndFeel; import org.compiere.util.Trace; /** @@ -125,11 +126,6 @@ public class CToggleButton extends JToggleButton implements CEditor public CToggleButton (String text, Icon icon, boolean selected) { super(text, icon, selected); - setContentAreaFilled(false); - setOpaque(false); - // - setFont(AdempierePLAF.getFont_Label()); - setForeground(AdempierePLAF.getTextColor_Label()); } /*************************************************************************/ @@ -144,12 +140,6 @@ public class CToggleButton extends JToggleButton implements CEditor if (bg.equals(getBackground())) return; super.setBackground( bg); - // ignore calls from javax.swing.LookAndFeel.installColors(LookAndFeel.java:61) - if (!Trace.getCallerClass(1).startsWith("javax")) - { - setOpaque(true); - setContentAreaFilled(true); - } } // setBackground /** @@ -172,12 +162,12 @@ public class CToggleButton extends JToggleButton implements CEditor * Set Background * @param bg AdempiereColor for Background, if null set standard background */ - public void setBackgroundColor (AdempiereColor bg) + public void setBackgroundColor (CompiereColor bg) { if (bg == null) - bg = AdempiereColor.getDefaultBackground(); + bg = new CompiereColor(AdempierePLAF.getFormBackground()); setOpaque(true); - putClientProperty(AdempierePLAF.BACKGROUND, bg); + putClientProperty(CompiereLookAndFeel.BACKGROUND, bg); super.setBackground (bg.getFlatColor()); } // setBackground @@ -185,11 +175,11 @@ public class CToggleButton extends JToggleButton implements CEditor * Get Background * @return Color for Background */ - public AdempiereColor getBackgroundColor () + public CompiereColor getBackgroundColor () { try { - return (AdempiereColor)getClientProperty(AdempierePLAF.BACKGROUND); + return (CompiereColor)getClientProperty(CompiereLookAndFeel.BACKGROUND); } catch (Exception e) { diff --git a/looks/src/org/compiere/plaf/ColorBlind.java b/looks/src/org/compiere/swing/ColorBlind.java similarity index 96% rename from looks/src/org/compiere/plaf/ColorBlind.java rename to looks/src/org/compiere/swing/ColorBlind.java index 3767aff90f..21dea3a5d6 100644 --- a/looks/src/org/compiere/plaf/ColorBlind.java +++ b/looks/src/org/compiere/swing/ColorBlind.java @@ -14,7 +14,7 @@ * 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.compiere.plaf; +package org.compiere.swing; import java.awt.Color; import java.util.logging.*; diff --git a/looks/src/org/compiere/plaf/AdempiereColorEditor.java b/looks/src/org/compiere/swing/ColorEditor.java similarity index 89% rename from looks/src/org/compiere/plaf/AdempiereColorEditor.java rename to looks/src/org/compiere/swing/ColorEditor.java index a825c757a6..38abeb0473 100644 --- a/looks/src/org/compiere/plaf/AdempiereColorEditor.java +++ b/looks/src/org/compiere/swing/ColorEditor.java @@ -14,13 +14,16 @@ * 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.compiere.plaf; +package org.compiere.swing; import java.awt.*; import java.awt.event.*; import java.beans.*; import java.util.*; import javax.swing.*; + +import org.adempiere.plaf.AdempierePLAF; +import org.compiere.plaf.CompiereColor; import org.compiere.swing.*; import org.compiere.util.*; @@ -30,7 +33,7 @@ import org.compiere.util.*; * @author Jorg Janke * @version $Id: AdempiereColorEditor.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ */ -public class AdempiereColorEditor extends CDialog +public class ColorEditor extends CDialog implements ActionListener, PropertyEditor { /** @@ -39,9 +42,9 @@ public class AdempiereColorEditor extends CDialog * @param color optional initial color * @return AdempiereColor */ - public static AdempiereColor showDialog (Frame owner, AdempiereColor color) + public static CompiereColor showDialog (Frame owner, CompiereColor color) { - AdempiereColorEditor cce = new AdempiereColorEditor (owner, color); + ColorEditor cce = new ColorEditor (owner, color); if (cce.isSaved()) return cce.getColor(); return color; @@ -53,9 +56,9 @@ public class AdempiereColorEditor extends CDialog * @param color optional initial color * @return AdempiereColor */ - public static AdempiereColor showDialog (Dialog owner, AdempiereColor color) + public static CompiereColor showDialog (Dialog owner, CompiereColor color) { - AdempiereColorEditor cce = new AdempiereColorEditor (owner, color); + ColorEditor cce = new ColorEditor (owner, color); if (cce.isSaved()) return cce.getColor(); return color; @@ -68,7 +71,7 @@ public class AdempiereColorEditor extends CDialog * @param owner owner * @param color Start Color */ - public AdempiereColorEditor (Frame owner, AdempiereColor color) + public ColorEditor (Frame owner, CompiereColor color) { super(owner, "", true); init (color); @@ -79,7 +82,7 @@ public class AdempiereColorEditor extends CDialog * @param owner owner * @param color Start Color */ - public AdempiereColorEditor (Dialog owner, AdempiereColor color) + public ColorEditor (Dialog owner, CompiereColor color) { super(owner, "", true); init (color); @@ -89,7 +92,7 @@ public class AdempiereColorEditor extends CDialog * Init Dialog * @param color Start Color */ - private void init (AdempiereColor color) + private void init (CompiereColor color) { try { @@ -119,13 +122,13 @@ public class AdempiereColorEditor extends CDialog if (color == null) setColor (m_cc); else - setColor (new AdempiereColor(color)); + setColor (new CompiereColor(color)); AdempierePLAF.showCenterScreen(this); } // init private static ResourceBundle res = ResourceBundle.getBundle("org.compiere.plaf.PlafRes"); - private AdempiereColor m_cc = null; + private CompiereColor m_cc = null; private boolean m_saved = false; private boolean m_setting = false; @@ -137,7 +140,7 @@ public class AdempiereColorEditor extends CDialog private FlowLayout southLayout = new FlowLayout(); private GridBagLayout northLayout = new GridBagLayout(); private CLabel typeLabel = new CLabel(); - private CComboBox typeField = new CComboBox(AdempiereColor.TYPES); + private CComboBox typeField = new CComboBox(CompiereColor.TYPES); private CButton gradientUpper = new CButton(); private CButton gradientLower = new CButton(); private CLabel urlLabel = new CLabel(); @@ -153,7 +156,7 @@ public class AdempiereColorEditor extends CDialog private CTextField distanceField = new CTextField(10); private CPanel centerPanel = new CPanel(); private CButton flatField = new CButton(); - private CComboBox gradientStartField = new CComboBox(AdempiereColor.GRADIENT_SP); + private CComboBox gradientStartField = new CComboBox(CompiereColor.GRADIENT_SP); private CTextField gradientDistanceField = new CTextField(10); private CLabel gradientStartLabel = new CLabel(); private CLabel gradientDistanceLabel = new CLabel(); @@ -312,14 +315,14 @@ public class AdempiereColorEditor extends CDialog private void cmd_type() { ValueNamePair vp = (ValueNamePair)typeField.getSelectedItem(); - if (vp.getValue().equals(AdempiereColor.TYPE_FLAT)) - m_cc = new AdempiereColor(AdempiereColor.TYPE_FLAT); - else if (vp.getValue().equals(AdempiereColor.TYPE_GRADIENT)) - m_cc = new AdempiereColor(AdempiereColor.TYPE_GRADIENT); - else if (vp.getValue().equals(AdempiereColor.TYPE_TEXTURE)) - m_cc = new AdempiereColor(AdempiereColor.TYPE_TEXTURE); - else if (vp.getValue().equals(AdempiereColor.TYPE_LINES)) - m_cc = new AdempiereColor(AdempiereColor.TYPE_LINES); + if (vp.getValue().equals(CompiereColor.TYPE_FLAT)) + m_cc = new CompiereColor(CompiereColor.TYPE_FLAT); + else if (vp.getValue().equals(CompiereColor.TYPE_GRADIENT)) + m_cc = new CompiereColor(CompiereColor.TYPE_GRADIENT); + else if (vp.getValue().equals(CompiereColor.TYPE_TEXTURE)) + m_cc = new CompiereColor(CompiereColor.TYPE_TEXTURE); + else if (vp.getValue().equals(CompiereColor.TYPE_LINES)) + m_cc = new CompiereColor(CompiereColor.TYPE_LINES); setColor (m_cc); } // cmd_type @@ -327,7 +330,7 @@ public class AdempiereColorEditor extends CDialog * Set Color and update UI * @param color color */ - public void setColor (AdempiereColor color) + public void setColor (CompiereColor color) { if (color == null && m_cc != null) return; @@ -335,7 +338,7 @@ public class AdempiereColorEditor extends CDialog // System.out.println("AdempiereColorEditor.setColor " + color); m_cc = color; if (m_cc == null) - m_cc = AdempierePanelUI.getDefaultBackground(); + m_cc = CompiereColor.getDefaultBackground(); // update display updateFields(); @@ -350,11 +353,11 @@ public class AdempiereColorEditor extends CDialog { m_setting = true; // Type - for (int i = 0; i < AdempiereColor.TYPES.length; i++) + for (int i = 0; i < CompiereColor.TYPES.length; i++) { - if (m_cc.getType().equals(AdempiereColor.TYPE_VALUES[i])) + if (m_cc.getType().equals(CompiereColor.TYPE_VALUES[i])) { - typeField.setSelectedItem(AdempiereColor.TYPES[i]); + typeField.setSelectedItem(CompiereColor.TYPES[i]); break; } } @@ -406,11 +409,11 @@ public class AdempiereColorEditor extends CDialog gradientUpper.setBackground(m_cc.getGradientUpperColor()); gradientLower.setBackground(m_cc.getGradientLowerColor()); gradientDistanceField.setText(String.valueOf(m_cc.getGradientRepeatDistance())); - for (int i = 0; i < AdempiereColor.GRADIENT_SP.length; i++) + for (int i = 0; i < CompiereColor.GRADIENT_SP.length; i++) { - if (m_cc.getGradientStartPoint() == AdempiereColor.GRADIENT_SP_VALUES[i]) + if (m_cc.getGradientStartPoint() == CompiereColor.GRADIENT_SP_VALUES[i]) { - gradientStartField.setSelectedItem(AdempiereColor.GRADIENT_SP[i]); + gradientStartField.setSelectedItem(CompiereColor.GRADIENT_SP[i]); break; } } @@ -473,7 +476,7 @@ public class AdempiereColorEditor extends CDialog * Get Color * @return Color, when saved - else null */ - public AdempiereColor getColor() + public CompiereColor getColor() { return m_cc; } // getColor @@ -501,8 +504,8 @@ public class AdempiereColorEditor extends CDialog */ public void setValue(Object value) { - if (value != null && value instanceof AdempiereColor) - setColor (new AdempiereColor((AdempiereColor)value)); + if (value != null && value instanceof CompiereColor) + setColor (new CompiereColor((CompiereColor)value)); else throw new IllegalArgumentException("AdempiereColorEditor.setValue requires AdempiereColor"); } // setValue diff --git a/looks/src/org/compiere/swing/ExtendedTheme.java b/looks/src/org/compiere/swing/ExtendedTheme.java new file mode 100644 index 0000000000..694e51a966 --- /dev/null +++ b/looks/src/org/compiere/swing/ExtendedTheme.java @@ -0,0 +1,30 @@ +package org.compiere.swing; + +import java.util.Map; + +import javax.swing.plaf.ColorUIResource; + +public interface ExtendedTheme { + + public ColorUIResource getWhite(); + public ColorUIResource getBlack(); + public ColorUIResource getErrorForeground(); + public ColorUIResource getErrorBackground(); + public ColorUIResource getInactiveBackground(); + public ColorUIResource getMandatoryBackground(); + public ColorUIResource getInfoBackground(); + + public final static ColorUIResource DEFAULT_MANDATORY_BG = new ColorUIResource(224, 224, 255); // blue-isch + public final static ColorUIResource DEFAULT_ERROR_BG = new ColorUIResource(255, 204, 204); // red-isch + public final static ColorUIResource DEFAULT_ERROR_FG = new ColorUIResource(204, 0, 0); // dark red + public final static ColorUIResource DEFAULT_INACTIVE_BG = new ColorUIResource(234, 234, 234); // light gray + public final static ColorUIResource DEFAULT_INFO_BG = new ColorUIResource(253, 237, 207); // light yellow + + public void setUIProperties(Map propertyMap); + + public final static String ERROR_BG_KEY = "TextField.errorBackground"; + public final static String ERROR_FG_KEY = "TextField.errorForeground"; + public final static String MANDATORY_BG_KEY = "TextField.mandatoryBackground"; + public final static String INACTIVE_BG_KEY = "TextField.inactiveBackground"; + public final static String INFO_BG_KEY = "Info.background"; +} diff --git a/looks/src/org/compiere/plaf/FontChooser.java b/looks/src/org/compiere/swing/FontChooser.java similarity index 96% rename from looks/src/org/compiere/plaf/FontChooser.java rename to looks/src/org/compiere/swing/FontChooser.java index 346b50614b..b6c4318463 100644 --- a/looks/src/org/compiere/plaf/FontChooser.java +++ b/looks/src/org/compiere/swing/FontChooser.java @@ -14,12 +14,14 @@ * 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.compiere.plaf; +package org.compiere.swing; import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; + +import org.adempiere.plaf.AdempierePLAF; import org.compiere.swing.*; /** diff --git a/looks/src/org/compiere/swing/ThemeUtils.java b/looks/src/org/compiere/swing/ThemeUtils.java new file mode 100644 index 0000000000..2612600bd3 --- /dev/null +++ b/looks/src/org/compiere/swing/ThemeUtils.java @@ -0,0 +1,220 @@ +package org.compiere.swing; + +import java.awt.Color; +import java.awt.Font; +import java.awt.SystemColor; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.logging.Logger; + +import javax.swing.plaf.ColorUIResource; +import javax.swing.plaf.FontUIResource; +import javax.swing.plaf.metal.MetalTheme; + +import org.compiere.plaf.CompiereColor; + +public final class ThemeUtils { + + /** Logger */ + private static Logger log = Logger.getLogger(ThemeUtils.class.getName()); + + /** + * Parses Color into String representation. + * Required as SystemColors and Alpha Colors have different formats + * @param c Color + * @return [r=102,g=102,b=153,a=255] + * @see #parseColor + */ + public static String getColorAsString (Color c) + { + if (c == null) + c = SystemColor.control; + StringBuffer sb = new StringBuffer("[r=").append(c.getRed()) + .append(",g=").append(c.getGreen()) + .append(",b=").append(c.getBlue()) + .append(",a=").append(c.getAlpha()) + .append("]"); + // System.out.println(sb.toString()); + return sb.toString(); + } // getColorAsString + + /** + * Parse Color. + *

+ * Color - [r=102,g=102,b=153,a=0] + * + * @param information string information to be parsed + * @param stdColor color used if info cannot parsed + * @return color + * @see #getColorAsString + */ + public static ColorUIResource parseColor (String information, ColorUIResource stdColor) + { + if (information == null + || information.length() == 0 + || information.trim().length() == 0) + return stdColor; + // System.out.print("ParseColor=" + info); + try + { + int r = Integer.parseInt(information.substring(information.indexOf("r=")+2, information.indexOf(",g="))); + int g = Integer.parseInt(information.substring(information.indexOf("g=")+2, information.indexOf(",b="))); + int b = 0; + int a = 255; + if (information.indexOf("a=") == -1) + b = Integer.parseInt(information.substring(information.indexOf("b=")+2, information.indexOf("]"))); + else + { + b = Integer.parseInt(information.substring(information.indexOf("b=")+2, information.indexOf(",a="))); + a = Integer.parseInt(information.substring(information.indexOf("a=")+2, information.indexOf("]"))); + } + ColorUIResource retValue = new ColorUIResource(new Color(r, g, b, a)); + // System.out.println(" - " + retValue.toString()); + return retValue; + } + catch (Exception e) + { + log.config(information + " - cannot parse: " + e.toString()); + } + return stdColor; + } // parseColor + + /** + * Parse Font + *

+ * javax.swing.plaf.FontUIResource[family=dialog.bold,name=Dialog,style=bold,size=12] + * + * @param information string information to be parsed + * @param stdFont font used if info cannot be parsed + * @return font + */ + public static FontUIResource parseFont(String information, FontUIResource stdFont) + { + if (information == null + || information.length() == 0 + || information.trim().length() == 0) + return stdFont; + // System.out.print("ParseFont=" + info); + try + { + String name = information.substring(information.indexOf("name=")+5, information.indexOf(",style=")); + String s = information.substring(information.indexOf("style=")+6, information.indexOf(",size=")); + int style = Font.PLAIN; + if (s.equals("bold")) + style = Font.BOLD; + else if (s.equals("italic")) + style = Font.ITALIC; + else if (s.equals("bolditalic")) + style = Font.BOLD | Font.ITALIC; + int size = Integer.parseInt(information.substring(information.indexOf(",size=")+6, information.lastIndexOf("]"))); + FontUIResource retValue = new FontUIResource(name,style,size); + // System.out.println(" - " + retValue.toString()); + return retValue; + } + catch (Exception e) + { + log.config(information + " - cannot parse: " + e.toString()); + } + return stdFont; + } // parseFont + + // Static property info + public static final String P_Primary1 = "#ColorPrimary1"; + public static final String P_Primary2 = "#ColorPrimary2"; + public static final String P_Primary3 = "#ColorPrimary3"; + public static final String P_Secondary1 = "#ColorSecondary1"; + public static final String P_Secondary2 = "#ColorSecondary2"; + public static final String P_Secondary3 = "#ColorSecondary3"; + public static final String P_Black = "#ColorBlack"; + public static final String P_White = "#ColorWhite"; + public static final String P_Error = "#ColorError"; + public static final String P_Info = "#ColorInfo"; + public static final String P_Mandatory = "#ColorMandatory"; + public static final String P_Inactive = "#ColorInactive"; + public static final String P_Txt_OK = "#ColorTextOK"; + public static final String P_Txt_Error = "#ColorTextError"; + // + public static final String P_Control = "#FontControl"; + public static final String P_System = "#FontSystem"; + public static final String P_User = "#FontUser"; + public static final String P_Small = "#FontSmall"; + public static final String P_Window = "#FontWindow"; + public static final String P_Menu = "#FontMenu"; + + /** + * Save information in Properties + */ + public static void save (Properties properties, MetalTheme theme) + { + log.config(CompiereColor.getDefaultBackground().toString()); + // + properties.setProperty(P_Primary1, getColorAsString(theme.getPrimaryControlDarkShadow())); + properties.setProperty(P_Primary2, getColorAsString(theme.getPrimaryControlShadow())); + properties.setProperty(P_Primary3, getColorAsString(theme.getPrimaryControl())); + properties.setProperty(P_Secondary1, getColorAsString(theme.getControlDarkShadow())); + properties.setProperty(P_Secondary2, getColorAsString(theme.getControlShadow())); + properties.setProperty(P_Secondary3, getColorAsString(theme.getControl())); + properties.setProperty(P_Txt_OK, getColorAsString(theme.getUserTextColor())); + + if ( theme instanceof ExtendedTheme ) { + ExtendedTheme e = (ExtendedTheme)theme; + properties.setProperty(P_Error, getColorAsString(e.getErrorBackground())); + properties.setProperty(P_Txt_Error, getColorAsString(e.getErrorForeground())); + properties.setProperty(P_Mandatory, getColorAsString(e.getMandatoryBackground())); + properties.setProperty(P_Inactive, getColorAsString(e.getInactiveBackground())); + properties.setProperty(P_White, getColorAsString(e.getWhite())); + properties.setProperty(P_Black, getColorAsString(e.getBlack())); + properties.setProperty(P_Info, getColorAsString(e.getInfoBackground())); + } else { + properties.setProperty(P_White, getColorAsString(Color.white)); + properties.setProperty(P_Black, getColorAsString(Color.black)); + properties.setProperty(P_Error, getColorAsString(ExtendedTheme.DEFAULT_ERROR_BG)); + properties.setProperty(P_Txt_Error, getColorAsString(ExtendedTheme.DEFAULT_ERROR_FG)); + properties.setProperty(P_Mandatory, getColorAsString(ExtendedTheme.DEFAULT_MANDATORY_BG)); + properties.setProperty(P_Inactive, getColorAsString(ExtendedTheme.DEFAULT_INACTIVE_BG)); + properties.setProperty(P_Info, getColorAsString(theme.getPrimaryControl())); + } + + // + properties.setProperty(P_Control, (theme.getControlTextFont()).toString()); + properties.setProperty(P_System, (theme.getSystemTextFont()).toString()); + properties.setProperty(P_User, (theme.getUserTextFont()).toString()); + properties.setProperty(P_Small, (theme.getSubTextFont()).toString()); + properties.setProperty(P_Window, (theme.getWindowTitleFont()).toString()); + properties.setProperty(P_Menu, (theme.getMenuTextFont()).toString()); + + } // save + + + /** + * Load Properties from properties + */ + public static void load (Properties properties, ExtendedTheme theme) + { + Map p = new HashMap(); + p.put(P_Primary1, parseColor (properties.getProperty(P_Primary1),null)); + p.put(P_Primary2, parseColor (properties.getProperty(P_Primary2),null)); + p.put(P_Primary3, parseColor (properties.getProperty(P_Primary3), null)); + p.put(P_Secondary1, parseColor (properties.getProperty(P_Secondary1), null)); + p.put(P_Secondary2, parseColor (properties.getProperty(P_Secondary2), null)); + p.put(P_Secondary3, parseColor (properties.getProperty(P_Secondary3), null)); + p.put(P_Error, parseColor(properties.getProperty(P_Error), null)); + p.put(P_Info, parseColor(properties.getProperty(P_Info), null)); + p.put(P_Mandatory, parseColor(properties.getProperty(P_Mandatory), null)); + p.put(P_Inactive, parseColor(properties.getProperty(P_Inactive), null)); + p.put(P_White,parseColor(properties.getProperty(P_White), null)); + p.put(P_Black, parseColor(properties.getProperty(P_Black), null)); + p.put(P_Txt_OK, parseColor(properties.getProperty(P_Txt_OK), null)); + p.put(P_Txt_Error,parseColor(properties.getProperty(P_Txt_Error), null)); + // + p.put(P_Control, parseFont(properties.getProperty(P_Control), null)); + p.put(P_System, parseFont(properties.getProperty(P_System), null)); + p.put(P_User, parseFont(properties.getProperty(P_User), null)); + p.put(P_Small, parseFont(properties.getProperty(P_Small), null)); + p.put(P_Window, parseFont(properties.getProperty(P_Window), null)); + p.put(P_Menu, parseFont(properties.getProperty(P_Menu), null)); + // + theme.setUIProperties(p); + } // load +} diff --git a/looks/src/org/compiere/util/Ini.java b/looks/src/org/compiere/util/Ini.java index c13440ba8e..e003dfe458 100644 --- a/looks/src/org/compiere/util/Ini.java +++ b/looks/src/org/compiere/util/Ini.java @@ -69,15 +69,18 @@ public final class Ini implements Serializable /** Look & Feel */ public static final String P_UI_LOOK = "UILookFeel"; - private static final String DEFAULT_UI_LOOK = AdempiereLookAndFeel.NAME; + private static final String DEFAULT_UI_LOOK = AdempiereLookAndFeel.NAME; /** UI Theme */ private static final String DEFAULT_UI_THEME = AdempiereThemeInnova.NAME; /** UI Theme */ public static final String P_UI_THEME = "UITheme"; - /** Flat Color UI */ + + /** Flat Color UI public static final String P_UI_FLAT = "UIFlat"; private static final boolean DEFAULT_UI_FLAT = false; + */ + /** Auto Save */ public static final String P_A_COMMIT = "AutoCommit"; private static final boolean DEFAULT_A_COMMIT = true; @@ -148,7 +151,7 @@ public final class Ini implements Serializable P_UID, P_PWD, P_TRACELEVEL, P_TRACEFILE, P_LANGUAGE, P_INI, P_CONNECTION, P_STORE_PWD, - P_UI_LOOK, P_UI_THEME, P_UI_FLAT, + P_UI_LOOK, P_UI_THEME, /* P_UI_FLAT,*/ P_A_COMMIT, P_A_LOGIN, P_A_NEW, P_ADEMPIERESYS, P_SHOW_ACCT, P_SHOW_TRL, P_SHOW_ADVANCED, P_CACHE_WINDOW, @@ -165,7 +168,7 @@ public final class Ini implements Serializable DEFAULT_UID, DEFAULT_PWD, DEFAULT_TRACELEVEL, DEFAULT_TRACEFILE?"Y":"N", DEFAULT_LANGUAGE, DEFAULT_INI, DEFAULT_CONNECTION, DEFAULT_STORE_PWD?"Y":"N", - DEFAULT_UI_LOOK, DEFAULT_UI_THEME, DEFAULT_UI_FLAT?"Y":"N", + DEFAULT_UI_LOOK, DEFAULT_UI_THEME, /* DEFAULT_UI_FLAT?"Y":"N", */ DEFAULT_A_COMMIT?"Y":"N", DEFAULT_A_LOGIN?"Y":"N", DEFAULT_A_NEW?"Y":"N", DEFAULT_ADEMPIERESYS?"Y":"N", DEFAULT_SHOW_ACCT?"Y":"N", DEFAULT_SHOW_TRL?"Y":"N", DEFAULT_SHOW_ADVANCED?"Y":"N", DEFAULT_CACHE_WINDOW?"Y":"N", diff --git a/looks/src/org/compiere/util/IniDialog.java b/looks/src/org/compiere/util/IniDialog.java index e941b59222..d9fb5831e9 100644 --- a/looks/src/org/compiere/util/IniDialog.java +++ b/looks/src/org/compiere/util/IniDialog.java @@ -23,6 +23,7 @@ import java.util.*; import java.util.logging.*; import javax.swing.*; +import org.adempiere.plaf.AdempierePLAF; import org.compiere.swing.*; import org.compiere.plaf.*; diff --git a/looks/src/org/compiere/util/MiniBrowser.java b/looks/src/org/compiere/util/MiniBrowser.java index 3f4b17b7d4..46a94124d5 100644 --- a/looks/src/org/compiere/util/MiniBrowser.java +++ b/looks/src/org/compiere/util/MiniBrowser.java @@ -24,7 +24,8 @@ import javax.swing.JDialog; import javax.swing.JEditorPane; import javax.swing.JScrollPane; -import org.compiere.plaf.AdempierePLAF; +import org.adempiere.plaf.AdempierePLAF; + /** * Mini Browser diff --git a/looks/swing.properties b/looks/swing.properties index f7f80e07b3..a3738c106e 100644 --- a/looks/swing.properties +++ b/looks/swing.properties @@ -1,4 +1,4 @@ -swing.defaultlaf=org.compiere.plaf.AdempiereLookAndFeel +swing.defaultlaf=org.adempiere.plaf.AdempiereLookAndFeel swing.installedlafs=Metal,Motif,Windows,Adempiere swing.installedlaf.Metal.class=javax.swing.plaf.metal.MetalLookAndFeel swing.installedlaf.Metal.name=Metal