[3175] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
| 2 | package org.openstreetmap.josm.actions;
|
---|
| 3 |
|
---|
| 4 | import java.awt.event.ActionEvent;
|
---|
| 5 | import java.beans.PropertyChangeListener;
|
---|
| 6 | import java.util.HashMap;
|
---|
| 7 | import java.util.Map;
|
---|
| 8 |
|
---|
| 9 | import javax.swing.Action;
|
---|
| 10 |
|
---|
| 11 | public class ParameterizedActionDecorator implements Action {
|
---|
| 12 |
|
---|
| 13 | private final ParameterizedAction action;
|
---|
| 14 | private final Map<String, Object> parameters;
|
---|
| 15 |
|
---|
| 16 | public ParameterizedActionDecorator(ParameterizedAction action, Map<String, Object> parameters) {
|
---|
| 17 | this.action = action;
|
---|
| 18 | this.parameters = new HashMap<String, Object>(parameters);
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | public void addPropertyChangeListener(PropertyChangeListener listener) {
|
---|
| 22 | action.addPropertyChangeListener(listener);
|
---|
| 23 | }
|
---|
| 24 | public Object getValue(String key) {
|
---|
| 25 | return action.getValue(key);
|
---|
| 26 | }
|
---|
| 27 | public boolean isEnabled() {
|
---|
| 28 | return action.isEnabled();
|
---|
| 29 | }
|
---|
| 30 | public void putValue(String key, Object value) {
|
---|
| 31 | action.putValue(key, value);
|
---|
| 32 | }
|
---|
| 33 | public void removePropertyChangeListener(PropertyChangeListener listener) {
|
---|
| 34 | action.removePropertyChangeListener(listener);
|
---|
| 35 | }
|
---|
| 36 | public void setEnabled(boolean b) {
|
---|
| 37 | action.setEnabled(b);
|
---|
| 38 | }
|
---|
| 39 | public void actionPerformed(ActionEvent e) {
|
---|
| 40 | action.actionPerformed(e, parameters);
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | public Map<String, Object> getParameters() {
|
---|
| 44 | return parameters;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | }
|
---|