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();
Showing posts with label swt. Show all posts
Showing posts with label swt. Show all posts
Thursday, April 17, 2008
Thursday, March 6, 2008
Numeric Only in Eclipse RCP SWT Text Widget
If you wanted to make an Eclipse RCP SWT text field numeric only here is a simple validation you can do. More to come on this as I need better support then this for like money fields, etc.
Text startText = new Text(group, SWT.BORDER);
startText.setText(txt);
startText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
startText.addListener (SWT.Verify, new Listener ()
{
public void handleEvent (Event e)
{
String string = e.text;
char [] chars = new char [string.length ()];
string.getChars (0, chars.length, chars, 0);
for (int i=0; i < chars.length; i++)
{
if (!('0' <= chars [i] && chars [i] <= '9') && (chars[i]!='.'))
{
e.doit = false;
return;
}
}
}
});
Subscribe to:
Posts (Atom)