Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » RCP closing view handle(RCP closing view handle)
RCP closing view handle [message #1019346] Fri, 15 March 2013 13:55 Go to next message
abc test is currently offline abc test
Messages: 4
Registered: January 2013
Junior Member
0 down vote favorite


In my Rcp application if user close a view all modified data not saved in to the project, inorder to avoid that implement ISavable part and override isSaveOnCloseNeeded() The pblm here is that it ask user any modification done while closing view.If click yes it sved modified data,but click no it again asking smeconfirmation window how avoid that my sample code like this public class ExplorerView extends CommonNavigator implements KeyListener, ISaveablePart, IProjectExplorerView {

@Override
public boolean isSaveOnCloseNeeded(){

if (true == isAnyProjectToSave()) {

MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(),
SWT.YES | SWT.NO
| SWT.ICON_WARNING);
messageBox.setText("Exit Explorer");
messageBox.setMessage("Do you want to save ]?");

int buttonID = messageBox.open();

if (SWT.YES == buttonID)
{
try
{
saveAll();


}
catch (Exception e)
{
e.printStackTrace();
}
}
if (SWT.NO == buttonID){

return false;

}
}

return false;
Re: RCP closing view handle [message #1021735 is a reply to message #1019346] Wed, 20 March 2013 15:41 Go to previous message
Wim Jongman is currently offline Wim Jongman
Messages: 418
Registered: July 2009
Senior Member
Hi abc,

Just implement ISaveablePart and flow with the framework.

Best regards,

Wim

> 0 down vote favorite
>
>
> In my Rcp application if user close a view all modified data not saved in
to the project, inorder to avoid that implement ISavable part and override
isSaveOnCloseNeeded() The pblm here is that it ask user any modification done
while closing view.If click yes it sved modified data,but click no it again
asking smeconfirmation window how avoid that my sample code like this public
class ExplorerView extends CommonNavigator implements KeyListener,
ISaveablePart, IProjectExplorerView {
>
> @Override
> public boolean isSaveOnCloseNeeded(){
>
> if (true == isAnyProjectToSave()) {
>
> MessageBox messageBox = new
MessageBox(Display.getCurrent().getActiveShell(),
> SWT.YES | SWT.NO
> | SWT.ICON_WARNING);
> messageBox.setText("Exit Explorer");
> messageBox.setMessage("Do you want to save ]?");
>
> int buttonID = messageBox.open();
>
> if (SWT.YES == buttonID)
> {
> try
> {
> saveAll();
>
>
> }
> catch (Exception e)
> {
> e.printStackTrace();
> }
> }
> if (SWT.NO == buttonID){
>
> return false;
>
> }
> }
>
> return false;
Previous Topic:java.lang.RuntimeException: Application could not be found in the registry
Next Topic:how to change colour of label in swt tree editor
Goto Forum:
  


Current Time: Sun Sep 21 18:18:31 GMT 2014

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

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