Changeset 12546 in josm for trunk


Ignore:
Timestamp:
2017-07-31T11:38:47+02:00 (7 years ago)
Author:
bastiK
Message:

see #14794 - javadoc

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/ActionParameter.java

    r6792 r12546  
    44import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting;
    55
     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 */
    613public abstract class ActionParameter<T> {
    714
    815    private final String name;
    916
     17    /**
     18     * Constructs a new ActionParameter.
     19     * @param name parameter name (the key)
     20     */
    1021    public ActionParameter(String name) {
    1122        this.name = name;
    1223    }
    1324
     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     */
    1430    public String getName() {
    1531        return name;
    1632    }
    1733
     34    /**
     35     * Get the value type of this action parameter.
     36     * @return the value type of this action parameter
     37     */
    1838    public abstract Class<T> getType();
    1939
     40    /**
     41     * Convert a given value into a string (serialization).
     42     * @param value the value
     43     * @return a string representation of the value
     44     */
    2045    public abstract String writeToString(T value);
    2146
     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     */
    2252    public abstract T readFromString(String s);
    2353
     54    /**
     55     * Simple ActionParameter implementation for string values.
     56     */
    2457    public static class StringActionParameter extends ActionParameter<String> {
    2558
  • trunk/src/org/openstreetmap/josm/actions/AdaptableAction.java

    r7937 r12546  
    44import javax.swing.Action;
    55
    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 */
    717public interface AdaptableAction extends Action {
    818}
  • trunk/src/org/openstreetmap/josm/actions/ParameterizedAction.java

    r8510 r12546  
    66import java.util.Map;
    77
     8/**
     9 * Interface for (toolbar-)actions that have additional parameters which need
     10 * to be saved to the preferences (and loaded back).
     11 */
    812public interface ParameterizedAction extends AdaptableAction {
    913
     14    /**
     15     * Get the list of parameters that describe the action.
     16     * @return the list of parameters that describe the action
     17     */
    1018    List<ActionParameter<?>> getActionParameters();
    1119
     20    /**
     21     * Invoke action using the given parameters.
     22     * @param e the ActionEvent
     23     * @param parameters parameter map
     24     */
    1225    void actionPerformed(ActionEvent e, Map<String, Object> parameters);
    1326}
  • trunk/src/org/openstreetmap/josm/actions/ParameterizedActionDecorator.java

    r8510 r12546  
    99import javax.swing.Action;
    1010
     11/**
     12 * Action wrapper that delegates to a {@link ParameterizedAction} object using
     13 * a specific set of parameters.
     14 */
    1115public class ParameterizedActionDecorator implements Action {
    1216
     
    1418    private final Map<String, Object> parameters;
    1519
     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     */
    1625    public ParameterizedActionDecorator(ParameterizedAction action, Map<String, Object> parameters) {
    1726        this.action = action;
     
    5463    }
    5564
     65    /**
     66     * Get the parameters used to invoke the wrapped action.
     67     * @return the parameters used to invoke the wrapped action
     68     */
    5669    public Map<String, Object> getParameters() {
    5770        return parameters;
Note: See TracChangeset for help on using the changeset viewer.