I have Part
containing a TreeViewer
with Node
s and each Node
has a name
property. I have a text field to edit the name of the currently selected node. I have bound the current selection and this text field as below:
IViewerObservableValue observedElementSingleSelection = ViewersObservables
.observeSingleSelection(treeViewer);
IObservableValue detailValue = PojoProperties.value(Node.PROPERTY_NAME, String.class)
.observeDetail(observedElementSingleSelection);
ISWTObservableValue observableNameText = WidgetProperties.text(SWT.Modify)
.observe(nameText);
dataBindingContext.bindValue(observableNameText, detailValue);
Now I would like to mark the part with this treeViewer
as dirty whenever the user edits the name of any Node
.
When this Part
opens the Node
s are retrieved from the database and the tree is created. If I add a ModifyListener
to the text field to mark the Part dirty then on initial loading the Part
is marked dirty, which I do not want. Is there any way to mark the Part
dirty only when the user edits the name of any Node
but not at the time of initial loading?
I have tried to set UpdateStrategy
so that the data binding is one-way i.e. only from view to model, but then on selection the Node
name does not appear in the text field.
I have tried with KeyListener
, but then I have to filter all non-printable keys to mark the Part
as dirty. Is there any better solution?