public class DeleteAction extends MapMode implements ModifierExListener
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
DeleteAction.DeleteMode |
private static class |
DeleteAction.DeleteParameters |
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter| Modifier and Type | Field and Description |
|---|---|
private boolean |
drawTargetHighlight |
private static HighlightHelper |
HIGHLIGHT_HELPER |
private java.awt.event.MouseEvent |
oldEvent |
private WaySegment |
oldHighlightedWaySegment
elements that have been highlighted in the previous iteration.
|
sc| Constructor and Description |
|---|
DeleteAction()
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.
|
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()
Returns a short translated help message describing how this map mode can be used, to be displayed in status line.
|
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 |
modifiersExChanged(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 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.
|
isEditableDataLayer, mouseClicked, mouseEntered, mouseExited, mousePressed, preferenceChanged, readPreferences, requestFocusInMapView, updateKeyModifiers, updateKeyModifiers, updateKeyModifiers, updateKeyModifiersEx, updateStatusLinecheckAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setHelpId, setTooltip, updateEnabledState, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFutureprivate java.awt.event.MouseEvent oldEvent
private transient WaySegment oldHighlightedWaySegment
private static final HighlightHelper HIGHLIGHT_HELPER
private boolean drawTargetHighlight
public DeleteAction()
public void enterMode()
MapModepublic void exitMode()
MapModepublic void actionPerformed(java.awt.event.ActionEvent e)
MapModeactionPerformed in interface java.awt.event.ActionListeneractionPerformed in class MapModepublic void doActionPerformed(java.awt.event.ActionEvent e)
e - Action eventpublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged in interface java.awt.event.MouseMotionListenermouseDragged in class MapModepublic void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved in interface java.awt.event.MouseMotionListenermouseMoved in class MapModee - The mouse event that has been capturedprivate void removeHighlighting()
private void addHighlighting(java.awt.event.MouseEvent e, int modifiers)
e - current mouse eventmodifiers - extended 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 - extended 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.MouseListenermouseReleased in class MapModepublic java.lang.String getModeHelpText()
MapModegetModeHelpText in class MapModepublic boolean layerIsSupported(Layer l)
MapModel 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 MapModel - layertrue if the layer is supported by this map modeprotected void updateEnabledState()
JosmActionJosmAction.updateEnabledState(Collection) to respond to changes in the collection
of selected primitives.
Default behavior is empty.updateEnabledState in class JosmActionJosmAction.updateEnabledState(Collection),
JosmAction.initEnabledState(),
JosmAction.listenToLayerChange()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 modifiersExChanged(int modifiers)
modifiersExChanged in interface ModifierExListenermodifiers - The new extended modifiers