com.tensegrity.palowebviewer.modules.ui.client
Class AbstractXObjectEditor

java.lang.Object
  extended by com.tensegrity.palowebviewer.modules.ui.client.AbstractXObjectEditor
All Implemented Interfaces:
IXObjectEditor
Direct Known Subclasses:
XCubeEditor

public abstract class AbstractXObjectEditor
extends java.lang.Object
implements IXObjectEditor

Abstract implementation for IXObjectEditor interface. It provides support for listeners, event firing and actions.


Field Summary
protected  IAction saveAction
          Save action object.
protected  IAction saveAsAction
          "Save As" action object.
 
Constructor Summary
AbstractXObjectEditor(IEngine engine, XObject object)
           
 
Method Summary
 void addEditorListener(IEditorListener listener)
          Add listener for the editor.
 void close(IEditorCloseCallback callback)
           
 void dispose()
          Dispose editor (Unsubscribe all listeners)
protected abstract  void doSave(IEditorSaveCallback callback)
          Call to this method is redirected from saveAction.
protected abstract  void doSaveAs(IEditorSaveCallback callback)
          Call to this method is redirected from saveAsAction.
protected abstract  void doSaveModified(IEditorSaveCallback callback)
           
protected  void fireModified()
          Notifies editor listeners that editor now has unsaved changes.
protected  void fireObjectRenamed()
           
protected  void fireSourceChanged()
          Notifies editor listeners that edited object has been changed.
protected  void fireUnmodified()
          Notifies editor listeners that editor now has no unsaved changes.
 IEngine getEngine()
           
 IPaloServerModel getPaloServerModel()
          Returns link to palo server model for the idited XObject.
 IAction getSaveAction()
          Returns save action for this editor.
 IAction getSaveAsAction()
          Returns "save as " action for this editor.
 XObject getXObject()
          Returns XObject for the editor.
protected abstract  boolean hasChanged(XObject[] path, XObject[] oldChildren, int type)
           
 boolean isInitialized()
           
 boolean isModified()
          Tells if there is any unsaved modifications.
protected abstract  boolean isObjectPart(XObject object)
           
protected  void onSourceChanged()
           
 void removeEditorListener(IEditorListener listener)
          Remove editor listener.
protected  void setModified(boolean modified)
          Marks the editor as modified or unmodified.
protected  void setObject(XObject object)
          Set XObject to edit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.tensegrity.palowebviewer.modules.ui.client.IXObjectEditor
getTitle
 

Field Detail

saveAction

protected final IAction saveAction
Save action object. Call to it's IAction.onActionPerformed(java.lang.Object) is delegated to doSave(com.tensegrity.palowebviewer.modules.engine.client.IEditorSaveCallback) method.


saveAsAction

protected final IAction saveAsAction
"Save As" action object. Call to it's IAction.onActionPerformed(java.lang.Object) is delegated to doSaveAs(com.tensegrity.palowebviewer.modules.engine.client.IEditorSaveCallback) method.

Constructor Detail

AbstractXObjectEditor

public AbstractXObjectEditor(IEngine engine,
                             XObject object)
Method Detail

isInitialized

public boolean isInitialized()

isObjectPart

protected abstract boolean isObjectPart(XObject object)

onSourceChanged

protected void onSourceChanged()

hasChanged

protected abstract boolean hasChanged(XObject[] path,
                                      XObject[] oldChildren,
                                      int type)

getPaloServerModel

public IPaloServerModel getPaloServerModel()
Returns link to palo server model for the idited XObject.


getEngine

public IEngine getEngine()

getSaveAction

public IAction getSaveAction()
Returns save action for this editor.

Specified by:
getSaveAction in interface IXObjectEditor

getSaveAsAction

public IAction getSaveAsAction()
Returns "save as " action for this editor. It could be disabled if "save as" action can not be performed in this editor.

Specified by:
getSaveAsAction in interface IXObjectEditor

isModified

public boolean isModified()
Tells if there is any unsaved modifications.

Specified by:
isModified in interface IXObjectEditor
Returns:
true if there unsaved changes, false otherwise.

getXObject

public XObject getXObject()
Returns XObject for the editor.

Specified by:
getXObject in interface IXObjectEditor
Returns:
editors title.

addEditorListener

public void addEditorListener(IEditorListener listener)
Add listener for the editor. It will be notified about editor's events.

Specified by:
addEditorListener in interface IXObjectEditor

removeEditorListener

public void removeEditorListener(IEditorListener listener)
Remove editor listener.

Specified by:
removeEditorListener in interface IXObjectEditor

setModified

protected void setModified(boolean modified)
Marks the editor as modified or unmodified.

Parameters:
modified - - state to set; If modified is true then state changed to modified and saveAction is enabled. Else state changed to unmodified and saveAction is disabled. Listeners are notified about the event.

doSave

protected abstract void doSave(IEditorSaveCallback callback)
Call to this method is redirected from saveAction.


doSaveAs

protected abstract void doSaveAs(IEditorSaveCallback callback)
Call to this method is redirected from saveAsAction.


setObject

protected void setObject(XObject object)
Set XObject to edit.

Parameters:
object - - object to set.

fireModified

protected void fireModified()
Notifies editor listeners that editor now has unsaved changes.


fireUnmodified

protected void fireUnmodified()
Notifies editor listeners that editor now has no unsaved changes.


fireSourceChanged

protected void fireSourceChanged()
Notifies editor listeners that edited object has been changed.


fireObjectRenamed

protected void fireObjectRenamed()

dispose

public void dispose()
Description copied from interface: IXObjectEditor
Dispose editor (Unsubscribe all listeners)

Specified by:
dispose in interface IXObjectEditor

close

public void close(IEditorCloseCallback callback)
Specified by:
close in interface IXObjectEditor

doSaveModified

protected abstract void doSaveModified(IEditorSaveCallback callback)