Eclipse Search

Loading

Apr 23, 2008

Window Title in an RCP app

In Eclipse IDE, you can see the window title in the format: perspective - editPart name - Eclipse SDK - workspace. But in an RCP app, the title is usually the Product Name defined in the *.product file. This tip explains how to change it dynamically like IM clients - where the window title should be product name - user name.

Window title is *not* set on the IWorkbenchWindow. You need to do it on the IWorkbenchWindowConfigurer.

Whenever the user performs a login/logout, you need to set the window title. The details are sketchy, as its left to you whether to pass the instance of the windowConfigurer to the Login/LogoutAction or implement some sort of event listener for login/logout and do the title change there. But in general:

IWorkbenchWindowConfigurer windowConfigurer = ...;
String title = Platform.getProduct().getName();
if(loggedIn)
title = title + " - " + userName;
windowConfigurer.setTitle(title);



In case you were wondering where to get the instance of the windowConfigurer, it will be passed to your application thru the WorkbenchAdvisor.createWorkbenchWindowAdvisor() method.

1 comments:

  1. Today I found an another way ...
    On the IWorkbenchWindow, you have getShell and on the shell, you can call setText. In this case, it's the title....
    ReplyDelete