Changeset 33694 in osm for applications/editors


Ignore:
Timestamp:
2017-10-03T22:34:26+02:00 (7 years ago)
Author:
donvip
Message:

fix #josm15320

Location:
applications/editors/josm/plugins/reltoolbox
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reltoolbox/build.xml

    r33530 r33694  
    44    <property name="commit.message" value="RelToolbox: make natural sort for relation and find relation lists"/>
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    6     <property name="plugin.main.version" value="12663"/>
     6    <property name="plugin.main.version" value="12840"/>
    77
    88    <property name="plugin.author" value="Ilya Zverev"/>
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java

    r33530 r33694  
    608608            if (property != null && property.length() > 0 && e.getSource() instanceof JCheckBoxMenuItem) {
    609609                boolean value = ((JCheckBoxMenuItem) e.getSource()).isSelected();
    610                 Main.pref.put(property, value);
     610                Main.pref.putBoolean(property, value);
    611611                show(getInvoker(), getX(), getY());
    612612            }
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateMultipolygonAction.java

    r33530 r33694  
    124124        // for now, just copying standard action
    125125        MultipolygonBuilder mpc = new MultipolygonBuilder();
    126         String error = mpc.makeFromWays(getLayerManager().getEditDataSet().getSelectedWays());
     126        String error = mpc.makeFromWays(ds.getSelectedWays());
    127127        if (error != null) {
    128128            JOptionPane.showMessageDialog(Main.parent, error);
     
    159159            }
    160160        }
    161         list.add(new AddCommand(rel));
     161        list.add(new AddCommand(ds, rel));
    162162        MainApplication.undoRedo.add(new SequenceCommand(tr("Create multipolygon"), list));
    163163
     
    166166        }
    167167
    168         getLayerManager().getEditDataSet().setSelected(rel);
     168        ds.setSelected(rel);
    169169    }
    170170
     
    335335        }
    336336
    337         for (String linearTag : Main.pref.getCollection(PREF_MULTIPOLY + "lineartags", DEFAULT_LINEAR_TAGS)) {
     337        for (String linearTag : Main.pref.getList(PREF_MULTIPOLY + "lineartags", DEFAULT_LINEAR_TAGS)) {
    338338            values.remove(linearTag);
    339339        }
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateRelationAction.java

    r33530 r33694  
    2222import org.openstreetmap.josm.actions.JosmAction;
    2323import org.openstreetmap.josm.command.AddCommand;
     24import org.openstreetmap.josm.data.osm.DataSet;
    2425import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2526import org.openstreetmap.josm.data.osm.Relation;
     
    6465            rel.put("type", type);
    6566        }
    66         for (OsmPrimitive selected : getLayerManager().getEditDataSet().getSelected()) {
     67        DataSet ds = getLayerManager().getEditDataSet();
     68        for (OsmPrimitive selected : ds.getSelected()) {
    6769            rel.addMember(new RelationMember("", selected));
    6870        }
    6971
    70         MainApplication.undoRedo.add(new AddCommand(rel));
     72        MainApplication.undoRedo.add(new AddCommand(ds, rel));
    7173
    7274        if (chRel != null) {
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DeleteChosenRelationAction.java

    r33530 r33694  
    3333        Relation r = rel.get();
    3434        rel.clear();
    35         Command c = DeleteCommand.delete(MainApplication.getLayerManager().getEditLayer(), Collections.singleton(r), true, true);
     35        Command c = DeleteCommand.delete(Collections.singleton(r), true, true);
    3636        if (c != null) {
    3737            MainApplication.undoRedo.add(c);
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DuplicateChosenRelationAction.java

    r33530 r33694  
    99
    1010import org.openstreetmap.josm.command.AddCommand;
     11import org.openstreetmap.josm.data.osm.DataSet;
    1112import org.openstreetmap.josm.data.osm.Relation;
    1213import org.openstreetmap.josm.gui.MainApplication;
     
    1718
    1819public class DuplicateChosenRelationAction extends AbstractAction implements ChosenRelationListener {
    19     private ChosenRelation rel;
     20    private final ChosenRelation rel;
    2021
    2122    public DuplicateChosenRelationAction(ChosenRelation rel) {
     
    3031    @Override
    3132    public void actionPerformed(ActionEvent e) {
    32         Relation r = rel.get();
    33         Relation copy = new Relation(r, true);
    34         MainApplication.undoRedo.add(new AddCommand(copy));
    35         rel.set(copy);
    36         if (MainApplication.getLayerManager().getEditDataSet() != null) {
    37             MainApplication.getLayerManager().getEditDataSet().setSelected(copy);
     33        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
     34        if (ds != null) {
     35            Relation r = rel.get();
     36            Relation copy = new Relation(r, true);
     37            MainApplication.undoRedo.add(new AddCommand(ds, copy));
     38            rel.set(copy);
     39            ds.setSelected(copy);
    3840        }
    3941    }
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java

    r33530 r33694  
    2424import org.openstreetmap.josm.command.SequenceCommand;
    2525import org.openstreetmap.josm.data.coor.EastNorth;
     26import org.openstreetmap.josm.data.osm.DataSet;
    2627import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
    2728import org.openstreetmap.josm.data.osm.MultipolygonBuilder;
     
    8586        List<OsmPrimitive> newSelection = new ArrayList<>();
    8687        List<Command> commands = new ArrayList<>();
    87         Command relationDeleteCommand = DeleteCommand.delete(
    88                 MainApplication.getLayerManager().getEditLayer(), Collections.singleton(r), true, true);
     88        Command relationDeleteCommand = DeleteCommand.delete(Collections.singleton(r), true, true);
    8989        if (relationDeleteCommand == null)
    9090            return;
    9191
     92        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    9293        for (JoinedPolygon p : mpc.outerWays) {
    9394
     
    123124                }
    124125                if (relationReused) {
    125                     commands.add(new AddCommand(n));
     126                    commands.add(new AddCommand(ds, n));
    126127                } else {
    127128                    relationReused = true;
     
    189190            result.setKeys(tags);
    190191            newSelection.add(candidateWay == null ? result : candidateWay);
    191             commands.add(candidateWay == null ? new AddCommand(result) : new ChangeCommand(candidateWay, result));
     192            commands.add(candidateWay == null ? new AddCommand(ds, result) : new ChangeCommand(candidateWay, result));
    192193        }
    193194
     
    199200        MainApplication.undoRedo.add(new SequenceCommand(tr("Reconstruct polygons from relation {0}",
    200201                r.getDisplayName(DefaultNameFormatter.getInstance())), commands));
    201         MainApplication.getLayerManager().getEditDataSet().setSelected(newSelection);
     202        ds.setSelected(newSelection);
    202203    }
    203204
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SplittingMultipolygons.java

    r33530 r33694  
    2020import org.openstreetmap.josm.data.coor.EastNorth;
    2121import org.openstreetmap.josm.data.coor.LatLon;
     22import org.openstreetmap.josm.data.osm.DataSet;
    2223import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
    2324import org.openstreetmap.josm.data.osm.Node;
     
    218219        }
    219220
     221        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    220222        for (int i = 1; i < chunks.size(); i++) {
    221223            List<Node> achunk = chunks.get(i);
     
    229231            newWay.setNodes(achunk);
    230232            if (commands != null) {
    231                 commands.add(new AddCommand(newWay));
     233                commands.add(new AddCommand(ds, newWay));
    232234            }
    233235        }
     
    273275        newRelation.put("type", "multipolygon");
    274276        newRelation.addMember(new RelationMember("outer", segment));
    275         Collection<String> linearTags = Main.pref.getCollection(PREF_MULTIPOLY + "lineartags", CreateMultipolygonAction.DEFAULT_LINEAR_TAGS);
     277        Collection<String> linearTags = Main.pref.getList(PREF_MULTIPOLY + "lineartags", CreateMultipolygonAction.DEFAULT_LINEAR_TAGS);
    276278        Way segmentCopy = new Way(segment);
    277279        boolean changed = false;
     
    307309        }
    308310        newRelation.addMember(new RelationMember("outer", addingWay.getUniqueId() == target.getUniqueId() ? target : addingWay));
    309         commands.add(new AddCommand(newRelation));
     311        commands.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newRelation));
    310312        resultingCommands.add(new SequenceCommand(tr("Complete multipolygon for way {0}",
    311313                DefaultNameFormatter.getInstance().format(segment)), commands));
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/TheRing.java

    r33530 r33694  
    1717import org.openstreetmap.josm.command.Command;
    1818import org.openstreetmap.josm.command.DeleteCommand;
     19import org.openstreetmap.josm.data.osm.DataSet;
    1920import org.openstreetmap.josm.data.osm.Node;
    2021import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    2223import org.openstreetmap.josm.data.osm.RelationMember;
    2324import org.openstreetmap.josm.data.osm.Way;
     25import org.openstreetmap.josm.gui.MainApplication;
    2426import org.openstreetmap.josm.tools.Geometry;
    2527import org.openstreetmap.josm.tools.Geometry.PolygonIntersection;
     
    329331        Way sourceCopy = new Way(source);
    330332        if (createMultipolygon) {
    331             Collection<String> linearTags = Main.pref.getCollection(PREF_MULTIPOLY + "lineartags", CreateMultipolygonAction.DEFAULT_LINEAR_TAGS);
     333            Collection<String> linearTags = Main.pref.getList(PREF_MULTIPOLY + "lineartags", CreateMultipolygonAction.DEFAULT_LINEAR_TAGS);
    332334            relation = new Relation();
    333335            relation.put("type", "multipolygon");
     
    369371        }
    370372
     373        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    371374        List<Command> commands = new ArrayList<>();
    372375        boolean foundOwnWay = false;
     
    375378            Way w = seg.constructWay(seg.isReference() ? null : sourceCopy);
    376379            if (needAdding) {
    377                 commands.add(new AddCommand(w));
     380                commands.add(new AddCommand(ds, w));
    378381            }
    379382            if (w.equals(source)) {
     
    398401        commands.addAll(relationCommands);
    399402        if (createMultipolygon) {
    400             commands.add(new AddCommand(relation));
     403            commands.add(new AddCommand(ds, relation));
    401404        }
    402405        return commands;
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/MultipolygonFixer.java

    r33311 r33694  
    1717import org.openstreetmap.josm.data.osm.RelationMember;
    1818import org.openstreetmap.josm.data.osm.Way;
     19import org.openstreetmap.josm.gui.MainApplication;
    1920
    2021/**
     
    4647    public Command fixRelation(Relation rel) {
    4748        Relation rr = fixMultipolygonRoles(rel);
    48         return rr != null ? new ChangeCommand(rel, rr) : null;
     49        return rr != null ? new ChangeCommand(MainApplication.getLayerManager().getEditDataSet(), rel, rr) : null;
    4950    }
    5051
     
    8283            if (m.isWay()) {
    8384                String role = null;
    84                 if (outerWays.contains((Way)m.getMember())) {
     85                if (outerWays.contains(m.getMember())) {
    8586                    role = "outer";
    86                 } else if (innerWays.contains((Way)m.getMember())) {
     87                } else if (innerWays.contains(m.getMember())) {
    8788                    role = "inner";
    8889                }
Note: See TracChangeset for help on using the changeset viewer.