Changeset 24114 in osm for applications/editors/josm/plugins/FixAddresses
- Timestamp:
- 2010-11-07T16:11:58+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/AddressEditDialog.java
r24109 r24114 293 293 294 294 AddressEditSelectionEvent ev = new AddressEditSelectionEvent(e.getSource(), 295 streetTable, unresolvedTable, editContainer);295 streetTable, unresolvedTable, null, editContainer); 296 296 297 297 for (AbstractAddressEditAction action : actions) { -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/AddressEditSelectionEvent.java
r24093 r24114 31 31 private JTable streetTable; 32 32 private JTable unresolvedAddressTable; 33 private JTable incompleteAddressTable; 33 34 private AddressEditContainer addressContainer; 34 35 … … 37 38 * @param source The event source. 38 39 * @param selStreet The street table component. 39 * @param unresolvedAddr The unresolved addresses table component.40 * @param unresolvedAddresses The unresolved addresses table component. 40 41 * @param incomplete The incomplete addresses table component. 41 42 * @param container The address container instance holding the entities for streets and addresses. 42 43 */ 43 public AddressEditSelectionEvent(Object source, JTable selStreet, JTable unresolvedAddr , AddressEditContainer container) {44 public AddressEditSelectionEvent(Object source, JTable selStreet, JTable unresolvedAddresses, JTable incompleteAddresses, AddressEditContainer container) { 44 45 super(source, -1, ""); 45 46 this.streetTable = selStreet; 46 this.unresolvedAddressTable = unresolvedAddr; 47 this.unresolvedAddressTable = unresolvedAddresses; 48 this.incompleteAddressTable = incompleteAddresses; 47 49 this.addressContainer = container; 48 50 } … … 63 65 return unresolvedAddressTable; 64 66 } 67 68 /** 69 * @return the incompleteAddressTable 70 */ 71 protected JTable getIncompleteAddressTable() { 72 return incompleteAddressTable; 73 } 65 74 75 /** 76 * Gets the address container. 77 * 78 * @return the address container 79 */ 66 80 public AddressEditContainer getAddressContainer() { 67 81 return addressContainer; … … 106 120 return null; 107 121 } 122 123 /** 124 * Gets the selected incomplete addresses. 125 * 126 * @return the selected incomplete addresses 127 */ 128 public List<OSMAddress> getSelectedIncompleteAddresses() { 129 if (incompleteAddressTable != null && 130 addressContainer != null && 131 addressContainer.getUnresolvedAddresses() != null) { 132 133 int[] selRows = incompleteAddressTable.getSelectedRows(); 134 135 List<OSMAddress> nodes = new ArrayList<OSMAddress>(); 136 for (int i = 0; i < selRows.length; i++) { 137 if (selRows[i] >= 0 && selRows[i] < addressContainer.getNumberOfIncompleteAddresses()) { 138 nodes.add(addressContainer.getIncompleteAddresses().get(selRows[i])); 139 } 140 } 141 return nodes; 142 } 143 return null; 144 } 108 145 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/IncompleteAddressesDialog.java
r24112 r24114 21 21 import javax.swing.JScrollPane; 22 22 import javax.swing.JTable; 23 import javax.swing.event.ListSelectionEvent; 24 import javax.swing.event.ListSelectionListener; 23 25 24 26 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; … … 33 35 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent; 34 36 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode; 37 import org.openstreetmap.josm.gui.SideButton; 35 38 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 36 39 import org.openstreetmap.josm.plugins.fixAddresses.AddressEditContainer; 40 import org.openstreetmap.josm.plugins.fixAddresses.IAddressEditContainerListener; 41 import org.openstreetmap.josm.plugins.fixAddresses.IOSMEntity; 42 import org.openstreetmap.josm.plugins.fixAddresses.gui.actions.AbstractAddressEditAction; 43 import org.openstreetmap.josm.plugins.fixAddresses.gui.actions.SelectAddressesInMapAction; 37 44 38 45 @SuppressWarnings("serial") 39 public class IncompleteAddressesDialog extends ToggleDialog implements DataSetListener { 46 public class IncompleteAddressesDialog extends ToggleDialog implements DataSetListener, ListSelectionListener, IAddressEditContainerListener { 47 private static final String FIXED_DIALOG_TITLE = tr("Incomplete Addresses"); 48 49 40 50 private AddressEditContainer container; 41 51 52 53 private SelectAddressesInMapAction selectAction = new SelectAddressesInMapAction(); 54 55 private AbstractAddressEditAction[] actions = new AbstractAddressEditAction[]{ 56 selectAction 57 }; 58 59 60 private JTable incompleteAddr; 61 42 62 /** 43 * @param name 44 * @param iconName 45 * @param tooltip 46 * @param shortcut 47 * @param preferredHeight 48 * @param container 63 * Instantiates a new "incomplete addresses" dialog. 64 * 49 65 */ 50 66 public IncompleteAddressesDialog() { 51 super(tr("Incomplete Addresses"), "incompleteaddress_24", tr("Show incomplete addresses"), null, 150); 67 super(FIXED_DIALOG_TITLE, "incompleteaddress_24", tr("Show incomplete addresses"), null, 150); 68 52 69 this.container = new AddressEditContainer(); 70 container.addChangedListener(this); 53 71 54 72 JPanel p = new JPanel(new BorderLayout()); 55 73 56 JTable incompleteAddr = new JTable(new IncompleteAddressesTableModel(container)); 74 incompleteAddr = new JTable(new IncompleteAddressesTableModel(container)); 75 incompleteAddr.getSelectionModel().addListSelectionListener(this); 76 57 77 JScrollPane sp = new JScrollPane(incompleteAddr); 58 78 p.add(sp, BorderLayout.CENTER); 59 79 this.add(p); 80 81 JPanel buttonPanel = getButtonPanel(5); 82 83 SideButton sb = new SideButton(selectAction); 84 buttonPanel.add(sb); 85 86 this.add(buttonPanel, BorderLayout.SOUTH); 87 88 for (AbstractAddressEditAction action : actions) { 89 action.setContainer(container); 90 } 60 91 } 61 92 … … 124 155 container.invalidate(); 125 156 } 157 158 /* (non-Javadoc) 159 * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) 160 */ 161 @Override 162 public void valueChanged(ListSelectionEvent e) { 163 AddressEditSelectionEvent event = new AddressEditSelectionEvent(e, null, null, incompleteAddr, container); 164 165 for (AbstractAddressEditAction action : actions) { 166 action.setEvent(event); 167 } 168 } 169 170 @Override 171 public void containerChanged(AddressEditContainer container) { 172 if (container != null && container.getNumberOfIncompleteAddresses() > 0) { 173 setTitle(String.format("%s (%d %s)", FIXED_DIALOG_TITLE, container.getNumberOfIncompleteAddresses(), tr("items"))); 174 } else { 175 setTitle(String.format("%s (%s)", FIXED_DIALOG_TITLE, tr("no items"))); 176 } 177 } 178 179 @Override 180 public void entityChanged(IOSMEntity node) { 181 // TODO Auto-generated method stub 182 183 } 126 184 127 185 -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/AbstractAddressEditAction.java
r24106 r24114 113 113 if (container != null) { 114 114 addressEditActionPerformed(container); 115 } else { // call super class hook116 actionPerformed(arg0);115 } else { 116 throw new RuntimeException("AbstractAddressEditAction has no container or event"); 117 117 } 118 118 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/SelectAddressesInMapAction.java
r24105 r24114 60 60 if (ev == null) return; 61 61 62 internalSelectAddresses(ev.getSelectedUnresolvedAddresses()); 62 if (ev.getSelectedUnresolvedAddresses() != null) { 63 internalSelectAddresses(ev.getSelectedUnresolvedAddresses()); 64 } else if (ev.getSelectedIncompleteAddresses() != null) { 65 internalSelectAddresses(ev.getSelectedIncompleteAddresses()); 66 } 63 67 } 64 68 65 69 @Override 66 70 public void addressEditActionPerformed(AddressEditContainer container) { 67 internalSelectAddresses(container.getUnresolvedAddresses());71 // do nothing 68 72 } 69 73 … … 73 77 @Override 74 78 protected void updateEnabledState(AddressEditContainer container) { 75 setEnabled( container != null && container.getNumberOfIncompleteAddresses() > 0);79 setEnabled(false); 76 80 } 77 81 … … 81 85 @Override 82 86 protected void updateEnabledState(AddressEditSelectionEvent event) { 83 setEnabled(event != null && event.getSelectedUnresolvedAddresses() != null);87 setEnabled(event != null && (event.getSelectedUnresolvedAddresses() != null || event.getSelectedIncompleteAddresses() != null)); 84 88 } 85 89
Note:
See TracChangeset
for help on using the changeset viewer.