|Detecting unsaved changes in a plugin view [message #1061750]
||Mon, 03 June 2013 18:36
| Joseph Gagnon
Registered: June 2013
I am working on a project where we are using eclipse RCP and JavaFX to provide the user interface. Additionally, we are required to use a framework that extends eclipse RCP and provides its own API on top of the RCP API. The application usage model from a high-level perspective is that major application functions are provided as separate perspectives with view extensions making up the main window(s) of the function. The usage of the view part appears to be the workhorse component provided by the 3rd party framework. They do not appear to have extended the editor part functionality in any way and I do not know whether editors still work as they would in "normal" RCP or if support has been altered in any way.|
Many views are for the most part read-only, but as we add more functionality, we are running into capability that requires user input and interaction, which will be saved to a database on the back end. I am trying to figure out how to detect when the user initiates the closing of something (application, perspective, etc.) in order to intercept that event, prompt the user if there are unsaved changes and allow them to choose to attempt a save or to discard their edits. In other words, I'd like to be able to stop the close from occurring unless there are no unsaved changes. If the user chooses to continue closing, they lose their edits and the close proceeds. If not, an attempt is made to validate and save their edits. If all goes well, the close then proceeds to completion.
I have poked around in the API as well as done web searches in an attempt to find information on how I could do this, to no avail. It seems to be one of those classic cases of "you can't get there from here". I have tried attaching various listeners and the API has some overridden methods, but in all cases, by the time the listener/method gets notified, the close has already taken place and it's too late.
The other difficulty I'm running into is that, even if I can find a way to intercept the closing event early enough to matter, I don't know how to gain access to the "inner" logic in the plugin (i.e. to get to the view model logic in order to do the data validation and save). My experimentation to this point has been in the plugin activator class and I don't how to get at the plugin's internals.
Keep in mind that we are also using JavaFX, so there is another layer of code and complexity in the mix. Each of our views consist of a view part (the RCP component) which then creates a JavaFX FXCanvas that provides the capability to interface eclipse RCP and SWT with JavaFX. The FXCanvas contains all of the UI code that makes up the screen view. The view part class has knowledge of the canvas class, the view model class and a "manager" class that provides asynchronous launching of background jobs (to web services) and receiving notification of job completion (and other events) via an event bus. My impression is that the RCP/JavaFX mixture should not present difficulties in regard to this, it's more for informational purposes.
I am by no means an eclipse RCP "expert". I have several years experience working on applications written to make use of eclipse RCP, but the technology itself is still pretty much a mystery to me. There's a lot there and it's very difficult sometimes to figure out how to do what's needed.
PC platform running windows 7
Eclipse Indigo (required by client)
Any ideas and suggestions are welcome and appreciated.
Powered by FUDForum
. Page generated in 0.01866 seconds