Ignore:
Timestamp:
2016-07-02T03:55:03+02:00 (9 years ago)
Author:
donvip
Message:

checkstyle

File:
1 edited

Legend:

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

    r29434 r32528  
     1// License: WTFPL. For details, see LICENSE file.
    12package iodb;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    25
    36import java.awt.event.ActionEvent;
    47import java.io.UnsupportedEncodingException;
    5 import java.net.*;
     8import java.net.URLEncoder;
     9
    610import javax.swing.AbstractAction;
    711import javax.swing.JOptionPane;
     12
    813import org.openstreetmap.josm.Main;
    914import org.openstreetmap.josm.gui.JosmUserIdentityManager;
    10 import static org.openstreetmap.josm.tools.I18n.tr;
    1115import org.openstreetmap.josm.tools.ImageProvider;
    1216
    1317/**
    1418 * A context-dependent action to deprecate an offset.
    15  * 
     19 *
    1620 * @author Zverik
    1721 * @license WTFPL
     
    2024    private ImageryOffsetBase offset;
    2125    private QuerySuccessListener listener;
    22    
     26
    2327    /**
    2428     * Initialize an action with an offset object.
    2529     */
    26     public DeprecateOffsetAction( ImageryOffsetBase offset ) {
     30    public DeprecateOffsetAction(ImageryOffsetBase offset) {
    2731        super(tr("Deprecate Offset"));
    2832        putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));
     
    3741     * on a positive answer.
    3842     */
     43    @Override
    3944    public void actionPerformed(ActionEvent e) {
    40         if( Main.map == null || Main.map.mapView == null || !Main.map.isVisible() )
     45        if (Main.map == null || Main.map.mapView == null || !Main.map.isVisible())
    4146            return;
    42        
     47
    4348        String desc = offset instanceof ImageryOffset ?
    4449                tr("Are you sure this imagery offset is wrong?") :
    45                 tr("Are you sure this calibration geometry is aligned badly?");
    46         if( JOptionPane.showConfirmDialog(Main.parent,
    47                 tr("Warning: deprecation is basically irreversible!")+ "\n" + desc,
    48                 ImageryOffsetTools.DIALOG_TITLE, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION ) {
    49             return;
    50         }
    51         deprecateOffset(offset, listener);
     50                    tr("Are you sure this calibration geometry is aligned badly?");
     51                if (JOptionPane.showConfirmDialog(Main.parent,
     52                        tr("Warning: deprecation is basically irreversible!")+ "\n" + desc,
     53                        ImageryOffsetTools.DIALOG_TITLE, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) {
     54                    return;
     55                }
     56                deprecateOffset(offset, listener);
    5257    }
    5358
     
    5560     * Installs a listener to process successful deprecation event.
    5661     */
    57     public void setListener( QuerySuccessListener listener ) {
     62    public void setListener(QuerySuccessListener listener) {
    5863        this.listener = listener;
    5964    }
     
    6166    /**
    6267     * Deprecate the given offset.
    63      * @see #deprecateOffset(iodb.ImageryOffsetBase, iodb.QuerySuccessListener) 
     68     * @see #deprecateOffset(iodb.ImageryOffsetBase, iodb.QuerySuccessListener)
    6469     */
    65     public static void deprecateOffset( ImageryOffsetBase offset ) {
     70    public static void deprecateOffset(ImageryOffsetBase offset) {
    6671        deprecateOffset(offset, null);
    6772    }
     
    7176     * and executes {@link SimpleOffsetQueryTask} with a query to deprecate the offset.
    7277     */
    73     public static void deprecateOffset( ImageryOffsetBase offset, QuerySuccessListener listener ) {
     78    public static void deprecateOffset(ImageryOffsetBase offset, QuerySuccessListener listener) {
    7479        String userName = JosmUserIdentityManager.getInstance().getUserName();
    75         if( userName == null ) {
    76             JOptionPane.showMessageDialog(Main.parent, tr("To store imagery offsets you must be a registered OSM user."), ImageryOffsetTools.DIALOG_TITLE, JOptionPane.ERROR_MESSAGE);
     80        if (userName == null) {
     81            JOptionPane.showMessageDialog(Main.parent, tr("To store imagery offsets you must be a registered OSM user."),
     82                    ImageryOffsetTools.DIALOG_TITLE, JOptionPane.ERROR_MESSAGE);
    7783            return;
    7884        }
     
    8086        String message = offset instanceof ImageryOffset
    8187                ? tr("Please enter the reason why you mark this imagery offset as deprecated")
    82                 : tr("Please enter the reason why you mark this calibration geometry as deprecated");
    83         String reason = StoreImageryOffsetAction.queryDescription(message + ":");
    84         if( reason == null )
    85             return;
    86        
    87         try {
    88             String query = "deprecate?id=" + offset.getId()
    89                 + "&author=" + URLEncoder.encode(userName, "UTF8")
    90                 + "&reason=" + URLEncoder.encode(reason, "UTF8");
    91             SimpleOffsetQueryTask depTask = new SimpleOffsetQueryTask(query, tr("Notifying the server of the deprecation..."));
    92             if( listener != null )
    93                 depTask.setListener(listener);
    94             Main.worker.submit(depTask);
    95         } catch( UnsupportedEncodingException ex ) {
    96             // WTF
    97         }
     88                        : tr("Please enter the reason why you mark this calibration geometry as deprecated");
     89                String reason = StoreImageryOffsetAction.queryDescription(message + ":");
     90                if (reason == null)
     91                    return;
     92
     93                try {
     94                    String query = "deprecate?id=" + offset.getId()
     95                    + "&author=" + URLEncoder.encode(userName, "UTF8")
     96                    + "&reason=" + URLEncoder.encode(reason, "UTF8");
     97                    SimpleOffsetQueryTask depTask = new SimpleOffsetQueryTask(query, tr("Notifying the server of the deprecation..."));
     98                    if (listener != null)
     99                        depTask.setListener(listener);
     100                    Main.worker.submit(depTask);
     101                } catch (UnsupportedEncodingException ex) {
     102                    Main.error(ex);
     103                }
    98104    }
    99105}
Note: See TracChangeset for help on using the changeset viewer.