org.nakedobjects.viewer.lightweight
Class AbstractObjectView

java.lang.Object
  extended byorg.nakedobjects.viewer.lightweight.AbstractView
      extended byorg.nakedobjects.viewer.lightweight.AbstractObjectView
All Implemented Interfaces:
java.lang.Cloneable, ObjectView, View
Direct Known Subclasses:
ClassIcon, DragOutline, EmptyField, ObjectIconView, OpenClassView

public abstract class AbstractObjectView
extends AbstractView
implements ObjectView


Field Summary
protected static org.apache.log4j.Logger LOG
           
 
Fields inherited from class org.nakedobjects.viewer.lightweight.AbstractView
DEBUG, DRAG_HANDLE_WIDTH, HPADDING, ICON_SIZE, VPADDING
 
Constructor Summary
AbstractObjectView()
           
 
Method Summary
protected  Color backgroundColor()
           
 void clearRootViewIdentified()
           
protected  java.lang.Object clone()
           
 void collectionAddUpdate(NakedCollection collection, NakedObject element)
           
 void collectionRemoveUpdate(NakedCollection collection, NakedObject element)
           
protected  Icon createIconImage(int size)
           
 java.lang.String debugDetails()
          Returns debug details about this view.
 void dispose()
          Called when a view is no longer needed and its resources can be disposed of.
 void dragCancel(DragHandler drag)
           
 void dragging(DragHandler drag)
           
 void dragObjectIn(ObjectDrag drag)
           
 void dragObjectOut(ObjectDrag drag)
           
 void draw(Canvas canvas)
          Called by the frame, or the parent view, when this view must redraw itself.
 void dropObject(ObjectDrag drag)
          Called when a dragged object is dropped onto this view.
 void dropView(ViewDrag drag)
          Default view drop behaviour that moves a dragged top level window, or creates a new top-level window for a dragged internal view
 void entered()
          Called as the mouse crosses the bounds, and ends up inside, of this view.
 void enteredSubview()
          Called as the mouse moves into one of this view's contained views.
 void exited()
          Called as the mouse crosses the bounds, and ends up outside, of this view.
 void exitedSubview()
          Called as the mouse moves back into view from one its contained views.
 void firstClick(Click click)
          Raises/lowers this view if it is a root view.
 Field getFieldOf()
          The object field that this view is for.
 NakedObject getObject()
           
 Size getRequiredSize()
           
 View getRoot()
           
 ObjectViewState getState()
           
protected  void init(NakedObject object)
           
 boolean isIdentified()
           
 boolean isRoot()
           
 View makeView(Naked object, Field fieldOf)
          Creates a new concrete view, using this view as a prototype, reassigning the naked object in the process.
 void menuOptions(MenuOptionSet options)
          Called when the popup menu is being populated for this view.
 void mouseMoved(Location at)
          Called as the mouse is moved around within this view.
 java.lang.String objectInfo()
          The information about this object to be displayed on the status bar.
 boolean objectLocatedAt(Location mouseLocation)
           
 void objectMenuOptions(MenuOptionSet options)
           
 void objectUpdate(NakedObject object)
           
 ObjectView parentObjectView()
          Returns the view that logically contains this view, i.e., for the associated object.
 DragView pickupObject(ObjectDrag drag)
          Returns the view that logically contains this view, i.e., for the associated object.
 DragView pickupView(ViewDrag drag)
           
 void removeViewsFor(NakedObject object, java.util.Vector toRemove)
          Called when this view is dropped onto the workspace.
 void secondClick(Click click)
          Called when the user double-clicked this view.
 void setRootViewIdentified()
           
 ObjectView topView()
           
 java.lang.String toString()
           
protected  boolean transparentBackground()
          Root views should be opaque
 void viewMenuOptions(MenuOptionSet options)
           
 
Methods inherited from class org.nakedobjects.viewer.lightweight.AbstractView
addControl, assignId, calculateRepaintArea, contains, createCanvas, defaultFieldHeight, getAbsoluteLocation, getBaseline, getBorder, getBounds, getId, getLocation, getName, getPadding, getParent, getSize, getWorkspace, identifyView, indicatesForView, invalidateLayout, isLayoutInvalid, isOpen, isReplaceable, layout, limitBounds, print, redraw, removeControl, repaintAll, setBorder, setBounds, setLayoutValid, setLocation, setParent, setSize, setWorkspace, thirdClick, validateLayout
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.nakedobjects.viewer.lightweight.View
calculateRepaintArea, contains, getAbsoluteLocation, getBaseline, getBorder, getBounds, getId, getLocation, getName, getPadding, getParent, getSize, getWorkspace, identifyView, indicatesForView, invalidateLayout, isLayoutInvalid, isOpen, isReplaceable, layout, print, redraw, setBorder, setBounds, setLocation, setSize, thirdClick, validateLayout
 

Field Detail

LOG

protected static final org.apache.log4j.Logger LOG
Constructor Detail

AbstractObjectView

public AbstractObjectView()
Method Detail

getFieldOf

public Field getFieldOf()
The object field that this view is for.

Returns:
The object field, or null if it is not a field

isIdentified

public boolean isIdentified()

getObject

public NakedObject getObject()
Specified by:
getObject in interface ObjectView

getRequiredSize

public Size getRequiredSize()
Specified by:
getRequiredSize in interface View

getRoot

public View getRoot()

isRoot

public boolean isRoot()
Specified by:
isRoot in interface ObjectView

setRootViewIdentified

public void setRootViewIdentified()
Specified by:
setRootViewIdentified in interface ObjectView

getState

public ObjectViewState getState()
Specified by:
getState in interface ObjectView

clearRootViewIdentified

public void clearRootViewIdentified()
Specified by:
clearRootViewIdentified in interface ObjectView

collectionAddUpdate

public void collectionAddUpdate(NakedCollection collection,
                                NakedObject element)
Specified by:
collectionAddUpdate in interface ObjectView

collectionRemoveUpdate

public void collectionRemoveUpdate(NakedCollection collection,
                                   NakedObject element)
Specified by:
collectionRemoveUpdate in interface ObjectView

debugDetails

public java.lang.String debugDetails()
Description copied from class: AbstractView
Returns debug details about this view.

Specified by:
debugDetails in interface View
Overrides:
debugDetails in class AbstractView
Returns:
String

dispose

public void dispose()
Description copied from interface: View
Called when a view is no longer needed and its resources can be disposed of.

Specified by:
dispose in interface View
Overrides:
dispose in class AbstractView

dragCancel

public void dragCancel(DragHandler drag)

dragObjectIn

public void dragObjectIn(ObjectDrag drag)

dragObjectOut

public void dragObjectOut(ObjectDrag drag)

dragging

public void dragging(DragHandler drag)

draw

public void draw(Canvas canvas)
Description copied from interface: View
Called by the frame, or the parent view, when this view must redraw itself.

Specified by:
draw in interface View
Overrides:
draw in class AbstractView

dropObject

public void dropObject(ObjectDrag drag)
Called when a dragged object is dropped onto this view. The default behaviour implemented here calls the action method on the target, passing the source object in as the only parameter.


dropView

public void dropView(ViewDrag drag)
Default view drop behaviour that moves a dragged top level window, or creates a new top-level window for a dragged internal view

Specified by:
dropView in interface ObjectView

entered

public void entered()
Description copied from interface: View
Called as the mouse crosses the bounds, and ends up inside, of this view. Is also called as the mouse returns into this view from a contained view.

Specified by:
entered in interface View
Overrides:
entered in class AbstractView

enteredSubview

public void enteredSubview()
Description copied from interface: View
Called as the mouse moves into one of this view's contained views.

Specified by:
enteredSubview in interface View
Overrides:
enteredSubview in class AbstractView

exited

public void exited()
Description copied from interface: View
Called as the mouse crosses the bounds, and ends up outside, of this view.

Specified by:
exited in interface View
Overrides:
exited in class AbstractView

exitedSubview

public void exitedSubview()
Description copied from interface: View
Called as the mouse moves back into view from one its contained views.

Specified by:
exitedSubview in interface View
Overrides:
exitedSubview in class AbstractView

firstClick

public void firstClick(Click click)
Raises/lowers this view if it is a root view. Button 1 raises, button 2 lowers.

Specified by:
firstClick in interface View
Overrides:
firstClick in class AbstractView

makeView

public final View makeView(Naked object,
                           Field fieldOf)
Description copied from interface: View
Creates a new concrete view, using this view as a prototype, reassigning the naked object in the process. The field is the field within the parent view's object that this field represents, and is null if the view is not part of another - i.e. it is not a field within an object.

Specified by:
makeView in interface View
Parameters:
object - the object the new view is for
Returns:
View

menuOptions

public void menuOptions(MenuOptionSet options)
Description copied from interface: View
Called when the popup menu is being populated for this view. Any options that need to appear on the menu should be added to the menuOptions object.

Specified by:
menuOptions in interface View
Overrides:
menuOptions in class AbstractView

mouseMoved

public void mouseMoved(Location at)
Description copied from interface: View
Called as the mouse is moved around within this view. Does nothing; should be overriden when needed.

Specified by:
mouseMoved in interface View
Overrides:
mouseMoved in class AbstractView
Parameters:
at - the position relative to the top-left of this view

objectInfo

public java.lang.String objectInfo()
The information about this object to be displayed on the status bar.

Specified by:
objectInfo in interface ObjectView

objectLocatedAt

public boolean objectLocatedAt(Location mouseLocation)
Specified by:
objectLocatedAt in interface ObjectView

objectMenuOptions

public void objectMenuOptions(MenuOptionSet options)
Specified by:
objectMenuOptions in interface ObjectView

objectUpdate

public void objectUpdate(NakedObject object)
Specified by:
objectUpdate in interface ObjectView

parentObjectView

public ObjectView parentObjectView()
Returns the view that logically contains this view, i.e., for the associated object. If this view is for a one to one to one association, then the view will be the view up one level in the view tree. However, if this view is for a one to many association, then the view will be view, not of the internal collection, but of the parent of the collection, i.e. up two levels.


pickupObject

public DragView pickupObject(ObjectDrag drag)
Description copied from interface: ObjectView
Returns the view that logically contains this view, i.e., for the associated object. If this view is for a one to one to one association, then the view will be the view up one level in the view tree. However, if this view is for a one to many association, then the view will be view, not of the internal collection, but of the parent of the collection, i.e. up two levels.

Specified by:
pickupObject in interface ObjectView

pickupView

public DragView pickupView(ViewDrag drag)
Specified by:
pickupView in interface ObjectView

removeViewsFor

public void removeViewsFor(NakedObject object,
                           java.util.Vector toRemove)
Description copied from interface: ObjectView
Called when this view is dropped onto the workspace. The default behaviour implemented here creates a new Form view for the object in this view. This view is then removed from the workspace and the new form view is added, effectively replacing it.

Specified by:
removeViewsFor in interface ObjectView

secondClick

public void secondClick(Click click)
Description copied from interface: View
Called when the user double-clicked this view. This method will have been preceded by a call to click.

Specified by:
secondClick in interface View
Overrides:
secondClick in class AbstractView

toString

public java.lang.String toString()

topView

public ObjectView topView()
Specified by:
topView in interface ObjectView

viewMenuOptions

public void viewMenuOptions(MenuOptionSet options)
Specified by:
viewMenuOptions in interface ObjectView

backgroundColor

protected Color backgroundColor()
Overrides:
backgroundColor in class AbstractView

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Throws:
java.lang.CloneNotSupportedException

createIconImage

protected Icon createIconImage(int size)

init

protected void init(NakedObject object)

transparentBackground

protected boolean transparentBackground()
Root views should be opaque

Overrides:
transparentBackground in class AbstractView