[Databinding] Probleme beim Binding von mehreren Listviewern un Comboviewern

gerritka

Mitglied
Hi,

ich hab Probleme mit der neuen Databinding Bibliothek von JFace (bekommt man ausm CVS bei eclipse.org).

Die Objekte/Klassen die beteiligt sind:
"Scenario": enthält ArrayList<Station>
"Station": enthält ArrayList<Host> und ArrayList<Cluster>
"Host": enthält keine Referenzen zu anderen Objekten
"Cluster": enhält die Referenz zu einem Host der in der Station verfügbar ist.

Insgesamt gibt es drei Listen mit Listviewern:
1. Stationen
2. Hosts
3. Cluster

Zu der Cluster-Liste gehört noch eine ComboBox, die immer alle Hosts einer Station enthält.
Folgendes Problem besteht jedoch:
Wenn ich zwei Stationen der Liste hinzufüge, dann der ersten Station einen Host und einen Cluster mit der Referenz zu dem Host hinzufüge und dann zu der zweiten Station wechsle, die noch keinen Host bzw. Cluster hat, wird die Referenz vom Cluster zum Host der ersten Station gelöscht. Grund hierfür ist (was ich durch Debugging herausfinden konnte), dass wenn man die Station wechselt die Listen in mehreren Threads aktualisiert werden. Wenn nun die Host Liste als erstes aktualisiert wird (und damit auch die Combobox für die Cluster) werden in diesem Fall alle Elemente gelöscht und damit auch die Referenz beim Cluster zum Host, da die Liste der Cluster noch nicht aktualisiert wurde. Frage wäre nun wie ich das verhindern könnte?

Anbei der Code fürs Binding:

Code:
// bind the stations of the scenario to the station-list
bindingContext.bind(stationsViewer,
    new ListModelDescription(new Property(scenario, "stations",
            Station.class, Boolean.TRUE), "name"), null);

// and make an obversable for the selected station
IObservable selectedStation = bindingContext.createObservable(new Property(
    stationsViewer, ViewersProperties.SINGLE_SELECTION,
    Station.class, Boolean.FALSE));
    
// bind the hosts of selected station to the host-list
bindingContext.bind(hostsViewer,
    new ListModelDescription(new Property(selectedStation, "hosts",
            Host.class, Boolean.TRUE), "name"), null);
                        
// and make an obversable for the selected host
IObservable selectedHost = bindingContext.createObservable(new Property(
    hostsViewer, ViewersProperties.SINGLE_SELECTION, Host.class,
    Boolean.FALSE));
    
// bind the cluster of the selected station to the cluster-list
bindingContext.bind(mySqlClusterViewer, new ListModelDescription(
    new Property(selectedStation, "mySqlCluster",
    MySqlCluster.class, Boolean.TRUE), "name"), null);
    
// and make an obversable for the selected cluster
IObservable selectedCluster = bindingContext.createObservable(new Property(
    mySqlClusterViewer, ViewersProperties.SINGLE_SELECTION,
    MySqlCluster.class, Boolean.FALSE));
    
// bind the hosts of the selceted station to a combobox from the cluster
// where i can select an host for the cluster
bindingContext.bind(new Property(
    comClusterProperties.getCobvHost(), ViewersProperties.CONTENT),
    new ListModelDescription(new Property(selectedStation, "hosts",
    Host.class, Boolean.TRUE), "name"), null);
    
// bind the selected host from the combobox with the host-Property 
// from the selected cluster
bindingContext.bind(new Property(
    comClusterProperties.getCobvHost(),
    ViewersProperties.SINGLE_SELECTION), new Property(
    selectedCluster, "host", Host.class, Boolean.FALSE), null);
 
Zurück