Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » selection stores the last element when an exception occurs(how to make the application recover from an exception?)
selection stores the last element when an exception occurs [message #515763] Sat, 20 February 2010 15:30
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
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;
		Iterator<BusinessObject> selectionIterator = selection.iterator();
		while( selectionIterator.hasNext() )
		    selectedObject =;

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.
Previous Topic:virtual tables, DAOs and the Job API: how to combine?
Next Topic:Adding a search box to main toolbar ?
Goto Forum:

Current Time: Sat May 26 02:45:34 GMT 2018

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

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

Back to the top