Skip to main content



      Home
Home » Eclipse Projects » JFace » Content not displaced in TreeViewer
Content not displaced in TreeViewer [message #1412469] Tue, 26 August 2014 04:28 Go to next message
Eclipse UserFriend
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 10: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 04:38 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 01:45:25 EDT 2025

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

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

Back to the top