Changeset 20384 in osm for applications
- Timestamp:
- 2010-03-09T12:59:21+01:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/turnrestrictions
- Files:
-
- 22 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/turnrestrictions/README
r20378 r20384 4 4 5 5 turnrestrictions plugin is a plugin for the open source map editor 6 JOSM. It allows to entermaintain information about turn restrictions6 JOSM. It allows to maintain information about turn restrictions 7 7 in the OpenStreetMap database. 8 8 9 9 SEE ALSO 10 ======== 11 http://wiki.openstreetmap.org/wiki/JOSM/Plugins/turnrestrictions 12 10 13 CREDIT 11 14 ====== 12 15 Initial development of this plugin was sponsored by skobbler GmbH, see 13 http:// beta.skobbler.de/.16 http://www.skobbler.de/. 14 17 15 Initial author: Karl Guggisberg16 18 17 19 -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/TurnRestrictionsListDialog.java
r20378 r20384 12 12 import java.util.HashSet; 13 13 import java.util.List; 14 import java.util.Set; 14 15 15 16 import javax.swing.AbstractAction; … … 23 24 24 25 import org.openstreetmap.josm.Main; 26 import org.openstreetmap.josm.actions.AutoScaleAction; 25 27 import org.openstreetmap.josm.data.osm.OsmPrimitive; 26 28 import org.openstreetmap.josm.data.osm.Relation; 27 29 import org.openstreetmap.josm.data.osm.RelationMember; 28 30 import org.openstreetmap.josm.gui.MapView; 31 import org.openstreetmap.josm.gui.SideButton; 29 32 import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener; 30 33 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; … … 56 59 private EditAction actEdit; 57 60 private DeleteAction actDelete; 61 private SelectSelectedTurnRestrictions actSelectSelectedTurnRestrictions; 62 private ZoomToAction actZoomTo; 58 63 private SwitchListViewHandler switchListViewHandler; 59 64 … … 101 106 JPanel pnl = new JPanel(new FlowLayout(FlowLayout.LEFT,0,0)); 102 107 pnl.setBorder(null); 103 pnl.add(new JButton(actNew = new NewAction())); 104 pnl.add(new JButton(actEdit = new EditAction())); 105 pnl.add(new JButton(actDelete = new DeleteAction())); 108 pnl.add(new SideButton(actNew = new NewAction(), false /* don't show the name */)); 109 pnl.add(new SideButton(actEdit = new EditAction(), false /* don't show the name */)); 110 pnl.add(new SideButton(actDelete = new DeleteAction(), false /* don't show the name */)); 111 112 actSelectSelectedTurnRestrictions = new SelectSelectedTurnRestrictions(); 113 actZoomTo = new ZoomToAction(); 106 114 return pnl; 107 115 } … … 155 163 currentListView.removeListSelectionListener(actEdit); 156 164 currentListView.removeListSelectionListener(actDelete); 165 currentListView.removeListSelectionListener(actSelectSelectedTurnRestrictions); 166 currentListView.removeListSelectionListener(actZoomTo); 157 167 pnlContent.remove(currentListView); 158 168 } 159 169 pnlContent.add(view,BorderLayout.CENTER); 170 currentListView = view; 160 171 view.addListSelectionListener(actEdit); 161 172 view.addListSelectionListener(actDelete); 173 view.addListSelectionListener(actSelectSelectedTurnRestrictions); 174 view.addListSelectionListener(actZoomTo); 162 175 actEdit.updateEnabledState(); 163 176 actDelete.updateEnabledState(); 164 currentListView = view; 177 actSelectSelectedTurnRestrictions.updateEnabledState(); 178 actZoomTo.updateEnabledState(); 165 179 currentListView.revalidate(); 166 180 currentListView.repaint(); … … 188 202 putValue(SHORT_DESCRIPTION,tr( "Open an editor for the selected turn restricion")); 189 203 putValue(SMALL_ICON, ImageProvider.get("dialogs", "edit")); 204 putValue(NAME, tr("Edit")); 190 205 setEnabled(false); 191 206 } … … 210 225 if (!isEnabled()) 211 226 return; 212 List<Relation> toEdit = pnlTurnRestrictionsInDataSet.getModel().getSelectedTurnRestrictions();227 List<Relation> toEdit = currentListView.getModel().getSelectedTurnRestrictions(); 213 228 if (toEdit.size() != 1) return; 214 229 launchEditor(toEdit.get(0)); … … 216 231 217 232 public void updateEnabledState() { 218 setEnabled( pnlTurnRestrictionsInDataSet.getModel().getSelectedTurnRestrictions().size() == 1);233 setEnabled(currentListView!= null && currentListView.getModel().getSelectedTurnRestrictions().size() == 1); 219 234 } 220 235 … … 234 249 putValue(SHORT_DESCRIPTION,tr("Delete the selected turn restriction")); 235 250 putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete")); 251 putValue(NAME, tr("Delete")); 236 252 setEnabled(false); 237 253 } … … 248 264 public void actionPerformed(ActionEvent e) { 249 265 if (!isEnabled()) return; 250 List<Relation> toDelete = pnlTurnRestrictionsInDataSet.getModel().getSelectedTurnRestrictions();266 List<Relation> toDelete = currentListView.getModel().getSelectedTurnRestrictions(); 251 267 for (Relation r: toDelete) { 252 268 deleteRelation(r); … … 255 271 256 272 public void updateEnabledState() { 257 setEnabled( !pnlTurnRestrictionsInDataSet.getModel().getSelectedTurnRestrictions().isEmpty());273 setEnabled(currentListView != null && !currentListView.getModel().getSelectedTurnRestrictions().isEmpty()); 258 274 } 259 275 … … 270 286 public NewAction() { 271 287 putValue(SHORT_DESCRIPTION,tr("Create a new turn restriction")); 272 putValue(SMALL_ICON, ImageProvider.get("dialogs", "addrelation")); 288 putValue(SMALL_ICON, ImageProvider.get("new")); 289 putValue(NAME, tr("New")); 273 290 updateEnabledState(); 274 291 } … … 290 307 updateEnabledState(); 291 308 } 309 } 310 311 /** 312 * Sets the selection of the current data set to the currently selected 313 * turn restrictions. 314 * 315 */ 316 class SelectSelectedTurnRestrictions extends AbstractAction implements ListSelectionListener { 317 class AbortException extends Exception {} 318 319 public SelectSelectedTurnRestrictions() { 320 putValue(SHORT_DESCRIPTION,tr("Set the current JOSM selection to the selected turn restrictions")); 321 putValue(SMALL_ICON, ImageProvider.get("selectall")); 322 putValue(NAME, tr("Select in current data layer")); 323 setEnabled(false); 324 } 325 326 public void actionPerformed(ActionEvent e) { 327 if (!isEnabled()) return; 328 List<Relation> toSelect = currentListView.getModel().getSelectedTurnRestrictions(); 329 if (toSelect.isEmpty()) return; 330 OsmDataLayer layer= Main.main.getEditLayer(); 331 if (layer == null) return; 332 layer.data.setSelected(toSelect); 333 } 334 335 public void updateEnabledState() { 336 setEnabled(currentListView != null && !currentListView.getModel().getSelectedTurnRestrictions().isEmpty()); 337 } 338 339 public void valueChanged(ListSelectionEvent e) { 340 updateEnabledState(); 341 } 342 } 343 344 /** 345 * Sets the selection of the current data set to the currently selected 346 * turn restrictions. 347 * 348 */ 349 class ZoomToAction extends AbstractAction implements ListSelectionListener { 350 class AbortException extends Exception {} 351 352 public ZoomToAction() { 353 putValue(SHORT_DESCRIPTION,tr("Zoom to the currently selected turn restrictions")); 354 putValue(SMALL_ICON, ImageProvider.get("dialogs/autoscale/selection")); 355 putValue(NAME, tr("Zoom to")); 356 setEnabled(false); 357 } 358 359 public void actionPerformed(ActionEvent e) { 360 if (!isEnabled()) return; 361 List<Relation> toSelect = currentListView.getModel().getSelectedTurnRestrictions(); 362 if (toSelect.isEmpty()) return; 363 OsmDataLayer layer= Main.main.getEditLayer(); 364 if (layer == null) return; 365 layer.data.setSelected(toSelect); 366 new AutoScaleAction("selection").autoScale(); 367 } 368 369 public void updateEnabledState() { 370 setEnabled(currentListView != null && !currentListView.getModel().getSelectedTurnRestrictions().isEmpty()); 371 } 372 373 public void valueChanged(ListSelectionEvent e) { 374 updateEnabledState(); 375 } 292 376 } 293 377 … … 320 404 add(actEdit); 321 405 add(actDelete); 406 addSeparator(); 407 add(actSelectSelectedTurnRestrictions); 408 add(actZoomTo); 322 409 } 323 410 } -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/TurnRestrictionsPlugin.java
r20378 r20384 2 2 3 3 import org.openstreetmap.josm.gui.MapFrame; 4 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 4 5 import org.openstreetmap.josm.plugins.Plugin; 5 6 import org.openstreetmap.josm.plugins.PluginInformation; 7 import org.openstreetmap.josm.plugins.turnrestrictions.preferences.PreferenceEditor; 6 8 9 /** 10 * This is the main class for the turnrestriction plugin. 11 * 12 */ 7 13 public class TurnRestrictionsPlugin extends Plugin{ 14 8 15 public TurnRestrictionsPlugin(PluginInformation info) { 9 16 super(info); … … 21 28 } 22 29 } 30 31 @Override 32 public PreferenceSetting getPreferenceSetting() { 33 return new PreferenceEditor(); 34 } 23 35 }
Note:
See TracChangeset
for help on using the changeset viewer.