|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.AbstractAction
org.openstreetmap.josm.actions.JosmAction
org.openstreetmap.josm.actions.mapmode.MapMode
org.openstreetmap.josm.actions.mapmode.DeleteAction
public class DeleteAction
A map mode that enables the user to delete nodes and other objects. The user can click on an object, which gets deleted if possible. When Ctrl is pressed when releasing the button, the objects and all its references are deleted. If the user did not press Ctrl and the object has any references, the user is informed and nothing is deleted. If the user enters the mapmode and any object is selected, all selected objects are deleted, if possible.
Nested Class Summary | |
---|---|
private static class |
DeleteAction.DeleteMode
|
private static class |
DeleteAction.DeleteParameters
|
Field Summary | |
---|---|
private boolean |
drawTargetHighlight
|
private java.awt.event.MouseEvent |
oldEvent
|
private WaySegment |
oldHighlightedWaySegment
|
private java.util.Set<OsmPrimitive> |
oldHighlights
elements that have been highlighted in the previous iteration. |
Fields inherited from class org.openstreetmap.josm.actions.mapmode.MapMode |
---|
alt, ctrl, cursor, shift |
Fields inherited from class org.openstreetmap.josm.actions.JosmAction |
---|
sc |
Fields inherited from class javax.swing.AbstractAction |
---|
changeSupport, enabled |
Fields inherited from interface javax.swing.Action |
---|
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON |
Constructor Summary | |
---|---|
DeleteAction(MapFrame mapFrame)
Construct a new DeleteAction. |
Method Summary | |
---|---|
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 |
doActionPerformed(java.awt.event.ActionEvent e)
|
void |
enterMode()
|
void |
eventDispatched(java.awt.AWTEvent e)
This is required to update the cursors when ctrl/shift/alt is pressed |
void |
exitMode()
|
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)
|
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. |
Methods inherited from class org.openstreetmap.josm.actions.mapmode.MapMode |
---|
mouseClicked, mouseEntered, mouseExited, mousePressed, updateKeyModifiers, updateKeyModifiers, updateKeyModifiers, updateStatusLine |
Methods inherited from class org.openstreetmap.josm.actions.JosmAction |
---|
destroy, getCurrentDataSet, getEditLayer, getShortcut, initEnabledState, installAdapters, setTooltip, updateEnabledState |
Methods inherited from class javax.swing.AbstractAction |
---|
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.awt.event.MouseEvent oldEvent
private java.util.Set<OsmPrimitive> oldHighlights
private WaySegment oldHighlightedWaySegment
private boolean drawTargetHighlight
Constructor Detail |
---|
public DeleteAction(MapFrame mapFrame)
mapFrame
- The frame this action belongs to.Method Detail |
---|
public void enterMode()
enterMode
in class MapMode
public void exitMode()
exitMode
in class 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)
public 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 void removeHighlighting()
private void addHighlighting(java.awt.event.MouseEvent e, int modifiers)
e
- modifiers
- private void repaintIfRequired(java.util.Set<OsmPrimitive> newHighlights, WaySegment newHighlightedWaySegment)
private void updateCursor(java.awt.event.MouseEvent e, int modifiers)
e
- modifiers
- private void giveUserFeedback(java.awt.event.MouseEvent e, int modifiers)
private void giveUserFeedback(java.awt.event.MouseEvent e)
public 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)
layerIsSupported
in class MapMode
protected 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
- thrown if layer is null
java.lang.IllegalArgumentException
- thrown if toDelete is nulprivate 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 updateCursorsilet
- Set to true if the user should not be bugged with additional
dialogs
public void eventDispatched(java.awt.AWTEvent e)
eventDispatched
in interface java.awt.event.AWTEventListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |