Changeset 12691 in josm for trunk/src/org


Ignore:
Timestamp:
2017-08-28T19:26:47+02:00 (7 years ago)
Author:
Don-vip
Message:

see #15182 - introduce Main.getEditDataSet to avoid unneeded GUI dependence in validator tests and tagging presets

Location:
trunk/src/org/openstreetmap/josm
Files:
9 edited

Legend:

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

    r12665 r12691  
    632632
    633633    /**
     634     * Gets the data set of the active edit layer.
     635     * @return That data set, <code>null</code> if there is no edit layer.
     636     * @since 12691
     637     */
     638    public DataSet getEditDataSet() {
     639        return null;
     640    }
     641
     642    /**
    634643     * Registers a {@code JosmAction} and its shortcut.
    635644     * @param action action defining its own shortcut
  • trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java

    r12636 r12691  
    8686     */
    8787    public synchronized void add(final Command c) {
    88         DataSet ds = Optional.ofNullable(c.getAffectedDataSet()).orElseGet(() -> MainApplication.getLayerManager().getEditDataSet());
     88        DataSet ds = Optional.ofNullable(c.getAffectedDataSet()).orElseGet(() -> Main.main.getEditDataSet());
    8989        Collection<? extends OsmPrimitive> oldSelection = null;
    9090        if (ds != null) {
     
    115115        if (commands.isEmpty())
    116116            return;
    117         DataSet ds = MainApplication.getLayerManager().getEditDataSet();
     117        DataSet ds = Main.main.getEditDataSet();
    118118        Collection<? extends OsmPrimitive> oldSelection = null;
    119119        if (ds != null) {
     
    156156        if (redoCommands.isEmpty())
    157157            return;
    158         DataSet ds = MainApplication.getLayerManager().getEditDataSet();
     158        DataSet ds = Main.main.getEditDataSet();
    159159        Collection<? extends OsmPrimitive> oldSelection = ds.getSelected();
    160160        for (int i = 0; i < num; ++i) {
  • trunk/src/org/openstreetmap/josm/data/osm/FilterModel.java

    r12656 r12691  
    9696     */
    9797    public void executeFilters() {
    98         DataSet ds = MainApplication.getLayerManager().getEditDataSet();
     98        DataSet ds = Main.main.getEditDataSet();
    9999        changed = false;
    100100        if (ds == null) {
     
    145145     */
    146146    public void executeFilters(Collection<? extends OsmPrimitive> primitives) {
    147         DataSet ds = MainApplication.getLayerManager().getEditDataSet();
     147        DataSet ds = Main.main.getEditDataSet();
    148148        if (ds == null)
    149149            return;
     
    207207     */
    208208    public void clearFilterFlags() {
    209         DataSet ds = MainApplication.getLayerManager().getEditDataSet();
     209        DataSet ds = Main.main.getEditDataSet();
    210210        if (ds != null) {
    211211            FilterWorker.clearFilterFlags(ds.allPrimitives());
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r12649 r12691  
    3232import org.openstreetmap.josm.data.validation.Test;
    3333import org.openstreetmap.josm.data.validation.TestError;
    34 import org.openstreetmap.josm.gui.MainApplication;
    3534import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    3635import org.openstreetmap.josm.tools.Logging;
     
    169168        mindist = Main.pref.getDouble(PREFIX + ".node_way_distance", 10.0);
    170169        minmiddledist = Main.pref.getDouble(PREFIX + ".way_way_distance", 0.0);
    171         DataSet dataSet = MainApplication.getLayerManager().getEditDataSet();
     170        DataSet dataSet = Main.main.getEditDataSet();
    172171        dsArea = dataSet == null ? null : dataSet.getDataSourceArea();
    173172    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java

    r12636 r12691  
    99import java.util.Set;
    1010
     11import org.openstreetmap.josm.Main;
    1112import org.openstreetmap.josm.command.Command;
    1213import org.openstreetmap.josm.data.osm.DataSet;
     
    1819import org.openstreetmap.josm.data.validation.Test;
    1920import org.openstreetmap.josm.data.validation.TestError;
    20 import org.openstreetmap.josm.gui.MainApplication;
    2121import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    2222
     
    142142    public void startTest(ProgressMonitor monitor) {
    143143        super.startTest(monitor);
    144         DataSet ds = MainApplication.getLayerManager().getEditDataSet();
     144        DataSet ds = Main.main.getEditDataSet();
    145145        if (ds == null)
    146146            return;
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r12686 r12691  
    397397    }
    398398
     399    @Override
     400    public DataSet getEditDataSet() {
     401        return getLayerManager().getEditDataSet();
     402    }
     403
    399404    /**
    400405     * Returns the command-line arguments used to run the application.
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

    r12656 r12691  
    382382            return;
    383383        }
    384         DataSet ds = MainApplication.getLayerManager().getEditDataSet();
     384        DataSet ds = Main.main.getEditDataSet();
    385385        Collection<OsmPrimitive> participants = Collections.emptyList();
    386         if (Main.main != null && ds != null) {
     386        if (ds != null) {
    387387            participants = ds.getSelected();
    388388        }
     
    556556
    557557    protected final void updateEnabledState() {
    558         setEnabled(Main.main != null && MainApplication.getLayerManager().getEditDataSet() != null);
     558        setEnabled(Main.main != null && Main.main.getEditDataSet() != null);
    559559    }
    560560
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSearchPrimitiveDialog.java

    r12637 r12691  
    8787            TaggingPreset preset = selector.getSelectedPresetAndUpdateClassification();
    8888            if (preset != null) {
    89                 final Set<OsmPrimitive> matching = new HashSet<>(MainApplication.getLayerManager().getEditDataSet().getPrimitives(preset));
    90                 MainApplication.getLayerManager().getEditDataSet().setSelected(matching);
     89                final Set<OsmPrimitive> matching = new HashSet<>(Main.main.getEditDataSet().getPrimitives(preset));
     90                Main.main.getEditDataSet().setSelected(matching);
    9191            }
    9292        }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSelector.java

    r12637 r12691  
    236236        boolean inTags = ckSearchInTags != null && ckSearchInTags.isSelected();
    237237
    238         DataSet ds = MainApplication.getLayerManager().getEditDataSet();
     238        DataSet ds = Main.main.getEditDataSet();
    239239        Collection<OsmPrimitive> selected = (ds == null) ? Collections.<OsmPrimitive>emptyList() : ds.getSelected();
    240240        final List<PresetClassification> result = classifications.getMatchingPresets(
     
    356356                typesInSelectionDirty = false;
    357357                typesInSelection.clear();
    358                 if (Main.main == null || MainApplication.getLayerManager().getEditDataSet() == null) return typesInSelection;
    359                 for (OsmPrimitive primitive : MainApplication.getLayerManager().getEditDataSet().getSelected()) {
     358                if (Main.main == null || Main.main.getEditDataSet() == null) return typesInSelection;
     359                for (OsmPrimitive primitive : Main.main.getEditDataSet().getSelected()) {
    360360                    typesInSelection.add(TaggingPresetType.forPrimitive(primitive));
    361361                }
Note: See TracChangeset for help on using the changeset viewer.