Changeset 29384 in osm for applications/editors/josm/plugins/imagery_offset_db/src/iodb/GetImageryOffsetAction.java
- Timestamp:
- 2013-03-22T22:18:26+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery_offset_db/src/iodb/GetImageryOffsetAction.java
r29381 r29384 20 20 * Download a list of imagery offsets for the current position, let user choose which one to use. 21 21 * 22 * @author zverik 22 * @author Zverik 23 * @license WTFPL 23 24 */ 24 25 public class GetImageryOffsetAction extends JosmAction { 25 26 27 /** 28 * Initialize the action. Sets "Ctrl+Alt+I" shortcut: the only shortcut in this plugin. 29 */ 26 30 public GetImageryOffsetAction() { 27 31 super(tr("Get Imagery Offset..."), "getoffset", tr("Download offsets for current imagery from a server"), … … 30 34 } 31 35 36 /** 37 * The action just executes {@link DownloadOffsetsTask}. 38 */ 32 39 public void actionPerformed(ActionEvent e) { 33 40 if( Main.map == null || Main.map.mapView == null || !Main.map.isVisible() ) … … 44 51 } 45 52 53 /** 54 * This action is enabled when there's a map, mapView and one of the layers 55 * is an imagery layer. 56 */ 46 57 @Override 47 58 protected void updateEnabledState() { … … 55 66 } 56 67 57 private void showOffsetDialog( List<ImageryOffsetBase> offsets, ImageryLayer layer ) { 68 /** 69 * Display a dialog for choosing between offsets. If there are no offsets in 70 * the list, displays the relevant message instead. 71 * @param offsets List of offset objects to choose from. 72 */ 73 private void showOffsetDialog( List<ImageryOffsetBase> offsets ) { 58 74 if( offsets.isEmpty() ) { 59 75 JOptionPane.showMessageDialog(Main.parent, … … 67 83 } 68 84 85 /** 86 * A task that downloads offsets for a given position and imagery layer, 87 * then parses resulting XML and calls 88 * {@link #showOffsetDialog(java.util.List)} on success. 89 */ 69 90 class DownloadOffsetsTask extends SimpleOffsetQueryTask { 70 91 private ImageryLayer layer; 71 92 private List<ImageryOffsetBase> offsets; 72 93 94 /** 95 * Initializes query object from the parameters. 96 * @param center A center point of a map view. 97 * @param layer The topmost imagery layer. 98 * @param imagery Imagery ID for the layer. 99 */ 73 100 public DownloadOffsetsTask( LatLon center, ImageryLayer layer, String imagery ) { 74 101 super(null, tr("Loading imagery offsets...")); … … 87 114 } 88 115 116 /** 117 * Displays offset dialog on success. 118 */ 89 119 @Override 90 120 protected void afterFinish() { 91 121 if( !cancelled && offsets != null ) 92 showOffsetDialog(offsets , layer);122 showOffsetDialog(offsets); 93 123 } 94 124 125 /** 126 * Parses the response with {@link IODBReader}. 127 * @param inp Response input stream. 128 * @throws iodb.SimpleOffsetQueryTask.UploadException Thrown on XML parsing error. 129 */ 95 130 @Override 96 131 protected void processResponse( InputStream inp ) throws UploadException {
Note:
See TracChangeset
for help on using the changeset viewer.