Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Updating Workbench when perspective changes
Updating Workbench when perspective changes [message #462108] Tue, 23 January 2007 09:40
Christoph is currently offline ChristophFriend
Messages: 55
Registered: July 2009
Member
Hi,

i have the following problem. IŽm looking for a solution for a couple of
hours but i canŽt come up with a solution so far.

I have a rcp-application with two perspectives. When the active
perspective is changed i want several thing within the workbench to be
changed. So i have written a PerspectiveListener and registered it with
the WorkbenchWindow. This works fine, the listener gets notified and i
have the Objects of the window and the new perspective. Everything is
prepared. But i canŽt figure out how to do the following:

- the toolbar of the window should be hidden
- the perspective-bar should be hidden
- one entry in the main-menu should be hidden

And i have one view with a JFace-Treeviewer in it. I want the entries in
this treeviewer to be updated depending on the new perspective. So i
called createPartControl() on that view, my model is created again with
the new entries and set as the input of the treeviewer, i even called
refresh() on the treeviewer, but nothing happens. I can debug this and see
that the model is created correctly and that it is set, but the view is
not updated.

Here is the code for my view:

public class MainView extends ViewPart {
public final static String ID="de.gebitms.geplan.ui.views.Main";
private TreeViewer treeViewer;
private ISession session;
private IAdapterFactory adapterFactory=new GeplanAdapterFactory();

public MainView() {
super();
}

public void createPartControl(Composite parent) {
initializeSession();
treeViewer = new TreeViewer(parent, SWT.BORDER | SWT.MULTI |
SWT.V_SCROLL);
getSite().setSelectionProvider(treeViewer);
Platform.getAdapterManager().registerAdapters(adapterFactory ,
Group.class);
treeViewer.setLabelProvider(new WorkbenchLabelProvider());
treeViewer.setContentProvider(new BaseWorkbenchContentProvider());
treeViewer.setInput(session.getRoot());
treeViewer.refresh();
}

public void dispose() {
Platform.getAdapterManager().unregisterAdapters(adapterFacto ry);
super.dispose();
}

private void initializeSession() {
session = new Session();
IGroup root;
String pers_akt=PlatformUI.getWorkbench().getActiveWorkbenchWindow( )
.getActivePage().getPerspective().getId();

root = session.getRoot();
Group gruppe1 = new Group(root,
Messages.getString("geplan.view.main.gruppe1"),1);
root.addEntry(gruppe1);
if (pers_akt.equals(GlobalTokens.PERSPECTIVE_ADMIN)){
Group gruppe2 = new Group(root,
Messages.getString("geplan.view.main.gruppe2"),2);
root.addEntry(gruppe2);
Group gruppe21 = new
Group(gruppe2,Messages.getString("geplan.view.main.gruppe21 "),21);
gruppe2.addEntry(gruppe21);
Group gruppe22 = new
Group(gruppe2,Messages.getString("geplan.view.main.gruppe22 "),22);
gruppe2.addEntry(gruppe22);
Group gruppe3 = new Group(root,
Messages.getString("geplan.view.main.gruppe3"),3);
root.addEntry(gruppe3);
Group gruppe31 = new
Group(gruppe3,Messages.getString("geplan.view.main.gruppe31 "),31);
gruppe3.addEntry(gruppe31);
Group gruppe32 = new
Group(gruppe3,Messages.getString("geplan.view.main.gruppe32 "),32);
gruppe3.addEntry(gruppe32);
Group gruppe4 = new Group(root,
Messages.getString("geplan.view.main.gruppe4"),4);
root.addEntry(gruppe4);
Group gruppe41 = new
Group(gruppe4,Messages.getString("geplan.view.main.gruppe41 "),41);
gruppe4.addEntry(gruppe41);
Group gruppe42 = new
Group(gruppe4,Messages.getString("geplan.view.main.gruppe42 "),42);
gruppe4.addEntry(gruppe42);
Group gruppe5 = new Group(root,
Messages.getString("geplan.view.main.gruppe5"),5);
root.addEntry(gruppe5);
Group gruppe51 = new
Group(gruppe5,Messages.getString("geplan.view.main.gruppe51 "),51);
gruppe5.addEntry(gruppe51);
Group gruppe52 = new
Group(gruppe5,Messages.getString("geplan.view.main.gruppe52 "),52);
gruppe5.addEntry(gruppe52);
}
Group gruppe6 = new Group(root,
Messages.getString("geplan.view.main.gruppe6"),6);
root.addEntry(gruppe6);
if (pers_akt.equals(GlobalTokens.PERSPECTIVE_ADMIN)){
Group gruppe61 = new
Group(gruppe6,Messages.getString("geplan.view.main.gruppe61 "),61);
gruppe6.addEntry(gruppe61);
Group gruppe62 = new
Group(gruppe6,Messages.getString("geplan.view.main.gruppe62 "),62);
gruppe6.addEntry(gruppe62);
Group gruppe63 = new
Group(gruppe6,Messages.getString("geplan.view.main.gruppe63 "),63);
gruppe6.addEntry(gruppe63);
}
Group gruppe64 = new
Group(gruppe6,Messages.getString("geplan.view.main.gruppe64 "),64);
gruppe6.addEntry(gruppe64);
if (pers_akt.equals(GlobalTokens.PERSPECTIVE_USER)){
Group gruppe7 = new Group(root,
Messages.getString("geplan.view.main.gruppe7"),7);
root.addEntry(gruppe7);
}
}

public void setFocus() {
treeViewer.getControl().setFocus();
}
}

And here is how i try to update the view:

for (Object view:window.getActivePage().getViewReferences()){
IViewReference viewRef=(IViewReference)view;
if (viewRef.getId().equals("de.gebitms.geplan.ui.views.Main")){
MainView mainView=(MainView)viewRef.getView(true);
if(mainView!=null)
mainView.createPartControl(mainView.getSite().getShell());
}
}

Can anybody here help me out with one of this things? Thanks very much in
advance for any help.
Christoph
Previous Topic:How to Refresh the UI -Table
Next Topic:Update workbench when active perspective changes
Goto Forum:
  


Current Time: Thu Sep 12 12:22:49 GMT 2024

Powered by FUDForum. Page generated in 0.03645 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top