From 3b655fc82d0e82d092e1fa8ad8fa73546425e67e Mon Sep 17 00:00:00 2001 From: Lukas Ladenberger <lukas.ladenberger@googlemail.com> Date: Mon, 17 Dec 2012 11:48:25 +0100 Subject: [PATCH] reactivated property sheet page --- de.bmotionstudio.gef.editor/plugin.xml | 7 ++++ .../gef/editor/BMSPerspectiveFactory.java | 2 +- .../gef/editor/BMotionOutlinePage.java | 31 +++++++++------- ...rtySheet.java => BMotionPropertyPage.java} | 11 ++++-- .../gef/editor/BMotionPropertyView.java | 26 +++++++++++++ .../gef/editor/BMotionStudioEditorPage.java | 24 ++++++------ .../editor/CustomSortPropertySheetEntry.java | 1 + .../gef/editor/VisualizationViewPart.java | 37 +++++++++++++++++-- .../editor/part/BMSTreeEditPartFactory.java | 7 ---- 9 files changed, 104 insertions(+), 42 deletions(-) rename de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/{BMotionStudioPropertySheet.java => BMotionPropertyPage.java} (65%) create 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 fcf68ecb..c18dc938 100644 --- a/de.bmotionstudio.gef.editor/plugin.xml +++ b/de.bmotionstudio.gef.editor/plugin.xml @@ -85,6 +85,13 @@ 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/BMSPerspectiveFactory.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSPerspectiveFactory.java index 2de5fb53..120b2f62 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(IPageLayout.ID_PROP_SHEET); + bottom.addView(BMotionPropertyView.ID); 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 d67b5086..2a2483cd 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 @@ -82,13 +82,15 @@ public class BMotionOutlinePage extends ContentOutlinePage { @Override public void createControl(Composite parent) { - initializeOverview(parent); - viewPart.getGraphicalViewer().getControl() - .addDisposeListener(disposeListener); - configureOutlineViewer(); - // hookOutlineViewer(); - initializeOutlineViewer(); - createMenu(); + GraphicalViewer graphicalViewer = viewPart.getGraphicalViewer(); + if (graphicalViewer != null) { + initializeOverview(parent); + graphicalViewer.getControl().addDisposeListener(disposeListener); + configureOutlineViewer(); + // hookOutlineViewer(); + initializeOutlineViewer(); + createMenu(); + } } private void initializeOutlineViewer() { @@ -129,7 +131,10 @@ public class BMotionOutlinePage extends ContentOutlinePage { } - protected void initializeOverview(Composite parent) { + private void initializeOverview(Composite parent) { + + GraphicalViewer graphicalViewer = this.viewPart.getGraphicalViewer(); + sash = new SashForm(parent, SWT.VERTICAL); getViewer().createControl(sash); @@ -140,11 +145,10 @@ public class BMotionOutlinePage extends ContentOutlinePage { LightweightSystem lws = new LightweightSystem(canvas); thumbnail = new ScrollableThumbnail( - (Viewport) ((ScalableRootEditPart) this.viewPart - .getGraphicalViewer().getRootEditPart()).getFigure()); - thumbnail.setSource(((ScalableRootEditPart) this.viewPart - .getGraphicalViewer().getRootEditPart()) - .getLayer(LayerConstants.PRINTABLE_LAYERS)); + (Viewport) ((ScalableRootEditPart) graphicalViewer + .getRootEditPart()).getFigure()); + thumbnail.setSource(((ScalableRootEditPart) graphicalViewer + .getRootEditPart()).getLayer(LayerConstants.PRINTABLE_LAYERS)); lws.setContents(thumbnail); @@ -156,6 +160,7 @@ public class BMotionOutlinePage extends ContentOutlinePage { } } }; + } public Control getControl() { diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioPropertySheet.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionPropertyPage.java similarity index 65% rename from de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioPropertySheet.java rename to de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionPropertyPage.java index 64eb3321..ad58095c 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioPropertySheet.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionPropertyPage.java @@ -6,18 +6,21 @@ package de.bmotionstudio.gef.editor; +import org.eclipse.gef.commands.CommandStack; +import org.eclipse.gef.ui.properties.UndoablePropertySheetPage; +import org.eclipse.jface.action.IAction; import org.eclipse.ui.views.properties.IPropertySheetEntry; -import org.eclipse.ui.views.properties.PropertySheetPage; import org.eclipse.ui.views.properties.PropertySheetSorter; /** * @author Lukas Ladenberger * */ -public class BMotionStudioPropertySheet extends PropertySheetPage { +public class BMotionPropertyPage extends UndoablePropertySheetPage { - public BMotionStudioPropertySheet() { - super(); + public BMotionPropertyPage(CommandStack commandStack, IAction undoAction, + IAction redoAction) { + super(commandStack, undoAction, redoAction); setSorter(new PropertySheetSorter() { @Override public int compare(IPropertySheetEntry entryA, 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 new file mode 100644 index 00000000..55394199 --- /dev/null +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionPropertyView.java @@ -0,0 +1,26 @@ +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/BMotionStudioEditorPage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditorPage.java index dadbd30d..0170c007 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditorPage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditorPage.java @@ -87,8 +87,6 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.part.IPageSite; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; -import org.eclipse.ui.views.properties.IPropertySheetPage; import com.thoughtworks.xstream.XStream; @@ -279,17 +277,17 @@ public class BMotionStudioEditorPage extends GraphicalEditor { @Override public Object getAdapter(@SuppressWarnings("rawtypes") Class type) { - if (type == ZoomManager.class) - return ((ScalableRootEditPart) getGraphicalViewer() - .getRootEditPart()).getZoomManager(); - if (type == IContentOutlinePage.class) - return new BMotionOutlinePage(); - if (type == IPropertySheetPage.class) { - BMotionStudioPropertySheet page = new BMotionStudioPropertySheet(); - page.setRootEntry(new CustomSortPropertySheetEntry( - getCommandStack())); - return page; - } + // if (type == ZoomManager.class) + // return ((ScalableRootEditPart) getGraphicalViewer() + // .getRootEditPart()).getZoomManager(); + // if (type == IContentOutlinePage.class) + // return new BMotionOutlinePage(); + // if (type == IPropertySheetPage.class) { + // BMotionPropertyPage page = new BMotionPropertyPage(); + // page.setRootEntry(new CustomSortPropertySheetEntry( + // getCommandStack())); + // return page; + // } return super.getAdapter(type); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/CustomSortPropertySheetEntry.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/CustomSortPropertySheetEntry.java index 41ffbc61..3d574ec0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/CustomSortPropertySheetEntry.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/CustomSortPropertySheetEntry.java @@ -33,6 +33,7 @@ public class CustomSortPropertySheetEntry extends UndoablePropertySheetEntry { super(stack); } + @Override protected PropertySheetEntry createChildEntry() { return new CustomSortPropertySheetEntry(getCommandStack()); } 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 989afd6d..e083f926 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 @@ -6,8 +6,10 @@ import org.eclipse.gef.EditDomain; import org.eclipse.gef.GraphicalViewer; import org.eclipse.gef.SnapToGeometry; import org.eclipse.gef.SnapToGrid; +import org.eclipse.gef.commands.CommandStack; import org.eclipse.gef.editparts.ScalableRootEditPart; import org.eclipse.gef.rulers.RulerProvider; +import org.eclipse.gef.ui.actions.ActionRegistry; import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; import org.eclipse.gef.ui.rulers.RulerComposite; import org.eclipse.swt.SWT; @@ -15,6 +17,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.part.IPage; import org.eclipse.ui.part.MessagePage; import org.eclipse.ui.part.Page; @@ -41,9 +44,13 @@ public class VisualizationViewPart extends PageBookView { private VisualizationViewPage page; + private ActionRegistry actionRegistry; + @Override public Object getAdapter(@SuppressWarnings("rawtypes") Class type) { + // System.out.println("Try to get adapter: " + type); + // // Adapter for zoom manager // if (type == ZoomManager.class) // return ((ScalableRootEditPart) getGraphicalViewer() @@ -54,9 +61,12 @@ public class VisualizationViewPart extends PageBookView { // // Adapter for property page if (type == IPropertySheetPage.class) { - BMotionStudioPropertySheet page = new BMotionStudioPropertySheet(); - page.setRootEntry(new CustomSortPropertySheetEntry(editDomain - .getCommandStack())); + BMotionPropertyPage page = new BMotionPropertyPage( + getCommandStack(), getActionRegistry().getAction( + ActionFactory.UNDO.getId()), getActionRegistry() + .getAction(ActionFactory.REDO.getId())); + page.setRootEntry(new CustomSortPropertySheetEntry( + getCommandStack())); return page; } @@ -68,12 +78,20 @@ public class VisualizationViewPart extends PageBookView { public void setFocus() { } + protected ActionRegistry getActionRegistry() { + if (actionRegistry == null) + actionRegistry = new ActionRegistry(); + return actionRegistry; + } + public Visualization getVisualization() { return this.visualizationView.getVisualization(); } public GraphicalViewer getGraphicalViewer() { - return page.getGraphicalViewer(); + if (page != null) + return page.getGraphicalViewer(); + return null; } @Override @@ -87,6 +105,7 @@ public class VisualizationViewPart extends PageBookView { @Override protected PageRec doCreatePage(IWorkbenchPart part) { + System.out.println("DO CREATE PAGE"); if (part instanceof BMotionStudioEditor) { BMotionStudioEditor editor = (BMotionStudioEditor) part; Simulation simulation = editor.getSimulation(); @@ -125,6 +144,10 @@ public class VisualizationViewPart extends PageBookView { return editDomain; } + protected CommandStack getCommandStack() { + return getEditDomain().getCommandStack(); + } + public void setEditDomain(EditDomain editDomain) { this.editDomain = editDomain; } @@ -156,9 +179,15 @@ public class VisualizationViewPart extends PageBookView { graphicalViewer.createControl(container); configureGraphicalViewer(); initGraphicalViewer(); + hookGraphicalViewer(); setPartName(getVisualizationView().getName()); } + protected void hookGraphicalViewer() { + // getSelectionSynchronizer().addViewer(getGraphicalViewer()); + getSite().setSelectionProvider(getGraphicalViewer()); + } + public void configureGraphicalViewer() { ScalableRootEditPart rootEditPart = new ScalableRootEditPart(); rootEditPart.setViewer(graphicalViewer); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSTreeEditPartFactory.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSTreeEditPartFactory.java index f092cadc..bf09178c 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSTreeEditPartFactory.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BMSTreeEditPartFactory.java @@ -43,17 +43,10 @@ public class BMSTreeEditPartFactory implements EditPartFactory { } } - // else if (model instanceof Observer) { - // part = new ObserverTreeEditPart(); - // } else if (model instanceof ObserverRootVirtualTreeNode) { - // part = new ObserverRootTreeEditpart(); - // } if (part != null) part.setModel(model); - System.out.println("CREATE EDIT PART!!! " + part); - return part; } -- GitLab