We know that the title is passed in applicationworkbenchwindowadvisor
public void preWindowOpen()
{ IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); configurer.setInitialSize(new Point(600, 500)); configurer.setShowCoolBar(false); configurer.setShowStatusLine(true); configurer.setShowProgressIndicator(true); configurer.setTitle(xxx); }
So how can we change it dynamically at runtime?
I was thinking about how to get iworkbenchwindowcycler at first, but I didn't have a clue at all. Then I came to the RCP news group and asked me what I was not satisfied, but one of them gave me inspiration, and he wrote:
I've used the following technique:
public static void changeAppTitle(String newTitle) { Display display = Display.getDefault(); if (display != null) { // Look at all the shells and pick the first one // that is a workbench window. Shell shells[] = display.getShells(); for (int i = 0; i < shells.length; i++) { Object data = shells[i].getData(); // Check whether this shell points to the // Application main window's shell if (data instanceof IWorkbenchWindow) { shells[i].setText(newTitle); break; } } } }
Since the title can be set through the shell of iworkbenchwindow, everything is fine. When initializing an action in actionbaradvisor, pass workbenchwindow as a parameter to the constructor, and then use window. getshell (). settext () in the Action :)
Remarks: This article Reprinted from: http://www.iteye.com/topic/40853