]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
git-svn-id: https://www.simantics.org/svn/simantics/3d/branches/dev@7286 ac1ea38d...
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 27 Oct 2008 14:25:52 +0000 (14:25 +0000)
committerluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 27 Oct 2008 14:25:52 +0000 (14:25 +0000)
org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/base/EditorLoader.java [new file with mode: 0644]
org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/base/ThreeDimensionalEditorPart.java
org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/common/JmeComposite.java

diff --git a/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/base/EditorLoader.java b/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/base/EditorLoader.java
new file mode 100644 (file)
index 0000000..dcc6cfc
--- /dev/null
@@ -0,0 +1,51 @@
+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
index 4ad22bd26d3ce668ec193c1528e073772cbaae6f..f2f3bc121eb7f15657d3f212d3c994bdea9bed04 100644 (file)
@@ -49,33 +49,13 @@ public abstract class ThreeDimensionalEditorPart extends ResourceEditorPart impl
                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
index 5cff3ffb36502d71c8364dce8900ce82f1b7ebe0..b11557289c753b153393dfef72377ae19095daf5 100644 (file)
@@ -17,6 +17,8 @@ import org.eclipse.core.runtime.Path;
 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
@@ -55,6 +57,14 @@ public class JmeComposite extends Composite {
             }\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
@@ -109,4 +119,6 @@ public class JmeComposite extends Composite {
        public DisplaySystem getDisplaySystem() {\r
                return displaySystem;\r
        }\r
+       \r
+       \r
 }\r