JHotDraw 7.4.1

org.jhotdraw.gui.event
Class AbstractAttributeEditorHandler<T>

java.lang.Object
  extended by org.jhotdraw.gui.event.AbstractAttributeEditorHandler<T>
All Implemented Interfaces:
Disposable
Direct Known Subclasses:
DrawingAttributeEditorHandler, FigureAttributeEditorHandler

public abstract class AbstractAttributeEditorHandler<T>
extends java.lang.Object
implements Disposable

AbstractAttributeEditorHandler mediates between an AttributeEditor and the currently selected Figure's in a DrawingEditor.


Design Patterns

Observer
Selection changes of DrawingView are observed by user interface components:
Subject: DrawingView; Observer: FigureSelectionListener; Concrete-Observer: AbstractAttributeEditorHandler, SelectionComponentDisplayer, SelectionComponentRepainter.


Version:
$Id: AbstractAttributeEditorHandler.java 604 2010-01-09 12:00:29Z rawcoder $
Author:
Werner Randelshofer

Nested Class Summary
protected  class AbstractAttributeEditorHandler.EventHandler
           
 
Field Summary
protected  DrawingView activeView
           
protected  AttributeEditor<T> attributeEditor
           
protected  AttributeKey<T> attributeKey
           
protected  java.util.LinkedList<java.lang.Object> attributeRestoreData
           
protected  java.util.Map<AttributeKey,java.lang.Object> defaultAttributes
           
protected  DrawingEditor drawingEditor
           
protected  int updateDepth
           
protected  DrawingView view
           
 
Constructor Summary
AbstractAttributeEditorHandler(AttributeKey<T> key, AttributeEditor<T> attributeEditor, DrawingEditor drawingEditor)
           
AbstractAttributeEditorHandler(AttributeKey<T> key, AttributeEditor<T> attributeEditor, DrawingEditor drawingEditor, boolean updateDrawingEditorDefaults)
           
AbstractAttributeEditorHandler(AttributeKey<T> key, java.util.Map<AttributeKey,java.lang.Object> defaultAttributes, AttributeEditor<T> attributeEditor, DrawingEditor drawingEditor, boolean updateDrawingEditorDefaults)
           
 
Method Summary
 void dispose()
          Disposes of all resources held by this object so that they can be garbage collected.
protected  DrawingView getActiveView()
           
 AttributeEditor<T> getAttributeEditor()
          Returns the AttributeEditor to which this FigureAttributeEditorHandler is attached.
 AttributeKey<T> getAttributeKey()
           
 DrawingEditor getDrawingEditor()
          Returns the DrawingEditor to which this FigureAttributeEditorHandler is attached.
protected abstract  java.util.Set<Figure> getEditedFigures()
           
 DrawingView getView()
          Returns the DrawingView to which this FigureAttributeEditorHandler is attached.
 boolean isUpdateDrawingEditorDefaults()
          Returns true if the attribute editor updates the default values of the drawing editor.
 void setAttributeEditor(AttributeEditor<T> newValue)
          Attaches the FigureAttributeEditorHandler to the specified AttributeEditor.
 void setAttributeKey(AttributeKey<T> newValue)
           
 void setDrawingEditor(DrawingEditor newValue)
          Attaches the FigureAttributeEditorHandler to the specified DrawingEditor.
 void setUpdateDrawingEditorDefaults(boolean newValue)
          Set this to true if you want the attribute editor to update the default values of the drawing editor.
 void setView(DrawingView newValue)
          Attaches the FigureAttributeEditorHandler to the specified DrawingView.
protected  void updateActiveView()
           
protected  void updateAttributeEditor()
           
protected  void updateFigures()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

drawingEditor

protected DrawingEditor drawingEditor

view

protected DrawingView view

activeView

protected DrawingView activeView

attributeEditor

protected AttributeEditor<T> attributeEditor

attributeKey

protected AttributeKey<T> attributeKey

updateDepth

protected int updateDepth

attributeRestoreData

protected java.util.LinkedList<java.lang.Object> attributeRestoreData

defaultAttributes

protected java.util.Map<AttributeKey,java.lang.Object> defaultAttributes
Constructor Detail

AbstractAttributeEditorHandler

public AbstractAttributeEditorHandler(AttributeKey<T> key,
                                      AttributeEditor<T> attributeEditor,
                                      DrawingEditor drawingEditor)

AbstractAttributeEditorHandler

public AbstractAttributeEditorHandler(AttributeKey<T> key,
                                      AttributeEditor<T> attributeEditor,
                                      DrawingEditor drawingEditor,
                                      boolean updateDrawingEditorDefaults)

AbstractAttributeEditorHandler

public AbstractAttributeEditorHandler(AttributeKey<T> key,
                                      java.util.Map<AttributeKey,java.lang.Object> defaultAttributes,
                                      AttributeEditor<T> attributeEditor,
                                      DrawingEditor drawingEditor,
                                      boolean updateDrawingEditorDefaults)
Method Detail

setDrawingEditor

public void setDrawingEditor(DrawingEditor newValue)
Attaches the FigureAttributeEditorHandler to the specified DrawingEditor.

The FigureAttributeEditorHandler listens to view changes and selection changes of the drawing editor and calls setEnabled(boolean) and updateField(Set<Figure>) on the field accordingly.

Parameters:
newValue - a drawing editor.

getDrawingEditor

public DrawingEditor getDrawingEditor()
Returns the DrawingEditor to which this FigureAttributeEditorHandler is attached.


setView

public void setView(DrawingView newValue)
Attaches the FigureAttributeEditorHandler to the specified DrawingView.

If a non-null value is provided, the FigureAttributeEditorHandler listens only to selection changes of the specified view. If a null value is provided, the FigureAttributeEditorHandler listens to all views of the drawing editor.

Parameters:
newValue - a drawing view.

getView

public DrawingView getView()
Returns the DrawingView to which this FigureAttributeEditorHandler is attached. Returns null, if the FigureAttributeEditorHandler is attached to all views of the DrawingEditor.


setUpdateDrawingEditorDefaults

public void setUpdateDrawingEditorDefaults(boolean newValue)
Set this to true if you want the attribute editor to update the default values of the drawing editor.

Parameters:
newValue -

isUpdateDrawingEditorDefaults

public boolean isUpdateDrawingEditorDefaults()
Returns true if the attribute editor updates the default values of the drawing editor.


getActiveView

protected DrawingView getActiveView()

setAttributeEditor

public void setAttributeEditor(AttributeEditor<T> newValue)
Attaches the FigureAttributeEditorHandler to the specified AttributeEditor.


getAttributeEditor

public AttributeEditor<T> getAttributeEditor()
Returns the AttributeEditor to which this FigureAttributeEditorHandler is attached.


getAttributeKey

public AttributeKey<T> getAttributeKey()

setAttributeKey

public void setAttributeKey(AttributeKey<T> newValue)

updateActiveView

protected void updateActiveView()

getEditedFigures

protected abstract java.util.Set<Figure> getEditedFigures()

updateAttributeEditor

protected void updateAttributeEditor()

updateFigures

protected void updateFigures()

dispose

public void dispose()
Description copied from interface: Disposable
Disposes of all resources held by this object so that they can be garbage collected.

Specified by:
dispose in interface Disposable

Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.