]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/base/EditorLoader.java
git-svn-id: https://www.simantics.org/svn/simantics/3d/trunk@22279 ac1ea38d-2e2b...
[simantics/3d.git] / org.simantics.proconf.g3d / src / org / simantics / proconf / g3d / base / EditorLoader.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007- VTT Technical Research Centre of Finland.\r
3  * All rights reserved. This program and the accompanying materials\r
4  * are made available under the terms of the Eclipse Public License v1.0\r
5  * which accompanies this distribution, and is available at\r
6  * http://www.eclipse.org/legal/epl-v10.html\r
7  *\r
8  * Contributors:\r
9  *     VTT Technical Research Centre of Finland - initial API and implementation\r
10  *******************************************************************************/\r
11 package org.simantics.proconf.g3d.base;\r
12 \r
13 import org.eclipse.ui.IPartListener;\r
14 import org.eclipse.ui.IWorkbenchPart;\r
15 \r
16 /**\r
17  * IPartListener that allows editor to load its content after the editorPart is activated.\r
18  * \r
19  * This is crucial with 3D graphics, which does not work if the editor part is activated\r
20  * after the data has been loaded.\r
21  * \r
22  * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
23  *\r
24  */\r
25 public abstract class EditorLoader implements IPartListener {\r
26 \r
27         boolean opened = false;\r
28         boolean activated = false;\r
29         \r
30     public void partOpened(IWorkbenchPart part) {\r
31         if (part.equals(getWorkbechPart())) {\r
32             opened = true;\r
33         }\r
34     }\r
35     \r
36     public void partActivated(IWorkbenchPart part) {\r
37         if (part.equals(getWorkbechPart())) {\r
38             if (opened & !activated) {\r
39                 activated = true;\r
40                 load();\r
41             }\r
42         }\r
43     }\r
44     \r
45     public void partBroughtToTop(IWorkbenchPart part) {}\r
46     \r
47     public void partClosed(IWorkbenchPart part) {}\r
48     \r
49     public void partDeactivated(IWorkbenchPart part) {}\r
50     \r
51     /**\r
52      * Returns the IWorkbenchPart of the editor\r
53      * @return\r
54      */\r
55     public abstract IWorkbenchPart getWorkbechPart();\r
56     \r
57     /**\r
58      * Starts the content loading process\r
59      */\r
60     public abstract void load();\r
61 }\r