--- /dev/null
+package org.simantics.proconf.g3d.base;\r
+\r
+import org.eclipse.ui.IPartListener;\r
+import org.eclipse.ui.IWorkbenchPart;\r
+\r
+/**\r
+ * IPartListener that allows editor to load its content after the editorPart is activated.\r
+ * \r
+ * This is crucial with 3D graphics, which does not work if the editor part is activated\r
+ * after the data has been loaded.\r
+ * \r
+ * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
+ *\r
+ */\r
+public abstract class EditorLoader implements IPartListener {\r
+\r
+ boolean opened = false;\r
+ boolean activated = false;\r
+ \r
+ public void partOpened(IWorkbenchPart part) {\r
+ if (part.equals(getWorkbechPart())) {\r
+ opened = true;\r
+ }\r
+ }\r
+ \r
+ public void partActivated(IWorkbenchPart part) {\r
+ if (part.equals(getWorkbechPart())) {\r
+ if (opened & !activated) {\r
+ activated = true;\r
+ load();\r
+ }\r
+ }\r
+ }\r
+ \r
+ public void partBroughtToTop(IWorkbenchPart part) {}\r
+ \r
+ public void partClosed(IWorkbenchPart part) {}\r
+ \r
+ public void partDeactivated(IWorkbenchPart part) {}\r
+ \r
+ /**\r
+ * Returns the IWorkbenchPart of the editor\r
+ * @return\r
+ */\r
+ public abstract IWorkbenchPart getWorkbechPart();\r
+ \r
+ /**\r
+ * Starts the content loading process\r
+ */\r
+ public abstract void load();\r
+}\r
editor = createEditor(getSessionContext());\r
\r
// add partlistener that loads the scene-graph when the view has been created\r
- this.getEditorSite().getPage().addPartListener(new IPartListener() {\r
- \r
- boolean opened = false;\r
- boolean activated = false;\r
- \r
- public void partOpened(IWorkbenchPart part) {\r
- if (part.equals(ThreeDimensionalEditorPart.this.getEditorSite().getPart())) {\r
- opened = true;\r
- }\r
- }\r
- \r
- public void partActivated(IWorkbenchPart part) {\r
- if (part.equals(ThreeDimensionalEditorPart.this.getEditorSite().getPart())) {\r
- if (opened & !activated) {\r
- activated = true;\r
- load();\r
- }\r
- }\r
+ this.getEditorSite().getPage().addPartListener(new EditorLoader() {\r
+\r
+ public IWorkbenchPart getWorkbechPart() {\r
+ return ThreeDimensionalEditorPart.this.getEditorSite().getPart();\r
}\r
\r
- public void partBroughtToTop(IWorkbenchPart part) {}\r
- \r
- public void partClosed(IWorkbenchPart part) {}\r
- \r
- public void partDeactivated(IWorkbenchPart part) {}\r
- \r
- private void load() {\r
+ public void load() {\r
//System.out.println("ThreeDimensionalEditorPart.reload()");\r
Session ses = ThreeDimensionalEditorPart.this.getSession();\r
GraphRequestAdapter r = new GraphRequestAdapter() {\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.events.ControlAdapter;\r
import org.eclipse.swt.events.ControlEvent;\r
+import org.eclipse.swt.events.PaintEvent;\r
+import org.eclipse.swt.events.PaintListener;\r
import org.eclipse.swt.graphics.Rectangle;\r
import org.eclipse.swt.layout.FillLayout;\r
import org.eclipse.swt.opengl.GLCanvas;\r
}\r
});\r
\r
+// this.addPaintListener(new PaintListener() {\r
+// @Override\r
+// public void paintControl(PaintEvent e) {\r
+// displaySystem.setCurrent();\r
+// JmeComposite.this.component.render();\r
+// }\r
+// });\r
+ \r
\r
}\r
\r
public DisplaySystem getDisplaySystem() {\r
return displaySystem;\r
}\r
+ \r
+ \r
}\r