Changeset 36136 in osm for applications/editors


Ignore:
Timestamp:
2023-09-11T20:01:42+02:00 (13 months ago)
Author:
taylor.smock
Message:

Fix #23170: DataIntegrityProblemException: Deleted node referenced when reconstructing a polygon

Location:
applications/editors/josm/plugins/reltoolbox
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java

    r36102 r36136  
    178178        rcPanel.add(chosenRelationPanel, BorderLayout.NORTH);
    179179
    180         roleBox.addPropertyChangeListener("enabled", new PropertyChangeListener() {
    181             @Override
    182             public void propertyChange(PropertyChangeEvent evt) {
    183                 boolean showRoleBox = roleBox.isEnabled();
    184                 roleBox.setVisible(showRoleBox);
    185                 chosenRelationComponent.setVisible(!showRoleBox);
    186             }
     180        roleBox.addPropertyChangeListener("enabled", evt -> {
     181            boolean showRoleBox = roleBox.isEnabled();
     182            roleBox.setVisible(showRoleBox);
     183            chosenRelationComponent.setVisible(!showRoleBox);
    187184        });
    188185
    189         sortAndFixAction.addPropertyChangeListener(new PropertyChangeListener() {
    190             @Override
    191             public void propertyChange(PropertyChangeEvent evt) {
    192                 sortAndFixButton.setVisible(sortAndFixAction.isEnabled());
    193             }
    194         });
     186        sortAndFixAction.addPropertyChangeListener(evt -> sortAndFixButton.setVisible(sortAndFixAction.isEnabled()));
    195187        sortAndFixButton.setVisible(false);
    196188
    197         downloadChosenRelationAction.addPropertyChangeListener(new PropertyChangeListener() {
    198             @Override
    199             public void propertyChange(PropertyChangeEvent evt) {
    200                 downloadButton.setVisible(downloadChosenRelationAction.isEnabled());
    201             }
    202         });
     189        downloadChosenRelationAction.addPropertyChangeListener(evt -> downloadButton.setVisible(downloadChosenRelationAction.isEnabled()));
    203190        downloadButton.setVisible(false);
    204191        if (Config.getPref().getBoolean(PREF_PREFIX + ".hidetopline", false)) {
     
    317304        columns.getColumn(1).setPreferredWidth(40);
    318305        columns.getColumn(0).setPreferredWidth(220);
    319         relationsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    320             @Override
    321             public void valueChanged(ListSelectionEvent e) {
    322                 int selectedRow = relationsTable.getSelectedRow();
    323                 if (selectedRow >= 0) {
    324                     chosenRelation.set((Relation) relationsData.getValueAt(selectedRow, 0));
    325                     relationsTable.clearSelection();
    326                 }
     306        relationsTable.getSelectionModel().addListSelectionListener(e -> {
     307            int selectedRow = relationsTable.getSelectedRow();
     308            if (selectedRow >= 0) {
     309                chosenRelation.set((Relation) relationsData.getValueAt(selectedRow, 0));
     310                relationsTable.clearSelection();
    327311            }
    328312        });
    329313    }
    330314
    331     private JComponent sizeButton(JComponent b, int width, int height) {
     315    private static JComponent sizeButton(JComponent b, int width, int height) {
    332316        Dimension pref = b.getPreferredSize();
    333317        b.setPreferredSize(new Dimension(width <= 0 ? pref.width : width, height <= 0 ? pref.height : height));
     
    495479        dlg.setModalityType(ModalityType.DOCUMENT_MODAL);
    496480
    497         role.getEditor().addActionListener(new ActionListener() {
    498             @Override
    499             public void actionPerformed(ActionEvent e) {
    500                 dlg.setVisible(false);
    501                 optionPane.setValue(JOptionPane.OK_OPTION);
    502             }
     481        role.getEditor().addActionListener(e -> {
     482            dlg.setVisible(false);
     483            optionPane.setValue(JOptionPane.OK_OPTION);
    503484        });
    504485
     
    752733        @Override
    753734        public void setSelectedItem(Object anItem) {
    754             int newIndex = anItem instanceof String ? roles.indexOf((String) anItem) : -1;
     735            int newIndex = anItem instanceof String ? roles.indexOf(anItem) : -1;
    755736            if (newIndex != selectedIndex) {
    756737                selectedIndex = newIndex;
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java

    r36134 r36136  
    6464        boolean wont = false;
    6565        for (RelationMember m : r.getMembers()) {
    66             if (m.isWay()) {
     66            if (m.isWay() && m.getWay().getReferrers().size() == 1) {
    6767                ways.add(m.getWay());
    6868            } else {
     
    7272        if (wont) {
    7373            JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    74                     tr("Multipolygon must consist only of ways"), tr("Reconstruct polygon"), JOptionPane.ERROR_MESSAGE);
     74                    tr("Multipolygon must consist only of ways with one referring relation"),
     75                    tr("Reconstruct polygon"), JOptionPane.ERROR_MESSAGE);
    7576            return;
    7677        }
     
    174175                                candidateWay = tmp;
    175176                            }
    176                             final Command deleteCommand = DeleteCommand.delete(Collections.singleton(w));
    177                             if (deleteCommand != null) {
    178                                 commands.add(deleteCommand);
    179                             }
     177                            commands.add(new DeleteCommand(w));
    180178                        }
    181179                    }
Note: See TracChangeset for help on using the changeset viewer.