Refresh problem in broswer when I use swt applet (embedded GEF GraphicalViewer) [message #231158] |
Wed, 28 February 2007 05:33 |
Eclipse User |
|
|
|
Originally posted by: jpkim.nguru.co.kr
Hello.
I make an applet within embedded GEF GraphicalViewer.
When I first open it, it works great.
But I push refresh button in browser, it doesn't work well. ( all labels are
not displayed and etc... )
I think SWT_AWT bridge has a problem.
Does anyone have a solution?
it is sourcecode...
public void run() {
/*
* Create an SWT Composite from an AWT canvas to be the parent of the
* SWT widgets. The AWT Canvas will be layed out by the Applet layout
* manager. The layout of the SWT widgets is handled by the application
* (see below).
*/
display = new Display();
cnvsAwtParent = new Canvas();
add(cnvsAwtParent, BorderLayout.CENTER);
swtParent = SWT_AWT.new_Shell(display, cnvsAwtParent);
swtParent.setLayout(new FillLayout());
/* Create SWT widget */
Composite cmpstParent = new Composite(swtParent, SWT.NONE);
cmpstParent.setLayout(new FillLayout());
ScrollingGraphicalViewer viewer = new ScrollingGraphicalViewer();
viewer.setEditDomain(new DefaultEditDomain(null));
viewer.createControl(cmpstParent);
viewer.setEditPartFactory(new GraphicalPartFactory());
try {
String fileName= "./example.logic";
File file = new File(fileName);
ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
diagram = (LogicDiagram) in.readObject();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
// LogicDiagramEditPart rootEditPart = new LogicDiagramEditPart();
// rootEditPart.setModel(diagram);
// viewer.getRootEditPart().setModel(diagram);
viewer.setContents(diagram);
// Size AWT Panel so that it is big enough to hold the SWT widgets
Point size = swtParent.computeSize(SWT.DEFAULT, SWT.DEFAULT);
cnvsAwtParent.setSize(size.x, size.y);
// Need to invoke the AWT layout manager or AWT and Swing
// widgets will not be visible
swtParent.layout();
cnvsAwtParent.validate();
cnvsAwtParent.repaint();
validate();
repaint();
// The SWT widget(s) require an event loop
while (display != null && !display.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.02415 seconds