center of tech

Disclaimer: everything written below is put here just to share my ideas and findings about how to change the UI of the VDI client used in a VDI3 environment. Since the client is packaged with all of its components in a jar file and there are no configurable ways of changing the UI at this moment, this involves updating components directly within in the jar file. I am in no way encouraging to do this with the way described here, especially not in a production environment because doing so will give you an unsupported environment. Applying a patch in the future might overwrite the changes made to the client. Furthermore, in the future, the client UI might very well be configurable. Consider this as my ‘hobby-bob’ project to see where we could get with this…
Having that said, I have had several requests of customers, partners and colleagues to change the VDI3 login screen. Again, although formally not supported it is no rocket-science to adapt the images and class files (required to change some of the UI style) in the off-the-shelf vdaclient.jar. The java client code based on AWT / Swing can (in a default installation) be located in /etc/opt/SUNWkio/sessions/vda. If you extract the jar file you will get to a bunch of directories and class files underneath com/sun/vda/client:
C:\Documents and Settings\Rene\My Documents\VDI>jar xf vdaclient.jar
C:\Documents and Settings\Rene\My Documents\VDI>cd com\sun\vda\client
C:\Documents and Settings\Rene\My Documents\VDI\com\sun\vda\client>dir
Volume in drive C has no label.
Volume Serial Number is 74B1-BF00
Directory of C:\Documents and Settings\Rene\My Documents\VDI\com\sun\vda\client
07/03/2009 08:20 PM <DIR> .
07/03/2009 08:20 PM <DIR> ..
07/03/2009 08:20 PM <DIR> images
07/03/2009 08:20 PM <DIR> model
07/03/2009 08:20 PM <DIR> resources
07/03/2009 08:20 PM <DIR> ui
07/03/2009 08:20 PM <DIR> util
07/03/2009 08:20 PM 2,641 VdaClient$ButtonActionListener.class
07/03/2009 08:20 PM 1,503 VdaClient$DesktopFetcher.class
07/03/2009 08:20 PM 2,340 VdaClient$DesktopStarter.class
07/03/2009 08:20 PM 1,890 VdaClient$Response.class
07/03/2009 08:20 PM 7,960 VdaClient.class
5 File(s) 16,334 bytes
7 Dir(s) 20,258,729,984 bytes free
|
so, what are the most common requests - in random order?
Adapting the images can be done by creating new images and updating the existing ones in the vdaclient.jar. So to start with, let us take a look inside the images directory as outlined above…
If we take a look at the images directory, we see a bunch of images that could potentially be replaced by corporate logo’s, style, etc. Most relevant images to adapt in many scenario’s are probably ‘dialog_background.png’ and ’sun_logo.png’.
One could take their own favorite image editor program and create some images based on the original one or create something from scratch. Just watch out that you keep about the exact same white space for selector boxes, drop down menus and error information to appear as can been seen in the original.
A simple example of an adapted ‘dialog_background’ image that I have made for a VDI demo show at Capgemini can be seen below.

Don’t pay attention to the error message. I have run the vdaclient.jar from my laptop (via ‘java -jar vdaclient.jar’) to get this screenshot and then obviously the Sun VDI service cannnot be contacted. Actually, this is not the best example since the logo at the lower right corner can be overwritten by (long) error messages that can occur in certain misconfigured situation. As this was not the case in this demo setup, I decided to leave it like this - based on Capgemini look and feel style.
In fact, if you create the image like this with the logo in the lower right corner, it will not show, since by default the white space will be rendered on top of the logo image (in order to get this right, you have to set the RootPanel and OptionsPanel as being transparent - this can be done by adding / changing the line ‘jpanel.setOpaque(false)’ to both methods ‘createRootPanel’ and ‘createOptionsPanel’ in the ‘Dialog’ class; how this can be done… see below).
So now we have this image created we need to update it in the vdaclient.jar file and we should be all set:
C:\Documents and Settings\Rene\My Documents\VDI>dir Volume in drive C has no label. Volume Serial Number is 74B1-BF00 Directory of C:\Documents and Settings\Rene\My Documents\VDI 07/03/2009 08:20 PM <DIR> . 07/03/2009 08:20 PM <DIR> .. 07/03/2009 08:20 PM <DIR> com 07/03/2009 08:20 PM <DIR> META-INF 06/12/2009 03:26 PM 382,968 vdaclient.jar 1 File(s) 382,968 bytes 4 Dir(s) 20,224,774,144 bytes free C:\Documents and Settings\Rene\My Documents\VDI>jar uf vdaclient.jar com\sun\vda \client\images\dialog_background.png C:\Documents and Settings\Rene\My Documents\VDI> |
Obviously, exactly the same method as described above applies to adapt the other images (e.g. ’sun_logo,png’, etc.).
Unfortunately, the background cannot easily be changed since it is not an image but a vertical gradient color that is generated by some Java code within vdaclient.jar. Let’s look at the relevant Wallpaper.class file by decompiling the class file as follows (using jad in my case):
C:\Documents and Settings\Rene\My Documents\VDI\com\sun\vda\client\ui>jad -s jav a Wallpaper.class Parsing Wallpaper.class... Generating Wallpaper.java C:\Documents and Settings\Rene\My Documents\VDI\com\sun\vda\client\ui> |
If we then take a look inside Wallpaper.java we see the following lines:
public class Wallpaper extends JPanel
{
public Wallpaper()
{
setOpaque(true);
}
public void paintComponent(Graphics g)
{
Graphics2D graphics2d = (Graphics2D)g;
Dimension dimension = getSize();
GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, FIRST_COLOR,
0.0F, dimension.height, SECOND_COLOR);
graphics2d.setPaint(gradientpaint);
graphics2d.fill(new java.awt.geom.Rectangle2D.Double(0.0D, 0.0D, dimensi
on.width, dimension.height));
}
public static final Color FIRST_COLOR = new Color(25, 107, 138);
public static final Color SECOND_COLOR = new Color(197, 212, 225);
}
|
It is easiest to just change the background color by changing the value of FIRST_COLOR and SECOND_COLOR. If we make the same color we get a solid background with that color. After the code change we have to compile the class again and update the vdaclient.jar file:
C:\Documents and Settings\Rene\My Documents\VDI\com\sun\vda\client\ui>java -vers ion java version "1.5.0_12" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04) Java HotSpot(TM) Client VM (build 1.5.0_12-b04, mixed mode, sharing) C:\Documents and Settings\Rene\My Documents\VDI\com\sun\vda\client\ui>javac -cla sspath ..\..\..\..\..\vdaclient.jar Wallpaper.java C:\Documents and Settings\Rene\My Documents\VDI\com\sun\vda\client\ui>cd ..\..\. .\..\.. C:\Documents and Settings\Rene\My Documents\VDI>jar uf vdaclient.jar com\sun\vda \client\ui\Wallpaper.class C:\Documents and Settings\Rene\My Documents\VDI> |
This is exactly what I have done for the login screen for our lab
environment Sunlabs (combined with yet another login image) as you can
see below.
Another thing we can do here is use a background image instead of a solid or gradient color. I have done this, it requires some more code changes but I found the total screen way to ‘crowded’. If you need some guidance here drop me a note.
Most (all?) of the text in the login UI can be found in the ‘resources’ directory. For each of the major languages a ‘ClientLabels_xx.properties’ file can be found. All of the strings could be changed to e.g. include the company name or similar. After you have done this you should obviously update the vdaclient.jar file again as described above.
Changing the fonts is a little more difficult since the fonts are defined within some of the class files. Therefore you need to decompile the appropriate class files (e.g., DesktopSelection, DialogContent, ThemeDefaults), change the fonts (or fontsize) used, compile again and update the vdaclient.jar file as described above at "3. Changing the background of the total screen".
Source/Kaynak : http://blogs.sun.com/renek/entry/changing_the_vdi3_login_gui