selection stores the last element when an exception occurs [message #515763] |
Sat, 20 February 2010 15:30 |
Luca Ferrari Messages: 159 Registered: November 2009 |
Senior Member |
|
|
Hello,
in my rcp application I've got a command that reacts differently depending on the user selection against a table. I've noted that if an exception occurs during the application usage, the selection stores the last element selected before the exception arised, even if the user changes its selection. To make it clearer this is the scenario:
- user selects row A
- an exception occurs (e.g., runtime exception due to network problems)
- user selects row B
- the command receives the selection, but it still has row A as first element
- user selects row C
- the command receives the selection, but it has row B (not C) as first element
It is like the selection, after the exeption, points to the previously selected elements and remains fixed to the previous-to-last selected element for every future selection.
I suspect that the selection does not get flushed due to the exception, so I tried to make a safe cycle in my command code as follows:
public Object execute(ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
// if the selection is empty I cannot proceed
if( selection.isEmpty() ){
return null;
}
else{
Iterator<BusinessObject> selectionIterator = selection.iterator();
while( selectionIterator.hasNext() )
selectedObject = selectionIterator.next();
}
However this does not work: the selection still returns the previous selected element. I'd like to understand why there is such behavior and how can I correct it.
|
|
|
Powered by
FUDForum. Page generated in 0.03369 seconds