org.openstreetmap.josm.gui.dialogs.relation
Class RelationDialogManager

java.lang.Object
  extended by java.awt.event.WindowAdapter
      extended by org.openstreetmap.josm.gui.dialogs.relation.RelationDialogManager
All Implemented Interfaces:
java.awt.event.WindowFocusListener, java.awt.event.WindowListener, java.awt.event.WindowStateListener, java.util.EventListener, MapView.LayerChangeListener

public class RelationDialogManager
extends java.awt.event.WindowAdapter
implements MapView.LayerChangeListener

RelationDialogManager keeps track of the open relation editors.


Nested Class Summary
private static class RelationDialogManager.DialogContext
          Helper class for keeping the context of a relation editor.
 
Field Summary
private  java.util.HashMap<RelationDialogManager.DialogContext,RelationEditor> openDialogs
          the map of open dialogs
(package private) static RelationDialogManager relationDialogManager
          keeps track of open relation editors
 
Constructor Summary
RelationDialogManager()
          constructor
 
Method Summary
 void activeLayerChange(Layer oldLayer, Layer newLayer)
          Notifies this listener that the active layer has changed.
 void close(OsmDataLayer layer, Relation relation)
          Closes the editor open for a specific layer and a specific relation.
 RelationEditor getEditorForRelation(OsmDataLayer layer, Relation relation)
          Replies the editor for the relation managed by layer.
static RelationDialogManager getRelationDialogManager()
          Replies the singleton RelationDialogManager
protected  boolean hasEditorWithCloseUpperLeftCorner(java.awt.Point p, RelationEditor thisEditor)
          Replies true, if there is another open RelationEditor whose upper left corner is close to p.
 boolean isOpenInEditor(OsmDataLayer layer, Relation relation)
          Replies true if there is an open relation editor for the relation managed by the given layer.
 void layerAdded(Layer newLayer)
          Notifies this listener that a layer has been added.
 void layerRemoved(Layer oldLayer)
          called when a layer is removed
 void positionOnScreen(RelationEditor editor)
          Positions a RelationEditor on the screen.
 void register(OsmDataLayer layer, Relation relation, RelationEditor editor)
          Register the relation editor for a relation managed by a OsmDataLayer.
 void updateContext(OsmDataLayer layer, Relation relation, RelationEditor editor)
           
 void windowClosed(java.awt.event.WindowEvent e)
           
 
Methods inherited from class java.awt.event.WindowAdapter
windowActivated, windowClosing, windowDeactivated, windowDeiconified, windowGainedFocus, windowIconified, windowLostFocus, windowOpened, windowStateChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

relationDialogManager

static RelationDialogManager relationDialogManager
keeps track of open relation editors


openDialogs

private final java.util.HashMap<RelationDialogManager.DialogContext,RelationEditor> openDialogs
the map of open dialogs

Constructor Detail

RelationDialogManager

public RelationDialogManager()
constructor

Method Detail

getRelationDialogManager

public static RelationDialogManager getRelationDialogManager()
Replies the singleton RelationDialogManager

Returns:
the singleton RelationDialogManager

register

public void register(OsmDataLayer layer,
                     Relation relation,
                     RelationEditor editor)
Register the relation editor for a relation managed by a OsmDataLayer.

Parameters:
layer - the layer
relation - the relation
editor - the editor

updateContext

public void updateContext(OsmDataLayer layer,
                          Relation relation,
                          RelationEditor editor)

close

public void close(OsmDataLayer layer,
                  Relation relation)
Closes the editor open for a specific layer and a specific relation.

Parameters:
layer - the layer
relation - the relation

isOpenInEditor

public boolean isOpenInEditor(OsmDataLayer layer,
                              Relation relation)
Replies true if there is an open relation editor for the relation managed by the given layer. Replies false if relation is null.

Parameters:
layer - the layer
relation - the relation. May be null.
Returns:
true if there is an open relation editor for the relation managed by the given layer; false otherwise

getEditorForRelation

public RelationEditor getEditorForRelation(OsmDataLayer layer,
                                           Relation relation)
Replies the editor for the relation managed by layer. Null, if no such editor is currently open. Returns null, if relation is null.

Parameters:
layer - the layer
relation - the relation
Returns:
the editor for the relation managed by layer. Null, if no such editor is currently open.
See Also:
isOpenInEditor(OsmDataLayer, Relation)

layerRemoved

public void layerRemoved(Layer oldLayer)
called when a layer is removed

Specified by:
layerRemoved in interface MapView.LayerChangeListener
Parameters:
oldLayer - The old removed layer

activeLayerChange

public void activeLayerChange(Layer oldLayer,
                              Layer newLayer)
Description copied from interface: MapView.LayerChangeListener
Notifies this listener that the active layer has changed.

Specified by:
activeLayerChange in interface MapView.LayerChangeListener
Parameters:
oldLayer - The previous active layer
newLayer - The new activer layer

layerAdded

public void layerAdded(Layer newLayer)
Description copied from interface: MapView.LayerChangeListener
Notifies this listener that a layer has been added.

Specified by:
layerAdded in interface MapView.LayerChangeListener
Parameters:
newLayer - The new added layer

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)
Specified by:
windowClosed in interface java.awt.event.WindowListener
Overrides:
windowClosed in class java.awt.event.WindowAdapter

hasEditorWithCloseUpperLeftCorner

protected boolean hasEditorWithCloseUpperLeftCorner(java.awt.Point p,
                                                    RelationEditor thisEditor)
Replies true, if there is another open RelationEditor whose upper left corner is close to p.

Parameters:
p - the reference point to check
Returns:
true, if there is another open RelationEditor whose upper left corner is close to p.

positionOnScreen

public void positionOnScreen(RelationEditor editor)
Positions a RelationEditor on the screen. Tries to center it on the screen. If it hide another instance of an editor at the same position this method tries to reposition editor by moving it slightly down and slightly to the right.

Parameters:
editor - the editor


JOSM