Ignore:
Timestamp:
2016-06-22T00:48:51+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #13023 - Replace uses of hasEditLayer() with new layer manager (patch by michael2402, modified) - gsoc-core

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java

    r10446 r10453  
    7474     */
    7575    public static void zoomToSelection() {
    76         if (Main.main == null || !Main.main.hasEditLayer())
     76        DataSet dataSet = Main.getLayerManager().getEditDataSet();
     77        if (dataSet == null) {
    7778            return;
    78         Collection<OsmPrimitive> sel = Main.getLayerManager().getEditLayer().data.getSelected();
     79        }
     80        Collection<OsmPrimitive> sel = dataSet.getSelected();
    7981        if (sel.isEmpty()) {
    8082            JOptionPane.showMessageDialog(
     
    279281        Collection<OsmPrimitive> sel = new HashSet<>();
    280282        if ("selection".equals(mode)) {
    281             sel = getLayerManager().getEditDataSet().getSelected();
     283            DataSet dataSet = getLayerManager().getEditDataSet();
     284            if (dataSet != null) {
     285                sel = dataSet.getSelected();
     286            }
    282287        } else {
    283288            Conflict<? extends OsmPrimitive> c = Main.map.conflictDialog.getSelectedConflict();
  • trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java

    r10448 r10453  
    135135    @Override
    136136    public void actionPerformed(ActionEvent e) {
    137         if (!Main.main.hasEditLayer()) {
     137        DataSet dataSet = Main.getLayerManager().getEditDataSet();
     138        if (dataSet == null) {
    138139            new Notification(
    139140                    tr("No data loaded."))
     
    144145        }
    145146
    146         final Collection<Way> selectedWays = Main.getLayerManager().getEditDataSet().getSelectedWays();
     147        final Collection<Way> selectedWays = dataSet.getSelectedWays();
    147148
    148149        if (selectedWays.isEmpty()) {
     
    157158        }
    158159
    159         final Collection<Relation> selectedRelations = Main.getLayerManager().getEditDataSet().getSelectedRelations();
     160        final Collection<Relation> selectedRelations = dataSet.getSelectedRelations();
    160161        final Relation multipolygonRelation = update
    161162                ? getSelectedMultipolygonRelation(selectedWays, selectedRelations)
  • trunk/src/org/openstreetmap/josm/actions/ViewportFollowToggleAction.java

    r7937 r10453  
    4242    @Override
    4343    protected void updateEnabledState() {
    44         setEnabled(Main.main.hasEditLayer());
     44        setEnabled(Main.getLayerManager().getEditDataSet() != null);
    4545    }
    4646}
  • trunk/src/org/openstreetmap/josm/actions/WireframeToggleAction.java

    r8510 r10453  
    3737    @Override
    3838    protected void updateEnabledState() {
    39         setEnabled(Main.main.hasEditLayer());
     39        setEnabled(Main.getLayerManager().getEditLayer() != null);
    4040    }
    4141
  • trunk/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java

    r10428 r10453  
    1010import org.openstreetmap.josm.actions.mapmode.DeleteAction;
    1111import org.openstreetmap.josm.data.osm.Relation;
     12import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1213import org.openstreetmap.josm.tools.ImageProvider;
    1314
     
    2829
    2930    protected void deleteRelation(Collection<Relation> toDelete) {
    30         if (toDelete == null)
     31        OsmDataLayer layer = Main.getLayerManager().getEditLayer();
     32        if (toDelete == null || layer == null)
    3133            return;
    32         DeleteAction.deleteRelations(Main.getLayerManager().getEditLayer(), toDelete);
     34
     35        DeleteAction.deleteRelations(layer, toDelete);
    3336        // clear selection after deletion
    3437        if (Main.map.relationListDialog != null)
     
    3841    @Override
    3942    public void actionPerformed(ActionEvent e) {
    40         if (!isEnabled() || !Main.main.hasEditLayer())
     43        if (!isEnabled())
    4144            return;
    4245        deleteRelation(relations);
Note: See TracChangeset for help on using the changeset viewer.