facets.core.app
Class NodeViewable

java.lang.Object
  extended by facets.util.Tracer
      extended by facets.core.superficial.TargetCore
          extended by facets.core.superficial.SFrameTarget
              extended by facets.core.superficial.app.SelectingFrame
                  extended by facets.core.superficial.app.ViewableFrame
                      extended by facets.core.app.StatefulViewable<TypedNode>
                          extended by facets.core.app.NodeViewable
All Implemented Interfaces:
Notifiable, Notifying, STarget, TargeterCore.TargetType, Identified, Titled

public class NodeViewable
extends StatefulViewable<TypedNode>

StatefulViewable for tree-type content.

NodeViewable extends its superclass by


Nested Class Summary
 
Nested classes/interfaces inherited from class facets.core.app.StatefulViewable
StatefulViewable.Clipper, StatefulViewable.ClipperSource
 
Nested classes/interfaces inherited from interface facets.core.superficial.STarget
STarget.Targeted
 
Nested classes/interfaces inherited from interface facets.core.superficial.Notifying
Notifying.Impact
 
Field Summary
 
Fields inherited from class facets.core.app.StatefulViewable
clipper
 
Fields inherited from class facets.core.superficial.SFrameTarget
framed
 
Fields inherited from class facets.core.superficial.TargetCore
targets
 
Fields inherited from interface facets.core.superficial.STarget
NONE
 
Constructor Summary
NodeViewable(TypedNode node)
           
NodeViewable(TypedNode root, StatefulViewable.ClipperSource clipperSource)
           
 
Method Summary
 boolean actionIsLive(SViewer viewer, ViewableAction action)
          Re-implementation that understands ActionViewerTarget.Actions.
protected  void actionTriggered(SViewer viewer, ViewableAction action)
          Re-implementation that understands ActionViewerTarget.Actions.
protected  boolean blockNotification()
          Enables notification to be restricted to this member of the tree.
protected  boolean canMergeEdits(Stateful[] earlier, Stateful[] later)
          Can one edit state subsume the other?
protected  boolean checkStateChange(Stateful stateThen, Stateful stateNow)
          Check for difference between two states of a content member.
protected  void copyContentState()
           
 void defineSelection(java.lang.Object definition)
          Re-implements abstract method.
 void deleteSelection()
           
 java.lang.Object identity()
          Return an object that is as far as possible unique for the implementation.
 Notifying.Impact impact()
          Allows this Notifying to specify a default Notifying.Impact.
 void insertStatefuls(Stateful... statefuls)
           
 void iterateSelection(boolean forward)
           
protected  STarget[] lazyElements()
          Lazily creates elements for this target.
protected  Stateful[] matchSelectionEdits(Stateful[] targets, Stateful[] edits)
          Re-implementation.
 Notifiable monitor()
          The current Notifiable in the notification tree, as set with setMonitor.
protected static TypedNode newDebugContentNode(java.lang.String title, java.lang.Object source)
           
protected static TypedNode newDebugContentNode(java.lang.String title, java.lang.Object[] source)
           
protected static TypedNode newDebugMonitorNode(Notifiable monitor)
           
 TypedNode newGraphNode()
          Returns a descriptive node for use in debug object graph.
protected  PathSelection newNodeChangeSelection(TypedNode root, TypedNode[] nodes, boolean removing)
           
protected  TypedNode[] newPasteTextStatefuls(java.lang.String text)
          Attempt to create content from a text representation.
static Stateful[] newStatefulArray(java.lang.Object[] array)
           
 void notify(Notice notice)
          Respond to the Notice passed.
 void notifyMonitor(Notifying.Impact impact)
          Call notify on the parent monitor in the notification tree, typically with itself as parameter to the Notice passed.
protected  PathSelection pathsFromRoot(PathSelection selection)
          Converts viewer selections to full paths.
protected  void restoreState(Stateful content, Stateful state)
           
protected  TypedNode rootState()
           
 SFrameTarget selectionFrame()
          Default implementation for TypedNode tree.
 void setFramedState(java.lang.Object stateSpec, boolean interim)
          Overrides method from ViewableFrame.
 void setMonitor(Notifiable monitor)
          Attach the Notifying to a Notifiable parent in the notification tree.
 boolean textSeemsPastable(java.lang.String text)
          Does the text passed seem to represent suitable content?
protected  void viewerSelectionChanged(SViewer viewer, SSelection selection)
          Respond to change in selection.
 
Methods inherited from class facets.core.app.StatefulViewable
canPaste, copyStatefulSelection, editSelection, newPasteStatefuls, newStatefulsText, updateAfterEditAction
 
Methods inherited from class facets.core.superficial.app.ViewableFrame
newViewerSelection, viewerActions, viewerSelectionEdited
 
Methods inherited from class facets.core.superficial.app.SelectingFrame
selection, setSelection
 
Methods inherited from class facets.core.superficial.SFrameTarget
newDebugChildren, notifiesTargeter, title
 
Methods inherited from class facets.core.superficial.TargetCore
elements, findMonitorOfType, isLive, join, newTargeter, setElements, setLive, toString, wantsFocus
 
Methods inherited from class facets.util.Tracer
trace, trace, trace, trace, trace, traceDebug, traceDebug, traceObjectText, traceOutput, traceOutputWithClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface facets.core.superficial.Notifying
impact, monitor, notifyMonitor, setMonitor
 
Methods inherited from interface facets.core.superficial.Notifiable
notify
 

Constructor Detail

NodeViewable

public NodeViewable(TypedNode node)

NodeViewable

public NodeViewable(TypedNode root,
                    StatefulViewable.ClipperSource clipperSource)
Method Detail

copyContentState

protected final void copyContentState()
Overrides:
copyContentState in class StatefulViewable<TypedNode>

selectionFrame

public SFrameTarget selectionFrame()
Default implementation for TypedNode tree.

Overrides:
selectionFrame in class SelectingFrame

lazyElements

protected STarget[] lazyElements()
Description copied from class: TargetCore
Lazily creates elements for this target.

Called at most once from TargetCore.elements().

Though defined in TargetCore this method is primarily for use by SFrameTargets, which always create their elements dynamically by reimplementing this method. Default implementation returns an empty STarget[].

Overrides:
lazyElements in class TargetCore

defineSelection

public void defineSelection(java.lang.Object definition)
Re-implements abstract method.

Overrides:
defineSelection in class SelectingFrame
Parameters:
definition - is cast to a TypedNode, a path to the content root constructed and from this a PathSelection which is passed to SelectingFrame.setSelection(SSelection) PLUS...

viewerSelectionChanged

protected void viewerSelectionChanged(SViewer viewer,
                                      SSelection selection)
Description copied from class: ViewableFrame
Respond to change in selection.

Called from ViewerTargetCore.selectionChanged(SSelection), must interpret a new viewer selection in terms of the complete content. Default implementation calls SelectingFrame.setSelection(SSelection) with selection.

Overrides:
viewerSelectionChanged in class ViewableFrame
Parameters:
viewer - in which the change took place
selection - the new selection in the viewer

pathsFromRoot

protected final PathSelection pathsFromRoot(PathSelection selection)
Converts viewer selections to full paths.

Traces the path from the indexed of each path in selection to the content root.

Parameters:
selection - to be converted

actionIsLive

public boolean actionIsLive(SViewer viewer,
                            ViewableAction action)
Description copied from class: StatefulViewable
Re-implementation that understands ActionViewerTarget.Actions.

Overrides:
actionIsLive in class StatefulViewable<TypedNode>
Parameters:
viewer - the active viewer
action - to be exposed

actionTriggered

protected void actionTriggered(SViewer viewer,
                               ViewableAction action)
Description copied from class: StatefulViewable
Re-implementation that understands ActionViewerTarget.Actions.

Overrides:
actionTriggered in class StatefulViewable<TypedNode>
Parameters:
viewer - the active viewer
action - specifies the action proposed

insertStatefuls

public void insertStatefuls(Stateful... statefuls)
Overrides:
insertStatefuls in class StatefulViewable<TypedNode>

iterateSelection

public void iterateSelection(boolean forward)
Overrides:
iterateSelection in class StatefulViewable<TypedNode>

deleteSelection

public void deleteSelection()
Overrides:
deleteSelection in class StatefulViewable<TypedNode>

newNodeChangeSelection

protected final PathSelection newNodeChangeSelection(TypedNode root,
                                                     TypedNode[] nodes,
                                                     boolean removing)

textSeemsPastable

public boolean textSeemsPastable(java.lang.String text)
Description copied from class: StatefulViewable
Does the text passed seem to represent suitable content?

Used to determine the live state of the viewer 'Paste' target; default return false.

Overrides:
textSeemsPastable in class StatefulViewable<TypedNode>
Parameters:
text - is currently on the system clipboard

newPasteTextStatefuls

protected TypedNode[] newPasteTextStatefuls(java.lang.String text)
Description copied from class: StatefulViewable
Attempt to create content from a text representation.

Called by StatefulViewable.newPasteStatefuls(); may return null (the default) to signal failure.

Overrides:
newPasteTextStatefuls in class StatefulViewable<TypedNode>
Parameters:
text - is currently on the system clipboard

matchSelectionEdits

protected Stateful[] matchSelectionEdits(Stateful[] targets,
                                         Stateful[] edits)
Re-implementation.

Matches based on TypedNode.type() and StatefulCore.title().

Parameters:
targets - from the current selection
edits - were passed to setFramedState(Object, boolean)

rootState

protected final TypedNode rootState()

setFramedState

public void setFramedState(java.lang.Object stateSpec,
                           boolean interim)
Overrides method from ViewableFrame.

Having converted both stateSpec and the PathSelection.selections() of SelectingFrame.selection() to Stateful[],

  1. matches edits to their targets by calling matchSelectionEdits(Stateful[], Stateful[])
  2. compares array members using checkStateChange(Stateful, Stateful)
  3. calls Stateful.setState(Object) in each path target with the appropriate edit
  4. stores non-interim changes in a private state management sequence

Overrides:
setFramedState in class SFrameTarget
Parameters:
stateSpec - must define the new state of SFrameTarget.framed
interim - if true the edit forms part of a sequence

checkStateChange

protected boolean checkStateChange(Stateful stateThen,
                                   Stateful stateNow)
Check for difference between two states of a content member.

Called from setFramedState(Object, boolean); default returns false.

Parameters:
stateThen - a copy of the previous state
stateNow - the current state

canMergeEdits

protected boolean canMergeEdits(Stateful[] earlier,
                                Stateful[] later)
Can one edit state subsume the other?

Called (indirectly) from setFramedState(Object, boolean); default is false

Parameters:
earlier - the previous edit
later - the new edit which may subsume earlier

restoreState

protected void restoreState(Stateful content,
                            Stateful state)

newStatefulArray

public static final Stateful[] newStatefulArray(java.lang.Object[] array)

newDebugContentNode

protected static final TypedNode newDebugContentNode(java.lang.String title,
                                                     java.lang.Object source)

newDebugContentNode

protected static final TypedNode newDebugContentNode(java.lang.String title,
                                                     java.lang.Object[] source)

newDebugMonitorNode

protected static final TypedNode newDebugMonitorNode(Notifiable monitor)

newGraphNode

public final TypedNode newGraphNode()
Returns a descriptive node for use in debug object graph.


impact

public Notifying.Impact impact()
Description copied from interface: Notifying
Allows this Notifying to specify a default Notifying.Impact.

Specified by:
impact in interface Notifying
Returns:
typically Notifying.Impact.DEFAULT

identity

public java.lang.Object identity()
Description copied from interface: Identified
Return an object that is as far as possible unique for the implementation.

This will usually be a class instance counter.

Specified by:
identity in interface Identified

monitor

public final Notifiable monitor()
The current Notifiable in the notification tree, as set with setMonitor.

Complains if no parent has been set.

Specified by:
monitor in interface Notifying

notify

public void notify(Notice notice)
Description copied from interface: Notifiable
Respond to the Notice passed.

When this method is called, the Notifiable should respond based on

Specified by:
notify in interface Notifiable

notifyMonitor

public final void notifyMonitor(Notifying.Impact impact)
Description copied from interface: Notifying
Call notify on the parent monitor in the notification tree, typically with itself as parameter to the Notice passed.

Has no effect if no monitor has been set.

This is the usual means to trigger a surface retargeting, being called by an exposing SFacet on its target.

Specified by:
notifyMonitor in interface Notifying
Parameters:
impact - suggests the level of retargeting required

blockNotification

protected boolean blockNotification()
Enables notification to be restricted to this member of the tree.

Checked by notify(Notice); default returns false.


setMonitor

public final void setMonitor(Notifiable monitor)
Description copied from interface: Notifying
Attach the Notifying to a Notifiable parent in the notification tree.

Specified by:
setMonitor in interface Notifying