Math2mat

/home/ythoma/docs/math2mat/svn/wp1/framework/m2mGUI/src/m2m/frontend/dynamicview/MyGraphicalEditor.java

Go to the documentation of this file.
00001 
00018 package m2m.frontend.dynamicview;
00019 
00020 import org.eclipse.gef.EditDomain;
00021 import org.eclipse.gef.GraphicalViewer;
00022 import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
00023 import org.eclipse.swt.events.DisposeEvent;
00024 import org.eclipse.swt.events.DisposeListener;
00025 import org.eclipse.swt.widgets.Composite;
00026 import org.eclipse.ui.IWorkbenchPage;
00027 import org.eclipse.ui.PlatformUI;
00028 import org.eclipse.ui.part.ViewPart;
00029 
00030 import m2m.frontend.dynamicview.editPart.SchemaEditPartFactory;
00031 import m2m.frontend.view.Editor;
00032 
00033 
00034 public class MyGraphicalEditor extends ViewPart 
00035 {
00039     public static final String ID = "dynamicview.mygraphicaleditor";
00040     private ScrollingGraphicalViewer graphicalViewer;
00041 
00042 
00043         /* (non-Javadoc)
00044          * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
00045          */
00046         @Override
00047         public void createPartControl(Composite parent) 
00048         {               
00049                 Editor editor = (Editor)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
00050                 
00051                 /* Initialisation of the graphicalViewer */
00052         graphicalViewer = new ScrollingGraphicalViewer();
00053                 graphicalViewer.createControl(parent);
00054                 graphicalViewer.setEditDomain(new EditDomain());
00055                 graphicalViewer.setEditPartFactory(new SchemaEditPartFactory());
00056                 graphicalViewer.setContents(editor.getModel().getSchema());
00057                 //((SchemaPart)(graphicalViewer.getRootEditPart().getContents())).Intersections();
00058                 graphicalViewer.getControl().addDisposeListener(new DisposeListener() {
00059                         @Override
00060                         public void widgetDisposed(DisposeEvent event) 
00061                         {                       
00062                                 IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
00063                                 page.hideView(((MyGraphicalProperty)page.findView(MyGraphicalProperty.ID)));
00064                                 if((Editor)page.getActiveEditor() != null)
00065                                         ((Editor)page.getActiveEditor()).setModel(null);
00066                         }
00067                 });
00068         }
00069 
00070 
00071         /* (non-Javadoc)
00072          * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
00073          */
00074         @Override
00075         public void setFocus() {        
00076         }
00077         
00078         
00083         public GraphicalViewer getGraphicalViewer ()
00084         {
00085                 return this.graphicalViewer;
00086         }
00087         
00088         
00093         public void setGraphicalViewer(ScrollingGraphicalViewer graphicalViewer) 
00094         {
00095                 this.graphicalViewer = graphicalViewer;
00096         }
00097 }
 All Classes Namespaces Files Functions Variables Enumerations