Hi,

i have a treeViewer with DataBinding. If i add a new entry to that treeViewer it is placed correctly in the tree (sorted alphabetically). If i change an entry i fire a PropertyChange event in my model and thus the tree entry is updated to it's new name. But it's not sorted. How can i sort the changed entry? I tried to call my sorting method from my editCommandHandler and it works, but i get an Exception when i close my program if i deleted an entry before i changed one. It seems i get this exception anytime when i close my program, if i called a treeViewer.refresh() or tried to sort the tree after i did something in the tree like making or deleting an entry.

Java Code:
!ENTRY org.eclipse.ui 4 0 2011-07-11 15:48:42.800
!MESSAGE assertion failed: Getter called on disposed observable org.eclipse.core.databinding.observable.list.WritableList@55ac459e
!STACK 0
org.eclipse.core.runtime.AssertionFailedException: assertion failed: Getter called on disposed observable org.eclipse.core.databinding.observable.list.WritableList@55ac459e
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
	at org.eclipse.core.databinding.observable.ObservableTracker.getterCalled(ObservableTracker.java:252)
	at org.eclipse.core.databinding.observable.list.ObservableList.getterCalled(ObservableList.java:241)
	at org.eclipse.core.databinding.observable.list.ObservableList.hashCode(ObservableList.java:92)
.....

My View:

Java Code:
	public void sortTable() {
		
		treeViewer.setComparator(new ViewerComparator() {					
			    @Override
			    public int compare(Viewer viewer, Object e1, Object e2) {

			    	if (e1 instanceof Project && e2 instanceof Project)
			        {	        	
			            return ((Project) e1).getName().compareToIgnoreCase(
			                   ((Project) e2).getName());
			        }
			        else if (e1 instanceof Stock && e2 instanceof Stock)
			        {
			            return ((Stock) e1).getIdentifier().compareToIgnoreCase(
			                   ((Stock) e2).getIdentifier());
			        }
			        else
			        {
			        	throw new IllegalArgumentException("Not comparable: " + e1 + " " + e2);
			        }
			    }
			});
	}
Java Code:
protected DataBindingContext initDataBindings() {
		ObservableListTreeContentProvider contentProvider = new MainViewContentProvider();
		treeViewer.setContentProvider(contentProvider);
		treeViewer.setLabelProvider(new MainViewLabelProvider(contentProvider
				.getKnownElements()));

		projectsList = new WritableList(model.readProjects(), Project.class);			
		treeViewer.setInput(projectsList);

		DataBindingContext bindingContext = new DataBindingContext();
                return bindingContext;
My ContentProvider
Java Code:
public class MainViewContentProvider extends ObservableListTreeContentProvider {
	
	public MainViewContentProvider() {
		super(getObservableListFactory(), null);
	}
	
	private static IObservableFactory getObservableListFactory() {
		return new IObservableFactory() {
			@Override
			public IObservable createObservable(Object target) {
			    if (target instanceof IObservableList) {
			      return (IObservable)target;
			    }
			    if (target instanceof ProjectsModel) {
			    	return BeanProperties.list("projects").observe(target);
			    }
			    if (target instanceof Project) {
			    	return BeanProperties.list("stocks").observe(target);
			    }
			    return null;	   
			}
		};
	}
 
	@Override
	public boolean hasChildren(Object element) {
	  if (element instanceof List<?>)
            return ((List<?>) element).size() > 0;

	   if (element instanceof Project)
	    return ((Project) element).getStocks().size() > 0;
	   return false;

	   }
 
}
My LabelProvider
Java Code:
public class MainViewLabelProvider extends ObservableMapLabelProvider{
 
	
	public MainViewLabelProvider(IObservableSet knownElements) {
		super(Properties.observeEach(knownElements,
				BeanProperties.values( new String[] {"name",
						"identifier"  })));
	}

	@Override
	public String getText(Object element) {
		String text = new String();
		
		if (element instanceof Project) {	
			text = (((Project) element).getName() + " ( " +((Project) element).getStocks().size() + " ) ");
			return text;
		}
		if (element instanceof Stock) {
			return ((Stock) element).getIdentifier();
		}
		return null;
	}
	
	@Override
	public Image getImage(Object element) {
		if (element instanceof Project)
		{	
			return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
		}
		if (element instanceof Stock) {
			return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
		}
		return null;
	}
}
Thanks for any help :)