Ignore:
Timestamp:
2014-10-19T01:27:04+02:00 (10 years ago)
Author:
donvip
Message:

[josm_plugins] fix java 7 warnings / global usage of try-with-resource

Location:
applications/editors/josm/plugins/imagery_offset_db/src/iodb
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetPlugin.java

    r30737 r30738  
    11package iodb;
    22
     3import static org.openstreetmap.josm.tools.I18n.marktr;
     4
    35import java.awt.event.KeyEvent;
    4 import java.util.*;
     6import java.util.Collection;
     7import java.util.LinkedList;
     8
    59import javax.swing.JMenu;
     10
    611import org.openstreetmap.josm.Main;
    712import org.openstreetmap.josm.data.Version;
     13import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
    814import org.openstreetmap.josm.plugins.Plugin;
    915import org.openstreetmap.josm.plugins.PluginInformation;
    10 import static org.openstreetmap.josm.tools.I18n.marktr;
    1116
    1217/**
    1318 * A plugin to request and store imagery offsets in the centralized database.
    14  * 
     19 *
    1520 * @author Zverik
    1621 * @license WTFPL
     
    1924    private GetImageryOffsetAction getAction;
    2025    private StoreImageryOffsetAction storeAction;
    21    
     26
    2227    /**
    2328     * Add both actions to their own menu. This creates
     
    2833    public ImageryOffsetPlugin( PluginInformation info ) {
    2934        super(info);
    30        
     35
    3136        getAction = new GetImageryOffsetAction();
    3237        storeAction = new StoreImageryOffsetAction();
    33        
     38
    3439        // before 5803 imagery menu was constantly regenerated, erasing extra items
    3540        // before 5729 it was regenerated only when the imagery list was modified (also bad)
     
    4348        // an ugly hack to add this plugin to the toolbar
    4449        if( Main.pref.getBoolean("iodb.modify.toolbar", true) ) {
    45             Collection<String> toolbar = new LinkedList<>(Main.toolbar.getToolString());
     50            Collection<String> toolbar = new LinkedList<>(ToolbarPreferences.getToolString());
    4651            if( !toolbar.contains("getoffset") ) {
    4752                toolbar.add("getoffset");
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialog.java

    r30737 r30738  
    11package iodb;
    22
    3 import java.awt.*;
     3import static org.openstreetmap.josm.tools.I18n.tr;
     4
     5import java.awt.BasicStroke;
     6import java.awt.Color;
     7import java.awt.Component;
     8import java.awt.FlowLayout;
     9import java.awt.Graphics2D;
     10import java.awt.GridLayout;
     11import java.awt.Point;
     12import java.awt.RenderingHints;
    413import java.awt.event.ActionEvent;
    514import java.awt.event.ActionListener;
     
    817import java.net.HttpURLConnection;
    918import java.net.URL;
    10 import java.util.*;
     19import java.util.ArrayList;
     20import java.util.Date;
    1121import java.util.List;
    12 import javax.swing.*;
     22
     23import javax.swing.AbstractAction;
     24import javax.swing.Box;
     25import javax.swing.BoxLayout;
     26import javax.swing.JButton;
     27import javax.swing.JCheckBox;
     28import javax.swing.JComponent;
     29import javax.swing.JDialog;
     30import javax.swing.JOptionPane;
     31import javax.swing.JPanel;
     32import javax.swing.JPopupMenu;
     33import javax.swing.KeyStroke;
    1334import javax.swing.border.CompoundBorder;
    1435import javax.swing.border.EmptyBorder;
     36
    1537import org.openstreetmap.josm.Main;
    1638import org.openstreetmap.josm.data.Bounds;
     
    1941import org.openstreetmap.josm.gui.layer.ImageryLayer;
    2042import org.openstreetmap.josm.gui.layer.MapViewPaintable;
    21 import org.openstreetmap.josm.tools.*;
    22 import static org.openstreetmap.josm.tools.I18n.tr;
     43import org.openstreetmap.josm.tools.ImageProvider;
     44import org.openstreetmap.josm.tools.LanguageInfo;
     45import org.openstreetmap.josm.tools.OpenBrowser;
     46import org.openstreetmap.josm.tools.Utils;
    2347
    2448/**
    2549 * The dialog which presents a choice between imagery align options.
    26  * 
     50 *
    2751 * @author Zverik
    2852 * @license WTFPL
     
    3155    protected static final String PREF_CALIBRATION = "iodb.show.calibration";
    3256    protected static final String PREF_DEPRECATED = "iodb.show.deprecated";
    33     private static final int MAX_OFFSETS = Main.main.pref.getInteger("iodb.max.offsets", 4);
     57    private static final int MAX_OFFSETS = Main.pref.getInteger("iodb.max.offsets", 4);
    3458
    3559    /**
     
    4569
    4670    /**
    47      * Initialize the dialog and install listeners. 
     71     * Initialize the dialog and install listeners.
    4872     * @param offsets The list of offset to choose from.
    4973     */
     
    6084                JComponent.WHEN_IN_FOCUSED_WINDOW);
    6185    }
    62    
     86
    6387    /**
    6488     * Creates the GUI.
     
    6993        calibrationBox.setSelected(Main.pref.getBoolean(PREF_CALIBRATION, true));
    7094        calibrationBox.addActionListener(new ActionListener() {
    71             public void actionPerformed( ActionEvent e ) {
     95            @Override
     96                        public void actionPerformed( ActionEvent e ) {
    7297                Main.pref.put(PREF_CALIBRATION, calibrationBox.isSelected());
    7398                updateButtonPanel();
     
    77102        deprecatedBox.setSelected(Main.pref.getBoolean(PREF_DEPRECATED, false));
    78103        deprecatedBox.addActionListener(new ActionListener() {
    79             public void actionPerformed( ActionEvent e ) {
     104            @Override
     105                        public void actionPerformed( ActionEvent e ) {
    80106                Main.pref.put(PREF_DEPRECATED, deprecatedBox.isSelected());
    81107                updateButtonPanel();
     
    154180     * It does nothing, only passes the event to all displayed offset buttons.
    155181     */
    156     public void zoomChanged() {
     182    @Override
     183        public void zoomChanged() {
    157184        for( Component c : buttonPanel.getComponents() ) {
    158185            if( c instanceof OffsetDialogButton ) {
     
    166193     * value, but looks nice.
    167194     */
    168     public void paint( Graphics2D g, MapView mv, Bounds bbox ) {
     195    @Override
     196        public void paint( Graphics2D g, MapView mv, Bounds bbox ) {
    169197        if( offsets == null )
    170198            return;
     
    181209        }
    182210    }
    183    
     211
    184212    /**
    185213     * Display the dialog and get the return value is case of a modal frame.
     
    208236     * @see #applyOffset()
    209237     */
    210     public void actionPerformed( ActionEvent e ) {
     238    @Override
     239        public void actionPerformed( ActionEvent e ) {
    211240        if( e.getSource() instanceof OffsetDialogButton ) {
    212241            selectedOffset = ((OffsetDialogButton)e.getSource()).getOffset();
     
    283312         * Remove the deprecated offset from the offsets list. Then rebuild the button panel.
    284313         */
    285         public void queryPassed() {
     314        @Override
     315                public void queryPassed() {
    286316            offset.setDeprecated(new Date(), JosmUserIdentityManager.getInstance().getUserName(), "");
    287317            updateButtonPanel();
     
    299329        }
    300330
    301         public void actionPerformed( ActionEvent e ) {
     331        @Override
     332                public void actionPerformed( ActionEvent e ) {
    302333            String base = Main.pref.get("url.openstreetmap-wiki", "http://wiki.openstreetmap.org/wiki/");
    303334            String lang = LanguageInfo.getWikiLanguagePrefix();
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/StoreImageryOffsetAction.java

    r30737 r30738  
    117117                query.append(key).append('=').append(URLEncoder.encode(params.get(key), "UTF8"));
    118118            }
    119             Main.main.worker.submit(new SimpleOffsetQueryTask(query.toString(), tr("Uploading a new offset...")));
     119            Main.worker.submit(new SimpleOffsetQueryTask(query.toString(), tr("Uploading a new offset...")));
    120120        } catch( UnsupportedEncodingException ex ) {
    121121            // WTF
Note: See TracChangeset for help on using the changeset viewer.