Ignore:
Timestamp:
2013-03-23T18:45:59+01:00 (12 years ago)
Author:
zverik
Message:

probably the last alpha of iodb (or first beta, whatever)

File:
1 edited

Legend:

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

    r29387 r29388  
    22
    33import java.awt.event.ActionEvent;
     4import java.io.UnsupportedEncodingException;
     5import java.net.URLEncoder;
    46import java.text.SimpleDateFormat;
    57import javax.swing.AbstractAction;
     
    1820    public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd MMMM yyyy");
    1921
    20     private Object info;
     22    ImageryOffsetBase offset;
    2123   
    2224    /**
     
    2729        super(tr("Offset Information"));
    2830        putValue(SMALL_ICON, ImageProvider.get("info"));
    29         if( offset != null )
    30             this.info = getInformationObject(offset);
     31        this.offset = offset;
    3132        setEnabled(offset != null);
    3233    }
    3334
    3435    /**
    35      * Shows a dialog with the pre-constructed message.
     36     * Shows a dialog with the pre-constructed message. Allows a user
     37     * to report the given offset.
    3638     */
    3739    public void actionPerformed(ActionEvent e) {
    38         JOptionPane.showMessageDialog(Main.parent, info, ImageryOffsetTools.DIALOG_TITLE, JOptionPane.PLAIN_MESSAGE);
     40        Object info = offset == null ? null : getInformationObject(offset);
     41        if( offset.isFlagged() )
     42            JOptionPane.showMessageDialog(Main.parent, info, ImageryOffsetTools.DIALOG_TITLE, JOptionPane.PLAIN_MESSAGE);
     43        else {
     44            int result = JOptionPane.showOptionDialog(Main.parent, info, ImageryOffsetTools.DIALOG_TITLE,
     45                    JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null,
     46                    new String[] { "OK", tr("Report this offset") }, null);
     47            if( result == 1 ) {
     48                // ask for a reason
     49                Object reason = JOptionPane.showInputDialog(Main.parent,
     50                        tr("You are to notify moderators of this offset. Why they should look into this case?"),
     51                        ImageryOffsetTools.DIALOG_TITLE, JOptionPane.PLAIN_MESSAGE);
     52                if( reason != null && reason.toString().length() > 0 ) {
     53                    try {
     54                        String query = "report?id=" + offset.getId()
     55                                + "&reason=" + URLEncoder.encode(reason.toString(), "UTF8");
     56                        SimpleOffsetQueryTask reportTask =
     57                                new SimpleOffsetQueryTask(query, tr("Reporting the offset..."));
     58                        Main.worker.submit(reportTask);
     59                    } catch( UnsupportedEncodingException ex ) {
     60                        // WTF
     61                    }
     62                }
     63            }
     64        }
    3965    }
    4066
     
    5783                ImageryOffsetTools.formatDistance(dist)));
    5884       
    59         sb.append('\n').append('\n');
    60         sb.append(tr("Created by {0} on {1}\n", offset.getAuthor(),
     85        sb.append("\n\n");
     86        sb.append(tr("Created by {0} on {1}", offset.getAuthor(),
    6187                DATE_FORMAT.format(offset.getDate()))).append('\n');
    6288        sb.append(tr("Description")).append(": ").append(offset.getDescription());
    6389       
    6490        if( offset.isDeprecated() ) {
    65             sb.append('\n').append('\n');
    66             sb.append(tr("Deprecated by {0} on {1}\n",offset.getAbandonAuthor(),
     91            sb.append("\n\n");
     92            sb.append(tr("Deprecated by {0} on {1}",offset.getAbandonAuthor(),
    6793                    DATE_FORMAT.format(offset.getAbandonDate()))).append('\n');
    6894            sb.append(tr("Reason")).append(": ").append(offset.getAbandonReason());
    6995        }
     96
     97        if( offset.isFlagged() ) {
     98            sb.append("\n\n").append(tr("This entry has been reported."));
     99        }
     100
    70101        return sb.toString();
    71102    }
Note: See TracChangeset for help on using the changeset viewer.