Changeset 23943 in osm
- Timestamp:
- 2010-10-31T01:03:00+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/AbstractAddressEditAction.java
r23933 r23943 18 18 import org.openstreetmap.josm.actions.JosmAction; 19 19 import org.openstreetmap.josm.plugins.fixAddresses.AddressEditContainer; 20 import org.openstreetmap.josm.plugins.fixAddresses.IAddressEditContainerListener; 21 import org.openstreetmap.josm.plugins.fixAddresses.INodeEntity; 20 22 21 23 /** … … 26 28 * container or on selection items. 27 29 * Most actions will work in both cases, so it is recommended to have one single method which 28 * accepts a list of addresses or streets and executes the tasks to be done by this action. 30 * accepts a list of addresses or streets and executes the tasks to be done by this action. 31 * 29 32 * @author Oliver Wieland <oliver.wieland@online.de> 30 *31 33 */ 32 34 33 35 @SuppressWarnings("serial") 34 public abstract class AbstractAddressEditAction extends JosmAction {36 public abstract class AbstractAddressEditAction extends JosmAction implements IAddressEditContainerListener { 35 37 private AddressEditSelectionEvent event; 36 38 protected AddressEditContainer container; … … 54 56 55 57 /** 58 * Gets the current address container. 56 59 * @return the container 57 60 */ … … 64 67 */ 65 68 public void setContainer(AddressEditContainer container) { 69 if (container != null) { // remove old listener first 70 container.removeChangedListener(this); 71 } 66 72 this.container = container; 67 73 updateEnabledState(); 74 if (container != null) { 75 container.addChangedListener(this); 76 } 68 77 } 69 78 … … 80 89 protected void setEvent(AddressEditSelectionEvent event) { 81 90 this.event = event; 91 updateEnabledState(); 92 } 93 94 /* (non-Javadoc) 95 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) 96 */ 97 @Override 98 public void actionPerformed(ActionEvent arg0) { 99 if (event != null) { // use the event acquired previously. 100 addressEditActionPerformed(event); 101 event = null; // consume event 102 } else { 103 if (container != null) { 104 addressEditActionPerformed(container); 105 } else { // call super class hook 106 actionPerformed(arg0); 107 } 108 } 82 109 } 83 110 … … 106 133 107 134 /** 108 * Updates 'enabled' state depending on the given address container object.109 * @param container The address container (maybe null).135 * Updates 'enabled' state depending on the current selection. 136 * @param container The selection event. 110 137 * @return 111 138 */ 112 139 protected abstract void updateEnabledState(AddressEditSelectionEvent event); 113 114 /* (non-Javadoc)115 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)116 */117 @Override118 public void actionPerformed(ActionEvent arg0) {119 if (event != null) { // use the event acquired previously.120 addressEditActionPerformed(event);121 event = null; // consume event122 } else {123 if (container != null) {124 addressEditActionPerformed(container);125 } else { // call super class hook126 actionPerformed(arg0);127 }128 }129 }130 131 140 132 141 /** … … 143 152 144 153 154 /* (non-Javadoc) 155 * @see org.openstreetmap.josm.plugins.fixAddresses.IAddressEditContainerListener#containerChanged(org.openstreetmap.josm.plugins.fixAddresses.AddressEditContainer) 156 */ 157 @Override 158 public void containerChanged(AddressEditContainer container) { 159 updateEnabledState(); 160 } 145 161 162 /* (non-Javadoc) 163 * @see org.openstreetmap.josm.plugins.fixAddresses.IAddressEditContainerListener#entityChanged(org.openstreetmap.josm.plugins.fixAddresses.INodeEntity) 164 */ 165 @Override 166 public void entityChanged(INodeEntity node) { 167 updateEnabledState(); 168 } 146 169 }
Note:
See TracChangeset
for help on using the changeset viewer.