source: josm/trunk/src/org/openstreetmap/josm/actions/ParameterizedActionDecorator.java@ 13252

Last change on this file since 13252 was 12546, checked in by bastiK, 7 years ago

see #14794 - javadoc

  • Property svn:eol-style set to native
File size: 1.9 KB
RevLine 
[3175]1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import java.awt.event.ActionEvent;
5import java.beans.PropertyChangeListener;
6import java.util.HashMap;
7import java.util.Map;
8
9import javax.swing.Action;
10
[12546]11/**
12 * Action wrapper that delegates to a {@link ParameterizedAction} object using
13 * a specific set of parameters.
14 */
[3175]15public class ParameterizedActionDecorator implements Action {
16
17 private final ParameterizedAction action;
18 private final Map<String, Object> parameters;
19
[12546]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 */
[3175]25 public ParameterizedActionDecorator(ParameterizedAction action, Map<String, Object> parameters) {
26 this.action = action;
[7005]27 this.parameters = new HashMap<>(parameters);
[3175]28 }
29
[6084]30 @Override
[3175]31 public void addPropertyChangeListener(PropertyChangeListener listener) {
32 action.addPropertyChangeListener(listener);
33 }
[8510]34
[6084]35 @Override
[3175]36 public Object getValue(String key) {
37 return action.getValue(key);
38 }
[8510]39
[6084]40 @Override
[3175]41 public boolean isEnabled() {
42 return action.isEnabled();
43 }
[8510]44
[6084]45 @Override
[3175]46 public void putValue(String key, Object value) {
47 action.putValue(key, value);
48 }
[8510]49
[6084]50 @Override
[3175]51 public void removePropertyChangeListener(PropertyChangeListener listener) {
52 action.removePropertyChangeListener(listener);
53 }
[8510]54
[6084]55 @Override
[3175]56 public void setEnabled(boolean b) {
57 action.setEnabled(b);
58 }
[8510]59
[6084]60 @Override
[3175]61 public void actionPerformed(ActionEvent e) {
62 action.actionPerformed(e, parameters);
63 }
64
[12546]65 /**
66 * Get the parameters used to invoke the wrapped action.
67 * @return the parameters used to invoke the wrapped action
68 */
[3175]69 public Map<String, Object> getParameters() {
70 return parameters;
71 }
72}
Note: See TracBrowser for help on using the repository browser.