[izpack-changes] r1762 - in izpack-src/branches/3.10: . src/lib/com/izforge/izpack/panels

noreply at berlios.de noreply at berlios.de
Wed Feb 28 22:40:35 CET 2007


Author: vralev
Date: 2007-02-28 22:40:19 +0100 (Wed, 28 Feb 2007)
New Revision: 1762

Modified:
   izpack-src/branches/3.10/Versions.txt
   izpack-src/branches/3.10/src/lib/com/izforge/izpack/panels/PacksPanelBase.java
Log:
Replaced the default checkbox icons in Gnome/KDE since they do not grey-out when disabled as notes in the helper label. This change is only effective for UNIX.

Modified: izpack-src/branches/3.10/Versions.txt
===================================================================
--- izpack-src/branches/3.10/Versions.txt	2007-02-24 11:05:59 UTC (rev 1761)
+++ izpack-src/branches/3.10/Versions.txt	2007-02-28 21:40:19 UTC (rev 1762)
@@ -10,6 +10,8 @@
   (Vladimir Ralev via Julien Ponge)
 - Workaround for a Sun bug in Java 6 which crashes the installer in some non-english locales,
   see http://jira.jboss.com/jira/browse/JBINSTALL-232 (Vladimir Ralev)
+- Replaced the default checkbox icons in Gnome/KDE since they do not grey-out when disabled
+  as notes in the helper label. This change is only effective for UNIX. (Vladimir Ralev)
 
   > 3.10.0 (build 2007.01.29)
 

Modified: izpack-src/branches/3.10/src/lib/com/izforge/izpack/panels/PacksPanelBase.java
===================================================================
--- izpack-src/branches/3.10/src/lib/com/izforge/izpack/panels/PacksPanelBase.java	2007-02-24 11:05:59 UTC (rev 1761)
+++ izpack-src/branches/3.10/src/lib/com/izforge/izpack/panels/PacksPanelBase.java	2007-02-28 21:40:19 UTC (rev 1762)
@@ -27,6 +27,7 @@
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Dimension;
+import java.awt.Graphics;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
@@ -42,6 +43,8 @@
 import javax.swing.BorderFactory;
 import javax.swing.Box;
 import javax.swing.BoxLayout;
+import javax.swing.ButtonModel;
+import javax.swing.Icon;
 import javax.swing.JCheckBox;
 import javax.swing.JLabel;
 import javax.swing.JOptionPane;
@@ -53,6 +56,7 @@
 import javax.swing.border.Border;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
+import javax.swing.plaf.metal.MetalLookAndFeel;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.TableCellEditor;
 import javax.swing.table.TableCellRenderer;
@@ -608,6 +612,13 @@
         public CheckBoxEditorRenderer(boolean useAsEditor)
         {
             display = new JCheckBox();
+            if(com.izforge.izpack.util.OsVersion.IS_UNIX)
+            {
+                display.setIcon(new LFIndependentIcon());
+                display.setDisabledIcon(new LFIndependentIcon());
+                display.setSelectedIcon(new LFIndependentIcon());
+                display.setDisabledSelectedIcon(new LFIndependentIcon());
+            }
             display.setHorizontalAlignment(CENTER);
             if (useAsEditor) display.addActionListener(this);
 
@@ -657,7 +668,88 @@
             stopCellEditing();
         }
     }
+    
+    public static class LFIndependentIcon implements Icon
+    {
+       ButtonModel buttonModel = null;
+       protected int getControlSize() { return 13; }
+       public void paintIcon(Component c, Graphics g, int x, int y)
+       {
+          ButtonModel model = ((JCheckBox)c).getModel();
+          buttonModel = model;
+          int controlSize = getControlSize();
+          if (model.isPressed() && model.isArmed())
+          {
+             g.setColor( MetalLookAndFeel.getControlShadow() );
+             if(model.isEnabled()) g.setColor(Color.green); else g.setColor(Color.gray);
+             g.fillRect( x, y, controlSize-1, controlSize-1);
+             drawPressedBorder(g, x, y, controlSize, controlSize, model);
+          }
+          else
+          {
+             drawBorder(g, x, y, controlSize, controlSize, model);
+          }
+          g.setColor( Color.green );
+          if (model.isSelected())
+          {
+             drawCheck(c,g,x,y);
+          }
+       }
+       private void drawBorder(Graphics g, int x, int y, int w, int h, ButtonModel model)
+       {
+          g.translate(x, y);
 
+          // outer frame rectangle
+          g.setColor(MetalLookAndFeel.getControlDarkShadow());
+          if(!model.isEnabled()) g.setColor(new Color(0.4f, 0.4f, 0.4f));
+          g.drawRect(0, 0, w-2, h-2);
+
+          // middle frame
+          g.setColor(MetalLookAndFeel.getControlHighlight());
+          if(!model.isEnabled()) g.setColor(new Color(0.6f, 0.6f, 0.6f));
+          g.drawRect(1, 1, w-2, h-2);
+
+          // background
+          if(model.isEnabled()) g.setColor(Color.white); else g.setColor(new Color(0.8f, 0.8f, 0.8f));
+          g.fillRect(2, 2, w-3, h-3);
+
+          //some extra lines for FX
+          g.setColor(MetalLookAndFeel.getControl());
+          g.drawLine(0, h-1, 1, h-2);
+          g.drawLine(w-1, 0, w-2, 1);
+          g.translate(-x, -y);
+       }
+       private void drawPressedBorder(Graphics g, int x, int y, int w, int h, ButtonModel model)
+       {
+          g.translate(x, y);
+          drawBorder(g, 0, 0, w, h, model);
+          g.setColor(MetalLookAndFeel.getControlShadow());
+          g.drawLine(1, 1, 1, h-2);
+          g.drawLine(1, 1, w-2, 1);
+          g.drawLine(2, 2, 2, h-3);
+          g.drawLine(2, 2, w-3, 2);
+          g.translate(-x, -y);
+       }
+       protected void drawCheck(Component c, Graphics g, int x, int y)
+       {
+          int controlSize = getControlSize();
+          if(buttonModel!=null)
+             if(buttonModel.isEnabled())
+                g.setColor(new Color(0.0f,0.6f,0.0f));
+             else g.setColor(new Color(0.1f,0.1f,0.1f));
+
+          g.drawLine( x+(controlSize-4), y+2, x+(controlSize-4)-4, y+2+4 );
+          g.drawLine( x+(controlSize-4), y+3, x+(controlSize-4)-4, y+3+4 );
+          g.drawLine( x+(controlSize-4), y+4, x+(controlSize-4)-4, y+4+4 );
+
+          g.drawLine( x+(controlSize-4)-4, y+2+4, x+(controlSize-4)-4-2, y+2+4-2 );
+          g.drawLine( x+(controlSize-4)-4, y+3+4, x+(controlSize-4)-4-2, y+3+4-2 );
+          g.drawLine( x+(controlSize-4)-4, y+4+4, x+(controlSize-4)-4-2, y+4+4-2 );
+       }
+       public int getIconWidth() {return getControlSize();}
+       public int getIconHeight() {return getControlSize();}
+    }
+    
     static class PacksPanelTableCellRenderer extends DefaultTableCellRenderer
     {
 




More information about the izpack-changes mailing list