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

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

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

Legend:

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

    r29384 r29388  
    100100                    fields.position = parseLatLon(attributes);
    101101                    fields.id = Integer.parseInt(attributes.getValue("id"));
     102                    if( attributes.getValue("flagged") != null && attributes.getValue("flagged").equals("yes") )
     103                        fields.flagged = true;
    102104                }
    103105            } else {
     
    183185        public String imagery;
    184186        public int minZoom, maxZoom;
     187        public boolean flagged;
    185188        public List<LatLon> geometry;
    186189
     
    208211            minZoom = -1;
    209212            maxZoom = -1;
     213            flagged = false;
    210214            geometry = new ArrayList<LatLon>();
    211215        }
     
    234238            result.setBasicInfo(position, author, description, date);
    235239            result.setDeprecated(abandonDate, abandonAuthor, abandonReason);
     240            if( flagged )
     241                result.setFlagged(flagged);
    236242            return result;
    237243        }
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetBase.java

    r29384 r29388  
    2323    protected String abandonAuthor;
    2424    protected String abandonReason;
     25    protected boolean flagged;
    2526   
    2627    /**
     
    3435        this.date = date;
    3536        this.abandonDate = null;
     37        this.flagged = false;
    3638    }
    3739
     
    5254        this.abandonAuthor = author;
    5355        this.abandonReason = reason;
     56    }
     57
     58    public boolean isFlagged() {
     59        return flagged;
     60    }
     61
     62    public void setFlagged( boolean flagged ) {
     63        this.flagged = flagged;
    5464    }
    5565
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialog.java

    r29386 r29388  
    214214        } else
    215215            selectedOffset = null;
    216         NavigatableComponent.removeZoomChangeListener(this);
    217         setVisible(false);
     216        boolean closeDialog = MODAL || selectedOffset == null
     217                || selectedOffset instanceof CalibrationObject
     218                || Main.pref.getBoolean("iodb.close.on.select", true);
     219        if( closeDialog ) {
     220            NavigatableComponent.removeZoomChangeListener(this);
     221            setVisible(false);
     222        }
    218223        if( !MODAL ) {
    219             Main.map.mapView.removeTemporaryLayer(this);
    220             Main.map.mapView.repaint();
    221             if( selectedOffset != null )
     224            if( closeDialog ) {
     225                Main.map.mapView.removeTemporaryLayer(this);
     226                Main.map.mapView.repaint();
     227            }
     228            if( selectedOffset != null ) {
    222229                applyOffset();
     230                if( !closeDialog )
     231                    updateButtonPanel();
     232            }
    223233        }
    224234    }
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialogButton.java

    r29386 r29388  
    7272
    7373        String description = offset.isDeprecated() ? offset.getAbandonReason() : offset.getDescription();
     74        description = description.replace("<", "&lt;").replace(">", "&gt;");
    7475        JLabel descriptionLabel = new JLabel("<html><div style=\"width: 300px;\">"+description+"</div></html>");
     76        Font descriptionFont = new Font(descriptionLabel.getFont().getName(), Font.BOLD, descriptionLabel.getFont().getSize() - 2);
     77        descriptionLabel.setFont(descriptionFont);
    7578
    7679        double offsetDistance = offset instanceof ImageryOffset
  • 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.