diff --git a/de.bmotionstudio.gef.editor/plugin.xml b/de.bmotionstudio.gef.editor/plugin.xml index b477d5256df1654f3d4e247de47cf75c45fdc728..560ae9ff5d6cd3771d9531f2590c1c0dc55646e5 100644 --- a/de.bmotionstudio.gef.editor/plugin.xml +++ b/de.bmotionstudio.gef.editor/plugin.xml @@ -64,7 +64,7 @@ <view allowMultiple="true" category="de.bmotionstudio.views" - class="de.bmotionstudio.gef.editor.VisualizationView" + class="de.bmotionstudio.gef.editor.VisualizationViewPart" id="de.bmotionstudio.gef.editor.VisualizationView" name="Visualization" restorable="true"> 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 e5acfee7ddf04b5329d39e888bdf5ada03b4b700..cd961b33c80cf98989abb87cb116906fb09762d2 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 @@ -23,7 +23,7 @@ public class BMSPaletteView extends PageBookView { @Override protected IWorkbenchPart getBootstrapPart() { IWorkbenchPage page = getSite().getPage(); - IViewPart view = page.findView(VisualizationView.ID); + IViewPart view = page.findView(VisualizationViewPart.ID); if (view != null) return view; return null; @@ -31,7 +31,7 @@ public class BMSPaletteView extends PageBookView { @Override protected PageRec doCreatePage(IWorkbenchPart part) { - if (part instanceof VisualizationView) { + if (part instanceof VisualizationViewPart) { BMSPaletteViewPage page = new BMSPaletteViewPage(); initPage(page); page.createControl(getPageBook()); @@ -47,7 +47,7 @@ public class BMSPaletteView extends PageBookView { @Override protected boolean isImportant(IWorkbenchPart part) { - return part instanceof VisualizationView; + return part instanceof VisualizationViewPart; } private class BMSPaletteViewPage extends Page { diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionEditorPlugin.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionEditorPlugin.java index 471fb40d71ffa52e5d42c6ab6994b7b4518d6ff8..5317ce24401ef95b3bdfb72badc8f435b35fe090 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionEditorPlugin.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionEditorPlugin.java @@ -26,7 +26,9 @@ import de.bmotionstudio.gef.editor.model.BConnection; import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControlList; import de.bmotionstudio.gef.editor.model.BMotionGuide; +import de.bmotionstudio.gef.editor.model.Simulation; import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.model.VisualizationView; /** * The activator class controls the plug-in life cycle @@ -211,6 +213,8 @@ public class BMotionEditorPlugin extends AbstractUIPlugin { public static void setAliases(XStream xstream) { xstream.registerConverter(new BControlListConverter()); + xstream.alias("simulation", Simulation.class); + xstream.alias("view", VisualizationView.class); xstream.alias("control", BControl.class); xstream.alias("visualization", Visualization.class); xstream.alias("guide", BMotionGuide.class); 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 734b7d0d64698e04bfe2f8b0b750bce13db1a258..842d6bf725dfbbeb91e47fd51902c20bf1a43941 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 @@ -7,32 +7,48 @@ package de.bmotionstudio.gef.editor; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; +import java.io.OutputStreamWriter; import java.util.HashMap; import java.util.Map; +import java.util.UUID; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.IExportedPreferences; import org.eclipse.core.runtime.preferences.IPreferenceFilter; import org.eclipse.core.runtime.preferences.IPreferencesService; import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.core.runtime.preferences.PreferenceFilterEntry; import org.eclipse.gef.EditDomain; +import org.eclipse.gef.commands.CommandStack; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorSite; import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IPartListener2; import org.eclipse.ui.IPerspectiveDescriptor; import org.eclipse.ui.IPerspectiveRegistry; +import org.eclipse.ui.IViewReference; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; @@ -42,16 +58,14 @@ import org.eclipse.ui.part.EditorPart; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.mapper.MapperWrapper; +import de.bmotionstudio.gef.editor.model.Simulation; import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.model.VisualizationView; import de.prob.logging.Logger; -public class BMotionStudioEditor extends EditorPart { +public class BMotionStudioEditor extends EditorPart implements IPartListener2 { - // private BMotionStudioEditorPage editPage; - - // private BMotionStudioRunPage runPage; - - private Visualization visualization; + private Simulation simulation; private EditDomain editDomain; @@ -59,86 +73,186 @@ public class BMotionStudioEditor extends EditorPart { private IFile file; - // private Animation animation; + private boolean isDirty; - // private ArrayList<IRunPageListener> runPageListener = new - // ArrayList<IRunPageListener>(); + private IPerspectiveDescriptor perspective; - // @Override - // protected void createPages() { - // createEditPage(); - // } + private String getPerspectiveId() { + return "BMS_" + file.getName().replace(".bmso", ""); + } - // private void createEditPage() { - // editPage = new BMotionStudioEditorPage(getVisualization(), this); - // try { - // int index = addPage(editPage, getEditorInput()); - // setPageText(index, "Edit"); - // } catch (PartInitException e) { - // e.printStackTrace(); - // } - // } + private String getPerspectiveFileName() { + return file.getName().replace(".bmso", ".bmsop"); + } - // public void createRunPage(Visualization visualization, Animation - // animation) { - // StaticListenerRegistry.registerListener(this); - // this.animation = animation; - // - // if (runPage != null) - // runPage.dispose(); - // - // runPage = new BMotionStudioRunPage(visualization); - // try { - // int index = addPage(runPage, getEditorInput()); - // setPageText(index, "Run"); - // setActivePage(index); - // fireRunPageCreatedListener(); - // } catch (PartInitException e) { - // } - // } + private void closePerspective(IWorkbenchPage page, + IPerspectiveDescriptor perspectiveDescriptor) { + if (perspectiveDescriptor == null || page == null) + return; + page.closePerspective(perspectiveDescriptor, false, true); + } - // public void removeRunPage() { - // fireRunPageRemovedListener(); - // if (runPage != null) { - // Display.getDefault().asyncExec(new Runnable() { - // public void run() { - // removePage(1); - // } - // }); - // } - // unregister(); - // } + private void deletePerspective(IWorkbenchPage page, + IPerspectiveDescriptor perspectiveDescriptor) { + if (perspectiveDescriptor == null || page == null) + return; + IPerspectiveRegistry perspectiveRegistry = page.getWorkbenchWindow() + .getWorkbench().getPerspectiveRegistry(); + perspectiveRegistry.deletePerspective(perspectiveDescriptor); + } - // private void fireRunPageCreatedListener() { - // for (IRunPageListener listener : runPageListener) { - // listener.runPageCreated(runPage); - // } - // } + private void openPerspective(IWorkbenchPage page) { + + if (page == null) + return; + + // Try to get the corresponding perspective + IPerspectiveRegistry perspectiveRegistry = page.getWorkbenchWindow() + .getWorkbench().getPerspectiveRegistry(); + String perspectiveId = getPerspectiveId(); + perspective = perspectiveRegistry.findPerspectiveWithId(perspectiveId); + + // Yes --> just switch to this perspective + if (perspective != null) { + switchPerspective(perspective.getId()); + } else { + // No --> create a new one + IPerspectiveDescriptor originalPerspectiveDescriptor = perspectiveRegistry + .findPerspectiveWithId("de.bmotionstudio.perspective.run"); + switchPerspective(originalPerspectiveDescriptor.getId()); + perspective = perspectiveRegistry.clonePerspective(perspectiveId, + perspectiveId, originalPerspectiveDescriptor); + // save the perspective + page.savePerspectiveAs(perspective); + } - // private void fireRunPageRemovedListener() { - // for (IRunPageListener listener : runPageListener) { - // listener.runPageRemoved(runPage); - // } - // } + } + + private void importPerspective(IFile perspectiveFile) { + + FileInputStream fis = null; + + try { + + IPreferenceFilter[] transfers = null; + transfers = new IPreferenceFilter[1]; + + // Only import if a perspective file exists + if (perspectiveFile.exists()) { + + File exportFile = new File(perspectiveFile.getLocationURI()); + fis = new FileInputStream(exportFile); + IPreferencesService service = Platform.getPreferencesService(); + // service.importPreferences(fis); + IExportedPreferences prefs = service.readPreferences(fis); + transfers[0] = new IPreferenceFilter() { + public String[] getScopes() { + return new String[] { InstanceScope.SCOPE }; + } + + public Map<String, PreferenceFilterEntry[]> getMapping( + String scope) { + Map<String, PreferenceFilterEntry[]> map = new HashMap<String, PreferenceFilterEntry[]>(); + map.put("org.eclipse.ui.workbench", + new PreferenceFilterEntry[] { new PreferenceFilterEntry( + getPerspectiveId() + "_persp") }); + return map; + } + }; + service.applyPreferences(prefs, transfers); + } + + } catch (FileNotFoundException e) { + } catch (CoreException e) { + } finally { + try { + if (fis != null) + fis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + } + + private void exportPerspective(final IPerspectiveDescriptor perspective) { + + if (perspective != null) { + + FileOutputStream fos = null; + + try { + + IPreferenceFilter[] transfers = null; + + transfers = new IPreferenceFilter[1]; + + // For export all create a preference filter that can export + // all nodes of the Instance and Configuration scopes + transfers[0] = new IPreferenceFilter() { + public String[] getScopes() { + return new String[] { InstanceScope.SCOPE }; + } + + public Map<String, PreferenceFilterEntry[]> getMapping( + String scope) { + Map<String, PreferenceFilterEntry[]> map = new HashMap<String, PreferenceFilterEntry[]>(); + map.put("org.eclipse.ui.workbench", + new PreferenceFilterEntry[] { new PreferenceFilterEntry( + perspective.getId() + "_persp") }); + return map; + } + }; + + IFile pFile = file.getProject().getFile( + file.getName().replace(".bmso", ".bmsop")); + + String content = ""; + + if (!pFile.exists()) + pFile.create(new ByteArrayInputStream(content.getBytes()), + true, new NullProgressMonitor()); + + File exportFile = new File(pFile.getLocationURI()); + fos = new FileOutputStream(exportFile); + IPreferencesService service = Platform.getPreferencesService(); + service.exportPreferences(service.getRootNode(), transfers, fos); + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + try { + if (fos != null) + fos.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } + + } @Override public void dispose() { - // unregister(); + IWorkbenchPage activePage = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + if (activePage != null) + activePage.removePartListener(this); super.dispose(); } - // public Visualization getVisualization() { - // return visualization; - // } - - // public void setDirty(boolean dirty) { - // editPage.setDirty(dirty); - // } - @Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { + site.getPage().addPartListener(this); + file = ((IFileEditorInput) input).getFile(); try { @@ -163,87 +277,66 @@ public class BMotionStudioEditor extends EditorPart { }; BMotionEditorPlugin.setAliases(xstream); - - visualization = (Visualization) xstream.fromXML(inputStream); - visualization.setProjectFile(file); + Object obj = xstream.fromXML(inputStream); editDomain = new EditDomain(); - // Check if a perspective for this visualization exists - IPerspectiveRegistry perspectiveRegistry = PlatformUI - .getWorkbench().getPerspectiveRegistry(); - - String perspectiveId = "BMS_" + file.getName().replace(".bmso", ""); - IPerspectiveDescriptor perspective = perspectiveRegistry - .findPerspectiveWithId(perspectiveId); - - // Yes --> switch to this perspective - if (perspective != null) { - switchPerspective(perspectiveId); - } else { - - // No --> create one - IWorkbenchWindow window = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow(); - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - IPerspectiveDescriptor personalPerspectiveDescriptor = perspectiveRegistry - .findPerspectiveWithId(perspectiveId); - if (personalPerspectiveDescriptor == null) { - IPerspectiveDescriptor originalPerspectiveDescriptor = perspectiveRegistry - .findPerspectiveWithId("de.bmotionstudio.perspective.run"); - switchPerspective(originalPerspectiveDescriptor.getId()); - personalPerspectiveDescriptor = perspectiveRegistry - .clonePerspective(perspectiveId, perspectiveId, - originalPerspectiveDescriptor); - // save the perspective - page.savePerspectiveAs(personalPerspectiveDescriptor); - exportPerspective(perspectiveId); + importPerspective(file.getProject().getFile( + getPerspectiveFileName())); + openPerspective(site.getPage()); + + if (obj instanceof Visualization) { + + simulation = new Simulation(); + + Visualization visualization = (Visualization) obj; + visualization.setProjectFile(file); + + VisualizationView visualizationView = new VisualizationView( + "New Visualization View", visualization); + + String secId = UUID.randomUUID().toString(); + createVisualizationViewPart(secId, editDomain, visualization); + + simulation.getVisualizationViews() + .put(secId, visualizationView); + + } else if (obj instanceof Simulation) { + simulation = (Simulation) obj; + } + + if (simulation != null) { + + for (Map.Entry<String, VisualizationView> entry : simulation + .getVisualizationViews().entrySet()) { + + String secId = entry.getKey(); + VisualizationView visView = entry.getValue(); + Visualization vis = visView.getVisualization(); + vis.setProjectFile(file); + // String partName = visView.getPartName(); + IViewReference viewReference = site.getPage() + .findViewReference( + VisualizationViewPart.ID, secId); + // Check if view already exists + if (viewReference != null) { + VisualizationViewPart visualizationView = (VisualizationViewPart) viewReference + .getView(false); + if (visualizationView != null) { + visualizationView.initGraphicalViewer(editDomain, + vis); + } else { + //TODO return some error! + } + } else { + // If not, create a new one + createVisualizationViewPart(secId, editDomain, vis); } + } } - // System.out.println("===> " - // + service.getRootNode().nodeExists( - // "/instance/org.eclipse.ui.workbench")); - // - // Preferences node = node; - // - // System.out.println(service.getRootNode().node("instance") - // .node("org.eclipse.ui.workbench").childrenNames().length); - // - // for (String s1 : service.getRootNode().childrenNames()) { - // - // Preferences node2 = service.getRootNode().node(s1); - // for (String s2 : node2.childrenNames()) - // for (String s3 : node2.node(s2) - // .childrenNames()) - // System.out.println(s3); - // } - - IWorkbenchWindow window = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow(); - IWorkbenchPage activePage = window.getActivePage(); - VisualizationView visualizationView1 = (VisualizationView) activePage - .showView(VisualizationView.ID, "1", - IWorkbenchPage.VIEW_VISIBLE); - visualizationView1.initGraphicalViewer(editDomain, visualization); - // - // VisualizationView visualizationView2 = (VisualizationView) - // activePage - // .showView(VisualizationView.ID, "2", - // IWorkbenchPage.VIEW_VISIBLE); - // visualizationView2.initGraphicalViewer(editDomain, - // visualization); - // - // VisualizationView visualizationView3 = (VisualizationView) - // activePage - // .showView(VisualizationView.ID, "3", - // IWorkbenchPage.VIEW_VISIBLE); - // visualizationView3.initGraphicalViewer(editDomain, - // visualization); - } catch (CoreException e) { e.printStackTrace(); } @@ -253,6 +346,19 @@ public class BMotionStudioEditor extends EditorPart { } + private VisualizationViewPart createVisualizationViewPart(String secId, + EditDomain editDomain, Visualization visualization) + throws PartInitException { + IWorkbenchWindow window = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + IWorkbenchPage activePage = window.getActivePage(); + VisualizationViewPart visualizationView = (VisualizationViewPart) activePage + .showView(VisualizationViewPart.ID, secId, + IWorkbenchPage.VIEW_VISIBLE); + visualizationView.initGraphicalViewer(editDomain, visualization); + return visualizationView; + } + private void switchPerspective(String id) { IWorkbench workbench = PlatformUI.getWorkbench(); try { @@ -271,60 +377,35 @@ public class BMotionStudioEditor extends EditorPart { // + getVisualization().getLanguage() + ")"; // } - private void exportPerspective(final String perspectiveName) { - - try { - - IPreferenceFilter[] transfers = null; - - // export all - transfers = new IPreferenceFilter[1]; - - // For export all create a preference filter that can export - // all nodes of the Instance and Configuration scopes - transfers[0] = new IPreferenceFilter() { - public String[] getScopes() { - return new String[] { InstanceScope.SCOPE }; - } - - public Map<String, PreferenceFilterEntry[]> getMapping( - String scope) { - Map<String, PreferenceFilterEntry[]> map = new HashMap<String, PreferenceFilterEntry[]>(); - map.put("org.eclipse.ui.workbench", - new PreferenceFilterEntry[] { new PreferenceFilterEntry( - perspectiveName + "_persp") }); - return map; - } - }; - - IFile pFile = file.getProject().getFile( - file.getName().replace(".bmso", ".bmsop")); - - String content = ""; - - if (!pFile.exists()) - pFile.create(new ByteArrayInputStream(content.getBytes()), - true, - new NullProgressMonitor()); - - File exportFile = new File(pFile.getLocationURI()); - FileOutputStream fos = new FileOutputStream(exportFile); - IPreferencesService service = Platform.getPreferencesService(); - service.exportPreferences(service.getRootNode(), transfers, fos); - - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + public void setDirty(boolean dirty) { + if (isDirty() != dirty) { + isDirty = dirty; + firePropertyChange(IEditorPart.PROP_DIRTY); } - } @Override public void doSave(final IProgressMonitor monitor) { - // editPage.doSave(monitor); + + exportPerspective(perspective); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + try { + // saveProperties(); + OutputStreamWriter writer = new OutputStreamWriter(out, "UTF8"); + XStream xstream = new XStream(); + BMotionEditorPlugin.setAliases(xstream); + xstream.toXML(simulation, writer); + IFile file = ((IFileEditorInput) getEditorInput()).getFile(); + file.setContents(new ByteArrayInputStream(out.toByteArray()), true, + false, monitor); + getCommandStack().markSaveLocation(); + } catch (CoreException ce) { + ce.printStackTrace(); + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } @Override @@ -340,91 +421,105 @@ public class BMotionStudioEditor extends EditorPart { @Override public boolean isDirty() { - // TODO Auto-generated method stub - return false; + return isDirty; } @Override public void createPartControl(Composite parent) { container = new Composite(parent, SWT.NONE); + container.setLayout(new FillLayout()); + Button button = new Button(container, SWT.PUSH); + button.setText("Add new Visualization View"); + button.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent e) { + + try { + + String secId = UUID.randomUUID().toString(); + // Create a new visualization + String version = Platform + .getBundle(BMotionEditorPlugin.PLUGIN_ID) + .getHeaders().get("Bundle-Version"); + Visualization visualization = new Visualization( + "RushHour.bmso", + "EventB", version); + + createVisualizationViewPart(secId, editDomain, + visualization); + + VisualizationView visualizationView = new VisualizationView( + "New Visulization View", visualization); + simulation.getVisualizationViews().put(secId, + visualizationView); + + setDirty(true); + + } catch (PartInitException e1) { + e1.printStackTrace(); + } + + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + + }); } @Override public void setFocus() { - // TODO Auto-generated method stub + } + public CommandStack getCommandStack() { + return getEditDomain().getCommandStack(); } - // @Override - // protected void pageChange(int newPageIndex) { - // String newPageString = getPageText(newPageIndex); - // if (newPageString.equals("Run")) { - // switchPerspective("de.bmotionstudio.perspective.run"); - // } else { - // switchPerspective("de.bmotionstudio.perspective.edit"); - // } - // } + protected EditDomain getEditDomain() { + return editDomain; + } - // private void switchPerspective(String id) { - // IWorkbench workbench = PlatformUI.getWorkbench(); - // try { - // workbench.showPerspective(id, workbench.getActiveWorkbenchWindow()); - // } catch (WorkbenchException e) { - // Logger.notifyUser( - // "An error occured while trying to switch the perspective.", - // e); - // } - // } + @Override + public void partActivated(IWorkbenchPartReference partRef) { + IWorkbenchPart part = partRef.getPart(false); + if (part == this) + openPerspective(partRef.getPage()); + } - // public BMotionStudioEditorPage getEditPage() { - // return this.editPage; - // } - // - // public BMotionStudioRunPage getRunPage() { - // return this.runPage; - // } + @Override + public void partBroughtToTop(IWorkbenchPartReference partRef) { + } - // public void reset() { - // removeRunPage(); - // } - // - // private void unregister() { - // getVisualization().setIsRunning(false); - // StaticListenerRegistry.unregisterListener(this); - // if (animation != null) { - // animation.unregister(); - // } - // } + @Override + public void partClosed(IWorkbenchPartReference partRef) { + if (partRef.getPart(false) == this) { + partRef.getPage().savePerspectiveAs(perspective); + exportPerspective(perspective); + closePerspective(partRef.getPage(), perspective); + deletePerspective(partRef.getPage(), perspective); + } + } - // public IEditorPart getCurrentPage() { - // return getActiveEditor(); - // } - // - // public void addRunPageListener(IRunPageListener listener) { - // this.runPageListener.add(listener); - // } - // - // public void removeRunPageListener(IRunPageListener listener) { - // this.runPageListener.remove(listener); - // } + @Override + public void partDeactivated(IWorkbenchPartReference partRef) { + } - // public double getZoomFactor() { - // switch (getActivePage()) { - // case 0: - // return editPage.getRootEditPart().getZoomManager().getZoom(); - // case 1: - // return runPage.getRootEditPart().getZoomManager().getZoom(); - // default: - // return 1; - // } - // } + @Override + public void partOpened(IWorkbenchPartReference partRef) { + } - // @Override - // protected void setActivePage(int pageIndex) { - // super.setActivePage(pageIndex); - // // TODO: This is a hack for fixing the selection bug in the editor! - // getSite().setSelectionProvider( - // editPage.getSite().getSelectionProvider()); - // } + @Override + public void partHidden(IWorkbenchPartReference partRef) { + } + + @Override + public void partVisible(IWorkbenchPartReference partRef) { + } + + @Override + public void partInputChanged(IWorkbenchPartReference partRef) { + } } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/VisualizationView.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/VisualizationViewPart.java similarity index 79% rename from de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/VisualizationView.java rename to de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/VisualizationViewPart.java index 3841d93c57d7d06b3057376ff1ea125c9da055d5..cdc04fbfc3160359f04a685e8857fcabba59d212 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/VisualizationView.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/VisualizationViewPart.java @@ -13,7 +13,7 @@ import org.eclipse.ui.views.properties.IPropertySheetPage; import de.bmotionstudio.gef.editor.model.Visualization; import de.bmotionstudio.gef.editor.part.BMSEditPartFactory; -public class VisualizationView extends ViewPart { +public class VisualizationViewPart extends ViewPart { public static String ID = "de.bmotionstudio.gef.editor.VisualizationView"; @@ -23,15 +23,6 @@ public class VisualizationView extends ViewPart { private Visualization visualization; - public VisualizationView() { - } - - // public VisualizationView(EditDomain editDomain, Visualization - // visualization) { - // this.editDomain = editDomain; - // this.visualization = visualization; - // } - public void initGraphicalViewer(EditDomain editDomain, Visualization visualization) { this.editDomain = editDomain; @@ -72,38 +63,28 @@ public class VisualizationView extends ViewPart { } - /** - * Returns the <code>CommandStack</code> of this editor's - * <code>EditDomain</code>. - * - * @return the <code>CommandStack</code> - */ public CommandStack getCommandStack() { return getEditDomain().getCommandStack(); } - /** - * Returns the edit domain. - * - * @return the edit domain - */ protected EditDomain getEditDomain() { return editDomain; } - /** - * Returns the graphical viewer. - * - * @return the graphical viewer - */ protected GraphicalViewer getGraphicalViewer() { return graphicalViewer; } @Override public void setFocus() { - // TODO Auto-generated method stub + } + public Visualization getVisualization() { + return visualization; + } + + public void setVisualization(Visualization visualization) { + this.visualization = visualization; } } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Simulation.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Simulation.java new file mode 100644 index 0000000000000000000000000000000000000000..f99cec3d117aded76318d10dd4a4300204b79605 --- /dev/null +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Simulation.java @@ -0,0 +1,23 @@ +package de.bmotionstudio.gef.editor.model; + +import java.util.HashMap; +import java.util.Map; + +public class Simulation { + + private Map<String, VisualizationView> views; + + public Simulation() { + this.views = new HashMap<String, VisualizationView>(); + } + + public Map<String, VisualizationView> getVisualizationViews() { + return views; + } + + public void setVisualizationViews( + Map<String, VisualizationView> visualizationViews) { + this.views = visualizationViews; + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/VisualizationView.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/VisualizationView.java new file mode 100644 index 0000000000000000000000000000000000000000..040b9c127f7c9aa940a4988d02bc6e8f7ebda5f2 --- /dev/null +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/VisualizationView.java @@ -0,0 +1,29 @@ +package de.bmotionstudio.gef.editor.model; + +public class VisualizationView { + + private String name; + private Visualization visualization; + + public VisualizationView(String name, Visualization visualization) { + this.name = name; + this.visualization = visualization; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Visualization getVisualization() { + return visualization; + } + + public void setVisualization(Visualization visualization) { + this.visualization = visualization; + } + +}