开发者

Checking Data Binding's value in SWT/Jface

I am trying to bind my SWT UI to a test model in Java. The binding works. But the value is exactly the value from the model. So in a case if the model is a boolean and it returns true, it will appear literally as "true" on the UI widget, which isn't what I want to show my users. Is there a way where I can check the bound value before putting into the UI widget? Say if the model returns true, I check if the model value was true then decide to show on my label as "It is correct" otherwise "No it is wrong" if false.

Similarly, in a case if I have a label and I want to bind it to a model that returns the value of an account's credit balance, my label may already have some text that says "Your account has " and I wish I could just append THE_BOUND_VALUE to the label and not have the whole label's value overwritten by the model's value. Here's how I do my bindings:

IObservableValue tableViewer_myTestObserveSingleSelection = ViewersObservables.observeSingleSelection(tableViewer_myTest);
    IObservableList tableViewer_myTestDataContentObserveDetailList = Bean开发者_如何学运维sObservables.observeDetailList(tableViewer_myTestObserveSingleSelection, "DataContent", TestModelData.class);
    tableViewer_DataContent.setInput(tableViewer_myTestDataContentObserveDetailList);

These codes are generated from windowsbuilder pro in eclipse but somehow, I cannot use anything to modify the way bound value to the way I want to display on my UI.

Thanks for any help.


You can do conversion between types with Converters. Take a look at this example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜