Ignore:
Timestamp:
2016-06-20T00:50:21+02:00 (8 years ago)
Author:
donvip
Message:

update to JOSM 10420, code cleanup

Location:
applications/editors/josm/plugins/utilsplugin2
Files:
39 edited

Legend:

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

    r31926 r32333  
    55    <property name="commit.message" value="[josm_utilsplugin2]: select boundary by double-click; multitagger table highlights"/>
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    7     <property name="plugin.main.version" value="8919"/>
     7    <property name="plugin.main.version" value="10420"/>
    88
    99    <property name="plugin.author" value="Kalle Lampila, Upliner, Zverik, akks, joshdoe and others"/>
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/AddIntersectionsAction.java

    r30737 r32333  
    2828
    2929public class AddIntersectionsAction extends JosmAction {
     30   
     31    /**
     32     * Constructs a new {@code AddIntersectionsAction}.
     33     */
    3034    public AddIntersectionsAction() {
    3135        super(tr("Add nodes at intersections"), "addintersect", tr("Add missing nodes at intersections of selected ways."),
     
    3842        if (!isEnabled())
    3943            return;
    40         List<Way> ways = OsmPrimitive.getFilteredList(getCurrentDataSet().getSelected(), Way.class);
     44        List<Way> ways = OsmPrimitive.getFilteredList(getLayerManager().getEditDataSet().getSelected(), Way.class);
    4145        if (ways.isEmpty()) {
    4246            new Notification(
     
    5660                Collection<? extends OsmPrimitive> pp = cmd.getParticipatingPrimitives();
    5761                for ( OsmPrimitive p : pp) { // find all affected nodes
    58                     if (p instanceof Node && p.isNew()) nodes.add((Node)p);
     62                    if (p instanceof Node && p.isNew())
     63                        nodes.add((Node)p);
    5964                }
    6065                if (!nodes.isEmpty()) {
    61                     getCurrentDataSet().setSelected(nodes);
    62                     }
     66                    getLayerManager().getEditDataSet().setSelected(nodes);
    6367                }
     68            }
    6469        }
    6570    }
     
    6772    @Override
    6873    protected void updateEnabledState() {
    69         if (getCurrentDataSet() == null) {
    70             setEnabled(false);
    71         } else {
    72             updateEnabledState(getCurrentDataSet().getSelected());
    73         }
     74        updateEnabledStateOnCurrentSelection();
    7475    }
    7576
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/AlignWayNodesAction.java

    r30737 r32333  
    2222    private static final double MOVE_THRESHOLD = 1e-9;
    2323
     24    /**
     25     * Constructs a new {@code AlignWayNodesAction}.
     26     */
    2427    public AlignWayNodesAction() {
    2528        super(TITLE, "dumbutils/alignwaynodes", tr("Align nodes in a way"),
     
    2932
    3033    public void actionPerformed( ActionEvent e ) {
    31         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     34        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
    3235        Set<Node> selectedNodes = filterNodes(selection);
    3336        int selectedNodesCount = selectedNodes.size();
     
    116119    @Override
    117120    protected void updateEnabledState() {
    118         if( getCurrentDataSet() == null ) {
    119             setEnabled(false);
    120         }  else
    121             updateEnabledState(getCurrentDataSet().getSelected());
     121        updateEnabledStateOnCurrentSelection();
    122122    }
    123123
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/CopyTagsAction.java

    r32099 r32333  
    4545    public void actionPerformed(ActionEvent e) {
    4646        if (isEmptySelection()) return;
    47         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
    48         copy(getEditLayer(), selection);
     47        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
     48        copy(getLayerManager().getEditLayer(), selection);
    4949    }
    5050
     
    6767    @Override
    6868    protected void updateEnabledState() {
    69         if (getCurrentDataSet() == null) {
    70             setEnabled(false);
    71         } else {
    72             updateEnabledState(getCurrentDataSet().getSelected());
    73         }
     69        updateEnabledStateOnCurrentSelection();
    7470    }
    7571
     
    7975    }
    8076
    81     private static boolean isEmptySelection() {
    82         Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected();
     77    private boolean isEmptySelection() {
     78        Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected();
    8379        if (sel.isEmpty()) {
    8480            JOptionPane.showMessageDialog(
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/ExtractPointAction.java

    r30737 r32333  
    2525
    2626/**
    27  *    Unselects all nodes
     27 * Extracts node from its ways.
    2828 */
    2929public class ExtractPointAction extends JosmAction {
    3030
    31    
     31    /**
     32     * Constructs a new {@code ExtractPointAction}.
     33     */
    3234    public ExtractPointAction() {
    3335        super(tr("Extract node"), "extnode",
     
    4042    @Override
    4143    public void actionPerformed(ActionEvent e) {
    42         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     44        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
    4345        List<Node> selectedNodes = OsmPrimitive.getFilteredList(selection, Node.class);
    4446        if (selectedNodes.size()!=1) {
     
    5052        Node ndCopy = new Node(nd.getCoor());
    5153        List<Command> cmds = new LinkedList<>();
    52        
     54
    5355        Point p = Main.map.mapView.getMousePosition();
    54         if (p!=null) cmds.add(new MoveCommand(nd,Main.map.mapView.getLatLon(p.x, p.y)));
     56        if (p != null)
     57            cmds.add(new MoveCommand(nd,Main.map.mapView.getLatLon(p.x, p.y)));
    5558        List<OsmPrimitive> refs = nd.getReferrers();
    5659        cmds.add(new AddCommand(ndCopy));
     
    7073    @Override
    7174    protected void updateEnabledState() {
    72         if (getCurrentDataSet() == null) {
    73             setEnabled(false);
    74         } else {
    75             updateEnabledState(getCurrentDataSet().getSelected());
    76         }
     75        updateEnabledStateOnCurrentSelection();
    7776    }
    7877
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/PasteRelationsAction.java

    r31040 r32333  
    3737    @Override
    3838    public void actionPerformed( ActionEvent e ) {
    39         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     39        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
    4040        if( selection.isEmpty() )
    4141            return;
     
    4343        Map<Relation, String> relations = new HashMap<>();
    4444        for( PrimitiveData pdata : Main.pasteBuffer.getDirectlyAdded() ) {
    45             OsmPrimitive p = getCurrentDataSet().getPrimitiveById(pdata.getUniqueId(), pdata.getType());
     45            OsmPrimitive p = getLayerManager().getEditDataSet().getPrimitiveById(pdata.getUniqueId(), pdata.getType());
    4646            if (p != null) {
    4747                    for( Relation r : OsmPrimitive.getFilteredList(p.getReferrers(), Relation.class)) {
     
    9191    @Override
    9292    protected void updateEnabledState() {
    93         if( getCurrentDataSet() == null ) {
    94             setEnabled(false);
    95         }  else
    96             updateEnabledState(getCurrentDataSet().getSelected());
     93        updateEnabledStateOnCurrentSelection();
    9794    }
    9895
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitObjectAction.java

    r30737 r32333  
    3838 * immediately.
    3939 */
    40 
    4140public class SplitObjectAction extends JosmAction {
    4241    /**
     
    5958    @Override
    6059    public void actionPerformed(ActionEvent e) {
    61         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     60        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
    6261
    6362        List<Node> selectedNodes = OsmPrimitive.getFilteredList(selection, Node.class);
     
    6867            return;
    6968        }
    70 
    7169
    7270        Way selectedWay = null;
     
    190188
    191189        List<List<Node>> wayChunks = SplitWayAction.buildSplitChunks(selectedWay, selectedNodes);
    192         //        List<List<Node>> wayChunks = buildSplitChunks(selectedWay, selectedNodes);
    193190        if (wayChunks != null) {
    194191            // close the chunks
     
    213210                }
    214211            }
    215             SplitWayAction.SplitWayResult result = SplitWayAction.splitWay(getEditLayer(), selectedWay, wayChunks, Collections.<OsmPrimitive>emptyList());
    216             //            SplitObjectResult result = splitObject(getEditLayer(),selectedWay, wayChunks);
     212            SplitWayAction.SplitWayResult result = SplitWayAction.splitWay(
     213                    getLayerManager().getEditLayer(), selectedWay, wayChunks, Collections.<OsmPrimitive>emptyList());
    217214            Main.main.undoRedo.add(result.getCommand());
    218215            if (splitWay != null)
    219216                Main.main.undoRedo.add(new DeleteCommand(splitWay));
    220             getCurrentDataSet().setSelected(result.getNewSelection());
     217            getLayerManager().getEditDataSet().setSelected(result.getNewSelection());
    221218        }
    222219    }
     
    245242    @Override
    246243    protected void updateEnabledState() {
    247         if (getCurrentDataSet() == null) {
    248             setEnabled(false);
    249         } else {
    250             updateEnabledState(getCurrentDataSet().getSelected());
    251         }
     244        updateEnabledStateOnCurrentSelection();
    252245    }
    253246
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitOnIntersectionsAction.java

    r30737 r32333  
    3434    public void actionPerformed( ActionEvent e ) {
    3535        List<Command> list = new ArrayList<>();
    36         List<Way> selectedWays = OsmPrimitive.getFilteredList(getCurrentDataSet().getSelected(), Way.class);
     36        List<Way> selectedWays = OsmPrimitive.getFilteredList(getLayerManager().getEditDataSet().getSelected(), Way.class);
    3737        Map<Way, List<Node>> splitWays = new HashMap<>();
    3838
     
    7979                List<OsmPrimitive> sel = new ArrayList<>(selectedWays.size());
    8080                sel.addAll(selectedWays);
    81                 SplitWayAction.SplitWayResult result = SplitWayAction.splitWay(getEditLayer(), splitWay, wayChunks, sel);
     81                SplitWayAction.SplitWayResult result = SplitWayAction.splitWay(getLayerManager().getEditLayer(), splitWay, wayChunks, sel);
    8282                list.add(result.getCommand());
    8383            }
     
    8686        if( !list.isEmpty() ) {
    8787            Main.main.undoRedo.add(list.size() == 1 ? list.get(0) : new SequenceCommand(TITLE, list));
    88             getCurrentDataSet().clearSelection();
     88            getLayerManager().getEditDataSet().clearSelection();
    8989        }
    9090    }
     
    9292    @Override
    9393    protected void updateEnabledState() {
    94         if( getCurrentDataSet() == null ) {
    95             setEnabled(false);
    96         }  else
    97             updateEnabledState(getCurrentDataSet().getSelected());
     94        updateEnabledStateOnCurrentSelection();
    9895    }
    9996
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SymmetryAction.java

    r30737 r32333  
    3535public final class SymmetryAction extends JosmAction {
    3636
     37    /**
     38     * Constructs a new {@code SymmetryAction}.
     39     */
    3740    public SymmetryAction() {
    3841        super(tr("Symmetry"), "symmetry", tr("Mirror selected nodes and ways."),
     
    4447    @Override
    4548    public void actionPerformed(ActionEvent e) {
    46         Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected();
     49        Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected();
    4750        HashSet<Node> nodes = new HashSet<>();
    4851        EastNorth p1=null,p2=null;
     
    8992    @Override
    9093    protected void updateEnabledState() {
    91         if (getCurrentDataSet() == null) {
    92             setEnabled(false);
    93         } else {
    94             updateEnabledState(getCurrentDataSet().getSelected());
    95         }
     94        updateEnabledStateOnCurrentSelection();
    9695    }
    9796
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/TagBufferAction.java

    r31653 r32333  
    3030    private Set<OsmPrimitive> selectionBuf = new HashSet<>();
    3131
     32    /**
     33     * Constructs a new {@code TagBufferAction}.
     34     */
    3235    public TagBufferAction() {
    3336        super(TITLE, "dumbutils/tagbuffer", tr("Pastes tags of previously selected object(s)"),
     
    4043    @Override
    4144    public void actionPerformed( ActionEvent e ) {
    42         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     45        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
    4346        if( selection.isEmpty() )
    4447            return;
     
    6467    @Override
    6568    protected void updateEnabledState() {
    66         if( getCurrentDataSet() == null ) {
     69        if( getLayerManager().getEditDataSet() == null ) {
    6770            setEnabled(false);
    6871            if( selectionBuf != null )
    6972                selectionBuf.clear();
    7073        }  else
    71             updateEnabledState(getCurrentDataSet().getSelected());
     74            updateEnabledState(getLayerManager().getEditDataSet().getSelected());
    7275    }
    7376
     
    9497            tags.putAll(currentTags);
    9598        }
    96         if( getCurrentDataSet() != null)
     99        if( getLayerManager().getEditDataSet() != null)
    97100            rememberSelectionTags();
    98101
     
    102105    private void rememberSelectionTags() {
    103106        // Fix #8350 - only care about tagged objects
    104         final Collection<OsmPrimitive> selectedTaggedObjects = Utils.filter(getCurrentDataSet().getSelected(), IS_TAGGED_PREDICATE);
     107        final Collection<OsmPrimitive> selectedTaggedObjects = Utils.filter(getLayerManager().getEditDataSet().getSelected(), IS_TAGGED_PREDICATE);
    105108        if( !selectedTaggedObjects.isEmpty() ) {
    106109            currentTags.clear();
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/TagSourceAction.java

    r31026 r32333  
    3333    @Override
    3434    public void actionPerformed( ActionEvent e ) {
    35         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     35        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
    3636        if( selection.isEmpty() || source == null || source.length() == 0 )
    3737            return;
     
    4242    @Override
    4343    protected void updateEnabledState() {
    44         if( getCurrentDataSet() == null ) {
     44        if( getLayerManager().getEditDataSet() == null ) {
    4545            setEnabled(false);
    4646            if( selectionBuf != null )
    4747                selectionBuf.clear();
    4848        }  else
    49             updateEnabledState(getCurrentDataSet().getSelected());
     49            updateEnabledState(getLayerManager().getEditDataSet().getSelected());
    5050    }
    5151
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/UnGlueRelationAction.java

    r30737 r32333  
    5151        LinkedList<Command> cmds = new LinkedList<>();
    5252        List<OsmPrimitive> newPrimitives = new LinkedList<>();
    53         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     53        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
    5454
    5555        for (OsmPrimitive p : selection) {
     
    8383            //Set selection all primiteves (new and old)
    8484            newPrimitives.addAll(selection);
    85             getCurrentDataSet().setSelected(newPrimitives);
     85            getLayerManager().getEditDataSet().setSelected(newPrimitives);
    8686            Main.map.mapView.repaint();
    8787        }
     
    9090    @Override
    9191    protected void updateEnabledState() {
    92         if (getCurrentDataSet() == null) {
    93             setEnabled(false);
    94         } else {
    95             updateEnabledState(getCurrentDataSet().getSelected());
    96         }
     92        updateEnabledStateOnCurrentSelection();
    9793    }
    9894
     
    10197        setEnabled(selection != null && !selection.isEmpty());
    10298    }
    103 
    10499}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/curves/CurveAction.java

    r30737 r32333  
    5353        updatePreferences();
    5454
    55         List<Node> selectedNodes = new ArrayList<>(getCurrentDataSet().getSelectedNodes());
    56         List<Way> selectedWays = new ArrayList<>(getCurrentDataSet().getSelectedWays());
     55        List<Node> selectedNodes = new ArrayList<>(getLayerManager().getEditDataSet().getSelectedNodes());
     56        List<Way> selectedWays = new ArrayList<>(getLayerManager().getEditDataSet().getSelectedWays());
    5757
    58         // Collection<Command> cmds = doSpline(selectedNodes, selectedWays);
    5958        Collection<Command> cmds = CircleArcMaker.doCircleArc(selectedNodes, selectedWays, angleSeparation);
    6059        if (cmds != null)
     
    6463    @Override
    6564    protected void updateEnabledState() {
    66         if (getCurrentDataSet() == null) {
    67             setEnabled(false);
    68         } else {
    69             updateEnabledState(getCurrentDataSet().getSelected());
    70         }
     65        updateEnabledStateOnCurrentSelection();
    7166    }
    7267
     
    7570        setEnabled(selection != null && !selection.isEmpty());
    7671    }
    77 
    78     public static void main(String[] args) {
    79     }
    80 
    8172}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/ChooseURLAction.java

    r30532 r32333  
    2121
    2222    public ChooseURLAction() {
    23          super(tr("Select custom URL"), "selecturl", tr("Select custom URL"),null,true,true);
     23        super(tr("Select custom URL"), "selecturl", tr("Select custom URL"),null,true,true);
    2424    }
    2525
    2626    @Override
    2727    public void actionPerformed(ActionEvent e) {
    28        showConfigDialog(false);
     28        showConfigDialog(false);
    2929    }
    3030
    3131    @Override
    3232    protected void updateEnabledState() {
    33         if (getCurrentDataSet() == null) {
    34             setEnabled(false);
    35         } else {
    36             setEnabled(true);
    37         }
     33        setEnabled(getLayerManager().getEditDataSet() != null);
    3834    }
    3935       
    4036    public static void showConfigDialog(final boolean fast) {
    41         JPanel all = new JPanel();
    42         GridBagLayout layout = new GridBagLayout();
    43         all.setLayout(layout);
     37        JPanel all = new JPanel(new GridBagLayout());
    4438       
    4539        List<String> items = URLList.getURLList();
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/OpenPageAction.java

    r31652 r32333  
    4343    @Override
    4444    public void actionPerformed(ActionEvent e) {
    45         Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected();
     45        Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected();
    4646        OsmPrimitive p=null;
    4747        if (sel.size()>=1) {
     
    8888        }
    8989        } catch (UnsupportedEncodingException ex) {
    90             System.err.println("Encoding error");
     90            Main.error(ex, "Encoding error");
    9191            return;
    9292        }
     
    9797            OpenBrowser.displayUrl(addr);
    9898        } catch (Exception ex) {
    99             System.err.println("Can not open URL"+addr);
     99            Main.error(ex, "Can not open URL " + addr);
    100100        }
    101101        //Collection<Command> cmds = new LinkedList<Command>();
    102102
    103           //  cmds.add(new MoveCommand(n, -2*ne*pr, -2*nn*pr ));
     103        //cmds.add(new MoveCommand(n, -2*ne*pr, -2*nn*pr ));
    104104        //Main.main.undoRedo.add(new SequenceCommand(tr("Symmetry"), cmds));
    105105    }
     
    107107    @Override
    108108    protected void updateEnabledState() {
    109         if (getCurrentDataSet() == null) {
    110             setEnabled(false);
    111         } else {
    112             setEnabled(true);
    113         }
     109        setEnabled(getLayerManager().getEditDataSet() != null);
    114110    }
    115 
    116    
    117111}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/latlon/LatLonAction.java

    r30737 r32333  
    8989    @Override
    9090    protected void updateEnabledState() {
    91         setEnabled(getEditLayer() != null);
     91        setEnabled(getLayerManager().getEditLayer() != null);
    9292    }
    9393}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTagAction.java

    r30993 r32333  
    1616    MultiTagDialog dlg;
    1717
     18    /**
     19     * Constructs a new {@code MultiTagAction}.
     20     */
    1821    public MultiTagAction() {
    1922        super(tr("Tag multiple objects [alpha]"), (String)null, tr("Edit tags of object list in table"),
     
    2831            return;
    2932        dlg = new MultiTagDialog();
    30         dlg.selectionChanged(getCurrentDataSet().getSelected());
     33        dlg.selectionChanged(getLayerManager().getEditDataSet().getSelected());
    3134        dlg.showDialog();
    3235    }
    3336
    34 
    3537    @Override
    3638    protected void updateEnabledState() {
    37         setEnabled(getEditLayer()!=null);
     39        setEnabled(getLayerManager().getEditLayer()!=null);
    3840    }
    3941
    4042    @Override
    4143    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
    42         setEnabled(getEditLayer()!=null);
     44        setEnabled(getLayerManager().getEditLayer()!=null);
    4345        if (dlg!=null && dlg.isVisible()) {
    4446            dlg.selectionChanged(selection);
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTagDialog.java

    r31890 r32333  
    136136                public void actionPerformed(ActionEvent e) {
    137137                    if (jt.isSelected()) tableModel.shownTypes.add(type); else tableModel.shownTypes.remove(type);
    138                     tableModel.updateData(Main.main.getCurrentDataSet().getSelected());
    139                 };
     138                    tableModel.updateData(Main.getLayerManager().getEditDataSet().getSelected());
     139                }
    140140            });
    141141            ImageProvider.get(type);
     
    208208
    209209    private void initAutocompletion() {
    210         OsmDataLayer l = Main.main.getEditLayer();
     210        OsmDataLayer l = Main.getLayerManager().getEditLayer();
    211211        AutoCompletionManager autocomplete = l.data.getAutoCompletionManager();
    212212        for (int i=0; i<tableModel.mainTags.length; i++) {
     
    233233            @Override
    234234            public void actionPerformed(ActionEvent e) {
    235                 Main.main.getCurrentDataSet().setSelected(getSelectedPrimitives());
     235                Main.getLayerManager().getEditDataSet().setSelected(getSelectedPrimitives());
    236236            }
    237237        });
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTaggerTableModel.java

    r30737 r32333  
    5454    public void setWatchSelection(boolean watchSelection) {
    5555        this.watchSelection = watchSelection;
    56         if (watchSelection && Main.main.hasEditLayer()) selectionChanged(Main.main.getCurrentDataSet().getSelected());
    57     }
    58    
     56        if (watchSelection && Main.getLayerManager().getEditLayer() != null)
     57            selectionChanged(Main.getLayerManager().getEditDataSet().getSelected());
     58    }
     59
    5960    @Override
    6061    public Object getValueAt(int rowIndex, int columnIndex) {
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryAction.java

    r30737 r32333  
    3030    @Override
    3131    public void actionPerformed(ActionEvent e) {
    32         if (getCurrentDataSet() == null) {
     32        if (getLayerManager().getEditDataSet() == null) {
    3333            return;
    3434        }
    3535
    3636        // There must be two ways selected: one with id > 0 and one new.
    37         List<OsmPrimitive> selection = new ArrayList<>(getCurrentDataSet().getSelected());
     37        List<OsmPrimitive> selection = new ArrayList<>(getLayerManager().getEditDataSet().getSelected());
    3838        if (selection.size() != 2) {
    3939            new Notification(
     
    6868    @Override
    6969    protected void updateEnabledState() {
    70         if( getCurrentDataSet() == null ) {
    71             setEnabled(false);
    72         }  else
    73             updateEnabledState(getCurrentDataSet().getSelected());
     70        updateEnabledStateOnCurrentSelection();
    7471    }
    7572
     
    7976    }
    8077}
    81 
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryUtils.java

    r31655 r32333  
    117117        // FIXME: handle different layers
    118118        List<Command> commands = new ArrayList<>();
    119         Command c = MergeNodesAction.mergeNodes(Main.main.getEditLayer(), Arrays.asList(subjectNode, referenceNode), referenceNode);
     119        Command c = MergeNodesAction.mergeNodes(Main.getLayerManager().getEditLayer(), Arrays.asList(subjectNode, referenceNode), referenceNode);
    120120        if (c == null) {
    121121            // User canceled
     
    204204        }
    205205
    206         Main.main.getCurrentDataSet().setSelected(referenceObject);
     206        Main.getLayerManager().getEditDataSet().setSelected(referenceObject);
    207207
    208208        return new ReplaceGeometryCommand(
     
    243243    public static ReplaceGeometryCommand buildReplaceWayCommand(Way subjectWay, Way referenceWay) {
    244244
    245         Area a = Main.main.getCurrentDataSet().getDataSourceArea();
     245        Area a = Main.getLayerManager().getEditDataSet().getDataSourceArea();
    246246        if (!isInArea(subjectWay, a) || !isInArea(referenceWay, a)) {
    247247            throw new ReplaceGeometryException(tr("The ways must be entirely within the downloaded area."));
     
    260260        } catch (UserCancelException e) {
    261261            // user canceled tag merge dialog
     262            Main.trace(e);
    262263            return null;
    263264        }
     
    358359
    359360        // Remove geometry way from selection
    360         Main.main.getCurrentDataSet().clearSelection(referenceWay);
     361        Main.getLayerManager().getEditDataSet().clearSelection(referenceWay);
    361362
    362363        // And delete old geometry way
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceMembershipAction.java

    r32099 r32333  
    3737    @Override
    3838    public void actionPerformed(ActionEvent e) {
    39         final Iterator<OsmPrimitive> selection = getCurrentDataSet().getSelected().iterator();
     39        final Iterator<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected().iterator();
    4040        final OsmPrimitive firstObject = selection.next();
    4141        final OsmPrimitive secondObject = selection.next();
     
    5656            )).setIcon(JOptionPane.WARNING_MESSAGE).show();
    5757        }
    58 
    5958    }
    6059
     
    8079    @Override
    8180    protected void updateEnabledState() {
    82         updateEnabledState(getCurrentDataSet() == null ? null : getCurrentDataSet().getSelected());
     81        updateEnabledStateOnCurrentSelection();
    8382    }
    8483
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/ConnectedMatch.java

    r30737 r32333  
    3232        Set<Node> matchedNodes = new HashSet<>();
    3333        // find all ways that match the expression
    34         Collection<Way> allWays = Main.main.getCurrentDataSet().getWays();
     34        Collection<Way> allWays = Main.getLayerManager().getEditDataSet().getWays();
    3535        for (Way way : allWays) {
    3636            if (match.match(way)) {
     
    3939        }
    4040        // find all nodes that match the expression
    41         Collection<Node> allNodes = Main.main.getCurrentDataSet().getNodes();
     41        Collection<Node> allNodes = Main.getLayerManager().getEditDataSet().getNodes();
    4242        for (Node node : allNodes) {
    4343            if (match.match(node)) {
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/InsideMatch.java

    r30737 r32333  
    3232        Collection<OsmPrimitive> matchedAreas = new HashSet<>();
    3333        // find all ways that match the expression
    34         Collection<Way> ways = Main.main.getCurrentDataSet().getWays();
     34        Collection<Way> ways = Main.getLayerManager().getEditDataSet().getWays();
    3535        for (Way way : ways) {
    3636            if (match.match(way)) {
     
    3939        }
    4040        // find all relations that match the expression
    41         Collection<Relation> rels = Main.main.getCurrentDataSet().getRelations();
     41        Collection<Relation> rels = Main.getLayerManager().getEditDataSet().getRelations();
    4242        for (Relation rel : rels) {
    4343            if (match.match(rel)) {
     
    4545            }
    4646        }
    47         inside = NodeWayUtils.selectAllInside(matchedAreas, Main.main.getCurrentDataSet(), false);
     47        inside = NodeWayUtils.selectAllInside(matchedAreas, Main.getLayerManager().getEditDataSet(), false);
    4848    }
    4949
     
    5555        return inside.contains(osm);
    5656    }
    57    
    5857}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/IntersectingMatch.java

    r30737 r32333  
    3030        Collection<Way> matchedWays = new HashSet<>();
    3131        // find all ways that match the expression
    32         Collection<Way> allWays = Main.main.getCurrentDataSet().getWays();
     32        Collection<Way> allWays = Main.getLayerManager().getEditDataSet().getWays();
    3333        for (Way way : allWays) {
    3434            if (match.match(way)) {
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/AdjacentNodesAction.java

    r30737 r32333  
    3333    @Override
    3434    public void actionPerformed(ActionEvent e) {
    35         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     35        DataSet ds = getLayerManager().getEditDataSet();
     36        Collection<OsmPrimitive> selection = ds.getSelected();
    3637        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
    3738
    38         Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
     39        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(ds.getSelected(), Way.class);
    3940       
    4041        // if no nodes and no ways are selected, do nothing
     
    6162            NodeWayUtils.addNodesConnectedToWays(selectedWays, newNodes);
    6263            activeWays.clear();
    63             getCurrentDataSet().setSelected(newNodes);
     64            ds.setSelected(newNodes);
    6465            return;
    6566        }
    6667
    6768        if (activeWays.isEmpty()) {
    68                 NodeWayUtils.addWaysConnectedToNodes(selectedNodes, activeWays);
     69            NodeWayUtils.addWaysConnectedToNodes(selectedNodes, activeWays);
    6970        }
    7071
     
    8889         }
    8990
    90          getCurrentDataSet().addSelected(newNodes);
    91          newNodes = null;
    92 
     91         ds.addSelected(newNodes);
    9392    }
    9493
    9594    @Override
    9695    protected void updateEnabledState() {
    97         if (getCurrentDataSet() == null) {
    98             setEnabled(false);
    99         } else {
    100             updateEnabledState(getCurrentDataSet().getSelected());
    101         }
     96        updateEnabledStateOnCurrentSelection();
    10297    }
    10398
     
    110105        setEnabled(!selection.isEmpty());
    111106    }
    112 
    113 
    114 
    115107}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/AdjacentWaysAction.java

    r30737 r32333  
    3232    @Override
    3333    public void actionPerformed(ActionEvent e) {
    34         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     34        DataSet ds = getLayerManager().getEditDataSet();
     35        Collection<OsmPrimitive> selection = ds.getSelected();
    3536        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
    3637
    37         Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
     38        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(ds.getSelected(), Way.class);
    3839
    3940        // select ways attached to already selected ways
     
    4849
    4950//        System.out.printf("%d ways added to selection\n",newWays.size()-selectedWays.size());
    50         getCurrentDataSet().setSelected(newWays);
     51        ds.setSelected(newWays);
    5152    }
    5253
    5354    @Override
    5455    protected void updateEnabledState() {
    55         if (getCurrentDataSet() == null) {
    56             setEnabled(false);
    57         } else {
    58             updateEnabledState(getCurrentDataSet().getSelected());
    59         }
     56        updateEnabledStateOnCurrentSelection();
    6057    }
    6158
     
    6865        setEnabled(!selection.isEmpty());
    6966    }
    70 
    71 
    72 
    7367}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/ConnectedWaysAction.java

    r30737 r32333  
    2929    @Override
    3030    public void actionPerformed(ActionEvent e) {
    31         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     31        DataSet ds = getLayerManager().getEditDataSet();
     32        Collection<OsmPrimitive> selection = ds.getSelected();
    3233        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
    33         Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
     34        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(ds.getSelected(), Way.class);
    3435
    3536        Set<Way> newWays = new HashSet<>();
     
    4546       
    4647//        System.out.printf("%d ways added to selection\n",newWays.size()-selectedWays.size());
    47         getCurrentDataSet().setSelected(newWays);
    48 
     48        ds.setSelected(newWays);
    4949    }
    5050
    5151    @Override
    5252    protected void updateEnabledState() {
    53         if (getCurrentDataSet() == null) {
    54             setEnabled(false);
    55         } else {
    56             updateEnabledState(getCurrentDataSet().getSelected());
    57         }
     53        updateEnabledStateOnCurrentSelection();
    5854    }
    5955
     
    6662        setEnabled(!selection.isEmpty());
    6763    }
    68 
    69 
    7064}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/IntersectedWaysAction.java

    r30737 r32333  
    1414
    1515import org.openstreetmap.josm.actions.JosmAction;
     16import org.openstreetmap.josm.data.osm.DataSet;
    1617import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1718import org.openstreetmap.josm.data.osm.Way;
     
    3334    @Override
    3435    public void actionPerformed(ActionEvent e) {
    35         Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
     36        DataSet ds = getLayerManager().getEditDataSet();
     37        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(ds.getSelected(), Way.class);
    3638
    3739        // select ways attached to already selected ways
     
    3941            Set<Way> newWays = new HashSet<>();
    4042            NodeWayUtils.addWaysIntersectingWays(
    41                     getCurrentDataSet().getWays(),
     43                    ds.getWays(),
    4244                    selectedWays, newWays);
    43             getCurrentDataSet().addSelected(newWays);
     45            ds.addSelected(newWays);
    4446            return;
    4547        } else {
     
    4850               ).setIcon(JOptionPane.WARNING_MESSAGE).show();
    4951        }
    50 
    5152    }
    5253
    5354    @Override
    5455    protected void updateEnabledState() {
    55         if (getCurrentDataSet() == null) {
    56             setEnabled(false);
    57         } else {
    58             updateEnabledState(getCurrentDataSet().getSelected());
    59         }
     56        updateEnabledStateOnCurrentSelection();
    6057    }
    6158
     
    6865        setEnabled(!selection.isEmpty());
    6966    }
    70 
    71 
    7267}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/IntersectedWaysRecursiveAction.java

    r30737 r32333  
    1414
    1515import org.openstreetmap.josm.actions.JosmAction;
     16import org.openstreetmap.josm.data.osm.DataSet;
    1617import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1718import org.openstreetmap.josm.data.osm.Way;
     
    3435    @Override
    3536    public void actionPerformed(ActionEvent e) {
    36        
    37         Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
     37        DataSet ds = getLayerManager().getEditDataSet();
     38        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(ds.getSelected(), Way.class);
    3839
    3940        if (!selectedWays.isEmpty()) {
    4041            Set<Way> newWays = new HashSet<>();
    4142            NodeWayUtils.addWaysIntersectingWaysRecursively(
    42                     getCurrentDataSet().getWays(),
     43                    ds.getWays(),
    4344                    selectedWays, newWays);
    44             getCurrentDataSet().addSelected(newWays);
     45            ds.addSelected(newWays);
    4546        } else {
    4647              new Notification(
     
    4849                ).setIcon(JOptionPane.WARNING_MESSAGE).show();
    4950        }
    50 
    5151    }
    52 
    5352
    5453    @Override
    5554    protected void updateEnabledState() {
    56         if (getCurrentDataSet() == null) {
    57             setEnabled(false);
    58         } else {
    59             updateEnabledState(getCurrentDataSet().getSelected());
    60         }
     55        updateEnabledStateOnCurrentSelection();
    6156    }
    6257
     
    6964        setEnabled(!selection.isEmpty());
    7065    }
    71 
    72 
    7366}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/MiddleNodesAction.java

    r30737 r32333  
    3535    @Override
    3636    public void actionPerformed(ActionEvent e) {
    37         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     37        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
    3838        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
    3939
     
    5151        // select only newly found nodes
    5252        newNodes.removeAll(selectedNodes);
    53         getCurrentDataSet().addSelected(newNodes);
    54         newNodes = null;
    55 
     53        getLayerManager().getEditDataSet().addSelected(newNodes);
    5654    }
    5755
    5856    @Override
    5957    protected void updateEnabledState() {
    60         if (getCurrentDataSet() == null) {
    61             setEnabled(false);
    62         } else {
    63             updateEnabledState(getCurrentDataSet().getSelected());
    64         }
     58        updateEnabledStateOnCurrentSelection();
    6559    }
    6660
     
    7367        setEnabled(!selection.isEmpty());
    7468    }
    75 
    76 
    77 
    7869}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectAllInsideAction.java

    r30701 r32333  
    1212
    1313import org.openstreetmap.josm.actions.JosmAction;
     14import org.openstreetmap.josm.data.osm.DataSet;
    1415import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1516import org.openstreetmap.josm.gui.Notification;
     
    3031    @Override
    3132    public void actionPerformed(ActionEvent e) {
    32         Collection<OsmPrimitive> insideSelected = NodeWayUtils.selectAllInside(getCurrentDataSet().getSelected(), getCurrentDataSet(), true);
     33        DataSet ds = getLayerManager().getEditDataSet();
     34        Collection<OsmPrimitive> insideSelected = NodeWayUtils.selectAllInside(ds.getSelected(), ds, true);
    3335       
    3436        if (!insideSelected.isEmpty()) {
    35             getCurrentDataSet().addSelected(insideSelected);
     37            ds.addSelected(insideSelected);
    3638        } else{
    3739            new Notification(
     
    4446    @Override
    4547    protected void updateEnabledState() {
    46         if (getCurrentDataSet() == null) {
    47             setEnabled(false);
    48         } else {
    49             updateEnabledState(getCurrentDataSet().getSelected());
    50         }
     48        updateEnabledStateOnCurrentSelection();
    5149    }
    5250
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectBoundaryAction.java

    r30459 r32333  
    4040    @Override
    4141    public void actionPerformed(ActionEvent e) {
    42         Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
    43         Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Node.class);
     42        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getLayerManager().getEditDataSet().getSelected(), Way.class);
     43        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(getLayerManager().getEditDataSet().getSelected(), Node.class);
    4444       
    4545        Set<Way> newWays = new HashSet<>();
     
    7676        newWays.add(w);
    7777        lastUsedStartingWay = w;
    78        
    7978                       
    8079        // try going left at each turn
     
    8483       
    8584        if (!newWays.isEmpty() ) {
    86             getCurrentDataSet().setSelected(newWays);
     85            getLayerManager().getEditDataSet().setSelected(newWays);
    8786        } else{
    88         new Notification(
    89             tr("Nothing found. Please select way that is a part of some polygon formed by connected ways")
    90             ).setIcon(JOptionPane.WARNING_MESSAGE).show();           
    91     }
     87            new Notification(tr("Nothing found. Please select way that is a part of some polygon formed by connected ways"))
     88                .setIcon(JOptionPane.WARNING_MESSAGE).show();           
     89        }
    9290    }
    9391
    9492    @Override
    9593    protected void updateEnabledState() {
    96         if (getCurrentDataSet() == null) {
    97             setEnabled(false);
    98         } else {
    99             setEnabled(true);
    100            // updateEnabledState(getCurrentDataSet().getSelected());
    101         }
     94        setEnabled(getLayerManager().getEditDataSet() != null);
    10295    }
    10396
     
    10598    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
    10699        if (selection == null) {
    107          //   setEnabled(false);
    108100            return;
    109101        }
    110102        setEnabled(true);
    111         //setEnabled(!selection.isEmpty());
    112103    }
    113104}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectHighwayAction.java

    r30737 r32333  
    1818
    1919import org.openstreetmap.josm.actions.JosmAction;
     20import org.openstreetmap.josm.data.osm.DataSet;
    2021import org.openstreetmap.josm.data.osm.Node;
    2122import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    4041    @Override
    4142    public void actionPerformed(ActionEvent e) {
    42         List<Way> selectedWays = OsmPrimitive.getFilteredList(getCurrentDataSet().getSelected(), Way.class);
     43        DataSet ds = getLayerManager().getEditDataSet();
     44        List<Way> selectedWays = OsmPrimitive.getFilteredList(ds.getSelected(), Way.class);
    4345
    4446        if( selectedWays.size() == 1 ) {
    45             getCurrentDataSet().setSelected(selectNamedRoad(selectedWays.get(0)));
     47            ds.setSelected(selectNamedRoad(selectedWays.get(0)));
    4648        } else if( selectedWays.size() == 2 ) {
    47             getCurrentDataSet().setSelected(selectHighwayBetween(selectedWays.get(0), selectedWays.get(1)));
     49            ds.setSelected(selectHighwayBetween(selectedWays.get(0), selectedWays.get(1)));
    4850        } else {
    4951            new Notification(
     
    112114    @Override
    113115    protected void updateEnabledState() {
    114         if (getCurrentDataSet() == null)
    115             setEnabled(false);
    116         else
    117             updateEnabledState(getCurrentDataSet().getSelected());
     116        updateEnabledStateOnCurrentSelection();
    118117    }
    119118
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectModNodesAction.java

    r30737 r32333  
    3434    @Override
    3535     public void actionPerformed(ActionEvent e) {
    36         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     36        DataSet ds = getLayerManager().getEditDataSet();
     37        Collection<OsmPrimitive> selection = ds.getSelected();
    3738        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
    38         getCurrentDataSet().clearSelection(selectedNodes);
     39        ds.clearSelection(selectedNodes);
    3940        Command cmd =null;
    4041
     
    6263            }
    6364            if (!nodes.isEmpty()) {
    64                 getCurrentDataSet().setSelected(nodes);
     65                ds.setSelected(nodes);
    6566                lastCmd = cmd; // remember last used command and last selection
    66                 lastHash = getCurrentDataSet().getSelected().hashCode();
     67                lastHash = ds.getSelected().hashCode();
    6768                return;
    6869                }
     
    7576    @Override
    7677    protected void updateEnabledState() {
    77         if (getCurrentDataSet() == null) {
    78             setEnabled(false);
    79         } else {
    80             updateEnabledState(getCurrentDataSet().getSelected());
    81         }
     78        updateEnabledStateOnCurrentSelection();
    8279    }
    8380
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectModWaysAction.java

    r30737 r32333  
    1010import org.openstreetmap.josm.actions.JosmAction;
    1111import org.openstreetmap.josm.command.Command;
     12import org.openstreetmap.josm.data.osm.DataSet;
    1213import org.openstreetmap.josm.data.osm.Node;
    1314import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    3435    @Override
    3536    public void actionPerformed(ActionEvent e) {
    36         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     37        DataSet ds = getLayerManager().getEditDataSet();
     38        Collection<OsmPrimitive> selection = ds.getSelected();
    3739        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
    38         getCurrentDataSet().clearSelection(selectedNodes);
    39         Command cmd =null;
     40        ds.clearSelection(selectedNodes);
     41        Command cmd;
    4042
    4143        if (Main.main.undoRedo.commands == null) return;
     
    6163                if (p instanceof Way && !p.isDeleted()) ways.add((Way)p);
    6264            }
    63             if (!ways.isEmpty() && !getCurrentDataSet().getSelected().containsAll(ways)) {
    64                 getCurrentDataSet().setSelected(ways);
     65            if (!ways.isEmpty() && !ds.getSelected().containsAll(ways)) {
     66                ds.setSelected(ways);
    6567                lastCmd = cmd; // remember last used command and last selection
    66                 lastHash = getCurrentDataSet().getSelected().hashCode();
     68                lastHash = ds.getSelected().hashCode();
    6769                return;
    6870                }
     
    7476    @Override
    7577    protected void updateEnabledState() {
    76         if (getCurrentDataSet() == null) {
    77             setEnabled(false);
    78         } else {
    79             updateEnabledState(getCurrentDataSet().getSelected());
    80         }
     78        updateEnabledStateOnCurrentSelection();
    8179    }
    8280
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectWayNodesAction.java

    r30737 r32333  
    4141    @Override
    4242    public void actionPerformed(ActionEvent e) {
    43         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     43        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
    4444
    4545        for (OsmPrimitive p : selection) {
     
    6060        }
    6161           
    62         getCurrentDataSet().setSelected(selectedNodes);
     62        getLayerManager().getEditDataSet().setSelected(selectedNodes);
    6363        selectedNodes = null;
    6464    }
     
    7676    @Override
    7777    protected void updateEnabledState() {
    78         if (getCurrentDataSet() == null) {
    79             setEnabled(false);
    80         } else {
    81             updateEnabledState(getCurrentDataSet().getSelected());
    82         }
     78        updateEnabledStateOnCurrentSelection();
    8379    }
    8480
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UndoSelectionAction.java

    r30737 r32333  
    3434    @Override
    3535    public void actionPerformed(ActionEvent e) {
    36         LinkedList<Collection<? extends OsmPrimitive>> history
    37                     = getCurrentDataSet().getSelectionHistory();
     36        DataSet ds = getLayerManager().getEditDataSet();
     37        LinkedList<Collection<? extends OsmPrimitive>> history = ds.getSelectionHistory();
    3838        if (history==null || history.isEmpty()) return; // empty history
    3939        int num=history.size();
    4040       
    41         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
    42 
     41        Collection<OsmPrimitive> selection = ds.getSelected();
    4342
    4443        if (selection!= null &&  selection.hashCode() != myAutomaticSelectionHash) {
     
    5554            newsel.clear();
    5655            newsel.addAll(histsel);
    57             newsel.retainAll(getCurrentDataSet().allNonDeletedPrimitives());
     56            newsel.retainAll(ds.allNonDeletedPrimitives());
    5857            if (newsel.size() > 0 ) break;
    5958            k++;
    6059        } while ( k < num );
    6160
    62         getCurrentDataSet().setSelected(newsel);
    63         lastSel = getCurrentDataSet().getSelected();
     61        ds.setSelected(newsel);
     62        lastSel = ds.getSelected();
    6463        myAutomaticSelectionHash = lastSel.hashCode();
    6564        // remeber last automatic selection
     
    6867    @Override
    6968    protected void updateEnabledState() {
    70         if (getCurrentDataSet() == null) {
    71             setEnabled(false);
    72         } else {
    73             updateEnabledState(getCurrentDataSet().getSelected());
    74         }
     69        updateEnabledStateOnCurrentSelection();
    7570    }
    7671
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UnselectNodesAction.java

    r29769 r32333  
    1515
    1616/**
    17  *    Unselects all nodes
     17 * Unselects all nodes
    1818 */
    1919public class UnselectNodesAction extends JosmAction {
    2020
    21    
     21    /**
     22     * Constructs a new {@code UnselectNodesAction}.
     23     */
    2224    public UnselectNodesAction() {
    2325        super(tr("Unselect nodes"), "unsnodes",
     
    3032    @Override
    3133    public void actionPerformed(ActionEvent e) {
    32         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
     34        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
    3335        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
    34         getCurrentDataSet().clearSelection(selectedNodes);
     36        getLayerManager().getEditDataSet().clearSelection(selectedNodes);
    3537    }
    3638
    3739    @Override
    3840    protected void updateEnabledState() {
    39         if (getCurrentDataSet() == null) {
    40             setEnabled(false);
    41         } else {
    42             updateEnabledState(getCurrentDataSet().getSelected());
    43         }
     41        updateEnabledStateOnCurrentSelection();
    4442    }
    4543
Note: See TracChangeset for help on using the changeset viewer.