From 518f4ab8955bdddac20d1d89df1764637adfc14a Mon Sep 17 00:00:00 2001 From: Lukas Ladenberger <lukas.ladenberger@googlemail.com> Date: Thu, 3 Jan 2013 11:44:44 +0100 Subject: [PATCH] fixed some bugs --- .../gef/editor/BMSPerspectiveFactory.java | 1 + .../gef/editor/BMotionOutlinePage.java | 5 +- .../gef/editor/BMotionStudioEditor.java | 48 +++++++------------ .../gef/editor/VisualizationViewPart.java | 39 ++++++++++----- 4 files changed, 48 insertions(+), 45 deletions(-) diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSPerspectiveFactory.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSPerspectiveFactory.java index 2de5fb53..0c2eb123 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSPerspectiveFactory.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSPerspectiveFactory.java @@ -42,6 +42,7 @@ public class BMSPerspectiveFactory implements IPerspectiveFactory { IFolderLayout right2 = layout.createFolder("right2", IPageLayout.BOTTOM, 0.60f, "right1"); right2.addView(LibraryView.ID); + right2.addView("fr.systerel.explorer.navigator.view"); // ProB State View + ProB History + ProB Event Error View (Right) // IFolderLayout right2 = layout.createFolder("right2", diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionOutlinePage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionOutlinePage.java index c6731c18..4ec90be5 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionOutlinePage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionOutlinePage.java @@ -79,7 +79,8 @@ public class BMotionOutlinePage extends ContentOutlinePage { this.viewPart.getSelectionSynchronizer().removeViewer(getViewer()); if (graphicalViewer != null) { if (graphicalViewer.getControl() != null - && !graphicalViewer.getControl().isDisposed()) + && !graphicalViewer.getControl().isDisposed() + && disposeListener != null) graphicalViewer.getControl().removeDisposeListener( disposeListener); } @@ -88,7 +89,7 @@ public class BMotionOutlinePage extends ContentOutlinePage { @Override public void createControl(Composite parent) { GraphicalViewer graphicalViewer = viewPart.getGraphicalViewer(); - if (graphicalViewer != null) { + if (graphicalViewer != null && graphicalViewer.getControl() != null) { initializeOverview(parent); graphicalViewer.getControl().addDisposeListener(disposeListener); configureOutlineViewer(); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditor.java index 04eaa635..05ca297d 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditor.java @@ -236,7 +236,6 @@ public class BMotionStudioEditor extends EditorPart implements @Override public void dispose() { - // getCommandStack().removeCommandStackListener(getCommandStackListener()); IWorkbenchPage activePage = PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage(); if (activePage != null) @@ -312,15 +311,14 @@ public class BMotionStudioEditor extends EditorPart implements Visualization vis = visView.getVisualization(); vis.setProjectFile(file); // String partName = visView.getPartName(); - IViewReference viewReference = site.getPage() - .findViewReference(VisualizationViewPart.ID, secId); + // IViewReference viewReference = site.getPage() + // .findViewReference(VisualizationViewPart.ID, secId); // Check if view already exists - - if (viewReference != null) { - } else { - // If not, create a new one - createVisualizationViewPart(secId, visView); - } + // if (viewReference != null) { + // } else { + // If not, create a new one + createVisualizationViewPart(secId, visView); + // } } @@ -358,6 +356,9 @@ public class BMotionStudioEditor extends EditorPart implements private VisualizationViewPart createVisualizationViewPart(String secId, VisualizationView visualizationView) throws PartInitException { + + System.out.println("CREATE VISUALIZATION PART: " + secId); + IWorkbenchWindow window = PlatformUI.getWorkbench() .getActiveWorkbenchWindow(); IWorkbenchPage activePage = window.getActivePage(); @@ -496,30 +497,14 @@ public class BMotionStudioEditor extends EditorPart implements this.simulation = simulation; } - // private CommandStackListener commandStackListener = new - // CommandStackListener() { - // public void commandStackChanged(EventObject event) { - // setDirty(getCommandStack().isDirty()); - // } - // }; - - // protected CommandStackListener getCommandStackListener() { - // return commandStackListener; - // } - - // public CommandStack getCommandStack() { - // return getEditDomain().getCommandStack(); - // } - - // protected EditDomain getEditDomain() { - // return editDomain; - // } - @Override public void partActivated(IWorkbenchPartReference partRef) { - // IWorkbenchPart part = partRef.getPart(false); - // if (part == this) - // openPerspective(partRef.getPage()); + if (partRef.getPart(false) == this) { + IPerspectiveDescriptor currentPerspective = getSite().getPage() + .getPerspective(); + if (!currentPerspective.getId().equals(perspective.getId())) + openPerspective(getSite().getPage()); + } } @Override @@ -529,6 +514,7 @@ public class BMotionStudioEditor extends EditorPart implements @Override public void partClosed(IWorkbenchPartReference partRef) { if (partRef.getPart(false) == this) { + switchPerspective(perspective.getId()); partRef.getPage().savePerspectiveAs(perspective); exportPerspective(perspective); closePerspective(partRef.getPage(), perspective); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/VisualizationViewPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/VisualizationViewPart.java index a69514c1..d1713e10 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/VisualizationViewPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/VisualizationViewPart.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.EventObject; import java.util.Iterator; import java.util.List; +import java.util.Map; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; @@ -86,6 +87,8 @@ public class VisualizationViewPart extends PageBookView implements private Composite container; + private Simulation simulation; + private BMotionStudioEditor editor; private BMotionSelectionSynchronizer selectionSynchronizer; @@ -134,15 +137,17 @@ public class VisualizationViewPart extends PageBookView implements return selectionSynchronizer; } - // Workaround for prevent recursive activiation of part + // Workaround for prevent recursive activation of part @Override public void setFocus() { - container.setFocus(); + this.container.setFocus(); super.setFocus(); } public Visualization getVisualization() { - return this.visualizationView.getVisualization(); + if (this.visualizationView != null) + return this.visualizationView.getVisualization(); + return null; } public GraphicalViewer getGraphicalViewer() { @@ -171,20 +176,25 @@ public class VisualizationViewPart extends PageBookView implements if (part instanceof BMotionStudioEditor) { - editor = (BMotionStudioEditor) part; - Simulation simulation = editor.getSimulation(); + BMotionStudioEditor cEditor = (BMotionStudioEditor) part; - if (simulation == null) + this.simulation = cEditor.getSimulation(); + if (this.simulation == null) return null; - this.editDomain = new EditDomain(); - getCommandStack().addCommandStackListener(this); + Map<String, VisualizationView> visualizationViews = this.simulation + .getVisualizationViews(); + + this.visualizationView = visualizationViews + .get(getViewSite().getSecondaryId()); - this.visualizationView = simulation.getVisualizationViews().get( - getViewSite().getSecondaryId()); if (visualizationView == null) return null; + this.editor = cEditor; + this.editDomain = new EditDomain(); + this.editDomain.getCommandStack().addCommandStackListener(this); + createActions(); page = new VisualizationViewPage(); @@ -212,6 +222,7 @@ public class VisualizationViewPart extends PageBookView implements @Override protected void doDestroyPage(IWorkbenchPart part, PageRec rec) { + unregister(); VisualizationViewPage page = (VisualizationViewPage) rec.page; page.dispose(); rec.dispose(); @@ -592,17 +603,21 @@ public class VisualizationViewPart extends PageBookView implements @Override public void dispose() { + unregister(); + super.dispose(); + } + + private void unregister() { if (getCommandStack() != null) getCommandStack().removeCommandStackListener(this); if (getActionRegistry() != null) getActionRegistry().dispose(); - super.dispose(); } @Override public void commandStackChanged(EventObject event) { updateActions(stackActions); - editor.setDirty(getCommandStack().isDirty()); + this.editor.setDirty(getCommandStack().isDirty()); } /** -- GitLab