Ignore:
Timestamp:
2016-09-03T16:16:04+02:00 (8 years ago)
Author:
donvip
Message:

checkstyle

Location:
applications/editors/josm/plugins/reverter
Files:
2 added
19 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reverter/.project

    r32286 r32905  
    1717                        </arguments>
    1818                </buildCommand>
     19                <buildCommand>
     20                        <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
     21                        <arguments>
     22                        </arguments>
     23                </buildCommand>
    1924        </buildSpec>
    2025        <natures>
    2126                <nature>org.eclipse.jdt.core.javanature</nature>
     27                <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
    2228        </natures>
    2329</projectDescription>
  • applications/editors/josm/plugins/reverter/src/reverter/ChangesetIdQuery.java

    r32516 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
     
    4243    private final JRadioButton rbSelectionUndelete = new JRadioButton(tr("Revert selection and restore deleted objects"));
    4344    private final JCheckBox cbNewLayer = new JCheckBox(tr("Download as new layer"));
    44    
     45
    4546    public Collection<Integer> getIdsInReverseOrder() {
    4647        return tcid.getIdsInReverseOrder();
    4748    }
    48    
     49
    4950    /**
    5051     * Replies true if the user requires to download into a new layer
     
    6465
    6566    public ChangesetIdQuery() {
    66         super(Main.parent, tr("Revert changeset"), new String[] {tr("Revert"),tr("Cancel")}, true);
    67         contentInsets = new Insets(10,10,10,5);
    68        
     67        super(Main.parent, tr("Revert changeset"), new String[] {tr("Revert"), tr("Cancel")}, true);
     68        contentInsets = new Insets(10, 10, 10, 5);
     69
    6970        panel.add(new JLabel(tr("Changeset id:")));
    7071
     
    8081        // forward the enter key stroke to the revert button
    8182        tcid.getKeymap().removeKeyStrokeBinding(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false));
    82        
     83
    8384        panel.add(cbId, GBC.eol().fill(GBC.HORIZONTAL));
    8485
     
    8889
    8990        rbFull.setSelected(true);
    90         panel.add(rbFull, GBC.eol().insets(0,10,0,0).fill(GBC.HORIZONTAL));
     91        panel.add(rbFull, GBC.eol().insets(0, 10, 0, 0).fill(GBC.HORIZONTAL));
    9192        panel.add(rbSelection, GBC.eol().fill(GBC.HORIZONTAL));
    9293        panel.add(rbSelectionUndelete, GBC.eol().fill(GBC.HORIZONTAL));
     
    102103        setButtonIcons(new String[] {"ok.png", "cancel.png" });
    103104        setDefaultButton(1);
    104        
     105
    105106        addWindowListener(new InternalWindowListener());
    106107        super.setupDialog();
    107        
     108
    108109        final DataSet ds = Main.getLayerManager().getEditDataSet();
    109        
     110
    110111        // Disables "Download in new layer" choice if there is no current data set (i.e no data layer)
    111112        if (ds == null) {
     
    118119            rbSelectionUndelete.setEnabled(false);
    119120        }
    120        
     121
    121122        // Enables/disables the Revert button when a changeset id is correctly set or not
    122123        tcid.getDocument().addDocumentListener(new DocumentListener() {
    123             @Override public void removeUpdate(DocumentEvent e) { idChanged(); }
    124             @Override public void insertUpdate(DocumentEvent e) { idChanged(); }
    125             @Override public void changedUpdate(DocumentEvent e) { idChanged(); }
     124            @Override public void removeUpdate(DocumentEvent e) {
     125                idChanged();
     126            }
     127
     128            @Override public void insertUpdate(DocumentEvent e) {
     129                idChanged();
     130            }
     131
     132            @Override public void changedUpdate(DocumentEvent e) {
     133                idChanged();
     134            }
     135
    126136            private void idChanged() {
    127137                if (tcid.hasFocus()) {
     
    130140            }
    131141        });
    132        
    133         if (Main.pref.getBoolean("downloadchangeset.autopaste", true)) { 
     142
     143        if (Main.pref.getBoolean("downloadchangeset.autopaste", true)) {
    134144            tcid.tryToPasteFromClipboard();
    135145        }
    136        
     146
    137147        // Initially sets the revert button consistent with text id field contents
    138148        buttons.get(0).setEnabled(tcid.readIds());
     
    142152     * Restore the current history from the preferences
    143153     *
    144      * @param cbHistory
     154     * @param cbHistory history combobox
    145155     */
    146156    protected void restoreChangesetsHistory(HistoryComboBox cbHistory) {
    147         List<String> cmtHistory = new LinkedList<>(Main.pref.getCollection(getClass().getName() + ".changesetsHistory", new LinkedList<String>()));
     157        List<String> cmtHistory = new LinkedList<>(
     158                Main.pref.getCollection(getClass().getName() + ".changesetsHistory", new LinkedList<String>()));
    148159        // we have to reverse the history, because ComboBoxHistory will reverse it again in addElement()
    149160        Collections.reverse(cmtHistory);
    150161        cbHistory.setPossibleItems(cmtHistory);
    151162    }
    152    
     163
    153164    /**
    154165     * Remind the current history in the preferences
    155      * @param cbHistory
     166     * @param cbHistory history combobox
    156167     */
    157168    protected void remindChangesetsHistory(HistoryComboBox cbHistory) {
     
    159170        Main.pref.putCollection(getClass().getName() + ".changesetsHistory", cbHistory.getHistory());
    160171    }
    161    
     172
    162173    private class InternalWindowListener implements WindowListener {
    163174        @Override public void windowClosed(WindowEvent e) {
     
    169180            }
    170181        }
    171    
     182
    172183        @Override public void windowOpened(WindowEvent e) {}
     184
    173185        @Override public void windowClosing(WindowEvent e) {}
     186
    174187        @Override public void windowIconified(WindowEvent e) {}
     188
    175189        @Override public void windowDeiconified(WindowEvent e) {}
     190
    176191        @Override public void windowActivated(WindowEvent e) {}
     192
    177193        @Override public void windowDeactivated(WindowEvent e) {}
    178194    }
  • applications/editors/josm/plugins/reverter/src/reverter/ChangesetIdsTextField.java

    r31596 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
     
    4041            try {
    4142                final StringTokenizer tokenizer = new StringTokenizer(value, ",.+/ \t\n");
    42                 while(tokenizer.hasMoreTokens()) {
     43                while (tokenizer.hasMoreTokens()) {
    4344                    ids.add(Integer.parseInt(tokenizer.nextToken().trim()));
    4445                }
  • applications/editors/josm/plugins/reverter/src/reverter/ChangesetReverter.java

    r32516 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
     
    5051public class ChangesetReverter {
    5152
    52     public static enum RevertType {
     53    public enum RevertType {
    5354        FULL,
    5455        SELECTION,
    5556        SELECTION_WITH_UNDELETE
    5657    }
    57    
     58
    5859    public static final Collection<Long> MODERATOR_REDACTION_ACCOUNTS = Collections.unmodifiableCollection(Arrays.asList(
    5960            722137L, // OSMF Redaction Account
     
    6465    public final Changeset changeset;
    6566    public final RevertType revertType;
    66    
     67
    6768    private final OsmDataLayer layer; // data layer associated with reverter
    6869    private final DataSet ds; // DataSet associated with reverter
     
    8485        }
    8586    }
     87
    8688    private void addMissingHistoryIds(Iterable<HistoryOsmPrimitive> primitives) {
    8789        for (HistoryOsmPrimitive p : primitives) {
    8890            addIfMissing(p.getPrimitiveId());
    8991            if (p.getType() == OsmPrimitiveType.WAY) {
    90                 for (long nd : ((HistoryWay)p).getNodes()) {
    91                     addIfMissing(new SimplePrimitiveId(nd,OsmPrimitiveType.NODE));
     92                for (long nd : ((HistoryWay) p).getNodes()) {
     93                    addIfMissing(new SimplePrimitiveId(nd, OsmPrimitiveType.NODE));
    9294                }
    9395            }
     
    99101            addIfMissing(p);
    100102            if (p.getType() == OsmPrimitiveType.WAY) {
    101                 for (Node nd : ((Way)p).getNodes()) {
     103                for (Node nd : ((Way) p).getNodes()) {
    102104                    addIfMissing(nd);
    103105                }
     
    124126    /**
    125127     * creates a reverter for specific changeset and fetches initial data
    126      * @param changesetId
    127      * @param monitor
    128      * @throws OsmTransferException
    129      * @throws RevertRedactedChangesetException
     128     * @param changesetId changeset id
     129     * @param monitor progress monitor
     130     * @throws OsmTransferException if data transfer errors occur
     131     * @throws RevertRedactedChangesetException if a redacted changeset is requested
    130132     */
    131133    public ChangesetReverter(int changesetId, RevertType revertType, boolean newLayer, ProgressMonitor monitor)
     
    162164
    163165        // Build our own lists of created/updated/modified objects for better performance
    164         for (Iterator<ChangesetDataSetEntry> it = cds.iterator();it.hasNext();) {
     166        for (Iterator<ChangesetDataSetEntry> it = cds.iterator(); it.hasNext();) {
    165167            ChangesetDataSetEntry entry = it.next();
    166168            if (!checkOsmChangeEntry(entry)) continue;
     
    174176        }
    175177    }
     178
    176179    public void checkMissingCreated() {
    177180        addMissingHistoryIds(created);
    178181    }
     182
    179183    public void checkMissingUpdated() {
    180184        addMissingHistoryIds(updated);
    181185    }
     186
    182187    public void checkMissingDeleted() {
    183188        addMissingHistoryIds(deleted);
    184189    }
    185    
    186     private void readObjectVersion(OsmServerMultiObjectReader rdr, PrimitiveId id, int version, ProgressMonitor progressMonitor) throws OsmTransferException {
     190
     191    private void readObjectVersion(OsmServerMultiObjectReader rdr, PrimitiveId id, int version, ProgressMonitor progressMonitor)
     192            throws OsmTransferException {
    187193        boolean readOK = false;
    188194        while (!readOK && version >= 1) {
     
    209215    /**
    210216     * fetch objects that were updated or deleted by changeset
    211      * @param progressMonitor
    212      * @throws OsmTransferException
     217     * @param progressMonitor progress monitor
     218     * @throws OsmTransferException if data transfer errors occur
    213219     */
    214220    @SuppressWarnings("unchecked")
     
    216222        final OsmServerMultiObjectReader rdr = new OsmServerMultiObjectReader();
    217223
    218         progressMonitor.beginTask(tr("Downloading objects history"),updated.size()+deleted.size()+1);
     224        progressMonitor.beginTask(tr("Downloading objects history"), updated.size()+deleted.size()+1);
    219225        try {
    220226            for (HashSet<HistoryOsmPrimitive> collection : Arrays.asList(new HashSet[]{updated, deleted})) {
     
    280286        switch (p.getType()) {
    281287        case NODE:
    282             return new Conflict<>((Node)p,new Node((Node)p), isMyDeleted);
     288            return new Conflict<>((Node) p, new Node((Node) p), isMyDeleted);
    283289        case CLOSEDWAY:
    284290        case WAY:
    285             return new Conflict<>((Way)p,new Way((Way)p), isMyDeleted);
     291            return new Conflict<>((Way) p, new Way((Way) p), isMyDeleted);
    286292        case MULTIPOLYGON:
    287293        case RELATION:
    288             return new Conflict<>((Relation)p,new Relation((Relation)p), isMyDeleted);
     294            return new Conflict<>((Relation) p, new Relation((Relation) p), isMyDeleted);
    289295        default: throw new AssertionError();
    290296        }
    291297    }
    292298
    293     private boolean hasEqualSemanticAttributes(OsmPrimitive current,HistoryOsmPrimitive history) {
     299    private boolean hasEqualSemanticAttributes(OsmPrimitive current, HistoryOsmPrimitive history) {
    294300        if (!current.getKeys().equals(history.getTags())) return false;
    295301        switch (current.getType()) {
    296302        case NODE:
    297             LatLon currentCoor = ((Node)current).getCoor();
    298             LatLon historyCoor = ((HistoryNode)history).getCoords();
     303            LatLon currentCoor = ((Node) current).getCoor();
     304            LatLon historyCoor = ((HistoryNode) history).getCoords();
    299305            if (currentCoor == historyCoor || (currentCoor != null && historyCoor != null && currentCoor.equals(historyCoor)))
    300306                return true;
    301307            // Handle case where a deleted note has been restored to avoid false conflicts (fix #josm8660)
    302308            if (currentCoor != null && historyCoor == null) {
    303                 LatLon previousCoor = ((Node)nds.getPrimitiveById(history.getPrimitiveId())).getCoor();
     309                LatLon previousCoor = ((Node) nds.getPrimitiveById(history.getPrimitiveId())).getCoor();
    304310                return previousCoor != null && previousCoor.equals(currentCoor);
    305311            }
    306             return false; 
     312            return false;
    307313        case CLOSEDWAY:
    308314        case WAY:
    309             List<Node> currentNodes = ((Way)current).getNodes();
    310             List<Long> historyNodes = ((HistoryWay)history).getNodes();
     315            List<Node> currentNodes = ((Way) current).getNodes();
     316            List<Long> historyNodes = ((HistoryWay) history).getNodes();
    311317            if (currentNodes.size() != historyNodes.size()) return false;
    312318            for (int i = 0; i < currentNodes.size(); i++) {
     
    317323        case RELATION:
    318324            List<org.openstreetmap.josm.data.osm.RelationMember> currentMembers =
    319                 ((Relation)current).getMembers();
    320             List<RelationMemberData> historyMembers = ((HistoryRelation)history).getMembers();
     325                ((Relation) current).getMembers();
     326            List<RelationMemberData> historyMembers = ((HistoryRelation) history).getMembers();
    321327            if (currentMembers.size() != historyMembers.size()) return false;
    322328            for (int i = 0; i < currentMembers.size(); i++) {
     
    326332                if (!currentMember.getRole().equals(historyMember.getRole())) return false;
    327333                if (!currentMember.getMember().getPrimitiveId().equals(new SimplePrimitiveId(
    328                         historyMember.getMemberId(),historyMember.getMemberType()))) return false;
     334                        historyMember.getMemberId(), historyMember.getMemberType()))) return false;
    329335            }
    330336            return true;
     
    342348        //////////////////////////////////////////////////////////////////////////
    343349        // Create commands to restore/update all affected objects
    344         DataSetCommandMerger merger = new DataSetCommandMerger(nds,ds);
     350        DataSetCommandMerger merger = new DataSetCommandMerger(nds, ds);
    345351        List<Command> cmds = merger.getCommandList();
    346352
     
    368374
    369375        for (Conflict<? extends OsmPrimitive> conflict : merger.getConflicts()) {
    370             cmds.add(new ConflictAddCommand(layer,conflict));
     376            cmds.add(new ConflictAddCommand(layer, conflict));
    371377        }
    372378
    373379        // Check objects versions
    374         for (Iterator<ChangesetDataSetEntry> it = cds.iterator();it.hasNext();) {
     380        for (Iterator<ChangesetDataSetEntry> it = cds.iterator(); it.hasNext();) {
    375381            ChangesetDataSetEntry entry = it.next();
    376382            if (!checkOsmChangeEntry(entry)) continue;
     
    385391                    /* Don't create conflict if changeset object and dataset object
    386392                     * has same semantic attributes (but different versions) */
    387                     !hasEqualSemanticAttributes(dp,hp)
     393                    !hasEqualSemanticAttributes(dp, hp)
    388394                    /* Don't create conflict if the object has to be deleted but has already been deleted */
    389395                    && !(toDelete.contains(dp) && dp.isDeleted())) {
    390                 cmds.add(new ConflictAddCommand(layer,CreateConflict(dp,
     396                cmds.add(new ConflictAddCommand(layer, CreateConflict(dp,
    391397                        entry.getModificationType() == ChangesetModificationType.CREATED)));
    392398                conflicted.add(dp);
     
    410416                               */
    411417                if (!conflicted.contains(p)) {
    412                     cmds.add(new ConflictAddCommand(layer,CreateConflict(p, true)));
     418                    cmds.add(new ConflictAddCommand(layer, CreateConflict(p, true)));
    413419                    conflicted.add(p);
    414420                }
     
    428434        return cmds;
    429435    }
    430    
     436
    431437    public boolean hasMissingObjects() {
    432438        return !missing.isEmpty();
    433439    }
    434    
     440
    435441    public void fixNodesWithoutCoordinates(ProgressMonitor progressMonitor) throws OsmTransferException {
    436442        for (Node n : nds.getNodes()) {
     
    439445                OsmPrimitive p = ds.getPrimitiveById(id);
    440446                if (p instanceof Node && p.getVersion() > 1) {
    441                     LatLon coor = ((Node)p).getCoor();
     447                    LatLon coor = ((Node) p).getCoor();
    442448                    if (coor == null) {
    443449                        final OsmServerMultiObjectReader rdr = new OsmServerMultiObjectReader();
     
    445451                        Collection<OsmPrimitive> result = rdr.parseOsm(progressMonitor.createSubTaskMonitor(1, true)).allPrimitives();
    446452                        if (!result.isEmpty()) {
    447                             coor = ((Node)result.iterator().next()).getCoor();
     453                            coor = ((Node) result.iterator().next()).getCoor();
    448454                        }
    449455                    }
  • applications/editors/josm/plugins/reverter/src/reverter/DataSetCommandMerger.java

    r31592 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
     
    4041     * constructor
    4142     */
    42     public DataSetCommandMerger(DataSet sourceDataSet, DataSet targetDataSet) {
     43    DataSetCommandMerger(DataSet sourceDataSet, DataSet targetDataSet) {
    4344        this.sourceDataSet = sourceDataSet;
    4445        this.targetDataSet = targetDataSet;
    4546        merge();
    4647    }
    47    
     48
    4849    private void addChangeCommandIfNotEquals(OsmPrimitive target, OsmPrimitive newTarget, boolean nominal) {
    4950        if (!target.hasEqualSemanticAttributes(newTarget)) {
    50             cmds.add(new ChangeCommand(target,newTarget));
     51            cmds.add(new ChangeCommand(target, newTarget));
    5152            if (nominal) {
    5253                nominalRevertedPrimitives.add(target);
     
    6667    private void mergePrimitive(OsmPrimitive source, OsmPrimitive target, OsmPrimitive newTarget) {
    6768        newTarget.mergeFrom(source);
    68         newTarget.setOsmId(target.getId(), (int)target.getVersion());
     69        newTarget.setOsmId(target.getId(), target.getVersion());
    6970        newTarget.setVisible(target.isVisible());
    7071        newTarget.setDeleted(false);
     
    7980        if (source.isIncomplete()) return;
    8081        if (!source.isVisible()) return;
    81         Node target = (Node)getMergeTarget(source);
     82        Node target = (Node) getMergeTarget(source);
    8283
    8384        Node newTarget = new Node(target);
    8485        mergePrimitive(source, target, newTarget);
    85         addChangeCommandIfNotEquals(target,newTarget,true);
     86        addChangeCommandIfNotEquals(target, newTarget, true);
    8687    }
    8788
     
    9798        if (source.isIncomplete()) return;
    9899        if (!source.isVisible()) return;
    99         Way target = (Way)getMergeTarget(source);
     100        Way target = (Way) getMergeTarget(source);
    100101
    101102        // use a set to avoid conflicts being added twice for closed ways, fixes #11811
     
    104105        List<Node> newNodes = new ArrayList<>(source.getNodesCount());
    105106        for (Node sourceNode : source.getNodes()) {
    106             Node targetNode = (Node)getMergeTarget(sourceNode);
     107            Node targetNode = (Node) getMergeTarget(sourceNode);
    107108            // Target node is not deleted or it will be undeleted when running existing commands
    108109            if (!targetNode.isDeleted() || nominalRevertedPrimitives.contains(targetNode)) {
     
    124125                Main.warn("New conflict: "+c);
    125126                conflicts.add(c);
    126                 Node targetNode = (Node)c.getTheir();
     127                Node targetNode = (Node) c.getTheir();
    127128                Node undeletedTargetNode = new Node(targetNode);
    128129                undeletedTargetNode.setDeleted(false);
    129                 addChangeCommandIfNotEquals(targetNode,undeletedTargetNode,false);
     130                addChangeCommandIfNotEquals(targetNode, undeletedTargetNode, false);
    130131            }
    131             addChangeCommandIfNotEquals(target,newTarget,true);
     132            addChangeCommandIfNotEquals(target, newTarget, true);
    132133        }
    133134    }
     
    152153                OsmPrimitive undeletedTargetMember;
    153154                switch(targetMember.getType()) {
    154                 case NODE: undeletedTargetMember = new Node((Node)targetMember); break;
    155                 case WAY: undeletedTargetMember = new Way((Way)targetMember); break;
    156                 case RELATION: undeletedTargetMember = new Relation((Relation)targetMember); break;
     155                case NODE: undeletedTargetMember = new Node((Node) targetMember); break;
     156                case WAY: undeletedTargetMember = new Way((Way) targetMember); break;
     157                case RELATION: undeletedTargetMember = new Relation((Relation) targetMember); break;
    157158                default: throw new AssertionError();
    158159                }
    159160                undeletedTargetMember.setDeleted(false);
    160                 addChangeCommandIfNotEquals(targetMember,undeletedTargetMember,false);
     161                addChangeCommandIfNotEquals(targetMember, undeletedTargetMember, false);
    161162            }
    162163            newMembers.add(new RelationMember(sourceMember.getRole(), targetMember));
     
    165166        mergePrimitive(source, target, newRelation);
    166167        newRelation.setMembers(newMembers);
    167         addChangeCommandIfNotEquals(target,newRelation,true);
     168        addChangeCommandIfNotEquals(target, newRelation, true);
    168169    }
    169    
     170
    170171    private void merge() {
    171172        for (Node node: sourceDataSet.getNodes()) {
  • applications/editors/josm/plugins/reverter/src/reverter/MultiOsmReader.java

    r29548 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
     
    2425            setParser(parser);
    2526            parse();
    26         } catch(XMLStreamException e) {
     27        } catch (XMLStreamException e) {
    2728           throw new IllegalDataException(e);
    28         } catch(Exception e) {
     29        } catch (Exception e) {
    2930            throw new IllegalDataException(e);
    3031        }
    3132    }
    32    
     33
    3334    public void processData() throws IllegalDataException {
    3435        prepareDataSet();
  • applications/editors/josm/plugins/reverter/src/reverter/ObjectsHistoryAction.java

    r31363 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
     
    1314
    1415    public ObjectsHistoryAction() {
    15         super(tr("Objects history"),null,tr("History reverter"),
     16        super(tr("Objects history"), null, tr("History reverter"),
    1617            Shortcut.registerShortcut("tool:history",
    1718                tr("Tool: Display objects history dialog"),
     
    2021        setEnabled(false);
    2122    }
     23
    2224    @Override
    2325    public void actionPerformed(ActionEvent arg0) {
  • applications/editors/josm/plugins/reverter/src/reverter/ObjectsHistoryDialog.java

    r23192 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
     
    1415public class ObjectsHistoryDialog extends ExtendedDialog {
    1516    public ObjectsHistoryDialog() {
    16         super(Main.parent, tr("Objects history"), new String[] {"Revert","Cancel"}, false);
    17         contentInsets = new Insets(10,10,10,5);
     17        super(Main.parent, tr("Objects history"), new String[] {"Revert", "Cancel"}, false);
     18        contentInsets = new Insets(10, 10, 10, 5);
    1819        setButtonIcons(new String[] {"ok.png", "cancel.png" });
    1920        setContent(new JPanel(new GridBagLayout()));
  • applications/editors/josm/plugins/reverter/src/reverter/OsmServerMultiObjectReader.java

    r30990 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
     
    2223    }
    2324
    24     public void readObject(long id,int version,OsmPrimitiveType type,ProgressMonitor progressMonitor) throws OsmTransferException {
     25    public void readObject(long id, int version, OsmPrimitiveType type, ProgressMonitor progressMonitor) throws OsmTransferException {
    2526        StringBuffer sb = new StringBuffer();
    2627        sb.append(type.getAPIName());
     
    3839        }
    3940    }
     41
    4042    /**
    4143     * Method to parse downloaded objects
    4244     * @return the data requested
    43      * @throws SAXException
    44      * @throws IOException
     45     * @throws SAXException in case of SAX error
     46     * @throws IOException in case of I/O error
    4547     */
    4648    @Override
  • applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetAction.java

    r31625 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
     
    1718
    1819    public RevertChangesetAction() {
    19         super(tr("Revert changeset"),"revert-changeset",tr("Revert changeset"),
     20        super(tr("Revert changeset"), "revert-changeset", tr("Revert changeset"),
    2021            Shortcut.registerShortcut("tool:revert",
    2122                tr("Tool: {0}", tr("Revert changeset")),
     
    2526
    2627    @Override
    27     public void actionPerformed(ActionEvent arg0)  {
     28    public void actionPerformed(ActionEvent arg0) {
    2829        final ChangesetIdQuery dlg = new ChangesetIdQuery();
    2930        if (dlg.showDialog().getValue() != 1) return;
  • applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetCommand.java

    r27795 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
    34import java.util.Collection;
     5
    46import javax.swing.Icon;
    57
  • applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetHandler.java

    r30258 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
     
    1112    public static final String permissionKey = "remotecontrol.permission.revert_changeset";
    1213    public static final boolean permissionDefault = true;
    13    
     14
    1415    private int changesetId;
    1516
     
    1718    protected void handleRequest() throws RequestHandlerErrorException,
    1819            RequestHandlerBadRequestException {
    19         try
    20         {
     20        try {
    2121            Main.worker.submit(new RevertChangesetTask(changesetId, ChangesetReverter.RevertType.FULL, true));
    2222        } catch (Exception ex) {
     
    2525            throw new RequestHandlerErrorException(ex);
    2626        }
    27 
    2827    }
    2928
  • applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetTask.java

    r31594 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
     
    1718import org.openstreetmap.josm.gui.util.GuiHelper;
    1819import org.openstreetmap.josm.io.OsmTransferException;
     20
    1921import reverter.ChangesetReverter.RevertType;
    2022
     
    3032        this(changesetId, revertType, false);
    3133    }
    32    
     34
    3335    public RevertChangesetTask(int changesetId, RevertType revertType, boolean autoConfirmDownload) {
    3436        this(changesetId, revertType, autoConfirmDownload, false);
    3537    }
    36    
     38
    3739    public RevertChangesetTask(int changesetId, RevertType revertType, boolean autoConfirmDownload, boolean newLayer) {
    3840        super(tr("Reverting..."));
     
    110112        List<Command> cmds = rev.getCommands();
    111113        final Command cmd = new RevertChangesetCommand(tr(revertType == RevertType.FULL ? "Revert changeset #{0}" :
    112                 "Partially revert changeset #{0}",changesetId),cmds);
     114                "Partially revert changeset #{0}", changesetId), cmds);
    113115        int n = 0;
    114116        for (Command c : cmds) {
  • applications/editors/josm/plugins/reverter/src/reverter/RevertRedactedChangesetException.java

    r30031 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
    34/**
    4  * Exception thrown if a changeset created by a modeartor redaction account is being reverted. 
     5 * Exception thrown if a changeset created by a modeartor redaction account is being reverted.
    56 */
    67@SuppressWarnings("serial")
  • applications/editors/josm/plugins/reverter/src/reverter/ReverterPlugin.java

    r29854 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
  • applications/editors/josm/plugins/reverter/src/reverter/ReverterUploadHook.java

    r32516 r32905  
     1// License: GPL. For details, see LICENSE file.
    12package reverter;
    23
     
    1112        pluginString = "reverter_plugin/" + plugin.getPluginInformation().version;
    1213    }
     14
    1315    @Override
    1416    public boolean checkUpload(APIDataSet apiDataSet) {
  • applications/editors/josm/plugins/reverter/src/reverter/corehacks/ChangesetDataSet.java

    r30737 r32905  
    66import java.util.Iterator;
    77import java.util.Map;
     8import java.util.Map.Entry;
    89import java.util.Set;
    9 import java.util.Map.Entry;
    1010
    1111import org.openstreetmap.josm.data.osm.PrimitiveId;
     
    1818public class ChangesetDataSet {
    1919
    20     public static enum ChangesetModificationType {
     20    public enum ChangesetModificationType {
    2121        CREATED,
    2222        UPDATED,
     
    2424    }
    2525
    26     public static interface ChangesetDataSetEntry {
    27         public ChangesetModificationType getModificationType();
    28         public HistoryOsmPrimitive getPrimitive();
    29         public int getEarliestVersion();
    30     }
    31 
    32     final private Map<PrimitiveId, Integer> earliestVersions = new HashMap<>();
    33     final private Map<PrimitiveId, HistoryOsmPrimitive> primitives = new HashMap<>();
    34     final private Map<PrimitiveId, ChangesetModificationType> modificationTypes = new HashMap<>();
     26    public interface ChangesetDataSetEntry {
     27        ChangesetModificationType getModificationType();
     28
     29        HistoryOsmPrimitive getPrimitive();
     30
     31        int getEarliestVersion();
     32    }
     33
     34    private final Map<PrimitiveId, Integer> earliestVersions = new HashMap<>();
     35    private final Map<PrimitiveId, HistoryOsmPrimitive> primitives = new HashMap<>();
     36    private final Map<PrimitiveId, ChangesetModificationType> modificationTypes = new HashMap<>();
    3537
    3638    /**
     
    4244     * @throws IllegalArgumentException thrown if cmt is null
    4345     */
    44     public void put(HistoryOsmPrimitive primitive, ChangesetModificationType cmt) throws IllegalArgumentException{
    45         CheckParameterUtil.ensureParameterNotNull(primitive,"primitive");
    46         CheckParameterUtil.ensureParameterNotNull(cmt,"cmt");
     46    public void put(HistoryOsmPrimitive primitive, ChangesetModificationType cmt) throws IllegalArgumentException {
     47        CheckParameterUtil.ensureParameterNotNull(primitive, "primitive");
     48        CheckParameterUtil.ensureParameterNotNull(cmt, "cmt");
    4749        PrimitiveId pid = primitive.getPrimitiveId();
    4850        if (primitives.containsKey(pid)) {
     
    5153                Integer earliest = earliestVersions.get(pid);
    5254                if (earliest == null || primitive.getVersion() < earliest) {
    53                     earliestVersions.put(pid, (int)primitive.getVersion());
     55                    earliestVersions.put(pid, (int) primitive.getVersion());
    5456                    if (cmt == ChangesetModificationType.CREATED)
    5557                        modificationTypes.put(pid, cmt);
     
    6163                }
    6264                if (earliestVersions.get(pid) == null) {
    63                     earliestVersions.put(pid, (int)primitives.get(pid).getVersion());
     65                    earliestVersions.put(pid, (int) primitives.get(pid).getVersion());
    6466                }
    6567            }
     
    9395    public int getEarliestVersion(PrimitiveId id) {
    9496        Integer earliestVersion = earliestVersions.get(id);
    95         if (earliestVersion == null) earliestVersion = (int)primitives.get(id).getVersion();
     97        if (earliestVersion == null) earliestVersion = (int) primitives.get(id).getVersion();
    9698        return earliestVersion;
    9799    }
     
    144146     */
    145147    public Set<HistoryOsmPrimitive> getPrimitivesByModificationType(ChangesetModificationType cmt) throws IllegalArgumentException {
    146         CheckParameterUtil.ensureParameterNotNull(cmt,"cmt");
     148        CheckParameterUtil.ensureParameterNotNull(cmt, "cmt");
    147149        HashSet<HistoryOsmPrimitive> ret = new HashSet<>();
    148150        for (Entry<PrimitiveId, ChangesetModificationType> entry: modificationTypes.entrySet()) {
     
    172174     */
    173175    public HistoryOsmPrimitive getPrimitive(PrimitiveId id) {
    174         if (id == null)  return null;
     176        if (id == null) return null;
    175177        return primitives.get(id);
    176178    }
     
    185187        private final int earliestVersion;
    186188
    187         public DefaultChangesetDataSetEntry(ChangesetModificationType modificationType, HistoryOsmPrimitive primitive, int earliestVersion) {
     189        DefaultChangesetDataSetEntry(ChangesetModificationType modificationType, HistoryOsmPrimitive primitive, int earliestVersion) {
    188190            this.modificationType = modificationType;
    189191            this.primitive = primitive;
     
    191193        }
    192194
     195        @Override
    193196        public ChangesetModificationType getModificationType() {
    194197            return modificationType;
    195198        }
    196199
     200        @Override
    197201        public HistoryOsmPrimitive getPrimitive() {
    198202            return primitive;
    199203        }
    200204
     205        @Override
    201206        public int getEarliestVersion() {
    202207            return earliestVersion;
     
    207212        private final Iterator<Entry<PrimitiveId, ChangesetModificationType>> typeIterator;
    208213
    209         public DefaultIterator() {
     214        DefaultIterator() {
    210215            typeIterator = modificationTypes.entrySet().iterator();
    211216        }
    212217
     218        @Override
    213219        public boolean hasNext() {
    214220            return typeIterator.hasNext();
    215221        }
    216222
     223        @Override
    217224        public ChangesetDataSetEntry next() {
    218225            Entry<PrimitiveId, ChangesetModificationType> next = typeIterator.next();
     
    220227            HistoryOsmPrimitive primitive = primitives.get(next.getKey());
    221228            Integer earliestVersion = earliestVersions.get(next.getKey());
    222             if (earliestVersion == null) earliestVersion = (int)primitive.getVersion();
     229            if (earliestVersion == null) earliestVersion = (int) primitive.getVersion();
    223230            return new DefaultChangesetDataSetEntry(type, primitive, earliestVersion);
    224231        }
    225232
     233        @Override
    226234        public void remove() {
    227235            throw new UnsupportedOperationException();
  • applications/editors/josm/plugins/reverter/src/reverter/corehacks/OsmChangesetContentParser.java

    r32685 r32905  
    1 // License: GPL. Copyright 2007 by Immanuel Scholz and others
     1// License: GPL. For details, see LICENSE file.
    22package reverter.corehacks;
    33
     
    2525import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    2626import org.openstreetmap.josm.tools.CheckParameterUtil;
     27import org.openstreetmap.josm.tools.XmlParsingException;
    2728import org.openstreetmap.josm.tools.date.DateUtils;
    28 import org.openstreetmap.josm.tools.XmlParsingException;
    2929import org.xml.sax.Attributes;
    3030import org.xml.sax.InputSource;
     
    7979            try {
    8080                l = Long.parseLong(v);
    81             } catch(NumberFormatException e) {
     81            } catch (NumberFormatException e) {
    8282                throwException(tr("Illegal value for mandatory attribute ''{0}'' of type long. Got ''{1}''.", name, v));
    8383            }
     
    104104        }
    105105*/
    106         protected Double getAttributeDouble(Attributes attr, String name) throws SAXException{
     106
     107        protected Double getAttributeDouble(Attributes attr, String name) throws SAXException {
    107108            String v = attr.getValue(name);
    108109            if (v == null) {
     
    112113            try {
    113114                d = Double.parseDouble(v);
    114             } catch(NumberFormatException e) {
     115            } catch (NumberFormatException e) {
    115116                throwException(tr("Illegal value for attribute ''{0}'' of type double. Got ''{1}''.", name, v));
    116117            }
     
    118119        }
    119120
    120         protected String getMandatoryAttributeString(Attributes attr, String name) throws SAXException{
     121        protected String getMandatoryAttributeString(Attributes attr, String name) throws SAXException {
    121122            String v = attr.getValue(name);
    122123            if (v == null) {
     
    133134        }
    134135*/
    135         protected boolean getMandatoryAttributeBoolean(Attributes attr, String name) throws SAXException{
     136
     137        protected boolean getMandatoryAttributeBoolean(Attributes attr, String name) throws SAXException {
    136138            String v = attr.getValue(name);
    137139            if (v == null) {
     
    145147        }
    146148
    147         protected  HistoryOsmPrimitive createPrimitive(Attributes atts, OsmPrimitiveType type) throws SAXException {
    148             long id = getMandatoryAttributeLong(atts,"id");
    149             long version = getMandatoryAttributeLong(atts,"version");
    150             long changesetId = getMandatoryAttributeLong(atts,"changeset");
    151             boolean visible= getMandatoryAttributeBoolean(atts, "visible");
     149        protected HistoryOsmPrimitive createPrimitive(Attributes atts, OsmPrimitiveType type) throws SAXException {
     150            long id = getMandatoryAttributeLong(atts, "id");
     151            long version = getMandatoryAttributeLong(atts, "version");
     152            long changesetId = getMandatoryAttributeLong(atts, "changeset");
     153            boolean visible = getMandatoryAttributeBoolean(atts, "visible");
    152154            String v = getMandatoryAttributeString(atts, "timestamp");
    153155            Date timestamp = DateUtils.fromString(v);
     
    158160                Double lat = getAttributeDouble(atts, "lat");
    159161                Double lon = getAttributeDouble(atts, "lon");
    160                 LatLon coor = (lat != null && lon != null) ? new LatLon(lat,lon) : null;
     162                LatLon coor = (lat != null && lon != null) ? new LatLon(lat, lon) : null;
    161163                primitive = new HistoryNode(
    162                         id,version,visible,User.getAnonymous(),changesetId,timestamp, coor
     164                        id, version, visible, User.getAnonymous(), changesetId, timestamp, coor
    163165                );
    164166
    165167            } else if (type.equals(OsmPrimitiveType.WAY)) {
    166168                primitive = new HistoryWay(
    167                         id,version,visible,User.getAnonymous(),changesetId,timestamp
     169                        id, version, visible, User.getAnonymous(), changesetId, timestamp
    168170                );
    169             }if (type.equals(OsmPrimitiveType.RELATION)) {
     171            } else if (type.equals(OsmPrimitiveType.RELATION)) {
    170172                primitive = new HistoryRelation(
    171                         id,version,visible,User.getAnonymous(),changesetId,timestamp
     173                        id, version, visible, User.getAnonymous(), changesetId, timestamp
    172174                );
    173175            }
     
    176178
    177179        protected void startNode(Attributes atts) throws SAXException {
    178             currentPrimitive= createPrimitive(atts, OsmPrimitiveType.NODE);
     180            currentPrimitive = createPrimitive(atts, OsmPrimitiveType.NODE);
    179181        }
    180182
    181183        protected void startWay(Attributes atts) throws SAXException {
    182             currentPrimitive= createPrimitive(atts, OsmPrimitiveType.WAY);
    183         }
     184            currentPrimitive = createPrimitive(atts, OsmPrimitiveType.WAY);
     185        }
     186
    184187        protected void startRelation(Attributes atts) throws SAXException {
    185             currentPrimitive= createPrimitive(atts, OsmPrimitiveType.RELATION);
     188            currentPrimitive = createPrimitive(atts, OsmPrimitiveType.RELATION);
    186189        }
    187190
    188191        protected void handleTag(Attributes atts) throws SAXException {
    189             String key= getMandatoryAttributeString(atts, "k");
    190             String value= getMandatoryAttributeString(atts, "v");
    191             currentPrimitive.put(key,value);
     192            String key = getMandatoryAttributeString(atts, "k");
     193            String value = getMandatoryAttributeString(atts, "v");
     194            currentPrimitive.put(key, value);
    192195        }
    193196
    194197        protected void handleNodeReference(Attributes atts) throws SAXException {
    195198            long ref = getMandatoryAttributeLong(atts, "ref");
    196             ((HistoryWay)currentPrimitive).addNode(ref);
     199            ((HistoryWay) currentPrimitive).addNode(ref);
    197200        }
    198201
     
    203206            try {
    204207                type = OsmPrimitiveType.fromApiTypeName(v);
    205             } catch(IllegalArgumentException e) {
     208            } catch (IllegalArgumentException e) {
    206209                throwException(tr("Illegal value for mandatory attribute ''{0}'' of type OsmPrimitiveType. Got ''{1}''.", "type", v));
    207210            }
    208211            String role = getMandatoryAttributeString(atts, "role");
    209             RelationMemberData member = new RelationMemberData(role, type,ref);
    210             ((HistoryRelation)currentPrimitive).addMember(member);
     212            RelationMemberData member = new RelationMemberData(role, type, ref);
     213            ((HistoryRelation) currentPrimitive).addMember(member);
    211214        }
    212215
     
    233236                currentModificationType = ChangesetModificationType.DELETED;
    234237            } else {
    235                 System.err.println(tr("Warning: unsupported start element ''{0}'' in changeset content at position ({1},{2}). Skipping.", qName, locator.getLineNumber(), locator.getColumnNumber()));
     238                System.err.println(tr("Warning: unsupported start element ''{0}'' in changeset content at position ({1},{2}). Skipping.",
     239                        qName, locator.getLineNumber(), locator.getColumnNumber()));
    236240            }
    237241        }
     
    243247                    || qName.equals("relation")) {
    244248                if (currentModificationType == null) {
    245                     throwException(tr("Illegal document structure. Found node, way, or relation outside of ''create'', ''modify'', or ''delete''."));
     249                    throwException(
     250                            tr("Illegal document structure. Found node, way, or relation outside of ''create'', ''modify'', or ''delete''."));
    246251                }
    247252                data.put(currentPrimitive, currentModificationType);
     
    261266                // do nothing
    262267            } else {
    263                 System.err.println(tr("Warning: unsupported end element ''{0}'' in changeset content at position ({1},{2}). Skipping.", qName, locator.getLineNumber(), locator.getColumnNumber()));
     268                System.err.println(tr("Warning: unsupported end element ''{0}'' in changeset content at position ({1},{2}). Skipping.",
     269                        qName, locator.getLineNumber(), locator.getColumnNumber()));
    264270            }
    265271        }
     
    310316            progressMonitor.indeterminateSubTask(tr("Parsing changeset content ..."));
    311317            SAXParserFactory.newInstance().newSAXParser().parse(source, new Parser());
    312         } catch(XmlParsingException e){
     318        } catch (XmlParsingException e) {
    313319            throw e;
    314320        } catch (ParserConfigurationException e) {
    315321            throw new XmlParsingException(e);
    316         } catch(SAXException e) {
     322        } catch (SAXException e) {
    317323            throw new XmlParsingException(e);
    318         } catch(IOException e) {
     324        } catch (IOException e) {
    319325            throw new XmlParsingException(e);
    320326        } finally {
  • applications/editors/josm/plugins/reverter/src/reverter/corehacks/OsmServerChangesetReader.java

    r30737 r32905  
    3636     *
    3737     */
    38     public OsmServerChangesetReader(){
     38    public OsmServerChangesetReader() {
    3939        setDoAuthenticate(false);
    4040    }
     
    7171            monitor.indeterminateSubTask(tr("Downloading changesets ..."));
    7272            return OsmChangesetParser.parse(in, monitor.createSubTaskMonitor(1, true));
    73         } catch(OsmTransferException e) {
     73        } catch (OsmTransferException e) {
    7474            throw e;
    75         } catch(IllegalDataException e) {
     75        } catch (IllegalDataException e) {
    7676            throw new OsmTransferException(e);
    7777        } finally {
     
    9696        }
    9797        try {
    98             monitor.beginTask(tr("Reading changeset {0} ...",id));
     98            monitor.beginTask(tr("Reading changeset {0} ...", id));
    9999            StringBuffer sb = new StringBuffer();
    100100            sb.append("changeset/").append(id);
     
    107107                return null;
    108108            return changesets.get(0);
    109         } catch(OsmTransferException e) {
     109        } catch (OsmTransferException e) {
    110110            throw e;
    111         } catch(IllegalDataException e) {
     111        } catch (IllegalDataException e) {
    112112            throw new OsmTransferException(e);
    113113        } finally {
     
    132132        }
    133133        try {
    134             monitor.beginTask(trn("Downloading {0} changeset ...", "Downloading {0} changesets ...",ids.size(),ids.size()));
     134            monitor.beginTask(trn("Downloading {0} changeset ...", "Downloading {0} changesets ...", ids.size(), ids.size()));
    135135            monitor.setTicksCount(ids.size());
    136136            List<Changeset> ret = new ArrayList<>();
    137             int i=0;
    138             for (Iterator<Integer> it = ids.iterator(); it.hasNext(); ) {
     137            int i = 0;
     138            for (Iterator<Integer> it = ids.iterator(); it.hasNext();) {
    139139                int id = it.next();
    140140                if (id <= 0) {
     
    147147                if (in == null)
    148148                    return null;
    149                 monitor.indeterminateSubTask(tr("({0}/{1}) Downloading changeset {2} ...", i,ids.size(), id));
     149                monitor.indeterminateSubTask(tr("({0}/{1}) Downloading changeset {2} ...", i, ids.size(), id));
    150150                List<Changeset> changesets = OsmChangesetParser.parse(in, monitor.createSubTaskMonitor(1, true));
    151151                if (changesets == null || changesets.isEmpty()) {
     
    156156            }
    157157            return ret;
    158         } catch(OsmTransferException e) {
     158        } catch (OsmTransferException e) {
    159159            throw e;
    160         } catch(IllegalDataException e) {
     160        } catch (IllegalDataException e) {
    161161            throw new OsmTransferException(e);
    162162        } finally {
     
    176176    public ChangesetDataSet downloadChangeset(int id, ProgressMonitor monitor) throws IllegalArgumentException, OsmTransferException {
    177177        if (id <= 0)
    178             throw new IllegalArgumentException(MessageFormat.format("Expected value of type integer > 0 for parameter ''{0}'', got {1}", "id", id));
     178            throw new IllegalArgumentException(
     179                    MessageFormat.format("Expected value of type integer > 0 for parameter ''{0}'', got {1}", "id", id));
    179180        if (monitor == null) {
    180181            monitor = NullProgressMonitor.INSTANCE;
     
    191192            ChangesetDataSet ds = parser.parse(monitor.createSubTaskMonitor(1, true));
    192193            return ds;
    193         } catch(UnsupportedEncodingException e) {
    194             throw new OsmTransferException(e);
    195         } catch(XmlParsingException e) {
     194        } catch (UnsupportedEncodingException e) {
     195            throw new OsmTransferException(e);
     196        } catch (XmlParsingException e) {
    196197            throw new OsmTransferException(e);
    197198        } finally {
Note: See TracChangeset for help on using the changeset viewer.