/******************************************************************************* * Copyright (c) 2007- VTT Technical Research Centre of Finland. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * VTT Technical Research Centre of Finland - initial API and implementation *******************************************************************************/ package org.simantics.proconf.g3d.base; import org.eclipse.ui.IPartListener; import org.eclipse.ui.IWorkbenchPart; /** * IPartListener that allows editor to load its content after the editorPart is activated. * * This is crucial with 3D graphics, which does not work if the editor part is activated * after the data has been loaded. * * @author Marko Luukkainen * */ public abstract class EditorLoader implements IPartListener { boolean opened = false; boolean activated = false; public void partOpened(IWorkbenchPart part) { if (part.equals(getWorkbechPart())) { opened = true; } } public void partActivated(IWorkbenchPart part) { if (part.equals(getWorkbechPart())) { if (opened & !activated) { activated = true; load(); } } } public void partBroughtToTop(IWorkbenchPart part) {} public void partClosed(IWorkbenchPart part) {} public void partDeactivated(IWorkbenchPart part) {} /** * Returns the IWorkbenchPart of the editor * @return */ public abstract IWorkbenchPart getWorkbechPart(); /** * Starts the content loading process */ public abstract void load(); }