001    /*
002     * $Id: ColumnHeaderRendererAddon.java,v 1.6 2005/10/13 08:59:57 kleopatra Exp $
003     *
004     * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
005     * Santa Clara, California 95054, U.S.A. All rights reserved.
006     *
007     * This library is free software; you can redistribute it and/or
008     * modify it under the terms of the GNU Lesser General Public
009     * License as published by the Free Software Foundation; either
010     * version 2.1 of the License, or (at your option) any later version.
011     * 
012     * This library is distributed in the hope that it will be useful,
013     * but WITHOUT ANY WARRANTY; without even the implied warranty of
014     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015     * Lesser General Public License for more details.
016     * 
017     * You should have received a copy of the GNU Lesser General Public
018     * License along with this library; if not, write to the Free Software
019     * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
020     */
021    package org.jdesktop.swingx.plaf;
022    
023    import java.util.ArrayList;
024    import java.util.Arrays;
025    import java.util.List;
026    
027    import javax.swing.LookAndFeel;
028    
029    import org.jdesktop.swingx.table.ColumnHeaderRenderer;
030    import org.jdesktop.swingx.util.OS;
031    
032    /**
033     * Addon for ColumnHeaderRenderer.<p>
034     * Loads LF specific sort icons.
035     * 
036     * @author Jeanette Winzenburg
037     *
038     */
039    public class ColumnHeaderRendererAddon extends AbstractComponentAddon {
040        
041      public ColumnHeaderRendererAddon() {
042        super("ColumnHeaderRenderer");
043      }
044      
045      public void initialize(LookAndFeelAddons addon) {
046          List defaults = new ArrayList();
047          String upIcon = null;
048          String downIcon = null;
049          if (isMac(addon)) {
050              upIcon = "sort-osx-up.png";
051              downIcon = "sort-osx-dn.png";
052          } else if (isWindows(addon)) {
053              if (isXP(addon)) {
054                  upIcon = "sort-xp-up.png";
055                  downIcon = "sort-xp-dn.png";
056                  
057              } else {
058                  upIcon = "sort-w2k-up.png";
059                  downIcon = "sort-w2k-dn.png";
060                  
061              }
062          } else if (isSynth()) {
063              upIcon = "sort-gtk-up.png";
064              downIcon = "sort-gtk-dn.png";
065              
066          } else {
067              upIcon = "sort-jlf-up.png";
068              downIcon = "sort-jlf-dn.png";
069          }
070          defaults.addAll(Arrays.asList(new Object[] { 
071                  ColumnHeaderRenderer.UP_ICON_KEY, 
072                      LookAndFeel.makeIcon(getClass(), "resources/" + upIcon),
073                  ColumnHeaderRenderer.DOWN_ICON_KEY, 
074                      LookAndFeel.makeIcon(getClass(), "resources/" + downIcon),
075          }));
076          addon.loadDefaults(defaults.toArray());
077      }
078    
079    
080      public void uninitialize(LookAndFeelAddons addon) {
081          List defaults = new ArrayList();
082          defaults.addAll(Arrays.asList(new Object[] { 
083                  ColumnHeaderRenderer.UP_ICON_KEY, null,
084                  ColumnHeaderRenderer.DOWN_ICON_KEY,  null,
085          }));
086          addon.loadDefaults(defaults.toArray());
087      }
088    
089      private boolean isXP(LookAndFeelAddons addon) {
090          return OS.isWindowsXP();
091      }
092    
093    }