Changeset 29388 in osm for applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetInfoAction.java
- Timestamp:
- 2013-03-23T18:45:59+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetInfoAction.java
r29387 r29388 2 2 3 3 import java.awt.event.ActionEvent; 4 import java.io.UnsupportedEncodingException; 5 import java.net.URLEncoder; 4 6 import java.text.SimpleDateFormat; 5 7 import javax.swing.AbstractAction; … … 18 20 public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd MMMM yyyy"); 19 21 20 private Object info;22 ImageryOffsetBase offset; 21 23 22 24 /** … … 27 29 super(tr("Offset Information")); 28 30 putValue(SMALL_ICON, ImageProvider.get("info")); 29 if( offset != null ) 30 this.info = getInformationObject(offset); 31 this.offset = offset; 31 32 setEnabled(offset != null); 32 33 } 33 34 34 35 /** 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. 36 38 */ 37 39 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 } 39 65 } 40 66 … … 57 83 ImageryOffsetTools.formatDistance(dist))); 58 84 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(), 61 87 DATE_FORMAT.format(offset.getDate()))).append('\n'); 62 88 sb.append(tr("Description")).append(": ").append(offset.getDescription()); 63 89 64 90 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(), 67 93 DATE_FORMAT.format(offset.getAbandonDate()))).append('\n'); 68 94 sb.append(tr("Reason")).append(": ").append(offset.getAbandonReason()); 69 95 } 96 97 if( offset.isFlagged() ) { 98 sb.append("\n\n").append(tr("This entry has been reported.")); 99 } 100 70 101 return sb.toString(); 71 102 }
Note:
See TracChangeset
for help on using the changeset viewer.