Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Bind selected Observable to TreeViewer
Bind selected Observable to TreeViewer [message #654384] Tue, 15 February 2011 13:58 Go to next message
Eclipse User
Originally posted by: quincy.cs.gmail.com

This is a multi-part message in MIME format.

------=_NextPart_000_000B_01CBCD5B.8A4692B0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable

I came across a question when trying to isolate an unrelated bug.

I'm trying to change Snippet018CheckboxTableViewerCheckedSelection into =
a treeviewer example of a similar concept.

To explain Snippet018CheckboxTableViewerCheckedSelection's concept in =
order to contrast/compare,

First, a table with two columns: name of people, and list of friends. =
So this first table depicts all people and their respective friends.
Second, a table with one column which is just the names of all people. =
Each name has a checkbox.

The concept is after selecting a person's name from the first table, the =
second table is filled with the respective checks for the friends of the =
selected person. In other words, modify a selected person's friends.

------------
Ok now what I want.

I want to keep the first table. The second, I want to modify. =20

The second table would instead contain a tree and is empty unless a =
person is selected. It still has one column and each row has a =
checkbox.

The concept is after selecting a person's name from the first table, the =
second table is filled with friend assignment possibilities which may =
differ from person to person. There would be a hierarchy where the =
first level is Company and second level is employees of that company. =
For all purposes a company is completely the same as a person. =20

Ok now to the technical issues. How do you bind the selection of the =
first table as the model which should display it=E2=80=99s friend =
assignment possibilities? Below is the fragment showing the binds I =
have tried. The first binding runs but has nothing to do with the =
selection of the first table. The second binding does not run because =
it throws a runtime error due to ViewerSupport trying to set the content =
provider of the viewer to =E2=80=98ObservableSetContentProvider=E2=80=99 =
then the viewer rejecting it in an assert:

Assert.isTrue(provider instanceof ITreeContentProvider
                || provider instanceof ITreePathContentProvider);


            /*
             * this runs, but NOT what I want.
             */
            ViewerSupport.bind(friendsTreeViewer, viewModelPplTree,=20
                    BeanProperties.set("friends",Person.class),=20
                    BeanProperties.value(Person.class, "name"));         =
  =20

            /*
             * this doesn't run, but it IS what I want.
             */
//            ViewerSupport.bind(friendsTreeViewer,=20
//                    =
BeansObservables.observeDetailSet(selectedPerson,"friends",Person.class),=

//                    BeanProperties.value(Person.class, "name"));


FINALLY THE QUESTION,
Is it possible then to bind a selected observable to a treeviewer?

Below is the full snippet.


import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.ComputedValue;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.databinding.viewers.ViewerSupport;
import org.eclipse.jface.databinding.viewers.ViewersObservables;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.layout.TableColumnLayout;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;

public class SnippetCheckboxTreeViewerCheckedSelection {

    public static void main(String[] args) {
        // The SWT event loop
        final Display display =3D Display.getDefault();
        Realm.runWithDefault(SWTObservables.getRealm(display), new =
Runnable() {
            public void run() {
                ViewModel viewModel =3D createSampleModel();
                ViewModelPeopleTree viewModelPplTree =3D new =
ViewModelPeopleTree();
                viewModelPplTree.setFriends(new =
HashSet(viewModel.getPeople()));

                Shell shell =3D new =
View(viewModel,viewModelPplTree).createShell();
                shell.open();
                while (!shell.isDisposed())
                    if (!display.readAndDispatch())
                        display.sleep();
            }
        });
        display.dispose();
    }

    private static ViewModel createSampleModel() {
        ViewModel viewModel =3D new ViewModel();

        Person stan =3D createPerson("Stan");
        Person kyle =3D createPerson("Kyle");
        Person eric =3D createPerson("Eric");
        Person kenny =3D createPerson("Kenny");
        Person wendy =3D createPerson("Wendy");
        Person butters =3D createPerson("Butters");

        setFriends(stan, new Person[] { kyle, eric, kenny, wendy });
        setFriends(kyle, new Person[] { stan, eric, kenny });
        setFriends(eric, new Person[] { eric });
        setFriends(kenny, new Person[] { stan, kyle, eric });
        setFriends(wendy, new Person[] { stan });
        setFriends(butters, new Person[0]);

        Person[] people =3D new Person[] { stan, kyle, eric, kenny, =
wendy,
                butters };
        viewModel.setPeople(Arrays.asList(people));
        return viewModel;
    }

    private static Person createPerson(String name) {
        Person person =3D new Person();
        person.setName(name);
        return person;
    }

    private static void setFriends(Person person, Person[] friends) {
        person.setFriends(new HashSet(Arrays.asList(friends)));
    }

    // Minimal JavaBeans support
    public static abstract class AbstractModelObject {
        private PropertyChangeSupport propertyChangeSupport =3D new =
PropertyChangeSupport(
                this);

        public void addPropertyChangeListener(PropertyChangeListener =
listener) {
            propertyChangeSupport.addPropertyChangeListener(listener);
        }

        public void addPropertyChangeListener(String propertyName,
                PropertyChangeListener listener) {
            =
propertyChangeSupport.addPropertyChangeListener(propertyName,
                    listener);
        }

        public void removePropertyChangeListener(PropertyChangeListener =
listener) {
            =
propertyChangeSupport.removePropertyChangeListener(listener);
        }

        public void removePropertyChangeListener(String propertyName,
                PropertyChangeListener listener) {
            =
propertyChangeSupport.removePropertyChangeListener(propertyName,
                    listener);
        }

        protected void firePropertyChange(String propertyName, Object =
oldValue,
                Object newValue) {
            propertyChangeSupport.firePropertyChange(propertyName, =
oldValue,
                    newValue);
        }
    }

    // The data model class.
    static class Person extends AbstractModelObject {
        private String name;
        private Set friends =3D new HashSet();
        private Set<Person>    children;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            firePropertyChange("name", this.name, this.name =3D name);
        }

        public Set getFriends() {
            return new HashSet(friends);
        }

        public void setFriends(Set friends) {
            firePropertyChange("friends", this.friends,
                    this.friends =3D new HashSet(friends));
        }
       =20
        public String toString() {
//            String str =3D name ;
//            if(getChildren()!=3Dnull && getChildren().size()>0){
//                str +=3D " children {";
//               =20
//                for(Person child : getChildren()){
//                    str +=3D " [" + child.getName() +"] ";
//                }
//               =20
//                str +=3D "}";
//            }
//           =20
            return name;
        }
    }

    static class ViewModel extends AbstractModelObject {
        private List people =3D new ArrayList();

        public List getPeople() {
            return new ArrayList(people);
        }

        public void setPeople(List people) {
            firePropertyChange("people", this.people,
                    this.people =3D new ArrayList(people));
        }
    }
   =20
    static class ViewModelPeopleTree extends Person {
       =20
    }

    // The GUI view
    static class View {
        private ViewModel viewModel;

        private Shell shell;

        private TableViewer peopleViewer;
        private Text personName;
        private CheckboxTreeViewer friendsTreeViewer;

        private ViewModelPeopleTree    viewModelPplTree;

        public View(ViewModel viewModel, ViewModelPeopleTree =
viewModelPplTree) {
            this.viewModel =3D viewModel;
            this.viewModelPplTree =3D viewModelPplTree;
        }

        public Shell createShell() {
            // Build a UI
            final Display display =3D Display.getCurrent();
            shell =3D new Shell(display);

            createUI(shell);

            // Bind UI
            bindUI();

            // Open and return the Shell
            shell.setSize(shell.computeSize(400, SWT.DEFAULT));
            shell.open();
            return shell;
        }

        private void createUI(Shell shell) {
            shell.setText("Binding checked elements in =
CheckboxTableViewer");
            shell.setLayout(new GridLayout(2, false));

            new Label(shell, SWT.NONE).setText("People");

            Composite peopleComposite =3D new Composite(shell, =
SWT.NONE);
            GridDataFactory.fillDefaults().grab(true, true).span(2, =
1).applyTo(
                    peopleComposite);
            TableColumnLayout peopleColumnLayout =3D new =
TableColumnLayout();
            peopleComposite.setLayout(peopleColumnLayout);

            peopleViewer =3D new TableViewer(peopleComposite, SWT.SINGLE
                    | SWT.BORDER | SWT.FULL_SELECTION);

            Table peopleTable =3D peopleViewer.getTable();
            peopleTable.setHeaderVisible(true);
            peopleTable.setLinesVisible(true);

            TableColumn nameColumn =3D new TableColumn(peopleTable, =
SWT.NONE);
            nameColumn.setText("Name");
            peopleColumnLayout.setColumnData(nameColumn,
                    new ColumnWeightData(1));

            TableColumn friendsColumn =3D new TableColumn(peopleTable, =
SWT.NONE);
            friendsColumn.setText("Friends");
            peopleColumnLayout.setColumnData(friendsColumn,
                    new ColumnWeightData(3));

            new Label(shell, SWT.NONE).setText("Name");

            personName =3D new Text(shell, SWT.BORDER);
            GridDataFactory.fillDefaults().grab(true, false)
                    .applyTo(personName);

            new Label(shell, SWT.NONE).setText("Friends");

            Composite friendsComposite =3D new =
Composite(shell,SWT.NONE);
            friendsComposite.setLayoutData(new =
GridData(GridData.FILL_BOTH));
            friendsComposite.setLayout(new GridLayout(1, false));        =


            friendsTreeViewer =3D new =
CheckboxTreeViewer(friendsComposite);

            Tree friendsTree =3D friendsTreeViewer.getTree();
            friendsTree.setHeaderVisible(true);
            friendsTree.setLinesVisible(true);
            TreeColumn friendNameColumn =3D new TreeColumn(friendsTree,
                    SWT.NONE);
            friendNameColumn.setText("Name");
            friendNameColumn.setWidth(100);
        }

        private void bindUI() {
            DataBindingContext dbc =3D new DataBindingContext();

            final IObservableList people =3D =
BeansObservables.observeList(Realm
                    .getDefault(), viewModel, "people");
           =20
            ViewerSupport.bind(peopleViewer, people, =
BeanProperties.values(
                    Person.class, new String[] { "name", "friends" }));

            final IObservableValue selectedPerson =3D ViewersObservables
                    .observeSingleSelection(peopleViewer);

            dbc.bindValue(SWTObservables.observeText(personName, =
SWT.Modify),
                    BeansObservables.observeDetailValue(selectedPerson, =
"name",
                            String.class));

            /*
             * original binding for table.
             */
//            ViewerSupport.bind(friendsTreeViewer, people, =
BeanProperties.value(
//                    Person.class, "name"));

            /*
             * this runs, but not what I want.
             */
            ViewerSupport.bind(friendsTreeViewer, viewModelPplTree,=20
                    BeanProperties.set("friends",Person.class),=20
                    BeanProperties.value(Person.class, "name"));         =
  =20

            /*
             * this doesn't run, but its what I want.
             */
//            ViewerSupport.bind(friendsTreeViewer,=20
//                    =
BeansObservables.observeDetailSet(selectedPerson,"friends",Person.class),=

//                    BeanProperties.value(Person.class, "name"));
           =20
            //no change
            dbc.bindSet(ViewersObservables.observeCheckedElements(
                    friendsTreeViewer, Person.class), BeansObservables
                    .observeDetailSet(selectedPerson, "friends", =
Person.class));
           =20
        }
    }
}


------=_NextPart_000_000B_01CBCD5B.8A4692B0
Content-Type: text/html;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<HTML><HEAD></HEAD>
<BODY dir=3Dltr>
<DIV dir=3Dltr>
<DIV style=3D"FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV>I came across a question when trying to isolate an unrelated =
bug.</DIV>
<DIV>&nbsp;</DIV>
<DIV>I'm trying to change Snippet018CheckboxTableViewerCheckedSelection =
into a=20
treeviewer example of a similar concept.</DIV>
<DIV>&nbsp;</DIV>
<DIV>To explain Snippet018CheckboxTableViewerCheckedSelection's concept =
in order=20
to contrast/compare,</DIV>
<DIV>&nbsp;</DIV>
<DIV>First, a table with two columns: name of people, and list of =
friends.&nbsp;=20
So this first table depicts all people and their respective =
friends.</DIV>
<DIV>Second, a table with one column which is just the names of all=20
people.&nbsp; Each name has a checkbox.</DIV>
<DIV>&nbsp;</DIV>
<DIV>The concept is after selecting a person's name from the first =
table, the=20
second table is filled with the respective checks for the friends of the =

selected person.&nbsp; In other words, modify a selected person's =
friends.</DIV>
<DIV>&nbsp;</DIV>
<DIV>------------</DIV>
<DIV>Ok now what I want.</DIV>
<DIV>&nbsp;</DIV>
<DIV>I want to keep the first table.&nbsp; The second, I want to =
modify.&nbsp;=20
</DIV>
<DIV>&nbsp;</DIV>
<DIV>The second table would instead contain a tree and is empty unless a =
person=20
is selected.&nbsp; It still has one column and each row has a =
checkbox.</DIV>
<DIV>&nbsp;</DIV>
<DIV>The concept is after selecting a person's name from the first =
table, the=20
second table is filled with friend assignment possibilities which may =
differ=20
from person to person.&nbsp; There would be a hierarchy where the first =
level is=20
Company and second level is employees of that company.&nbsp; For all =
purposes a=20
company is completely the same as a person.&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>Ok now to the technical issues.&nbsp; How do you bind the selection =
of the=20
first table as the model which should display it=E2=80=99s friend =
assignment=20
possibilities?&nbsp; Below is the fragment showing the binds I have =
tried.&nbsp;=20
The first binding runs but has nothing to do with the selection of the =
first=20
table.&nbsp; The second binding does not run because it throws a runtime =
error=20
due to ViewerSupport trying to set the content provider of the viewer to =

=E2=80=98ObservableSetContentProvider=E2=80=99 then the viewer rejecting =
it in an assert:</DIV>
<DIV>&nbsp;</DIV>
<DIV>
</DIV>
<DIV>Assert.isTrue(provider instanceof ITreeContentProvider</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
|| provider instanceof ITreePathContentProvider);</DIV>
<DIV>
</DIV>
<DIV>&nbsp;</DIV>
<DIV>
</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
/*</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; *=20
this runs, but NOT what I want.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;=20
*/</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
ViewerSupport.bind(friendsTreeViewer, viewModelPplTree, </DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
BeanProperties.set("friends",Person.class), </DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
BeanProperties.value(Person.class,=20
"name"));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
/*</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; *=20
this doesn't run, but it IS what I want.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;=20
*/</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
=20
ViewerSupport.bind(friendsTreeViewer, </DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
BeansObservables.observeDetailSet(selectedPerson,"friends",Person.class),=
</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
BeanProperties.value(Person.class, "name"));</DIV>
<DIV>
</DIV>
<DIV>&nbsp;</DIV>
<DIV>FINALLY THE QUESTION,</DIV>
<DIV>Is it possible then to bind a selected observable to a =
treeviewer?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Below is the full snippet.</DIV>
<DIV>&nbsp;</DIV>
<DIV>
</DIV>
<DIV>&nbsp;</DIV>
<DIV>import java.beans.PropertyChangeListener;</DIV>
<DIV>import java.beans.PropertyChangeSupport;</DIV>
<DIV>import java.util.ArrayList;</DIV>
<DIV>import java.util.Arrays;</DIV>
<DIV>import java.util.HashSet;</DIV>
<DIV>import java.util.List;</DIV>
<DIV>import java.util.Set;</DIV>
<DIV>&nbsp;</DIV>
<DIV>import org.eclipse.core.databinding.DataBindingContext;</DIV>
<DIV>import org.eclipse.core.databinding.beans.BeanProperties;</DIV>
<DIV>import org.eclipse.core.databinding.beans.BeansObservables;</DIV>
<DIV>import org.eclipse.core.databinding.observable.Realm;</DIV>
<DIV>import =
org.eclipse.core.databinding.observable.list.IObservableList;</DIV>
<DIV>import =
org.eclipse.core.databinding.observable.value.ComputedValue;</DIV>
<DIV>import=20
org.eclipse.core.databinding.observable.value.IObservableValue;</DIV>
<DIV>import org.eclipse.jface.databinding.swt.SWTObservables;</DIV>
<DIV>import org.eclipse.jface.databinding.viewers.ViewerSupport;</DIV>
<DIV>import =
org.eclipse.jface.databinding.viewers.ViewersObservables;</DIV>
<DIV>import org.eclipse.jface.dialogs.IInputValidator;</DIV>
<DIV>import org.eclipse.jface.dialogs.InputDialog;</DIV>
<DIV>import org.eclipse.jface.dialogs.MessageDialog;</DIV>
<DIV>import org.eclipse.jface.layout.GridDataFactory;</DIV>
<DIV>import org.eclipse.jface.layout.GridLayoutFactory;</DIV>
<DIV>import org.eclipse.jface.layout.TableColumnLayout;</DIV>
<DIV>import org.eclipse.jface.viewers.CheckboxTableViewer;</DIV>
<DIV>import org.eclipse.jface.viewers.CheckboxTreeViewer;</DIV>
<DIV>import org.eclipse.jface.viewers.ColumnWeightData;</DIV>
<DIV>import org.eclipse.jface.viewers.IStructuredSelection;</DIV>
<DIV>import org.eclipse.jface.viewers.StructuredSelection;</DIV>
<DIV>import org.eclipse.jface.viewers.TableViewer;</DIV>
<DIV>import org.eclipse.jface.window.Window;</DIV>
<DIV>import org.eclipse.swt.SWT;</DIV>
<DIV>import org.eclipse.swt.layout.GridData;</DIV>
<DIV>import org.eclipse.swt.layout.GridLayout;</DIV>
<DIV>import org.eclipse.swt.widgets.Button;</DIV>
<DIV>import org.eclipse.swt.widgets.Composite;</DIV>
<DIV>import org.eclipse.swt.widgets.Display;</DIV>
<DIV>import org.eclipse.swt.widgets.Event;</DIV>
<DIV>import org.eclipse.swt.widgets.Label;</DIV>
<DIV>import org.eclipse.swt.widgets.Listener;</DIV>
<DIV>import org.eclipse.swt.widgets.Shell;</DIV>
<DIV>import org.eclipse.swt.widgets.Table;</DIV>
<DIV>import org.eclipse.swt.widgets.TableColumn;</DIV>
<DIV>import org.eclipse.swt.widgets.Text;</DIV>
<DIV>import org.eclipse.swt.widgets.Tree;</DIV>
<DIV>import org.eclipse.swt.widgets.TreeColumn;</DIV>
<DIV>&nbsp;</DIV>
<DIV>public class SnippetCheckboxTreeViewerCheckedSelection {</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; public static void main(String[] args) {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // The SWT event =
loop</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; final Display display =
=3D=20
Display.getDefault();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() =
{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
public=20
void run() {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
ViewModel viewModel =3D createSampleModel();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
ViewModelPeopleTree viewModelPplTree =3D new =
ViewModelPeopleTree();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
viewModelPplTree.setFriends(new HashSet(viewModel.getPeople()));</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
Shell shell =3D new =
View(viewModel,viewModelPplTree).createShell();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
shell.open();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
while (!shell.isDisposed())</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
if (!display.readAndDispatch())</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
display.sleep();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; display.dispose();</DIV>
<DIV>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; private static ViewModel createSampleModel() =
{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ViewModel viewModel =3D =
new=20
ViewModel();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Person stan =3D=20
createPerson("Stan");</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Person kyle =3D=20
createPerson("Kyle");</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Person eric =3D=20
createPerson("Eric");</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Person kenny =3D=20
createPerson("Kenny");</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Person wendy =3D=20
createPerson("Wendy");</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Person butters =3D=20
createPerson("Butters");</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setFriends(stan, new =
Person[] {=20
kyle, eric, kenny, wendy });</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setFriends(kyle, new =
Person[] {=20
stan, eric, kenny });</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setFriends(eric, new =
Person[] {=20
eric });</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setFriends(kenny, new =
Person[] {=20
stan, kyle, eric });</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setFriends(wendy, new =
Person[] {=20
stan });</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setFriends(butters, new=20
Person[0]);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Person[] people =3D new =
Person[] {=20
stan, kyle, eric, kenny, wendy,</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
butters };</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
viewModel.setPeople(Arrays.asList(people));</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return viewModel;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; private static Person createPerson(String name) =
{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Person person =3D new=20
Person();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
person.setName(name);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return person;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; private static void setFriends(Person person, =
Person[]=20
friends) {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; person.setFriends(new=20
HashSet(Arrays.asList(friends)));</DIV>
<DIV>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; // Minimal JavaBeans support</DIV>
<DIV>&nbsp;&nbsp;&nbsp; public static abstract class AbstractModelObject =
{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private =
PropertyChangeSupport=20
propertyChangeSupport =3D new PropertyChangeSupport(</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
this);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void=20
addPropertyChangeListener(PropertyChangeListener listener) {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
propertyChangeSupport.addPropertyChangeListener(listener);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void=20
addPropertyChangeListener(String propertyName,</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
PropertyChangeListener listener) {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
propertyChangeSupport.addPropertyChangeListener(propertyName,</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
listener);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void=20
removePropertyChangeListener(PropertyChangeListener listener) {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
propertyChangeSupport.removePropertyChangeListener(listener);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void=20
removePropertyChangeListener(String propertyName,</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
PropertyChangeListener listener) {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
propertyChangeSupport.removePropertyChangeListener(propertyName,</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
listener);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected void=20
firePropertyChange(String propertyName, Object oldValue,</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
Object newValue) {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
propertyChangeSupport.firePropertyChange(propertyName, oldValue,</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
newValue);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; // The data model class.</DIV>
<DIV>&nbsp;&nbsp;&nbsp; static class Person extends AbstractModelObject =
{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private String =
name;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private Set friends =3D =
new=20
HashSet();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private=20
Set&lt;Person&gt;&nbsp;&nbsp;&nbsp; children;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public String getName() =
{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
return=20
name;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void =
setName(String name)=20
{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
firePropertyChange("name", this.name, this.name =3D name);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Set getFriends() =
{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
return=20
new HashSet(friends);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void =
setFriends(Set=20
friends) {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
firePropertyChange("friends", this.friends,</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
this.friends =3D new HashSet(friends));</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public String toString() =
{</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 String=20
str =3D name ;</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
=20
if(getChildren()!=3Dnull &amp;&amp; getChildren().size()&gt;0){</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
str +=3D " children {";</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
for(Person child : getChildren()){</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
str +=3D " [" + child.getName() +"] ";</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
}</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
str +=3D "}";</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
=20
}</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 </DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
return=20
name;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; static class ViewModel extends =
AbstractModelObject=20
{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private List people =3D =
new=20
ArrayList();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public List getPeople() =
{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
return=20
new ArrayList(people);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void =
setPeople(List=20
people) {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
firePropertyChange("people", this.people,</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
this.people =3D new ArrayList(people));</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; static class ViewModelPeopleTree extends Person =
{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; // The GUI view</DIV>
<DIV>&nbsp;&nbsp;&nbsp; static class View {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private ViewModel=20
viewModel;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private Shell =
shell;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private TableViewer=20
peopleViewer;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private Text =
personName;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private =
CheckboxTreeViewer=20
friendsTreeViewer;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private=20
ViewModelPeopleTree&nbsp;&nbsp;&nbsp; viewModelPplTree;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public View(ViewModel =
viewModel,=20
ViewModelPeopleTree viewModelPplTree) {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
this.viewModel =3D viewModel;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
this.viewModelPplTree =3D viewModelPplTree;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Shell =
createShell()=20
{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
// Build=20
a UI</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
final=20
Display display =3D Display.getCurrent();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
shell =3D=20
new Shell(display);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
createUI(shell);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
// Bind=20
UI</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
bindUI();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
// Open=20
and return the Shell</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
shell.setSize(shell.computeSize(400, SWT.DEFAULT));</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
shell.open();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
return=20
shell;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void =
createUI(Shell=20
shell) {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
shell.setText("Binding checked elements in CheckboxTableViewer");</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
shell.setLayout(new GridLayout(2, false));</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
new=20
Label(shell, SWT.NONE).setText("People");</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Composite peopleComposite =3D new Composite(shell, SWT.NONE);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
GridDataFactory.fillDefaults().grab(true, true).span(2, =
1).applyTo(</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
peopleComposite);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
TableColumnLayout peopleColumnLayout =3D new TableColumnLayout();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
peopleComposite.setLayout(peopleColumnLayout);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
peopleViewer =3D new TableViewer(peopleComposite, SWT.SINGLE</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
| SWT.BORDER | SWT.FULL_SELECTION);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Table=20
peopleTable =3D peopleViewer.getTable();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
peopleTable.setHeaderVisible(true);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
peopleTable.setLinesVisible(true);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
TableColumn nameColumn =3D new TableColumn(peopleTable, SWT.NONE);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
nameColumn.setText("Name");</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
peopleColumnLayout.setColumnData(nameColumn,</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
new ColumnWeightData(1));</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
TableColumn friendsColumn =3D new TableColumn(peopleTable, =
SWT.NONE);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
friendsColumn.setText("Friends");</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
peopleColumnLayout.setColumnData(friendsColumn,</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
new ColumnWeightData(3));</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
new=20
Label(shell, SWT.NONE).setText("Name");</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
personName =3D new Text(shell, SWT.BORDER);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
GridDataFactory.fillDefaults().grab(true, false)</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
..applyTo(personName);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
new=20
Label(shell, SWT.NONE).setText("Friends");</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Composite friendsComposite =3D new Composite(shell,SWT.NONE);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
friendsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
friendsComposite.setLayout(new GridLayout(1,=20
false));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
friendsTreeViewer =3D new CheckboxTreeViewer(friendsComposite);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Tree=20
friendsTree =3D friendsTreeViewer.getTree();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
friendsTree.setHeaderVisible(true);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
friendsTree.setLinesVisible(true);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
TreeColumn friendNameColumn =3D new TreeColumn(friendsTree,</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
SWT.NONE);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
friendNameColumn.setText("Name");</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
friendNameColumn.setWidth(100);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void bindUI() =
{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
DataBindingContext dbc =3D new DataBindingContext();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
final=20
IObservableList people =3D BeansObservables.observeList(Realm</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
..getDefault(), viewModel, "people");</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
ViewerSupport.bind(peopleViewer, people, BeanProperties.values(</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Person.class, new String[] { "name", "friends" }));</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
final=20
IObservableValue selectedPerson =3D ViewersObservables</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
..observeSingleSelection(peopleViewer);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
dbc.bindValue(SWTObservables.observeText(personName, SWT.Modify),</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
BeansObservables.observeDetailValue(selectedPerson, "name",</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;=20
String.class));</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
/*</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; *=20
original binding for table.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;=20
*/</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
=20
ViewerSupport.bind(friendsTreeViewer, people, =
BeanProperties.value(</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Person.class, "name"));</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
/*</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; *=20
this runs, but not what I want.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;=20
*/</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
ViewerSupport.bind(friendsTreeViewer, viewModelPplTree, </DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
BeanProperties.set("friends",Person.class), </DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
BeanProperties.value(Person.class,=20
"name"));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
/*</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; *=20
this doesn't run, but its what I want.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;=20
*/</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
=20
ViewerSupport.bind(friendsTreeViewer, </DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
BeansObservables.observeDetailSet(selectedPerson,"friends",Person.class),=
</DIV>
<DIV>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
BeanProperties.value(Person.class, "name"));</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
//no=20
change</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
dbc.bindSet(ViewersObservables.observeCheckedElements(</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
friendsTreeViewer, Person.class), BeansObservables</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
..observeDetailSet(selectedPerson, "friends", Person.class));</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>}</DIV>
<DIV>
</DIV>
<DIV>&nbsp;</DIV></DIV></DIV></BODY></HTML>

------=_NextPart_000_000B_01CBCD5B.8A4692B0--
Re: Bind selected Observable to TreeViewer [message #655037 is a reply to message #654384] Fri, 18 February 2011 06:23 Go to previous message
Matthew Hall is currently offline Matthew Hall
Messages: 368
Registered: July 2009
Senior Member
On 02/15/2011 06:58 AM, Quincy Mitchell wrote:
> /*
> * this runs, but NOT what I want.
> */
> ViewerSupport.bind(friendsTreeViewer, viewModelPplTree,
> BeanProperties.set("friends",Person.class),
> BeanProperties.value(Person.class, "name"));
> /*
> * this doesn't run, but it IS what I want.
> */
> // ViewerSupport.bind(friendsTreeViewer,
> // BeansObservables.observeDetailSet(selectedPerson,"friends",Person.class),
> // BeanProperties.value(Person.class, "name"));
> [/code]

If I understand what you're trying to do, I think you want:

ViewerSupport.bind(friendsTreeViewer, selectedPerson,
BeanProperties.set("friends", Person.class),
BeanProperties.value(Person.class, "name"));

Where selectedPerson is an IObservableValue that observes the selection
of the left-hand table.

Is this what you're looking for?

Matthew
Previous Topic:Multiple ApplicationWindow-instances?
Next Topic:Showing log file in TextViewer
Goto Forum:
  


Current Time: Wed Oct 22 08:07:33 GMT 2014

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

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