/*
 * $Id$
 *
 * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
 * Santa Clara, California 95054, U.S.A. All rights reserved.
 */
package org.jdesktop.swingx.plaf;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.swing.LookAndFeel;
import javax.swing.UIManager;

import org.jdesktop.swingx.plaf.metal.MetalLookAndFeelAddons;
import org.jdesktop.swingx.plaf.windows.WindowsLookAndFeelAddons;
import org.jdesktop.swingx.table.ColumnHeaderRenderer;
import org.jdesktop.swingx.util.OS;
/**
 * Addon for <code>JXTable</code>.<br>
 *
 */
public class ColumnHeaderRendererAddon implements ComponentAddon {
    
  public String getName() {
    return "ColumnHeaderRenderer";
  }

  public void initialize(LookAndFeelAddons addon) {
      List defaults = new ArrayList();
      String upIcon = null;
      String downIcon = null;
      if (isMac(addon)) {
          upIcon = "sort-osx-up.png";
          downIcon = "sort-osx-dn.png";
//      } else if (isMotif(addon)) {
//          
      } else if (isWindows(addon)) {
          if (isXP(addon)) {
              upIcon = "sort-xp-up.png";
              downIcon = "sort-xp-dn.png";
              
          } else {
              upIcon = "sort-w2k-up.png";
              downIcon = "sort-w2k-dn.png";
              
          }
      } else if (isSynth(addon)) {
          upIcon = "sort-gtk-up.png";
          downIcon = "sort-gtk-dn.png";
          
      } else {
          upIcon = "sort-jlf-up.png";
          downIcon = "sort-jlf-dn.png";
      }
      defaults.addAll(Arrays.asList(new Object[] { 
              ColumnHeaderRenderer.UP_ICON_KEY, 
                  LookAndFeel.makeIcon(getClass(), "resources/" + upIcon),
              ColumnHeaderRenderer.DOWN_ICON_KEY, 
                  LookAndFeel.makeIcon(getClass(), "resources/" + downIcon),
      }));
      addon.loadDefaults(defaults.toArray());
  }


  public void uninitialize(LookAndFeelAddons addon) {
      List defaults = new ArrayList();
      defaults.addAll(Arrays.asList(new Object[] { 
              ColumnHeaderRenderer.UP_ICON_KEY, null,
              ColumnHeaderRenderer.DOWN_ICON_KEY,  null,
      }));
      addon.loadDefaults(defaults.toArray());
  }

  private boolean isXP(LookAndFeelAddons addon) {
      return OS.isWindowsXP();
  }
  
  private boolean isPlastic(LookAndFeelAddons addon) {
      return UIManager.getLookAndFeel().getClass().getName().contains("Plastic");
  }

  private boolean isSynth(LookAndFeelAddons addon) {
      return UIManager.getLookAndFeel().getClass().getName().contains("ynth");
  }

  private boolean isWindows(LookAndFeelAddons addon) {
      return addon instanceof WindowsLookAndFeelAddons;
  }
  
  private boolean isMotif(LookAndFeelAddons addon) {
      return UIManager.getLookAndFeel().getID().equals("Motif");
  }

  private boolean isMac(LookAndFeelAddons addon) {
      // TODO Auto-generated method stub
      return false;
  }
  

}

@@ -284,166 +284,8 @@
 el;%0A
-import javax.swing.UIManager;%0A%0Aimport org.jdesktop.swingx.plaf.metal.MetalLookAndFeelAddons;%0Aimport org.jdesktop.swingx.plaf.windows.WindowsLookAndFeelAddons;
 %0Aimp
@@ -372,16 +372,17 @@
 til.OS;%0A
+%0A
 /**%0A * A
@@ -466,19 +466,24 @@
 don 
-implement
+extend
 s 
+Abstract
 Comp
@@ -513,22 +513,33 @@
 lic 
-String getName
+ColumnHeaderRendererAddon
 () %7B
@@ -543,23 +543,22 @@
 ) %7B%0A    
-return 
+super(
 %22ColumnH
@@ -571,22 +571,25 @@
 enderer%22
+)
 ;%0A  %7D%0A
+  
 %0A  publi
@@ -1206,21 +1206,16 @@
 isSynth(
-addon
 )) %7B%0A   
@@ -2174,650 +2174,8 @@
 %0A  %7D
-%0A  %0A  private boolean isPlastic(LookAndFeelAddons addon) %7B%0A      return UIManager.getLookAndFeel().getClass().getName().contains(%22Plastic%22);%0A  %7D%0A%0A  private boolean isSynth(LookAndFeelAddons addon) %7B%0A      return UIManager.getLookAndFeel().getClass().getName().contains(%22ynth%22);%0A  %7D%0A%0A  private boolean isWindows(LookAndFeelAddons addon) %7B%0A      return addon instanceof WindowsLookAndFeelAddons;%0A  %7D%0A  %0A  private boolean isMotif(LookAndFeelAddons addon) %7B%0A      return UIManager.getLookAndFeel().getID().equals(%22Motif%22);%0A  %7D%0A%0A  private boolean isMac(LookAndFeelAddons addon) %7B%0A      // TODO Auto-generated method stub%0A      return false;%0A  %7D%0A  
 %0A%0A%7D%0A

use AbstractComponentAddon