Thursday, April 17, 2008

Screen Refresh Problems in Eclipse RCP Solved!

On my current project I was having some serious problems with screen refresh and I finally found a work around. The problem was I have a 4 pane perspective setup with 4+ views. The left half of the application area is a PDF viewer. When a user (me doing testing) would open a new PDF the fragments of the filedialog would remain overlayed during opening of the new PDF as well as the other views shifting over into the PDF area. The reason is because I had to do a HideView then ShowView. If I just did a close/open document function call in my swing PDF component the pdf component (I use icesoft IcePDF) would not always work. I am pretty sure this is due to the SWT to AWT bridge I have to do. So now here is the code to fix it!

Shell shell;
shell = getSite().getShell();
PDFView view = (PDFView)getSite().getPage().findView(PDFView.ID);
getSite().getPage().hideView(view);
shell.update();

Just doing a shell update seemed to do the trick, you may want to also look at this code if the above does not work for you. Look at the comments out code and it may be useful to you.

Shell shell;
shell = getSite().getShell();
// Display display = shell.getDisplay();
// Point shellSize = shell.getSize();
// shell.redraw(0,0,shellSize.x,shellSize.y,true);
PDFView view = (PDFView)getSite().getPage().findView(PDFView.ID);
getSite().getPage().hideView(view);
shell.update();
// display.update();