Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Treeviewer only refreshes when clicked on
Treeviewer only refreshes when clicked on [message #840622] Tue, 10 April 2012 10:00 Go to next message
El Shorty is currently offline El ShortyFriend
Messages: 37
Registered: March 2012
Member
Hey all,

So I have a treeviewer with groups & the persons in the group but it only refreshes the moment I click on it. Isn't it possible to let it refresh the moment something changes?

In my view that contains the treeviewer this is how I make it refresh:

ISelectionListener listener = new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection sel) {
if (!(sel instanceof IStructuredSelection))
return;
IStructuredSelection ss = (IStructuredSelection) sel;
Object o = ss.getFirstElement();
if (o instanceof Group || o instanceof Person)
{
treeViewer.setInput(new GroupList());
treeViewer.refresh();
}
}
};

public void createPartControl(Composite parent) {
....
getSite().getPage().addSelectionListener(listener);
}

@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
treeViewer.refresh();

}

When I click on an item in the treeviewer it opens an editor, the changes I make here (for example adding a new person to a group) works fine. When I click in the treeviewer, it refreshes and shows me the correct data. But what I want is that the moment I add the person to the group the treeviewer gets updates without that I need to click in it
Re: Treeviewer only refreshes when clicked on [message #840632 is a reply to message #840622] Tue, 10 April 2012 10:11 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The TreeViewer is only an example that starts you on your way to a
properly customized editor/view.

A common Eclipse ergonomic is to use the linked icon (bidirectional
arrow) to select auto-update. You could use it to select between the
current behaviour (which is good when you are looking somewhere else)
and your behaviour (which is good when you are looking at the TreeViewer).

Regards

Ed Willink




On 10/04/2012 11:00, El Shorty wrote:
> Hey all,
>
> So I have a treeviewer with groups & the persons in the group but it
> only refreshes the moment I click on it. Isn't it possible to let it
> refresh the moment something changes?
>
> In my view that contains the treeviewer this is how I make it refresh:
>
> ISelectionListener listener = new ISelectionListener() {
> @Override
> public void selectionChanged(IWorkbenchPart part, ISelection
> sel) {
> if (!(sel instanceof IStructuredSelection))
> return;
> IStructuredSelection ss = (IStructuredSelection) sel;
> Object o = ss.getFirstElement();
> if (o instanceof Group || o instanceof Person)
> {
> treeViewer.setInput(new GroupList());
> treeViewer.refresh();
> }
> }
> };
>
> public void createPartControl(Composite parent) {
> ....
> getSite().getPage().addSelectionListener(listener);
> }
>
> @Override
> public void selectionChanged(IWorkbenchPart part, ISelection
> selection) {
> treeViewer.refresh();
>
> }
>
> When I click on an item in the treeviewer it opens an editor, the
> changes I make here (for example adding a new person to a group) works
> fine. When I click in the treeviewer, it refreshes and shows me the
> correct data. But what I want is that the moment I add the person to
> the group the treeviewer gets updates without that I need to click in it
>
Re: Treeviewer only refreshes when clicked on [message #840729 is a reply to message #840622] Tue, 10 April 2012 12:52 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
EMF's generated editors show how to set up a tree viewer that updates
(responds to model notifications) as you change the model.


On 10/04/2012 12:00 PM, El Shorty wrote:
> Hey all,
>
> So I have a treeviewer with groups & the persons in the group but it
> only refreshes the moment I click on it. Isn't it possible to let it
> refresh the moment something changes?
>
> In my view that contains the treeviewer this is how I make it refresh:
>
> ISelectionListener listener = new ISelectionListener() {
> @Override
> public void selectionChanged(IWorkbenchPart part, ISelection
> sel) {
> if (!(sel instanceof IStructuredSelection))
> return;
> IStructuredSelection ss = (IStructuredSelection) sel;
> Object o = ss.getFirstElement();
> if (o instanceof Group || o instanceof Person)
> {
> treeViewer.setInput(new GroupList());
> treeViewer.refresh();
> }
> }
> };
>
> public void createPartControl(Composite parent) {
> ....
> getSite().getPage().addSelectionListener(listener);
> }
>
> @Override
> public void selectionChanged(IWorkbenchPart part, ISelection
> selection) {
> treeViewer.refresh();
>
> }
>
> When I click on an item in the treeviewer it opens an editor, the
> changes I make here (for example adding a new person to a group) works
> fine. When I click in the treeviewer, it refreshes and shows me the
> correct data. But what I want is that the moment I add the person to
> the group the treeviewer gets updates without that I need to click in it
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Cross-Resource Reference URI format
Next Topic:How to prevent TreeViewer collapse on add/delete of model entities
Goto Forum:
  


Current Time: Thu Mar 28 09:17:36 GMT 2024

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

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

Back to the top