How to set title in RCP application's View? [message #506635] |
Fri, 08 January 2010 07:55  |
Eclipse User |
|
|
|
I am developing an RCP application based on Eclipse and use i18n to load message resources. My requirement is that I need to change the View title based on locale/i18n. I am using setPartName to do that.
It does change it, but the issue is that it shows the title-changes only after the view has been clicked. So, in a way, it first displays the previously used title for the view [I am using WorkbenchPlugin.getDefault().getDataLocation() to use/set workspace settings].
Use cases:
- English user opens the application and sees the View titles in English. On close of the application, his settings are saved including the views that were opened.
- Japanese user (changed Locale) now opens the application, and application uses same workspace settings as for the English user, so opens the same views as opened previously by the English user. But he initially sees the View titles in English. Only after he clicks on the View titles, does he sees them in Japanese.=>ERROR (Expected: a click should not have been necessary to see the title in Japanese)
Please suggest a solution!!
Thanks
|
|
|
|
|
Re: How to set title in RCP application's View? [message #538512 is a reply to message #526067] |
Mon, 07 June 2010 15:43  |
Eclipse User |
|
|
|
Thanks for the help. I used your suggestion of resetting the perspective and did a little more.
I got hold of all the perspective and reset them. I also had saved the views before resetting them and then displayed the views again after resetting the perspective.
Here is my code:
public void postStartup(){
super.postStartup();
if (UserLocale.hasLocaleChangedForClient()){
IViewReference [] viewRefs = getCurrentViews();
IPerspectiveDescriptor originalPd = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getPerspective();
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
IPerspectiveDescriptor[] pds = page.getOpenPerspectives();
for (IPerspectiveDescriptor pd : pds ){
if (page != null){
page.setPerspective(PlatformUI.getWorkbench().getPerspective Registry().findPerspectiveWithId(pd.getId()));
page.resetPerspective();
}
}
page.setPerspective(originalPd);
showViews(viewRefs);
}
}
private IViewReference[] getCurrentViews() {
IViewReference[] viewRefs = PlatformUI.getWorkbench().
getActiveWorkbenchWindow().getActivePage().getViewReferences ();
return viewRefs;
}
private void showViews(IViewReference[] viewRefs) {
for (IViewReference viewRef : viewRefs) {
String id = viewRef.getId();
String sid = viewRef.getSecondaryId();
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().showView(id, sid,
IWorkbenchPage.VIEW_VISIBLE);
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.04871 seconds