- Timestamp:
- 2017-07-31T11:38:47+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ActionParameter.java
r6792 r12546 4 4 import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting; 5 5 6 /** 7 * Abstract class for <i>key=value</i> parameters, used in {@link ParameterizedAction}. 8 * <p> 9 * The key ({@link #name}) is a string and the value of class {@link T}. The value can be 10 * converted to and from a string. 11 * @param <T> the value type 12 */ 6 13 public abstract class ActionParameter<T> { 7 14 8 15 private final String name; 9 16 17 /** 18 * Constructs a new ActionParameter. 19 * @param name parameter name (the key) 20 */ 10 21 public ActionParameter(String name) { 11 22 this.name = name; 12 23 } 13 24 25 /** 26 * Get the name of this action parameter. 27 * The name is used as a key, to look up values for the parameter. 28 * @return the name of this action parameter 29 */ 14 30 public String getName() { 15 31 return name; 16 32 } 17 33 34 /** 35 * Get the value type of this action parameter. 36 * @return the value type of this action parameter 37 */ 18 38 public abstract Class<T> getType(); 19 39 40 /** 41 * Convert a given value into a string (serialization). 42 * @param value the value 43 * @return a string representation of the value 44 */ 20 45 public abstract String writeToString(T value); 21 46 47 /** 48 * Create a value from the given string representation (deserialization). 49 * @param s the string representation of the value 50 * @return the corresponding value object 51 */ 22 52 public abstract T readFromString(String s); 23 53 54 /** 55 * Simple ActionParameter implementation for string values. 56 */ 24 57 public static class StringActionParameter extends ActionParameter<String> { 25 58 -
trunk/src/org/openstreetmap/josm/actions/AdaptableAction.java
r7937 r12546 4 4 import javax.swing.Action; 5 5 6 /* allow us to tell the toolbar that name and icon may be changed */ 6 /** 7 * Interface to indicate that name (tooltip) and icon may be changed for an entry 8 * in the toolbar. 9 * <p> 10 * The name and icon of an {@link org.openstreetmap.josm.gui.preferences.ToolbarPreferences.ActionDefinition} 11 * is saved to the preferences when the wrapped action implements AdaptableAction. 12 * <p> 13 * The user will have options to change the name and icon in the 14 * {@link org.openstreetmap.josm.gui.preferences.ToolbarPreferences} when the action 15 * for the toolbar entry implements AdaptableAction. 16 */ 7 17 public interface AdaptableAction extends Action { 8 18 } -
trunk/src/org/openstreetmap/josm/actions/ParameterizedAction.java
r8510 r12546 6 6 import java.util.Map; 7 7 8 /** 9 * Interface for (toolbar-)actions that have additional parameters which need 10 * to be saved to the preferences (and loaded back). 11 */ 8 12 public interface ParameterizedAction extends AdaptableAction { 9 13 14 /** 15 * Get the list of parameters that describe the action. 16 * @return the list of parameters that describe the action 17 */ 10 18 List<ActionParameter<?>> getActionParameters(); 11 19 20 /** 21 * Invoke action using the given parameters. 22 * @param e the ActionEvent 23 * @param parameters parameter map 24 */ 12 25 void actionPerformed(ActionEvent e, Map<String, Object> parameters); 13 26 } -
trunk/src/org/openstreetmap/josm/actions/ParameterizedActionDecorator.java
r8510 r12546 9 9 import javax.swing.Action; 10 10 11 /** 12 * Action wrapper that delegates to a {@link ParameterizedAction} object using 13 * a specific set of parameters. 14 */ 11 15 public class ParameterizedActionDecorator implements Action { 12 16 … … 14 18 private final Map<String, Object> parameters; 15 19 20 /** 21 * Constructs a new ParameterizedActionDecorator. 22 * @param action the action that is invoked by this wrapper 23 * @param parameters parameters used for invoking the action 24 */ 16 25 public ParameterizedActionDecorator(ParameterizedAction action, Map<String, Object> parameters) { 17 26 this.action = action; … … 54 63 } 55 64 65 /** 66 * Get the parameters used to invoke the wrapped action. 67 * @return the parameters used to invoke the wrapped action 68 */ 56 69 public Map<String, Object> getParameters() { 57 70 return parameters;
Note:
See TracChangeset
for help on using the changeset viewer.