X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.proconf.g3d%2Fsrc%2Forg%2Fsimantics%2Fproconf%2Fg3d%2Fbase%2FThreeDimensionalEditorPart.java;h=a3da25103e60cff356df0fb9c8c87c1c532c36fb;hb=refs%2Fheads%2Fdev;hp=4ad22bd26d3ce668ec193c1528e073772cbaae6f;hpb=477a3eae417fe71addfcf8f87dab41f87151a384;p=simantics%2F3d.git diff --git a/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/base/ThreeDimensionalEditorPart.java b/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/base/ThreeDimensionalEditorPart.java index 4ad22bd2..a3da2510 100644 --- a/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/base/ThreeDimensionalEditorPart.java +++ b/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/base/ThreeDimensionalEditorPart.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. + * 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 @@ -15,7 +15,6 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IPartListener; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.IWorkbenchPart; import org.simantics.db.Graph; @@ -26,7 +25,7 @@ import org.simantics.db.Resource; import org.simantics.db.events.GraphChangeEvent; import org.simantics.db.management.ISessionContext; import org.simantics.proconf.ui.workbench.ResourceEditorPart; -import org.simantics.utils.ErrorLogger; +import org.simantics.utils.ui.ErrorLogger; public abstract class ThreeDimensionalEditorPart extends ResourceEditorPart implements ThreeDimensionalEditorProvider{ @@ -49,33 +48,13 @@ public abstract class ThreeDimensionalEditorPart extends ResourceEditorPart impl editor = createEditor(getSessionContext()); // add partlistener that loads the scene-graph when the view has been created - this.getEditorSite().getPage().addPartListener(new IPartListener() { - - boolean opened = false; - boolean activated = false; - - public void partOpened(IWorkbenchPart part) { - if (part.equals(ThreeDimensionalEditorPart.this.getEditorSite().getPart())) { - opened = true; - } - } - - public void partActivated(IWorkbenchPart part) { - if (part.equals(ThreeDimensionalEditorPart.this.getEditorSite().getPart())) { - if (opened & !activated) { - activated = true; - load(); - } - } + this.getEditorSite().getPage().addPartListener(new EditorLoader() { + + public IWorkbenchPart getWorkbechPart() { + return ThreeDimensionalEditorPart.this.getEditorSite().getPart(); } - public void partBroughtToTop(IWorkbenchPart part) {} - - public void partClosed(IWorkbenchPart part) {} - - public void partDeactivated(IWorkbenchPart part) {} - - private void load() { + public void load() { //System.out.println("ThreeDimensionalEditorPart.reload()"); Session ses = ThreeDimensionalEditorPart.this.getSession(); GraphRequestAdapter r = new GraphRequestAdapter() { @@ -159,12 +138,14 @@ public abstract class ThreeDimensionalEditorPart extends ResourceEditorPart impl private void hookPageSelection() { pageSelectionListener = new ISelectionListener() { public void selectionChanged(IWorkbenchPart part, ISelection selection) { - if (part == ThreeDimensionalEditorPart.this) - return; + if (part == ThreeDimensionalEditorPart.this) { + return; + } pageSelectionChanged(part, selection); } }; getSite().getPage().addPostSelectionListener(pageSelectionListener); + getSite().getPage().addSelectionListener(pageSelectionListener); ISelection sel = getSite().getPage().getSelection(); IWorkbenchPart wb = getSite().getPage().getActivePart(); pageSelectionChanged(wb, sel); @@ -181,8 +162,10 @@ public abstract class ThreeDimensionalEditorPart extends ResourceEditorPart impl } public void dispose() { - if (pageSelectionListener != null) + if (pageSelectionListener != null) { getSite().getPage().removePostSelectionListener(pageSelectionListener); + getSite().getPage().removeSelectionListener(pageSelectionListener); + } editor.dispose(); super.dispose(); }