Changeset 32263 in osm


Ignore:
Timestamp:
2016-06-15T14:46:51+02:00 (8 years ago)
Author:
donvip
Message:

fix #josm12958 - update to JOSM 10282 + fix mapmode dynamics + add javadocs, fix warnings

Location:
applications/editors/josm/plugins/editgpx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/editgpx/.settings/org.eclipse.jdt.core.prefs

    r30736 r32263  
    8181org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
    8282org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
     83org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
    8384org.eclipse.jdt.core.compiler.problem.unusedImport=warning
    8485org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
  • applications/editors/josm/plugins/editgpx/.settings/org.eclipse.jdt.ui.prefs

    r23659 r32263  
    1 #Sat Oct 16 19:07:29 CEST 2010
    21cleanup.add_default_serial_version_id=true
    32cleanup.add_generated_serial_version_id=false
     
    6261sp_cleanup.add_missing_methods=false
    6362sp_cleanup.add_missing_nls_tags=false
    64 sp_cleanup.add_missing_override_annotations=false
     63sp_cleanup.add_missing_override_annotations=true
     64sp_cleanup.add_missing_override_annotations_interface_methods=true
    6565sp_cleanup.add_serial_version_id=false
    6666sp_cleanup.always_use_blocks=true
     
    6868sp_cleanup.always_use_this_for_non_static_field_access=false
    6969sp_cleanup.always_use_this_for_non_static_method_access=false
     70sp_cleanup.convert_functional_interfaces=false
    7071sp_cleanup.convert_to_enhanced_for_loop=false
    7172sp_cleanup.correct_indentation=true
    7273sp_cleanup.format_source_code=false
    7374sp_cleanup.format_source_code_changes_only=false
     75sp_cleanup.insert_inferred_type_arguments=false
    7476sp_cleanup.make_local_variable_final=false
    7577sp_cleanup.make_parameters_final=false
     
    8789sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
    8890sp_cleanup.remove_private_constructors=true
     91sp_cleanup.remove_redundant_type_arguments=false
    8992sp_cleanup.remove_trailing_whitespaces=true
    9093sp_cleanup.remove_trailing_whitespaces_all=true
     
    100103sp_cleanup.sort_members=false
    101104sp_cleanup.sort_members_all=false
     105sp_cleanup.use_anonymous_class_creation=false
    102106sp_cleanup.use_blocks=false
    103107sp_cleanup.use_blocks_only_for_return_and_throw=false
     108sp_cleanup.use_lambda=false
    104109sp_cleanup.use_parentheses_in_expressions=false
    105110sp_cleanup.use_this_for_non_static_field_access=false
     
    107112sp_cleanup.use_this_for_non_static_method_access=false
    108113sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
     114sp_cleanup.use_type_arguments=false
  • applications/editors/josm/plugins/editgpx/build.xml

    r32148 r32263  
    44    <property name="commit.message" value="Changed constructor signature of plugin main class"/>
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    6     <property name="plugin.main.version" value="10144"/>
     6    <property name="plugin.main.version" value="10282"/>
    77   
    88    <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/editgpx/src/org/openstreetmap/josm/plugins/editgpx/EditGpxLayer.java

    r30634 r32263  
    3838    private GPXLayerImportAction layerImport;
    3939
    40     public EditGpxLayer(String str, EditGpxData gpxData) {
    41         super(str);
     40    /**
     41     * Constructs a new {@code EditGpxLayer}.
     42     * @param gpxData edit gpx data
     43     */
     44    public EditGpxLayer(EditGpxData gpxData) {
     45        super(tr("EditGpx"));
    4246        data = gpxData;
    4347        layerImport = new GPXLayerImportAction(data);
     
    4953     */
    5054    public void initializeImport() {
    51         try {
    52             if (data.isEmpty()) {
    53                 layerImport.activateImport();
    54             }
    55         } catch (Exception e) {
    56             Main.error(e);
     55        if (data.isEmpty()) {
     56            layerImport.activateImport();
    5757        }
    5858    }
     
    116116    }
    117117
    118 
    119118    public void reset(){
    120119        //TODO implement a reset
    121120    }
    122 
    123121
    124122    @Override
     
    126124        // TODO Auto-generated method stub
    127125    }
    128 
    129126
    130127    /**
     
    142139     */
    143140    public class ConvertToGpxLayerAction extends AbstractAction {
     141        /**
     142         * Constructs a new {@code ConvertToGpxLayerAction}.
     143         */
    144144        public ConvertToGpxLayerAction() {
    145145            super(tr("Convert to GPX layer"), ImageProvider.get("converttogpx"));
     
    147147        @Override
    148148        public void actionPerformed(ActionEvent e) {
    149             if (Main.map.mapMode instanceof EditGpxMode) {
    150                 if (!Main.map.selectSelectTool(false)) {
    151                     Main.map.selectZoomTool(false); // Select tool might not be support of active layer, zoom is always supported
    152                 }
     149            if (Main.map.mapMode instanceof EditGpxMode && !Main.map.selectSelectTool(false)) {
     150                Main.map.selectZoomTool(false); // Select tool might not be support of active layer, zoom is always supported
    153151            }
    154152            Main.main.addLayer(new GpxLayer(toGpxData(false), tr("Converted from: {0}", getName())));
     
    161159     */
    162160    public class ConvertToAnonTimeGpxLayerAction extends AbstractAction {
     161        /**
     162         * Constructs a new {@code ConvertToAnonTimeGpxLayerAction}.
     163         */
    163164        public ConvertToAnonTimeGpxLayerAction() {
    164165            super(tr("Convert to GPX layer with anonymised time"), ImageProvider.get("converttogpx"));
     
    166167        @Override
    167168        public void actionPerformed(ActionEvent e) {
    168             if (Main.map.mapMode instanceof EditGpxMode) {
    169                 if (!Main.map.selectSelectTool(false)) {
    170                     Main.map.selectZoomTool(false); // Select tool might not be support of active layer, zoom is always supported
    171                 }
     169            if (Main.map.mapMode instanceof EditGpxMode && !Main.map.selectSelectTool(false)) {
     170                Main.map.selectZoomTool(false); // Select tool might not be support of active layer, zoom is always supported
    172171            }
    173172            Main.main.addLayer(new GpxLayer(toGpxData(true), tr("Converted from: {0}", getName())));
  • applications/editors/josm/plugins/editgpx/src/org/openstreetmap/josm/plugins/editgpx/EditGpxMode.java

    r32223 r32263  
    1818import org.openstreetmap.josm.actions.mapmode.MapMode;
    1919import org.openstreetmap.josm.gui.MapFrame;
    20 import org.openstreetmap.josm.gui.MapView;
    21 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    22 import org.openstreetmap.josm.gui.layer.Layer;
     20import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     21import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     22import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
     23import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
    2324import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2425import org.openstreetmap.josm.plugins.editgpx.data.EditGpxData;
     
    3132    private static final long serialVersionUID = 7940589057093872411L;
    3233    Point pointPressed;
    33     MapFrame mapFrame;
     34    private final MapFrame mapFrame;
    3435    Rectangle oldRect;
    35     MapFrame frame;
    36     EditGpxLayer currentEditLayer;
     36    transient EditGpxLayer currentEditLayer;
    3737
    38     public EditGpxMode(MapFrame mapFrame, String name, String desc) {
    39         super(name, "editgpx_mode.png", desc, mapFrame, Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
     38    /**
     39     * Constructs a new {@code EditGpxMode}.
     40     * @param mapFrame map frame
     41     */
     42    public EditGpxMode(MapFrame mapFrame) {
     43        super("editgpx", "editgpx_mode.png", tr("edit gpx tracks"), Main.map, Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
     44        this.mapFrame = mapFrame;
    4045    }
    4146
     
    4550        Main.map.mapView.addMouseListener(this);
    4651        Main.map.mapView.addMouseMotionListener(this);
    47         MapView.addLayerChangeListener(this);
     52        Main.map.mapView.getLayerManager().addLayerChangeListener(this);
    4853        updateLayer();
    4954    }
     
    5459        Main.map.mapView.removeMouseListener(this);
    5560        Main.map.mapView.removeMouseMotionListener(this);
    56         MapView.removeLayerChangeListener(this);
     61        Main.map.mapView.getLayerManager().removeLayerChangeListener(this);
    5762    }
    5863
     
    7883        requestFocusInMapView();
    7984
    80         Point pointReleased = e.getPoint();
    81 
    82         Rectangle r = createRect(pointReleased, pointPressed);
     85        Rectangle r = createRect(e.getPoint(), pointPressed);
    8386
    8487        //go through nodes and mark the ones in the selection rect as deleted
     
    133136     */
    134137    private void paintRect(Point p1, Point p2) {
    135         if (frame != null) {
    136             Graphics g = frame.getGraphics();
     138        if (mapFrame != null) {
     139            Graphics g = mapFrame.getGraphics();
    137140
    138141            Rectangle r = oldRect;
     
    152155    }
    153156
    154     public void setFrame(MapFrame mapFrame) {
    155         frame = mapFrame;
    156     }
    157 
    158157    /**
    159158     * create new layer, add listeners and try importing gpx data.
     
    161160    private void updateLayer() {
    162161
    163         List<EditGpxLayer> layers = Main.map.mapView.getLayersOfType(EditGpxLayer.class);
    164         currentEditLayer = layers.isEmpty()?null:layers.get(0);
     162        List<EditGpxLayer> layers = Main.map.mapView.getLayerManager().getLayersOfType(EditGpxLayer.class);
     163        currentEditLayer = layers.isEmpty() ? null : layers.get(0);
    165164
    166165        if(currentEditLayer == null) {
    167             currentEditLayer = new EditGpxLayer(tr("EditGpx"), new EditGpxData());
     166            currentEditLayer = new EditGpxLayer(new EditGpxData());
    168167            Main.main.addLayer(currentEditLayer);
    169168            currentEditLayer.initializeImport();
     
    172171    }
    173172
    174     public void activeLayerChange(Layer oldLayer, Layer newLayer) { }
     173    @Override
     174    public void layerAdded(LayerAddEvent e) {
     175        // Do nothing
     176    }
    175177
    176     public void layerAdded(Layer newLayer) { }
    177 
    178     public void layerRemoved(Layer oldLayer) {
    179         if (oldLayer instanceof EditGpxLayer) {
     178    @Override
     179    public void layerRemoving(LayerRemoveEvent e) {
     180        if (e.getRemovedLayer() instanceof EditGpxLayer) {
    180181            currentEditLayer = null;
    181182            if (Main.map.mapMode instanceof EditGpxMode) {
    182                 if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) {
     183                if (Main.map.mapView.getLayerManager().getActiveLayer() instanceof OsmDataLayer) {
    183184                    Main.map.selectSelectTool(false);
    184185                } else {
     
    190191
    191192    @Override
    192     public void destroy() {
    193         super.destroy();
    194         MapView.removeLayerChangeListener(this);
     193    public void layerOrderChanged(LayerOrderChangeEvent e) {
     194        // Do nothing
    195195    }
    196196}
  • applications/editors/josm/plugins/editgpx/src/org/openstreetmap/josm/plugins/editgpx/EditGpxPlugin.java

    r28612 r32263  
    33 */
    44package org.openstreetmap.josm.plugins.editgpx;
    5 
    6 import static org.openstreetmap.josm.tools.I18n.tr;
    7 
    8 import java.net.URL;
    95
    106import javax.swing.ImageIcon;
     
    2622 * - BUG: when importing eGpxLayer is shown as RawGpxLayer??
    2723 * - implement reset if user made mistake while marking
    28  *
    29  *
    3024 */
    3125public class EditGpxPlugin extends Plugin {
    3226
    33     private IconToggleButton btn;
    34     private EditGpxMode mode;
    35 
     27    /**
     28     * Constructs a new {@code EditGpxPlugin}.
     29     * @param info plugin information
     30     */
    3631    public EditGpxPlugin(PluginInformation info) {
    3732        super(info);
    38         mode = new EditGpxMode(Main.map, "editgpx", tr("edit gpx tracks"));
    39 
    40         btn = new IconToggleButton(mode);
    41         btn.setVisible(true);
    4233    }
    4334
     
    4738    @Override
    4839    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
    49         mode.setFrame(newFrame);
    50         if (oldFrame == null && newFrame != null) {
     40        if (newFrame != null) {
     41            EditGpxMode mode = new EditGpxMode(newFrame);
    5142            if (Main.map != null)
    52                 Main.map.addMapMode(btn);
     43                Main.map.addMapMode(new IconToggleButton(mode));
    5344        }
    5445    }
    5546
    5647    public static ImageIcon loadIcon(String name) {
    57         URL url = EditGpxPlugin.class.getResource("/images/editgpx.png");
    58         return new ImageIcon(url);
     48        return new ImageIcon(EditGpxPlugin.class.getResource("/images/editgpx.png"));
    5949    }
    6050}
  • applications/editors/josm/plugins/editgpx/src/org/openstreetmap/josm/plugins/editgpx/GPXLayerImportAction.java

    r30634 r32263  
    1111import java.awt.Component;
    1212import java.awt.event.ActionEvent;
    13 import java.util.Collection;
    1413
    1514import javax.swing.AbstractAction;
     
    5352
    5453        final JList<GpxLayer> layerList = new JList<>(dModel);
    55         Collection<Layer> data = Main.map.mapView.getAllLayers();
    5654        int layerCnt = 0;
    5755
    58         for (Layer l : data){
    59             if(l instanceof GpxLayer){
     56        for (Layer l : Main.map.mapView.getLayerManager().getLayers()){
     57            if (l instanceof GpxLayer){
    6058                dModel.addElement((GpxLayer) l);
    6159                layerCnt++;
     
    6563            layerList.setSelectionInterval(0, layerCnt-1);
    6664            layerList.setCellRenderer(new DefaultListCellRenderer(){
    67                 @Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
     65                @Override
     66                public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    6867                    Layer layer = (Layer)value;
    6968                    JLabel label = (JLabel)super.getListCellRendererComponent(list,
     
    114113    /**
    115114     * called when pressing "Import.." from context menu of EditGpx layer
    116      *
    117115     */
     116    @Override
    118117    public void actionPerformed(ActionEvent arg0) {
    119118        activateImport();
Note: See TracChangeset for help on using the changeset viewer.