org.openstreetmap.josm.command
Class ChangePropertyCommand

java.lang.Object
  extended by org.openstreetmap.josm.command.PseudoCommand
      extended by org.openstreetmap.josm.command.Command
          extended by org.openstreetmap.josm.command.ChangePropertyCommand

public class ChangePropertyCommand
extends Command

Command that manipulate the key/value structure of several objects. Manages deletion, adding and modify of values and keys.


Field Summary
private  java.util.List<OsmPrimitive> objects
          All primitives that are affected with this command.
private  java.util.AbstractMap<java.lang.String,java.lang.String> tags
          Key and value pairs.
 
Constructor Summary
ChangePropertyCommand(java.util.Collection<? extends OsmPrimitive> objects, java.util.AbstractMap<java.lang.String,java.lang.String> tags)
          Creates a command to change multiple properties of multiple objects
ChangePropertyCommand(java.util.Collection<? extends OsmPrimitive> objects, java.lang.String key, java.lang.String value)
          Creates a command to change one property of multiple objects
ChangePropertyCommand(OsmPrimitive object, java.lang.String key, java.lang.String value)
          Creates a command to change on property of one object
 
Method Summary
 boolean executeCommand()
          Executes the command on the dataset.
 void fillModifiedData(java.util.Collection<OsmPrimitive> modified, java.util.Collection<OsmPrimitive> deleted, java.util.Collection<OsmPrimitive> added)
          Fill in the changed data this command operates on.
 java.util.Collection<PseudoCommand> getChildren()
          Returns the subcommands of this command.
 javax.swing.Icon getDescriptionIcon()
          Provides a descriptive icon of this command.
 java.lang.String getDescriptionText()
          Provides a description text representing this command.
private  void init(java.util.Collection<? extends OsmPrimitive> objects)
          Initialize the instance by finding what objects will be modified
 
Methods inherited from class org.openstreetmap.josm.command.Command
checkAndConfirmOutlyingOperation, getLayer, getOrig, getParticipatingPrimitives, invalidBecauselayerRemoved, undoCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objects

private final java.util.List<OsmPrimitive> objects
All primitives that are affected with this command.


tags

private final java.util.AbstractMap<java.lang.String,java.lang.String> tags
Key and value pairs. If value is null, delete all key references with the given key. Otherwise, change the properties of all objects to the given value or create keys of those objects that do not have the key yet.

Constructor Detail

ChangePropertyCommand

public ChangePropertyCommand(java.util.Collection<? extends OsmPrimitive> objects,
                             java.util.AbstractMap<java.lang.String,java.lang.String> tags)
Creates a command to change multiple properties of multiple objects

Parameters:
objects - the objects to modify
tags - the properties to set

ChangePropertyCommand

public ChangePropertyCommand(java.util.Collection<? extends OsmPrimitive> objects,
                             java.lang.String key,
                             java.lang.String value)
Creates a command to change one property of multiple objects

Parameters:
objects - the objects to modify
key - the key of the property to set
value - the value of the key to set

ChangePropertyCommand

public ChangePropertyCommand(OsmPrimitive object,
                             java.lang.String key,
                             java.lang.String value)
Creates a command to change on property of one object

Parameters:
object - the object to modify
key - the key of the property to set
value - the value of the key to set
Method Detail

init

private void init(java.util.Collection<? extends OsmPrimitive> objects)
Initialize the instance by finding what objects will be modified

Parameters:
objects - the objects to (possibly) modify

executeCommand

public boolean executeCommand()
Description copied from class: Command
Executes the command on the dataset. This implementation will remember all primitives returned by fillModifiedData for restoring them on undo.

Overrides:
executeCommand in class Command

fillModifiedData

public void fillModifiedData(java.util.Collection<OsmPrimitive> modified,
                             java.util.Collection<OsmPrimitive> deleted,
                             java.util.Collection<OsmPrimitive> added)
Description copied from class: Command
Fill in the changed data this command operates on. Add to the lists, don't clear them.

Specified by:
fillModifiedData in class Command
Parameters:
modified - The modified primitives
deleted - The deleted primitives
added - The added primitives

getDescriptionText

public java.lang.String getDescriptionText()
Description copied from class: PseudoCommand
Provides a description text representing this command.

Specified by:
getDescriptionText in class PseudoCommand

getDescriptionIcon

public javax.swing.Icon getDescriptionIcon()
Description copied from class: PseudoCommand
Provides a descriptive icon of this command.

Overrides:
getDescriptionIcon in class PseudoCommand

getChildren

public java.util.Collection<PseudoCommand> getChildren()
Description copied from class: PseudoCommand
Returns the subcommands of this command. Override for subclasses that have child commands.

Overrides:
getChildren in class PseudoCommand
Returns:
the subcommands, null if there are no child commands


JOSM