Changeset 22551 in osm


Ignore:
Timestamp:
2010-08-03T08:23:15+02:00 (14 years ago)
Author:
jttt
Message:

Adapt to latest josm

Location:
applications/editors/josm/plugins/photo_geotagging
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/photo_geotagging/build.xml

    r22535 r22551  
    2727        <property name="commit.message" value="update to josm latest; only recompile (setCancelButton)" />
    2828        <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    29         <property name="plugin.main.version" value="3403" />
     29        <property name="plugin.main.version" value="3408" />
    3030
    3131
     
    148148
    149149        <!--
    150         ************************** Publishing the plugin *********************************** 
     150        ************************** Publishing the plugin ***********************************
    151151        -->
    152152        <!--
    153                 ** extracts the JOSM release for the JOSM version in ../core and saves it in the 
     153                ** extracts the JOSM release for the JOSM version in ../core and saves it in the
    154154                ** property ${coreversion.info.entry.revision}
    155155                **
     
    200200
    201201        <!--
    202                 ** commits the plugin.jar 
     202                ** commits the plugin.jar
    203203                -->
    204204        <target name="commit-dist">
    205205                <echo>
    206206        ***** Properties of published ${plugin.jar} *****
    207         Commit message    : '${commit.message}'                                 
     207        Commit message    : '${commit.message}'
    208208        Plugin-Mainversion: ${plugin.main.version}
    209209        JOSM build version: ${coreversion.info.entry.revision}
    210210        Plugin-Version    : ${version.entry.commit.revision}
    211         ***** / Properties of published ${plugin.jar} *****                                     
    212                                                
     211        ***** / Properties of published ${plugin.jar} *****
     212
    213213        Now commiting ${plugin.jar} ...
    214214        </echo>
  • applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/GeotaggingAction.java

    r19873 r22551  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.Component;
    67import java.awt.Dimension;
    78import java.awt.GridBagLayout;
    89import java.awt.event.ActionEvent;
    910import java.awt.event.ActionListener;
    10 
     11import java.io.File;
    1112import java.io.IOException;
    12 import java.io.File;
    13 
     13import java.text.DecimalFormat;
    1414import java.util.ArrayList;
    1515import java.util.List;
    1616
     17import javax.swing.AbstractAction;
    1718import javax.swing.BorderFactory;
    1819import javax.swing.DefaultListModel;
     
    2122import javax.swing.JLabel;
    2223import javax.swing.JList;
     24import javax.swing.JMenuItem;
    2325import javax.swing.JOptionPane;
    2426import javax.swing.JPanel;
     
    2729import javax.swing.UIManager;
    2830
    29 import java.text.DecimalFormat;
    30 
    3131import org.openstreetmap.josm.Main;
    3232import org.openstreetmap.josm.gui.ExtendedDialog;
    3333import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     34import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
     35import org.openstreetmap.josm.gui.layer.Layer;
     36import org.openstreetmap.josm.gui.layer.Layer.LayerAction;
    3437import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer;
    3538import org.openstreetmap.josm.gui.layer.geoimage.ImageEntry;
    3639import org.openstreetmap.josm.tools.GBC;
     40import org.openstreetmap.josm.tools.ImageProvider;
    3741
    3842/**
    3943 * The action to aks the user for confirmation and then do the tagging.
    4044 */
    41 class GeotaggingAction implements ActionListener {
     45class GeotaggingAction extends AbstractAction implements LayerAction {
    4246    final static boolean debug = false;
    4347    final static String KEEP_BACKUP = "plugins.photo_geotagging.keep_backup";
     
    4549    final static int MTIME_MODE_PREVIOUS_VALUE = 2;
    4650
    47     final private GeoImageLayer layer;
    48     public GeotaggingAction(GeoImageLayer layer) {
    49         this.layer = layer;
     51    public GeotaggingAction() {
     52        super(tr("Write coordinates to image header"), ImageProvider.get("geotagging"));
    5053    }
    5154
    5255    public void actionPerformed(ActionEvent arg0) {
     56
     57        GeoImageLayer layer = getLayer();
     58
    5359        final List<ImageEntry> images = new ArrayList<ImageEntry>();
    5460        for (ImageEntry e : layer.getImages()) {
     
    125131    }
    126132
    127     class GeoTaggingRunnable extends PleaseWaitRunnable {
     133    static class GeoTaggingRunnable extends PleaseWaitRunnable {
    128134        final private List<ImageEntry> images;
    129135        final private boolean keep_backup;
     
    164170                        testMTimeReadAndWrite(e.getFile());
    165171                    }
    166                    
     172
    167173                    Long mTime = null;
    168174                    if (mTimeMode == MTIME_MODE_PREVIOUS_VALUE) {
     
    281287            }
    282288        }
    283        
     289
    284290        boolean testMTimeReadAndWriteDone = false;
    285        
     291
    286292        private void testMTimeReadAndWrite(File file) throws IOException {
    287293            if (testMTimeReadAndWriteDone)  // do this only once
     
    308314        }
    309315    }
     316
     317    private GeoImageLayer getLayer() {
     318        return (GeoImageLayer)LayerListDialog.getInstance().getModel().getSelectedLayers().get(0);
     319    }
     320
     321    /**
     322     * Check if there is any suitable image.
     323     */
     324    private boolean enabled(GeoImageLayer layer) {
     325        for (ImageEntry e : layer.getImages()) {
     326            if (e.getPos() != null && e.getGpsTime() != null)
     327                return true;
     328        }
     329        return false;
     330    }
     331
     332        public Component createMenuComponent() {
     333        JMenuItem geotaggingItem = new JMenuItem(this);
     334        geotaggingItem.setEnabled(enabled(getLayer()));
     335        return geotaggingItem;
     336        }
     337
     338        public boolean supportLayers(List<Layer> layers) {
     339                return layers.size() == 1 && layers.get(0) instanceof GeoImageLayer;
     340        }
    310341}
  • applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/GeotaggingPlugin.java

    r19845 r22551  
    22package org.openstreetmap.josm.plugins.photo_geotagging;
    33
    4 import static org.openstreetmap.josm.tools.I18n.tr;
    5 
    6 import java.awt.Component;
    7 
    8 import javax.swing.JMenuItem;
    9 
    10 import org.openstreetmap.josm.gui.layer.Layer;
    114import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer;
    12 import org.openstreetmap.josm.gui.layer.geoimage.ImageEntry;
    135import org.openstreetmap.josm.plugins.Plugin;
    146import org.openstreetmap.josm.plugins.PluginInformation;
    15 import org.openstreetmap.josm.tools.ImageProvider;
    167
    178/**
     
    2718    public GeotaggingPlugin(PluginInformation info) {
    2819        super(info);
    29         GeoImageLayer.registerMenuAddition(new GeotaggingMenuAddition());
     20        GeoImageLayer.registerMenuAddition(new GeotaggingAction());
    3021    }
    3122
    32     /**
    33      * Adds a menu entry to the right click menu of each geoimage layer.
    34      */
    35     class GeotaggingMenuAddition implements GeoImageLayer.LayerMenuAddition {
    36         public Component getComponent(Layer layer) {
    37             JMenuItem geotaggingItem = new JMenuItem(tr("Write coordinates to image header"), ImageProvider.get("geotagging"));;
    38             geotaggingItem.addActionListener(new GeotaggingAction((GeoImageLayer) layer));
    39             geotaggingItem.setEnabled(enabled((GeoImageLayer) layer));
    40             return geotaggingItem;
    41         }
    42 
    43         /**
    44          * Check if there is any suitable image.
    45          */
    46         private boolean enabled(GeoImageLayer layer) {
    47             for (ImageEntry e : layer.getImages()) {
    48                 if (e.getPos() != null && e.getGpsTime() != null)
    49                     return true;
    50             }
    51             return false;
    52         }
    53     }
    5423}
Note: See TracChangeset for help on using the changeset viewer.