[izpack-devel] patch: use intance number to customize strings

Bartz, Klaus Klaus.Bartz at coi.de
Thu Nov 16 18:33:10 CET 2006


Hi Stefan,
I do not use multiple instances of one panel class (else I 
had seen the problem at impl the feature) but it hear good.
Unfortunately I have nearly no time...
Please send us your changes as a diff -u (comments as java 
comments in the files). Simplest you checkout the SVN
IzPack project and make the diff with SVN.

Cheers

Klaus

>-----Original Message-----
>From: izpack-devel-bounces at lists.berlios.de
>[mailto:izpack-devel-bounces at lists.berlios.de]On Behalf Of Stefan
>Wachter
>Sent: Thursday, November 16, 2006 2:53 PM
>To: izpack-devel at lists.berlios.de
>Subject: [izpack-devel] patch: use intance number to customize strings
>
>
>Hi all,
>
>I have several UserInputPanels that should have different 
>headlines. I looked into the code and 
>recognized that only a single headline can be configured that 
>is used for all UserInputPanels. 
>Therefore I patched the getI18nStringForClass(String subkey) 
>method in the IzPanel class to consider 
>instance numbers and added the method getInstanceNumber() with 
>a default implementation that returns -1:
>
>// start code
>
>public String getI18nStringForClass(String subkey)
>{
>     String retval = null;
>     Class clazz = this.getClass();
>     while (retval == null && !clazz.getName().endsWith(".IzPanel"))
>     {
>         int instanceNumber = getInstanceNumber();
>         if (instanceNumber != -1) {
>             retval = getI18nStringForClass(clazz.getName(), 
>subkey + "." + instanceNumber, null);
>             if (retval != null) return retval;
>         }
>         retval = getI18nStringForClass(clazz.getName(), subkey, null);
>         clazz = clazz.getSuperclass();
>     }
>     return (retval);
>}
>
>protected int getInstanceNumber() { return -1; }
>
>// end code
>
>In order to make use of this new flexibility, I overloaded the 
>getInstanceNumber() method in the 
>UserInputPanel class returning the instance number of the 
>UserInputPanel:
>
>// start code
>
>protected int getInstanceNumber() { return instanceNumber; }
>
>// end code
>
>Now different headlines can be configured for the various 
>UserInputPanels. For example:
>
><langpack>
>   <str id="UserInputPanel.headline.0" txt="Rechnername und Port"/>
>   <str id="UserInputPanel.headline.1" txt="Shortcuts"/>
>   <str id="UserInputPanel.headline.2" txt="PolFHa-Server starten"/>
></langpack>
>
>Is this code of public interest? Will someone integrate it into IzPack?
>
>Cheers,
>--Stefan
>
>_______________________________________________
>izpack-devel mailing list
>izpack-devel at lists.berlios.de
>https://lists.berlios.de/mailman/listinfo/izpack-devel
>



More information about the izpack-devel mailing list