Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

override close action in eclipse editor

I have a eclipse rcp application in which i had created a editor which extends EditorPart.

I want to do some release resource work in its close() editor action, so i want to override its close action or any method that just came in to action before to close event.

I had tried dispose() but it to late to work on it.

Or is there any specific listener that listen close event.

i want to have like that:

@override
public void close()
{
  //do something resource release related task.
}

Update: basically i want to intercept close event for a editor.

like image 824
RTA Avatar asked Mar 21 '23 13:03

RTA


1 Answers

You can use IPartListener for this purpose:

public class YourEditor extends EditorPart {

@Override
    public void init(IEditorSite site, IEditorInput input) throws PartInitException {
getSite().getPage().addPartListener(new IPartListener() {

            @Override
            public void partOpened(IWorkbenchPart part) {
                // TODO Auto-generated method stub

            }

            @Override
            public void partDeactivated(IWorkbenchPart part) {
                // TODO Auto-generated method stub

            }

            @Override
            public void partClosed(IWorkbenchPart part) {
                // TODO Auto-generated method stub

            }

            @Override
            public void partBroughtToTop(IWorkbenchPart part) {
                // TODO Auto-generated method stub

            }

            @Override
            public void partActivated(IWorkbenchPart part) {
                // TODO Auto-generated method stub

            }
        });
    }
}
like image 94
Alex K. Avatar answered Mar 29 '23 12:03

Alex K.