edu.usc.cse.desi.editor
Class DESIEditor

java.lang.Object
  extended byorg.eclipse.ui.part.WorkbenchPart
      extended byorg.eclipse.ui.part.EditorPart
          extended byorg.eclipse.ui.part.MultiPageEditorPart
              extended byedu.usc.cse.desi.editor.DESIEditor
All Implemented Interfaces:
org.eclipse.gef.commands.CommandStackListener, org.eclipse.core.runtime.IAdaptable, org.eclipse.ui.IEditorPart, org.eclipse.core.runtime.IExecutableExtension, org.eclipse.ui.ISaveablePart, org.eclipse.ui.ISelectionListener, org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.IWorkbenchPart2

public class DESIEditor
extends org.eclipse.ui.part.MultiPageEditorPart
implements org.eclipse.gef.commands.CommandStackListener, org.eclipse.ui.ISelectionListener

This class will be our "mother" class that is our editor. It will contain and set up the two sub-pages, GraphicalEditor and TabularEditor.

Author:
Nels Started Apr 9, 2004

Field Summary
private  boolean dirty
           
private  int graphicalPageNumber
           
private  org.eclipse.gef.ui.actions.ActionRegistry myActionRegistry
           
private  org.eclipse.gef.commands.CommandStack myCurrentComStack
           
private  java.lang.Object myCurrentSelection
           
private  DESIViewModel myModel
           
private  OverviewOutlinePage myOutlinePage
           
private  org.eclipse.gef.palette.PaletteRoot myPaletteRoot
           
private  PropertyInitializer myPropInitializer
           
private  java.util.List mySelectionActions
           
private  java.util.List myStackActions
           
private  org.eclipse.gef.ui.parts.SelectionSynchronizer mySynchronizer
           
private  edu.uci.ics.xarchutils.XArchFlatInterface myXARCH
           
private  edu.uci.ics.xarchutils.ObjRef myXARCHRef
           
private  java.util.List propertyActions
           
private  int selectionPageNumber
           
private  int tabularPageNumber
           
 
Fields inherited from class org.eclipse.ui.part.MultiPageEditorPart
 
Fields inherited from class org.eclipse.ui.part.EditorPart
 
Fields inherited from class org.eclipse.ui.part.WorkbenchPart
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Constructor Summary
DESIEditor()
           
 
Method Summary
 void alertSelectionPageOfChange(org.eclipse.jface.viewers.ISelection selection)
          This method was created for DESI 2.0.
 void commandStackChanged(java.util.EventObject event)
          When the command stack changes, the actions interested in the command stack are updated.
private  void copyXADLReferences(DESIViewModel old_model, DESIViewModel new_model)
          When the DESI model changes, if we are operating on top of a xADL model, this must be called.
protected  void createActions()
          Creates actions for this editor.
 DESIViewModel createDESIModelFromXADLModel(DeSiDataModel xadl_model)
          This method comes from the USC/UCI/JPL project.
protected  void createPages()
           
 void doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void doSaveAs()
           
protected  void firePropertyChange(int property)
           
protected  org.eclipse.gef.ui.actions.ActionRegistry getActionRegistry()
          Lazily creates and returns the action registry.
 java.lang.Object getAdapter(java.lang.Class type)
           
 DESIViewModel getModel()
          Returns the shared model that all pages of this editor will use.
 java.lang.Object getMyCurrentSelection()
          Returns whatever is currently selected.
 PropertyInitializer getMyPropInitializer()
           
 OverviewOutlinePage getOutlinePage()
          When called, this method returns either the existing or a new Outline page.
 AbstractPage getPage(int page_num)
          Returns the page with the given page number.
 org.eclipse.gef.palette.PaletteRoot getPaletteRoot()
          In case any other pages need to use a palette, here is the palette root.
protected  org.eclipse.gef.ui.parts.SelectionSynchronizer getSelectionSynchronizer()
          Returns the selection syncronizer object.
 DeSiDataModel getXADLModelFromFile(java.lang.String file_name)
          This method will, given the xadl file name, return the xadl DESI api which will then allow us to load it into our in-memory model.
 void gotoMarker(org.eclipse.core.resources.IMarker marker)
           
 void init(org.eclipse.ui.IEditorSite site, org.eclipse.ui.IEditorInput input)
          Initialize the model from the file that is given as input.
 boolean isDirty()
          Is the model dirty, or not?
 boolean isSaveAsAllowed()
           
protected  void pageChange(int newPageIndex)
          This method is called when the user switches from one page to the next.
 void selectionChanged(org.eclipse.ui.IWorkbenchPart part, org.eclipse.jface.viewers.ISelection selection)
           
 void setDirty(boolean b)
          sets whether or not the model is dirty.
 void setModel(DESIViewModel new_model)
          This method sets the model for DESI and for all of its subpages.
 void switchToSelectionPage()
          When this method is called, the editor will switch to the selection page.
protected  void updateActions(java.util.List actionIds)
          A convenience method for updating a set of actions defined by the given List of action IDs.
private  void updateXADLParents(DESIViewModel current_model)
          When the DESI model changes, if we are operating on top of a xADL model, this method must be called.
 
Methods inherited from class org.eclipse.ui.part.MultiPageEditorPart
addPage, addPage, createPartControl, createSite, dispose, getActiveEditor, getActivePage, getContainer, getControl, getEditor, getPageCount, getPageImage, getPageText, handlePropertyChange, removePage, setActivePage, setControl, setFocus, setPageImage, setPageText
 
Methods inherited from class org.eclipse.ui.part.EditorPart
getEditorInput, getEditorSite, getTitleToolTip, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setInput, setPartName
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPropertyListener, getConfigurationElement, getContentDescription, getDefaultImage, getPartName, getSite, getTitle, getTitleImage, removePropertyListener, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, removePropertyListener
 

Field Detail

dirty

private boolean dirty

graphicalPageNumber

private int graphicalPageNumber

myActionRegistry

private org.eclipse.gef.ui.actions.ActionRegistry myActionRegistry

myCurrentComStack

private org.eclipse.gef.commands.CommandStack myCurrentComStack

myCurrentSelection

private java.lang.Object myCurrentSelection

myModel

private DESIViewModel myModel

myPropInitializer

private PropertyInitializer myPropInitializer

myOutlinePage

private OverviewOutlinePage myOutlinePage

myPaletteRoot

private org.eclipse.gef.palette.PaletteRoot myPaletteRoot

mySelectionActions

private java.util.List mySelectionActions

myStackActions

private java.util.List myStackActions

mySynchronizer

private org.eclipse.gef.ui.parts.SelectionSynchronizer mySynchronizer

propertyActions

private java.util.List propertyActions

selectionPageNumber

private int selectionPageNumber

tabularPageNumber

private int tabularPageNumber

myXARCH

private edu.uci.ics.xarchutils.XArchFlatInterface myXARCH

myXARCHRef

private edu.uci.ics.xarchutils.ObjRef myXARCHRef
Constructor Detail

DESIEditor

public DESIEditor()
Method Detail

alertSelectionPageOfChange

public void alertSelectionPageOfChange(org.eclipse.jface.viewers.ISelection selection)
This method was created for DESI 2.0. When the selection is changed, the selection page needs to be updated. This method does just that. It sends the model element that has been selected to the selection page and sets it as the contents.

Parameters:
selection - ISelection

commandStackChanged

public void commandStackChanged(java.util.EventObject event)
When the command stack changes, the actions interested in the command stack are updated.

Specified by:
commandStackChanged in interface org.eclipse.gef.commands.CommandStackListener
Parameters:
event - the change event

createActions

protected void createActions()
Creates actions for this editor. Subclasses should override this method to create and register actions with the ActionRegistry.


createDESIModelFromXADLModel

public DESIViewModel createDESIModelFromXADLModel(DeSiDataModel xadl_model)
This method comes from the USC/UCI/JPL project. It will allow us to take the model from a xADL wrapper and convert it into our own in-memory model. If you think I don't know that this method is enormously complex, then you're just being silly.

Parameters:
xadl_model - usc.cse.desi.rasdsmodel.DESIDataModel The already-initialized xADL Model.
Returns:
edu.usc.cse.desi.model.DESIDataModel A new DESIDataModel that contains the in-memory model.

createPages

protected void createPages()

doSave

public void doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
Specified by:
doSave in interface org.eclipse.ui.ISaveablePart

doSaveAs

public void doSaveAs()
Specified by:
doSaveAs in interface org.eclipse.ui.ISaveablePart

firePropertyChange

protected void firePropertyChange(int property)
See Also:
WorkbenchPart.firePropertyChange(int)

getActionRegistry

protected org.eclipse.gef.ui.actions.ActionRegistry getActionRegistry()
Lazily creates and returns the action registry.

Returns:
the action registry

getAdapter

public java.lang.Object getAdapter(java.lang.Class type)
Specified by:
getAdapter in interface org.eclipse.core.runtime.IAdaptable

getModel

public DESIViewModel getModel()
Returns the shared model that all pages of this editor will use.

Returns:
DESIViewModel

getMyCurrentSelection

public java.lang.Object getMyCurrentSelection()
Returns whatever is currently selected. Mostly used for the selection page.

Returns:
The currently selected ISelection.

getOutlinePage

public OverviewOutlinePage getOutlinePage()
When called, this method returns either the existing or a new Outline page. The outline page contains the thumbnail view and also may contain, in the future, an outline of the hosts and components.

Returns:
OverviewOutlinePage

getPage

public AbstractPage getPage(int page_num)
Returns the page with the given page number.

Parameters:
page_num - int
Returns:
AbstractPage

getPaletteRoot

public org.eclipse.gef.palette.PaletteRoot getPaletteRoot()
In case any other pages need to use a palette, here is the palette root.

Returns:
PaletteRoot

getSelectionSynchronizer

protected org.eclipse.gef.ui.parts.SelectionSynchronizer getSelectionSynchronizer()
Returns the selection syncronizer object. The synchronizer can be used to sync the selection of 2 or more EditPartViewers.

Returns:
the syncrhonizer

getXADLModelFromFile

public DeSiDataModel getXADLModelFromFile(java.lang.String file_name)
This method will, given the xadl file name, return the xadl DESI api which will then allow us to load it into our in-memory model.

Parameters:
file_name - String The file name.
Returns:
The xadl model.

getMyPropInitializer

public PropertyInitializer getMyPropInitializer()
Returns:
Returns the myPropInitializer.

gotoMarker

public void gotoMarker(org.eclipse.core.resources.IMarker marker)

init

public void init(org.eclipse.ui.IEditorSite site,
                 org.eclipse.ui.IEditorInput input)
          throws org.eclipse.ui.PartInitException
Initialize the model from the file that is given as input.

Specified by:
init in interface org.eclipse.ui.IEditorPart
Throws:
org.eclipse.ui.PartInitException

isDirty

public boolean isDirty()
Is the model dirty, or not?

Specified by:
isDirty in interface org.eclipse.ui.ISaveablePart
Returns:

isSaveAsAllowed

public boolean isSaveAsAllowed()
Specified by:
isSaveAsAllowed in interface org.eclipse.ui.ISaveablePart

pageChange

protected void pageChange(int newPageIndex)
This method is called when the user switches from one page to the next. Switch to Tab View: We must fill the tables with the contents of the current delpoyment.


selectionChanged

public void selectionChanged(org.eclipse.ui.IWorkbenchPart part,
                             org.eclipse.jface.viewers.ISelection selection)
Specified by:
selectionChanged in interface org.eclipse.ui.ISelectionListener

setDirty

public void setDirty(boolean b)
sets whether or not the model is dirty.

Parameters:
b -

setModel

public void setModel(DESIViewModel new_model)
This method sets the model for DESI and for all of its subpages. This method has changed. It used to a temporary method but it has changed and now it gives the new and former model to all of the pages of the editor.

Parameters:
new_model - DESIViewModel - The new model.

copyXADLReferences

private void copyXADLReferences(DESIViewModel old_model,
                                DESIViewModel new_model)
When the DESI model changes, if we are operating on top of a xADL model, this must be called. It will copy the references of xADL models from the old model to the new model. Precondition: hosts, components and links have unique ids (given from the xADL file)

Parameters:
old_model -
new_model -

updateXADLParents

private void updateXADLParents(DESIViewModel current_model)
When the DESI model changes, if we are operating on top of a xADL model, this method must be called. It will tell every xADL component to get moved to the host that it should be moved to, as specified by the DeSi model.

Parameters:
current_model -

switchToSelectionPage

public void switchToSelectionPage()
When this method is called, the editor will switch to the selection page.


updateActions

protected void updateActions(java.util.List actionIds)
A convenience method for updating a set of actions defined by the given List of action IDs. The actions are found by looking up the ID in the action registry. If the corresponding action is an UpdateAction, it will have its update() method called.

Parameters:
actionIds - the list of IDs to update