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

noreply at berlios.de noreply at berlios.de
Thu Nov 30 12:50:37 CET 2006


Author: dreil
Date: 2006-11-30 12:50:25 +0100 (Thu, 30 Nov 2006)
New Revision: 1661

Modified:
   izpack-src/trunk/Versions.txt
   izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerFrame.java
Log:
Added support for custom icons


Modified: izpack-src/trunk/Versions.txt
===================================================================
--- izpack-src/trunk/Versions.txt	2006-11-29 17:03:01 UTC (rev 1660)
+++ izpack-src/trunk/Versions.txt	2006-11-30 11:50:25 UTC (rev 1661)
@@ -13,6 +13,7 @@
   to Stefan Wachter).
 - Added dtd for conditions (Dennis Reil)
 - Added support for panelid in InstallerImage-Definition (Dennis Reil)
+- Added support for customicons (Dennis Reil)
 
   > 3.9.0 (build 2006.09.25)
 - Fix Accents In French Langpack (Fabrice Mirabile)

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerFrame.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerFrame.java	2006-11-29 17:03:01 UTC (rev 1660)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerFrame.java	2006-11-30 11:50:25 UTC (rev 1661)
@@ -216,6 +216,10 @@
      * Resource name of the conditions specification
      */
     private static final String CONDITIONS_SPECRESOURCENAME = "conditions.xml";
+    /**
+     * Resource name for custom icons
+     */
+    private static final String CUSTOM_ICONS_RESOURCEFILE = "customicons.xml";
 
     /**
      * The constructor (normal mode).
@@ -241,6 +245,7 @@
 
         // Builds the GUI
         loadIcons();
+        loadCustomIcons();
         loadPanels();
         buildGUI();
 
@@ -386,7 +391,58 @@
             UIManager.put(icon.getAttribute("id"), img);
         }
     }
+    
+    /**
+     * Loads custom icons into the installer.
+     * 
+     * @throws Exception
+     */
+    protected void loadCustomIcons() throws Exception {
+      // We try to load and add a custom langpack.
+      InputStream inXML = null;
+      try {
+        inXML = ResourceManager.getInstance().getInputStream(
+            CUSTOM_ICONS_RESOURCEFILE);
+      } catch (Throwable exception) {
+        Debug.trace("Resource " + CUSTOM_ICONS_RESOURCEFILE + " not defined. No custom icons available.");
+        return;
+      }
+      Debug.trace("Custom icons available.");
+      URL url;
+      ImageIcon img;
+      XMLElement icon;
 
+      // Initialises the parser
+      StdXMLParser parser = new StdXMLParser();
+      parser.setBuilder(new StdXMLBuilder());
+      parser.setReader(new StdXMLReader(inXML));
+      parser.setValidator(new NonValidator());
+
+      // We get the data
+      XMLElement data = (XMLElement) parser.parse();
+
+      // We load the icons
+      Vector children = data.getChildrenNamed("icon");
+      int size = children.size();
+      for (int i = 0; i < size; i++) {
+        icon = (XMLElement) children.get(i);
+        url = InstallerFrame.class.getResource(icon.getAttribute("res"));
+        img = new ImageIcon(url);
+        Debug.trace("Icon with id found: " + icon.getAttribute("id"));
+        icons.put(icon.getAttribute("id"), img);
+      }
+
+      // We load the Swing-specific icons
+      children = data.getChildrenNamed("sysicon");
+      size = children.size();
+      for (int i = 0; i < size; i++) {
+        icon = (XMLElement) children.get(i);
+        url = InstallerFrame.class.getResource(icon.getAttribute("res"));
+        img = new ImageIcon(url);
+        UIManager.put(icon.getAttribute("id"), img);
+      }
+    }
+
     /**
      * Builds the GUI.
      */




More information about the izpack-changes mailing list