[izpack-changes] r1710 - in izpack-src/trunk: . src/lib/com/izforge/izpack/installer

noreply at berlios.de noreply at berlios.de
Mon Jan 15 08:39:56 CET 2007


Author: dreil
Date: 2007-01-15 08:39:53 +0100 (Mon, 15 Jan 2007)
New Revision: 1710

Modified:
   izpack-src/trunk/Versions.txt
   izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerFrame.java
Log:
icon resource name extension for dynamically changing the installer image


Modified: izpack-src/trunk/Versions.txt
===================================================================
--- izpack-src/trunk/Versions.txt	2007-01-14 21:08:50 UTC (rev 1709)
+++ izpack-src/trunk/Versions.txt	2007-01-15 07:39:53 UTC (rev 1710)
@@ -51,6 +51,7 @@
   - support for the new "installGroup"-attribute for the "programGroup" element of the shortcutSpec.xml
   - late creation of shortcuts, for example in case ShortcutPanel is displayed before InstallPanel
   - fixed a bug where each Shortcut-Subgroup influenced the remaining Shortcut creation
+- Added icon resource extension, to dynamically change installer icon (Dennis Reil) 
 
   > 3.9.0 (build 2006.09.25)
 - Fix NullPointerException in CompilerConfig, if you specify a 

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerFrame.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerFrame.java	2007-01-14 21:08:50 UTC (rev 1709)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerFrame.java	2007-01-15 07:39:53 UTC (rev 1710)
@@ -108,11 +108,12 @@
  * 
  * @author Julien Ponge created October 27, 2002
  * @author Fabrice Mirabile added fix for alert window on cross button, July 06 2005
- * @author Dennis Reil, added RulesEngine November 10 2006
+ * @author Dennis Reil, added RulesEngine November 10 2006, several changes in January 2007
  */
 public class InstallerFrame extends JFrame
 {
 
+   
     private static final long serialVersionUID = 3257852069162727473L;
 
     /**
@@ -122,7 +123,13 @@
             .getProperty("java.specification.version"));
 
     private static final String ICON_RESOURCE = "Installer.image";
+    
+    /**
+     * Name of the variable where to find an extension to the resource name of the icon resource
+     */
+    private static final String ICON_RESOURCE_EXT_VARIABLE_NAME = "installerimage.ext";
 
+
     private static final String HEADING_ICON_RESOURCE = "Heading.image";
 
     // private static final int HEADINGLINES = 1;
@@ -554,6 +561,7 @@
     {
         ResourceManager rm = ResourceManager.getInstance();
         ImageIcon icon = null;
+        String iconext = this.getIconResourceNameExtension();
         if (tryBaseIcon)
         {
             try
@@ -562,11 +570,11 @@
             }
             catch (Exception e) // This is not that clean ...
             {
-                icon = rm.getImageIconResource(resPrefix + "." + PanelNo);
+                icon = rm.getImageIconResource(resPrefix + "." + PanelNo + iconext);
             }
         }
         else
-            icon = rm.getImageIconResource(resPrefix + "." + PanelNo);
+            icon = rm.getImageIconResource(resPrefix + "." + PanelNo + iconext);
         return (icon);
     }
 
@@ -575,6 +583,7 @@
     {
         ResourceManager rm = ResourceManager.getInstance();
         ImageIcon icon = null;
+        String iconext = this.getIconResourceNameExtension();
         if (tryBaseIcon)
         {
             try
@@ -583,13 +592,43 @@
             }
             catch (Exception e) // This is not that clean ...
             {
-                icon = rm.getImageIconResource(resPrefix + "." + panelid);
+                icon = rm.getImageIconResource(resPrefix + "." + panelid + iconext);
             }
         }
         else
-            icon = rm.getImageIconResource(resPrefix + "." + panelid);
+            icon = rm.getImageIconResource(resPrefix + "." + panelid + iconext);
         return (icon);
     }
+    
+    /**
+     * Returns the current set extension to icon resource names. Can be used to change
+     * the static installer image based on user input
+     * @return a resource extension 
+     *         or an empty string if the variable was not set.
+     */
+    private String getIconResourceNameExtension()
+    {
+        try 
+        {
+            String iconext = this.installdata.getVariable(ICON_RESOURCE_EXT_VARIABLE_NAME);
+            if (iconext == null){
+              iconext = "";
+            }
+            else {
+              
+              if ((iconext.length() > 0) && (iconext.charAt(0) != '.')){
+                iconext = "." + iconext;
+              }
+            }
+            iconext = iconext.trim();
+            return iconext;
+        }
+        catch (Exception e)
+        {
+            // in case of error, return an empty string
+            return "";
+        }
+   }
 
     private void loadAndShowImage(int panelNo)
     {




More information about the izpack-changes mailing list