Changeset 4751 in josm
- Timestamp:
- 2011-12-30T17:31:00+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r4711 r4751 59 59 import org.openstreetmap.josm.gui.help.HelpUtil; 60 60 import org.openstreetmap.josm.gui.io.SaveLayersDialog; 61 import org.openstreetmap.josm.gui.layer.JumpToMarkerActions; 61 62 import org.openstreetmap.josm.gui.layer.Layer; 62 63 import org.openstreetmap.josm.gui.layer.Layer.LayerAction; … … 92 93 MultikeyActionsHandler.getInstance().addAction(instance.new ShowHideLayerAction(false)); 93 94 MultikeyActionsHandler.getInstance().addAction(instance.new ActivateLayerAction()); 95 JumpToMarkerActions.initialize(); 94 96 } 95 97 … … 1555 1557 } 1556 1558 1557 public static List<MultikeyInfo> getLayerInfoByClass(Class<? extends Layer> layerClass) { 1559 // This is not Class<? extends Layer> on purpose, to allow asking for layers implementing some interface 1560 public static List<MultikeyInfo> getLayerInfoByClass(Class<?> layerClass) { 1558 1561 1559 1562 List<MultikeyInfo> result = new ArrayList<MultikeyShortcutAction.MultikeyInfo>(); -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r4627 r4751 55 55 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 56 56 import org.openstreetmap.josm.gui.layer.GpxLayer; 57 import org.openstreetmap.josm.gui.layer.JumpToMarkerActions.JumpToMarkerLayer; 58 import org.openstreetmap.josm.gui.layer.JumpToMarkerActions.JumpToNextMarker; 59 import org.openstreetmap.josm.gui.layer.JumpToMarkerActions.JumpToPreviousMarker; 57 60 import org.openstreetmap.josm.gui.layer.Layer; 58 61 import org.openstreetmap.josm.tools.ExifReader; … … 68 71 import com.drew.metadata.exif.GpsDirectory; 69 72 70 public class GeoImageLayer extends Layer implements PropertyChangeListener { 73 public class GeoImageLayer extends Layer implements PropertyChangeListener, JumpToMarkerLayer { 71 74 72 75 List<ImageEntry> data; … … 230 233 tr("Error"), 231 234 JOptionPane.ERROR_MESSAGE 232 ); 235 ); 233 236 } 234 237 if (layer != null) { … … 299 302 } 300 303 entries.add(SeparatorLayerAction.INSTANCE); 304 entries.add(new JumpToNextMarker(this)); 305 entries.add(new JumpToPreviousMarker(this)); 306 entries.add(SeparatorLayerAction.INSTANCE); 301 307 entries.add(new LayerListPopup.InfoAction(this)); 302 308 … … 312 318 } 313 319 return trn("{0} image loaded.", "{0} images loaded.", data.size(), data.size()) 314 + " " + trn("{0} was found to be GPS tagged.", "{0} were found to be GPS tagged.", i, i); 320 + " " + trn("{0} was found to be GPS tagged.", "{0} were found to be GPS tagged.", i, i); 315 321 } 316 322 … … 529 535 } catch (MetadataException ex) { 530 536 } 531 537 532 538 try { 533 539 // longitude … … 694 700 tr("Error"), 695 701 JOptionPane.ERROR_MESSAGE 696 ); 702 ); 697 703 } 698 704 … … 818 824 return copy; 819 825 } 826 827 public void jumpToNextMarker() { 828 showNextPhoto(); 829 } 830 831 public void jumpToPreviousMarker() { 832 showPreviousPhoto(); 833 } 820 834 } -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r4710 r4751 12 12 import java.awt.Point; 13 13 import java.awt.event.ActionEvent; 14 import java.awt.event.KeyEvent;15 14 import java.awt.event.MouseAdapter; 16 15 import java.awt.event.MouseEvent; 17 16 import java.io.File; 18 import java.lang.ref.WeakReference;19 17 import java.net.URL; 20 18 import java.util.ArrayList; … … 41 39 import org.openstreetmap.josm.gui.layer.CustomizeColor; 42 40 import org.openstreetmap.josm.gui.layer.GpxLayer; 41 import org.openstreetmap.josm.gui.layer.JumpToMarkerActions.JumpToMarkerLayer; 42 import org.openstreetmap.josm.gui.layer.JumpToMarkerActions.JumpToNextMarker; 43 import org.openstreetmap.josm.gui.layer.JumpToMarkerActions.JumpToPreviousMarker; 43 44 import org.openstreetmap.josm.gui.layer.Layer; 44 45 import org.openstreetmap.josm.tools.AudioPlayer; 45 46 import org.openstreetmap.josm.tools.ImageProvider; 46 import org.openstreetmap.josm.tools.MultikeyActionsHandler;47 import org.openstreetmap.josm.tools.MultikeyShortcutAction;48 import org.openstreetmap.josm.tools.Shortcut;49 47 50 48 /** … … 59 57 * The data is read only. 60 58 */ 61 public class MarkerLayer extends Layer { 59 public class MarkerLayer extends Layer implements JumpToMarkerLayer { 62 60 63 61 /** … … 138 136 }); 139 137 } 140 141 static {142 MultikeyActionsHandler.getInstance().addAction(new JumpToNextMarker(null));143 MultikeyActionsHandler.getInstance().addAction(new JumpToPreviousMarker(null));144 }145 146 138 147 139 /** … … 450 442 } 451 443 452 public static final class JumpToNextMarker extends AbstractAction implements MultikeyShortcutAction {453 454 private final MarkerLayer layer;455 private WeakReference<MarkerLayer> lastLayer;456 457 public JumpToNextMarker(MarkerLayer layer) {458 putValue(ACCELERATOR_KEY, Shortcut.registerShortcut("core_multikey:nextMarker", "", 'J', Shortcut.GROUP_DIRECT, KeyEvent.ALT_DOWN_MASK + KeyEvent.CTRL_DOWN_MASK).getKeyStroke());459 putValue(SHORT_DESCRIPTION, tr("Jump to next marker"));460 putValue(NAME, tr("Jump to next marker"));461 462 this.layer = layer;463 }464 465 @Override466 public void actionPerformed(ActionEvent e) {467 execute(layer);468 }469 470 @Override471 public void executeMultikeyAction(int index, boolean repeat) {472 Layer l = LayerListDialog.getLayerForIndex(index);473 if (l != null) {474 if (l instanceof MarkerLayer) {475 execute((MarkerLayer) l);476 }477 } else if (repeat && lastLayer != null) {478 l = lastLayer.get();479 if (LayerListDialog.isLayerValid(l)) {480 execute((MarkerLayer) l);481 }482 }483 }484 485 486 private void execute(MarkerLayer l) {487 l.jumpToNextMarker();488 lastLayer = new WeakReference<MarkerLayer>(l);489 }490 491 @Override492 public List<MultikeyInfo> getMultikeyCombinations() {493 return LayerListDialog.getLayerInfoByClass(MarkerLayer.class);494 }495 496 @Override497 public MultikeyInfo getLastMultikeyAction() {498 if (lastLayer != null)499 return LayerListDialog.getLayerInfo(lastLayer.get());500 else501 return null;502 }503 504 }505 506 public static final class JumpToPreviousMarker extends AbstractAction implements MultikeyShortcutAction {507 508 private WeakReference<MarkerLayer> lastLayer;509 private final MarkerLayer layer;510 511 public JumpToPreviousMarker(MarkerLayer layer) {512 this.layer = layer;513 514 putValue(ACCELERATOR_KEY, Shortcut.registerShortcut("core_multikey:previousMarker", "", 'P', Shortcut.GROUP_DIRECT, KeyEvent.ALT_DOWN_MASK + KeyEvent.CTRL_DOWN_MASK).getKeyStroke());515 putValue(SHORT_DESCRIPTION, tr("Jump to previous marker"));516 putValue(NAME, tr("Jump to previous marker"));517 }518 519 @Override520 public void actionPerformed(ActionEvent e) {521 execute(layer);522 }523 524 @Override525 public void executeMultikeyAction(int index, boolean repeat) {526 Layer l = LayerListDialog.getLayerForIndex(index);527 if (l != null) {528 if (l instanceof MarkerLayer) {529 execute((MarkerLayer) l);530 }531 } else if (repeat && lastLayer != null) {532 l = lastLayer.get();533 if (LayerListDialog.isLayerValid(l)) {534 execute((MarkerLayer) l);535 }536 }537 }538 539 private void execute(MarkerLayer l) {540 l.jumpToPreviousMarker();541 lastLayer = new WeakReference<MarkerLayer>(l);542 }543 544 @Override545 public List<MultikeyInfo> getMultikeyCombinations() {546 return LayerListDialog.getLayerInfoByClass(MarkerLayer.class);547 }548 549 @Override550 public MultikeyInfo getLastMultikeyAction() {551 if (lastLayer != null)552 return LayerListDialog.getLayerInfo(lastLayer.get());553 else554 return null;555 }556 557 }558 444 559 445 private class SynchronizeAudio extends AbstractAction {
Note:
See TracChangeset
for help on using the changeset viewer.