From 54d859ae1fa35f1f2909b0aec5b6da24c599943a Mon Sep 17 00:00:00 2001 From: Lukas Ladenberger <lukas.ladenberger@googlemail.com> Date: Mon, 17 Dec 2012 16:30:57 +0100 Subject: [PATCH] fixed raising exception (prevent recursive activation of parts) by means of a workaround --- de.bmotionstudio.gef.editor/plugin.xml | 7 ----- .../gef/editor/BMSPaletteView.java | 13 ++++----- .../gef/editor/BMSPerspectiveFactory.java | 2 +- .../gef/editor/BMotionOutlinePage.java | 11 ++++--- .../gef/editor/BMotionPropertyView.java | 26 ----------------- .../gef/editor/VisualizationViewPart.java | 29 +++++++++++++++++-- .../gef/editor/library/LibraryPage.java | 25 +++++++--------- .../gef/editor/library/LibraryView.java | 25 ++++++++-------- 8 files changed, 64 insertions(+), 74 deletions(-) delete mode 100644 de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionPropertyView.java diff --git a/de.bmotionstudio.gef.editor/plugin.xml b/de.bmotionstudio.gef.editor/plugin.xml index c18dc938..fcf68ecb 100644 --- a/de.bmotionstudio.gef.editor/plugin.xml +++ b/de.bmotionstudio.gef.editor/plugin.xml @@ -85,13 +85,6 @@ name="Outline" restorable="true"> </view> - <view - category="de.bmotionstudio.views" - class="de.bmotionstudio.gef.editor.BMotionPropertyView" - id="de.bmotionstudio.gef.editor.PropertyView" - name="Properties" - restorable="true"> - </view> </extension> <extension point="org.eclipse.ui.menus"> diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSPaletteView.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSPaletteView.java index b89cc1a7..b405751b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSPaletteView.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSPaletteView.java @@ -1,7 +1,6 @@ package de.bmotionstudio.gef.editor; import org.eclipse.draw2d.ColorConstants; -import org.eclipse.gef.EditDomain; import org.eclipse.gef.dnd.TemplateTransferDragSourceListener; import org.eclipse.gef.ui.palette.PaletteViewer; import org.eclipse.swt.SWT; @@ -34,12 +33,12 @@ public class BMSPaletteView extends PageBookView { @Override public void partActivated(IWorkbenchPart part) { - if (part instanceof VisualizationViewPart) { - VisualizationViewPart visView = (VisualizationViewPart) part; - EditDomain domain = visView.getEditDomain(); - if (domain != null) - domain.setPaletteViewer(paletteViewer); - } + // if (part instanceof VisualizationViewPart) { + // VisualizationViewPart visView = (VisualizationViewPart) part; + // EditDomain domain = visView.getEditDomain(); + // if (domain != null) + // domain.setPaletteViewer(paletteViewer); + // } super.partActivated(part); } 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 120b2f62..2de5fb53 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 @@ -60,7 +60,7 @@ public class BMSPerspectiveFactory implements IPerspectiveFactory { // views IFolderLayout bottom = layout.createFolder("bottom2", IPageLayout.BOTTOM, 0.65f, "bottom1"); - bottom.addView(BMotionPropertyView.ID); + bottom.addView(IPageLayout.ID_PROP_SHEET); bottom.addView(ObserverView.ID); } 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 2a2483cd..95e0d306 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 @@ -74,10 +74,12 @@ public class BMotionOutlinePage extends ContentOutlinePage { protected void unhookOutlineViewer() { GraphicalViewer graphicalViewer = viewPart.getGraphicalViewer(); // getSelectionSynchronizer().removeViewer(getViewer()); - if (graphicalViewer.getControl() != null - && !graphicalViewer.getControl().isDisposed()) - graphicalViewer.getControl().removeDisposeListener( - disposeListener); + if (graphicalViewer != null) { + if (graphicalViewer.getControl() != null + && !graphicalViewer.getControl().isDisposed()) + graphicalViewer.getControl().removeDisposeListener( + disposeListener); + } } @Override @@ -167,6 +169,7 @@ public class BMotionOutlinePage extends ContentOutlinePage { return sash; } + @Override public void dispose() { unhookOutlineViewer(); super.dispose(); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionPropertyView.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionPropertyView.java deleted file mode 100644 index 55394199..00000000 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionPropertyView.java +++ /dev/null @@ -1,26 +0,0 @@ -package de.bmotionstudio.gef.editor; - -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.PropertySheet; - -public class BMotionPropertyView extends PropertySheet { - - public static final String ID = "de.bmotionstudio.gef.editor.PropertyView"; - - @Override - protected IWorkbenchPart getBootstrapPart() { - IWorkbenchPage page = getSite().getPage(); - IViewPart view = page.findView(VisualizationViewPart.ID); - if (view != null) - return view; - return null; - } - - @Override - protected boolean isImportant(IWorkbenchPart part) { - return part instanceof VisualizationViewPart; - } - -} 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 e083f926..7c3ba559 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 @@ -46,6 +46,8 @@ public class VisualizationViewPart extends PageBookView { private ActionRegistry actionRegistry; + private Composite x; + @Override public Object getAdapter(@SuppressWarnings("rawtypes") Class type) { @@ -74,8 +76,11 @@ public class VisualizationViewPart extends PageBookView { } + // Workaround for prevent recursive activiation of part @Override public void setFocus() { + x.setFocus(); + super.setFocus(); } protected ActionRegistry getActionRegistry() { @@ -103,9 +108,26 @@ public class VisualizationViewPart extends PageBookView { return page; } + @Override + protected void partVisible(IWorkbenchPart part) { + // TODO Auto-generated method stub + super.partVisible(part); + } + + @Override + public void partActivated(IWorkbenchPart part) { + // System.out.println(this + " : ACTIVATE: " + part); + super.partActivated(part); + } + + @Override + public void createPartControl(Composite parent) { + this.x = parent; + super.createPartControl(parent); + } + @Override protected PageRec doCreatePage(IWorkbenchPart part) { - System.out.println("DO CREATE PAGE"); if (part instanceof BMotionStudioEditor) { BMotionStudioEditor editor = (BMotionStudioEditor) part; Simulation simulation = editor.getSimulation(); @@ -123,7 +145,10 @@ public class VisualizationViewPart extends PageBookView { } @Override - protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) { + protected void doDestroyPage(IWorkbenchPart part, PageRec rec) { + VisualizationViewPage page = (VisualizationViewPage) rec.page; + page.dispose(); + rec.dispose(); } @Override diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryPage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryPage.java index 18fa72be..f50bbecb 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryPage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryPage.java @@ -40,8 +40,6 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.ui.part.IPageSite; import org.eclipse.ui.part.Page; -import de.bmotionstudio.gef.editor.BMotionStudioEditor; - public class LibraryPage extends Page { private Image previewImage; @@ -54,10 +52,9 @@ public class LibraryPage extends Page { private Action importImagesAction, deleteItemAction; - private BMotionStudioEditor editor; + // private BMotionStudioEditor editor; - public LibraryPage(final BMotionStudioEditor editor) { - this.editor = editor; + public LibraryPage() { } @Override @@ -216,7 +213,7 @@ public class LibraryPage extends Page { List<LibraryObject> tmpList = new ArrayList<LibraryObject>(); - if (editor != null) { + // if (editor != null) { // TODO Reimplement me! @@ -260,7 +257,7 @@ public class LibraryPage extends Page { // } // } - } + // } return tmpList; @@ -289,13 +286,13 @@ public class LibraryPage extends Page { super.dispose(); } - public BMotionStudioEditor getEditor() { - return editor; - } - - public void setEditor(final BMotionStudioEditor editor) { - this.editor = editor; - } + // public BMotionStudioEditor getEditor() { + // return editor; + // } + // + // public void setEditor(final BMotionStudioEditor editor) { + // this.editor = editor; + // } public TableViewer getTableViewer() { return tvLibrary; diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryView.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryView.java index 96202926..7f90e0af 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryView.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/library/LibraryView.java @@ -6,7 +6,7 @@ package de.bmotionstudio.gef.editor.library; -import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.part.IPage; @@ -14,7 +14,7 @@ import org.eclipse.ui.part.MessagePage; import org.eclipse.ui.part.PageBook; import org.eclipse.ui.part.PageBookView; -import de.bmotionstudio.gef.editor.BMotionStudioEditor; +import de.bmotionstudio.gef.editor.VisualizationViewPart; public class LibraryView extends PageBookView { @@ -39,13 +39,10 @@ public class LibraryView extends PageBookView { @Override protected PageRec doCreatePage(IWorkbenchPart part) { - if (part instanceof BMotionStudioEditor) { - page = new LibraryPage((BMotionStudioEditor) part); - initPage(page); - page.createControl(getPageBook()); - return new PageRec(part, page); - } - return null; + page = new LibraryPage(); + initPage(page); + page.createControl(getPageBook()); + return new PageRec(part, page); } @Override @@ -58,19 +55,21 @@ public class LibraryView extends PageBookView { @Override protected IWorkbenchPart getBootstrapPart() { IWorkbenchPage page = getSite().getPage(); - if (page != null) { - return page.getActiveEditor(); - } + IViewPart view = page.findView(VisualizationViewPart.ID); + if (view != null) + return view; return null; } + public void partBroughtToTop(IWorkbenchPart part) { partActivated(part); } @Override protected boolean isImportant(IWorkbenchPart part) { - return (part instanceof IEditorPart); + return part instanceof VisualizationViewPart; } + } \ No newline at end of file -- GitLab