IAdapterFactory for expensive adaptable?
In our RCP application we have views which require a C
, and use an IAdapterFactory
to get there from an 开发者_运维问答A
and B
. The problem is that while A->C
is fast, B->C
is much slower (e.g., a database or file-system look-up) and should be done in a UI job.
We thought about using a CProxy
or LightweightC
and asking the proxy or a service for the real C
in a UI job, but this solution feels like it breaks the intended purpose of adapters since views will be required to know that they can't directly access a C
through the adapter factory.
Is there a best practice in this case, or am I forced to have my views understand that sometimes a more expensive conversion is necessary?
I would not use Adapters for expensive operations. In this scenario I'm passing A or B to the view that should visualize the adapted object (e.g. via SelectionService) and visualize a running operation in the target view, often with a progressmonitor in the upper right corner of the view that will visualize C, schedule the adapting operation (as non-ui job) and visualizing C. The advantage is that your UI is not blocked, you can call also your Adaptors in this job (via Platform.getAdapterManager().getAdapter(...)) and it's the most transparent way for the user IMHO.
精彩评论