Dynamically change the title of the eclipse RCP Application

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.