public class DeleteAction extends MapMode implements ModifierListener
Modifier and Type | Class and Description |
---|---|
private static class |
DeleteAction.DeleteMode |
private static class |
DeleteAction.DeleteParameters |
JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
Modifier and Type | Field and Description |
---|---|
private boolean |
drawTargetHighlight |
private static HighlightHelper |
highlightHelper |
private java.awt.event.MouseEvent |
oldEvent |
private WaySegment |
oldHighlightedWaySegment
elements that have been highlighted in the previous iteration.
|
sc
Constructor and Description |
---|
DeleteAction(MapFrame mapFrame)
Construct a new DeleteAction.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Call selectMapMode(this) on the parent mapFrame.
|
private void |
addHighlighting(java.awt.event.MouseEvent e,
int modifiers)
handles everything related to highlighting primitives and way
segments for the given pointer position (via MouseEvent) and modifiers.
|
private Command |
buildDeleteCommands(java.awt.event.MouseEvent e,
int modifiers,
boolean silent)
This function takes any mouse event argument and builds the list of elements
that should be deleted but does not actually delete them.
|
static void |
deleteRelation(OsmDataLayer layer,
Relation toDelete)
Deletes the relation in the context of the given layer.
|
static void |
deleteRelations(OsmDataLayer layer,
java.util.Collection<Relation> toDelete)
Deletes the relations in the context of the given layer.
|
static void |
doActionPerformed(java.awt.event.ActionEvent e)
Invoked when the action occurs.
|
void |
enterMode()
Makes this map mode active.
|
void |
exitMode()
Makes this map mode inactive.
|
private DeleteAction.DeleteParameters |
getDeleteParameters(java.awt.event.MouseEvent e,
int modifiers) |
java.lang.String |
getModeHelpText() |
private void |
giveUserFeedback(java.awt.event.MouseEvent e)
Gives the user feedback for the action he/she is about to do.
|
private void |
giveUserFeedback(java.awt.event.MouseEvent e,
int modifiers)
Gives the user feedback for the action he/she is about to do.
|
boolean |
layerIsSupported(Layer l)
Determines if layer
l is supported by this map mode. |
void |
modifiersChanged(int modifiers)
This is required to update the cursors when ctrl/shift/alt is pressed
|
void |
mouseDragged(java.awt.event.MouseEvent e) |
void |
mouseMoved(java.awt.event.MouseEvent e)
Listen to mouse move to be able to update the cursor (and highlights)
|
void |
mouseReleased(java.awt.event.MouseEvent e)
If user clicked with the left button, delete the nearest object.
|
private static void |
removeHighlighting()
removes any highlighting that may have been set beforehand.
|
private void |
repaintIfRequired(java.util.Set<OsmPrimitive> newHighlights,
WaySegment newHighlightedWaySegment) |
private void |
updateCursor(java.awt.event.MouseEvent e,
int modifiers)
This function handles all work related to updating the cursor and highlights
|
protected void |
updateEnabledState()
Override in subclasses to update the enabled state of the action when
something in the JOSM state changes, i.e.
|
mouseClicked, mouseEntered, mouseExited, mousePressed, preferenceChanged, readPreferences, requestFocusInMapView, updateKeyModifiers, updateKeyModifiers, updateKeyModifiers, updateStatusLine
destroy, getCurrentDataSet, getEditLayer, getShortcut, initEnabledState, installAdapters, setTooltip, updateEnabledState, waitFuture
private java.awt.event.MouseEvent oldEvent
private transient WaySegment oldHighlightedWaySegment
private static final HighlightHelper highlightHelper
private boolean drawTargetHighlight
public DeleteAction(MapFrame mapFrame)
mapFrame
- The frame this action belongs to.public void enterMode()
MapMode
public void exitMode()
MapMode
public void actionPerformed(java.awt.event.ActionEvent e)
MapMode
actionPerformed
in interface java.awt.event.ActionListener
actionPerformed
in class MapMode
public static void doActionPerformed(java.awt.event.ActionEvent e)
e
- Action eventpublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
mouseDragged
in class MapMode
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
mouseMoved
in class MapMode
e
- The mouse event that has been capturedprivate static void removeHighlighting()
private void addHighlighting(java.awt.event.MouseEvent e, int modifiers)
e
- current mouse eventmodifiers
- mouse modifiers, not necessarly taken from the given mouse eventprivate void repaintIfRequired(java.util.Set<OsmPrimitive> newHighlights, WaySegment newHighlightedWaySegment)
private void updateCursor(java.awt.event.MouseEvent e, int modifiers)
e
- current mouse eventmodifiers
- mouse modifiers, not necessarly taken from the given mouse eventprivate void giveUserFeedback(java.awt.event.MouseEvent e, int modifiers)
e
- mouse eventmodifiers
- mouse modifiersprivate void giveUserFeedback(java.awt.event.MouseEvent e)
e
- mouse eventpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
mouseReleased
in class MapMode
public java.lang.String getModeHelpText()
getModeHelpText
in class MapMode
public boolean layerIsSupported(Layer l)
MapMode
l
is supported by this map mode.
By default, all tools will work with all layers.
Can be overwritten to require a special type of layerlayerIsSupported
in class MapMode
l
- layertrue
if the layer is supported by this map modeprotected void updateEnabledState()
JosmAction
JosmAction.updateEnabledState(Collection)
to respond to changes in the collection
of selected primitives.
Default behavior is empty.updateEnabledState
in class JosmAction
JosmAction.updateEnabledState(Collection)
,
JosmAction.initEnabledState()
public static void deleteRelation(OsmDataLayer layer, Relation toDelete)
layer
- the layer in whose context the relation is deleted. Must not be null.toDelete
- the relation to be deleted. Must not be null.java.lang.IllegalArgumentException
- if layer is nulljava.lang.IllegalArgumentException
- if toDelete is nullpublic static void deleteRelations(OsmDataLayer layer, java.util.Collection<Relation> toDelete)
layer
- the layer in whose context the relations are deleted. Must not be null.toDelete
- the relations to be deleted. Must not be null.java.lang.IllegalArgumentException
- if layer is nulljava.lang.IllegalArgumentException
- if toDelete is nullprivate DeleteAction.DeleteParameters getDeleteParameters(java.awt.event.MouseEvent e, int modifiers)
private Command buildDeleteCommands(java.awt.event.MouseEvent e, int modifiers, boolean silent)
e
- MouseEvent from which modifiers and position are takenmodifiers
- For explanation, see updateCursor(java.awt.event.MouseEvent, int)
silent
- Set to true if the user should not be bugged with additional dialogspublic void modifiersChanged(int modifiers)
modifiersChanged
in interface ModifierListener