Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Content not displaced in TreeViewer
Content not displaced in TreeViewer [message #1412469] Tue, 26 August 2014 08:28 Go to next message
Mihael Schmidt is currently offline Mihael SchmidtFriend
Messages: 81
Registered: August 2010
Member
Hi,

I have a tree viewer and a content and label provider for the tree viewer. Most things just work. Content provider provides the content. The label provider provides text and images.

Removing an element is also working fine (calling viewer.remove(element) ).

But when I try to "insert" a new element then it ain't displayed. I insert a new element by calling

viewer.refresh(parent, true);


on the parent. The content provider is queried for the content of the parent and it is providing the content including the "inserted"/new element. So far so good. But it never queries the label provider for the element and it is not displaying it.

What am I doing wrong?
Re: Content not displaced in TreeViewer [message #1412595 is a reply to message #1412469] Tue, 26 August 2014 14:48 Go to previous messageGo to next message
Eclipse UserFriend
Works for me -- I modified the JFace Snippet002 to add a a button to add a child to a node and then call update, and it works fine (see below).

Be sure that your model objects implement equals() and hashCode().

Brian.

public Snippet002TreeViewer(Shell shell) {
		final TreeViewer v = new TreeViewer(shell);
		v.setLabelProvider(new LabelProvider());
		v.setContentProvider(new MyContentProvider());
		v.setInput(createModel());

		Button b = new Button(shell, SWT.PUSH);
		b.setText("Add Child");
		b.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				MyModel root = (MyModel) v.getInput();
				root.child.get(0).child.add(new MyModel(99999, root));
				v.refresh(root, true);
			}
		});
	}
Re: Content not displaced in TreeViewer [message #1413301 is a reply to message #1412595] Thu, 28 August 2014 08:38 Go to previous message
Mihael Schmidt is currently offline Mihael SchmidtFriend
Messages: 81
Registered: August 2010
Member
Thanx for the info about hashcode() and equals(). Have forgotten about that (though I already implemented them with Eclipse generating the methods).

I forgot that I had enabled some viewer filters. And the model got modified in a background job without notifying the viewer.

Thanx for the quick post.
Previous Topic:ToolBarManager added to CoolBarManager grabs horizontal space?
Next Topic:ComboViewer Horizontal Layout
Goto Forum:
  


Current Time: Thu Mar 28 18:00:33 GMT 2024

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

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

Back to the top