Changeset 14143 in josm for trunk


Ignore:
Timestamp:
2018-08-12T14:27:32+02:00 (6 years ago)
Author:
Don-vip
Message:

see #15229 - deprecate Main.main - new class OsmDataManager

Location:
trunk
Files:
2 added
28 edited

Legend:

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

    r14140 r14143  
    44import java.awt.Component;
    55import java.net.URL;
    6 import java.util.Collection;
    7 import java.util.Collections;
    86import java.util.Map;
    97import java.util.Set;
     
    119import org.openstreetmap.josm.data.Preferences;
    1210import org.openstreetmap.josm.data.UndoRedoHandler;
    13 import org.openstreetmap.josm.data.osm.DataSet;
    14 import org.openstreetmap.josm.data.osm.IPrimitive;
    15 import org.openstreetmap.josm.data.osm.OsmData;
    16 import org.openstreetmap.josm.data.osm.OsmPrimitive;
     11import org.openstreetmap.josm.data.osm.IOsmDataManager;
    1712import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
    1813import org.openstreetmap.josm.data.projection.Projection;
     
    3227 * @since 98
    3328 */
    34 public abstract class Main {
     29public abstract class Main implements IOsmDataManager {
    3530
    3631    /**
     
    4136    /**
    4237     * Global application.
    43      */
     38     * @deprecated Not needed anymore
     39     */
     40    @Deprecated
    4441    public static volatile Main main;
    4542
     
    8380        main = instance;
    8481    }
    85 
    86     /**
    87      * Replies the current selected OSM primitives, from a end-user point of view.
    88      * It is not always technically the same collection of primitives than {@link DataSet#getSelected()}.
    89      * @return The current selected OSM primitives, from a end-user point of view. Can be {@code null}.
    90      * @since 6546
    91      */
    92     public Collection<OsmPrimitive> getInProgressSelection() {
    93         return Collections.emptyList();
    94     }
    95 
    96     /**
    97      * Replies the current selected primitives, from a end-user point of view.
    98      * It is not always technically the same collection of primitives than {@link OsmData#getSelected()}.
    99      * @return The current selected primitives, from a end-user point of view. Can be {@code null}.
    100      * @since 13926
    101      */
    102     public Collection<? extends IPrimitive> getInProgressISelection() {
    103         return Collections.emptyList();
    104     }
    105 
    106     /**
    107      * Gets the active edit data set (not read-only).
    108      * @return That data set, <code>null</code>.
    109      * @see #getActiveDataSet
    110      * @since 12691
    111      */
    112     public abstract DataSet getEditDataSet();
    113 
    114     /**
    115      * Gets the active data set (can be read-only).
    116      * @return That data set, <code>null</code>.
    117      * @see #getEditDataSet
    118      * @since 13434
    119      */
    120     public abstract DataSet getActiveDataSet();
    121 
    122     /**
    123      * Sets the active data set (and also edit data set if not read-only).
    124      * @param ds New data set, or <code>null</code>
    125      * @since 13434
    126      */
    127     public abstract void setActiveDataSet(DataSet ds);
    128 
    129     /**
    130      * Determines if the list of data sets managed by JOSM contains {@code ds}.
    131      * @param ds the data set to look for
    132      * @return {@code true} if the list of data sets managed by JOSM contains {@code ds}
    133      * @since 12718
    134      */
    135     public abstract boolean containsDataSet(DataSet ds);
    13682
    13783    ///////////////////////////////////////////////////////////////////////////
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r14135 r14143  
    2323import javax.swing.JOptionPane;
    2424
    25 import org.openstreetmap.josm.Main;
    2625import org.openstreetmap.josm.actions.ReverseWayAction.ReverseWayResult;
    2726import org.openstreetmap.josm.command.AddCommand;
     
    833832
    834833    private void commitCommand(Command c) {
    835         if (Main.main != null && addUndoRedo) {
     834        if (addUndoRedo) {
    836835            UndoRedoHandler.getInstance().add(c);
    837836        } else {
     
    16001599    private void makeCommitsOneAction(String message) {
    16011600        cmds.clear();
    1602         if (Main.main != null && addUndoRedo) {
     1601        if (addUndoRedo) {
    16031602            UndoRedoHandler ur = UndoRedoHandler.getInstance();
    16041603            int i = Math.max(ur.commands.size() - cmdsCount, 0);
  • trunk/src/org/openstreetmap/josm/actions/RedoAction.java

    r14134 r14143  
    88import java.awt.event.KeyEvent;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.UndoRedoHandler;
    1211import org.openstreetmap.josm.data.UndoRedoHandler.CommandQueueListener;
     
    4342    @Override
    4443    protected void updateEnabledState() {
    45         setEnabled(Main.main != null && !UndoRedoHandler.getInstance().redoCommands.isEmpty());
     44        setEnabled(!UndoRedoHandler.getInstance().redoCommands.isEmpty());
    4645    }
    4746
  • trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

    r14138 r14143  
    181181            text.append("Program arguments: ").append(Arrays.toString(paramCleanup(commandLineArgs).toArray())).append('\n');
    182182        }
    183         if (Main.main != null) {
    184             DataSet dataset = MainApplication.getLayerManager().getActiveDataSet();
    185             if (dataset != null) {
    186                 String result = DatasetConsistencyTest.runTests(dataset);
    187                 if (result.isEmpty()) {
    188                     text.append("Dataset consistency test: No problems found\n");
    189                 } else {
    190                     text.append("\nDataset consistency test:\n").append(result).append('\n');
    191                 }
     183        DataSet dataset = MainApplication.getLayerManager().getActiveDataSet();
     184        if (dataset != null) {
     185            String result = DatasetConsistencyTest.runTests(dataset);
     186            if (result.isEmpty()) {
     187                text.append("Dataset consistency test: No problems found\n");
     188            } else {
     189                text.append("\nDataset consistency test:\n").append(result).append('\n');
    192190            }
    193191        }
  • trunk/src/org/openstreetmap/josm/actions/UndoAction.java

    r14134 r14143  
    88import java.awt.event.KeyEvent;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.UndoRedoHandler;
    1211import org.openstreetmap.josm.data.UndoRedoHandler.CommandQueueListener;
     
    4342    @Override
    4443    protected void updateEnabledState() {
    45         setEnabled(Main.main != null && !UndoRedoHandler.getInstance().commands.isEmpty());
     44        setEnabled(!UndoRedoHandler.getInstance().commands.isEmpty());
    4645    }
    4746
  • trunk/src/org/openstreetmap/josm/actions/ZoomToAction.java

    r13434 r14143  
    1010import javax.swing.event.ListSelectionListener;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1413import org.openstreetmap.josm.gui.MainApplication;
     
    105104
    106105    protected final void updateEnabledState() {
    107         if (Main.main == null || MainApplication.getLayerManager().getActiveDataLayer() != this.table.getLayer()) {
     106        if (MainApplication.getLayerManager().getActiveDataLayer() != this.table.getLayer()) {
    108107            setEnabled(false);
    109108            putValue(SHORT_DESCRIPTION, descriptionInactiveLayer);
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWays.java

    r14134 r14143  
    1111import java.util.Set;
    1212
    13 import org.openstreetmap.josm.Main;
    1413import org.openstreetmap.josm.command.AddCommand;
    1514import org.openstreetmap.josm.command.Command;
     
    2019import org.openstreetmap.josm.data.osm.Node;
    2120import org.openstreetmap.josm.data.osm.NodeGraph;
     21import org.openstreetmap.josm.data.osm.OsmDataManager;
    2222import org.openstreetmap.josm.data.osm.Way;
    2323import org.openstreetmap.josm.tools.Geometry;
     
    190190
    191191    private List<Command> makeAddWayAndNodesCommandList() {
    192         DataSet ds = Main.main.getEditDataSet();
     192        DataSet ds = OsmDataManager.getInstance().getEditDataSet();
    193193        List<Command> commands = new ArrayList<>(sortedNodes.size() + ways.size());
    194194        for (int i = 0; i < sortedNodes.size() - (isClosedPath() ? 1 : 0); i++) {
  • trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java

    r13852 r14143  
    219219     *
    220220     * Note that changes are not applied to the data yet. You have to
    221      * submit the command first, i.e. {@code Main.main.undoredo.add(result)}.
     221     * submit the command first, i.e. {@code UndoRedoHandler.getInstance().add(result)}.
    222222     *
    223223     * @param way the way to split. Must not be null.
     
    237237     *
    238238     * Note that changes are not applied to the data yet. You have to
    239      * submit the command first, i.e. {@code Main.main.undoredo.add(result)}.
     239     * submit the command first, i.e. {@code UndoRedoHandler.getInstance().add(result)}.
    240240     *
    241241     * @param way the way to split. Must not be null.
     
    464464     *
    465465     * Note that changes are not applied to the data yet. You have to
    466      * submit the command first, i.e. {@code Main.main.undoredo.add(result)}.
     466     * submit the command first, i.e. {@code UndoRedoHandler.getInstance().add(result)}.
    467467     *
    468468     * Replies null if the way couldn't be split at the given nodes.
  • trunk/src/org/openstreetmap/josm/command/conflict/ConflictAddCommand.java

    r13173 r14143  
    1515import org.openstreetmap.josm.data.osm.DataSet;
    1616import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
     17import org.openstreetmap.josm.data.osm.OsmDataManager;
    1718import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1819import org.openstreetmap.josm.tools.ImageProvider;
     
    6667    public void undoCommand() {
    6768        DataSet ds = getAffectedDataSet();
    68         if (Main.main != null && !Main.main.containsDataSet(ds)) {
     69        if (!OsmDataManager.getInstance().containsDataSet(ds)) {
    6970            Logging.warn(tr("Layer ''{0}'' does not exist any more. Cannot remove conflict for object ''{1}''.",
    7071                    ds.getName(),
  • trunk/src/org/openstreetmap/josm/command/conflict/ConflictResolveCommand.java

    r13434 r14143  
    66import java.util.Objects;
    77
    8 import org.openstreetmap.josm.Main;
    98import org.openstreetmap.josm.command.Command;
    109import org.openstreetmap.josm.data.conflict.Conflict;
    1110import org.openstreetmap.josm.data.conflict.ConflictCollection;
    1211import org.openstreetmap.josm.data.osm.DataSet;
     12import org.openstreetmap.josm.data.osm.OsmDataManager;
    1313import org.openstreetmap.josm.tools.Logging;
    1414
     
    6363
    6464        DataSet ds = getAffectedDataSet();
    65         if (Main.main != null) {
    66             if (!Main.main.containsDataSet(ds)) {
    67                 Logging.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more",
    68                         this.toString(),
    69                         ds.getName()
    70                 ));
    71                 return;
    72             }
     65        if (!OsmDataManager.getInstance().containsDataSet(ds)) {
     66            Logging.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more",
     67                    this.toString(),
     68                    ds.getName()
     69            ));
     70            return;
     71        }
    7372
    74             Main.main.setActiveDataSet(ds);
    75         }
     73        OsmDataManager.getInstance().setActiveDataSet(ds);
    7674        reconstituteConflicts();
    7775    }
  • trunk/src/org/openstreetmap/josm/command/conflict/RelationMemberConflictResolverCommand.java

    r13434 r14143  
    1010import javax.swing.Icon;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.conflict.Conflict;
    1413import org.openstreetmap.josm.data.osm.DataSet;
     14import org.openstreetmap.josm.data.osm.OsmDataManager;
    1515import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1616import org.openstreetmap.josm.data.osm.Relation;
     
    7373    public void undoCommand() {
    7474        DataSet ds = getAffectedDataSet();
    75         if (!Main.main.containsDataSet(ds)) {
     75        if (!OsmDataManager.getInstance().containsDataSet(ds)) {
    7676            Logging.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more",
    7777                    this.toString(),
     
    8181        }
    8282
    83         Main.main.setActiveDataSet(ds);
     83        OsmDataManager.getInstance().setActiveDataSet(ds);
    8484
    8585        // restore the former state
  • trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java

    r14134 r14143  
    77import java.util.Objects;
    88
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.command.Command;
    1110import org.openstreetmap.josm.data.osm.DataSet;
     11import org.openstreetmap.josm.data.osm.OsmDataManager;
    1212import org.openstreetmap.josm.spi.preferences.Config;
    1313import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    291291        if (commands.isEmpty())
    292292            return;
    293         DataSet ds = Main.main.getEditDataSet();
     293        DataSet ds = OsmDataManager.getInstance().getEditDataSet();
    294294        if (ds != null) {
    295295            ds.beginUpdate();
  • trunk/src/org/openstreetmap/josm/data/osm/FilterModel.java

    r13434 r14143  
    9898     */
    9999    public void executeFilters() {
    100         DataSet ds = Main.main.getActiveDataSet();
     100        DataSet ds = OsmDataManager.getInstance().getActiveDataSet();
    101101        changed = false;
    102102        if (ds == null) {
     
    150150     */
    151151    public void executeFilters(Collection<? extends OsmPrimitive> primitives) {
    152         DataSet ds = Main.main.getEditDataSet();
     152        DataSet ds = OsmDataManager.getInstance().getEditDataSet();
    153153        if (ds == null)
    154154            return;
     
    209209     */
    210210    public void clearFilterFlags() {
    211         DataSet ds = Main.main.getEditDataSet();
     211        DataSet ds = OsmDataManager.getInstance().getEditDataSet();
    212212        if (ds != null) {
    213213            FilterWorker.clearFilterFlags(ds.allPrimitives());
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r13942 r14143  
    1818import java.util.Set;
    1919
    20 import org.openstreetmap.josm.Main;
    2120import org.openstreetmap.josm.data.coor.EastNorth;
    2221import org.openstreetmap.josm.data.coor.LatLon;
     
    2423import org.openstreetmap.josm.data.osm.DataSet;
    2524import org.openstreetmap.josm.data.osm.Node;
     25import org.openstreetmap.josm.data.osm.OsmDataManager;
    2626import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2727import org.openstreetmap.josm.data.osm.QuadBuckets;
     
    169169        mindist = Config.getPref().getDouble(PREFIX + ".node_way_distance", 10.0);
    170170        minmiddledist = Config.getPref().getDouble(PREFIX + ".way_way_distance", 0.0);
    171         DataSet dataSet = Main.main != null ? Main.main.getEditDataSet() : null;
     171        DataSet dataSet = OsmDataManager.getInstance().getEditDataSet();
    172172        dsArea = dataSet == null ? null : dataSet.getDataSourceArea();
    173173    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java

    r12691 r14143  
    99import java.util.Set;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.command.Command;
    1312import org.openstreetmap.josm.data.osm.DataSet;
     13import org.openstreetmap.josm.data.osm.OsmDataManager;
    1414import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1515import org.openstreetmap.josm.data.osm.Relation;
     
    142142    public void startTest(ProgressMonitor monitor) {
    143143        super.startTest(monitor);
    144         DataSet ds = Main.main.getEditDataSet();
     144        DataSet ds = OsmDataManager.getInstance().getEditDataSet();
    145145        if (ds == null)
    146146            return;
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r14140 r14143  
    7878import org.openstreetmap.josm.actions.downloadtasks.DownloadTask;
    7979import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler;
    80 import org.openstreetmap.josm.actions.mapmode.DrawAction;
    8180import org.openstreetmap.josm.actions.search.SearchAction;
    8281import org.openstreetmap.josm.cli.CLIModule;
     
    9089import org.openstreetmap.josm.data.osm.DataSet;
    9190import org.openstreetmap.josm.data.osm.IPrimitive;
    92 import org.openstreetmap.josm.data.osm.OsmData;
     91import org.openstreetmap.josm.data.osm.OsmDataManager;
    9392import org.openstreetmap.josm.data.osm.OsmPrimitive;
    9493import org.openstreetmap.josm.data.osm.UserInfo;
     
    418417    }
    419418
     419    /**
     420     * @deprecated Use {@code OsmDataManager.getInstance().getInProgressSelection()}
     421     */
     422    @Deprecated
    420423    @Override
    421424    public Collection<OsmPrimitive> getInProgressSelection() {
    422         if (map != null && map.mapMode instanceof DrawAction) {
    423             return ((DrawAction) map.mapMode).getInProgressSelection();
    424         } else {
    425             DataSet ds = layerManager.getActiveDataSet();
    426             if (ds == null) return Collections.emptyList();
    427             return ds.getSelected();
    428         }
    429     }
    430 
     425        return OsmDataManager.getInstance().getInProgressSelection();
     426    }
     427
     428    /**
     429     * @deprecated Use {@code OsmDataManager.getInstance().getInProgressSelection()}
     430     */
     431    @Deprecated
    431432    @Override
    432433    public Collection<? extends IPrimitive> getInProgressISelection() {
    433         if (map != null && map.mapMode instanceof DrawAction) {
    434             return ((DrawAction) map.mapMode).getInProgressSelection();
    435         } else {
    436             OsmData<?, ?, ?, ?> ds = layerManager.getActiveData();
    437             if (ds == null) return Collections.emptyList();
    438             return ds.getSelected();
    439         }
    440     }
    441 
     434        return OsmDataManager.getInstance().getInProgressSelection();
     435    }
     436
     437    /**
     438     * @deprecated Use {@code OsmDataManager.getInstance().getEditDataSet()}
     439     */
     440    @Deprecated
    442441    @Override
    443442    public DataSet getEditDataSet() {
    444         return getLayerManager().getEditDataSet();
    445     }
    446 
     443        return OsmDataManager.getInstance().getEditDataSet();
     444    }
     445
     446    /**
     447     * @deprecated Use {@code OsmDataManager.getInstance().getActiveDataSet()}
     448     */
     449    @Deprecated
    447450    @Override
    448451    public DataSet getActiveDataSet() {
    449         return getLayerManager().getActiveDataSet();
    450     }
    451 
     452        return OsmDataManager.getInstance().getActiveDataSet();
     453    }
     454
     455    /**
     456     * @deprecated Use {@code OsmDataManager.getInstance().setActiveDataSet}
     457     */
     458    @Deprecated
    452459    @Override
    453460    public void setActiveDataSet(DataSet ds) {
    454         Optional<OsmDataLayer> layer = getLayerManager().getLayersOfType(OsmDataLayer.class).stream()
    455                 .filter(l -> l.data.equals(ds)).findFirst();
    456         if (layer.isPresent()) {
    457             getLayerManager().setActiveLayer(layer.get());
    458         }
    459     }
    460 
     461        OsmDataManager.getInstance().setActiveDataSet(ds);
     462    }
     463
     464    /**
     465     * @deprecated Use {@code OsmDataManager.getInstance().containsDataSet}
     466     */
     467    @Deprecated
    461468    @Override
    462469    public boolean containsDataSet(DataSet ds) {
     
    488495     * @return the MapFrame
    489496     * @see MainPanel
    490      * @since 12630 (as a replacement to {@code Main.map})
     497     * @since 12630
    491498     */
    492499    public static MapFrame getMap() {
     
    497504     * Returns the main panel.
    498505     * @return the main panel
    499      * @since 12642 (as a replacement to {@code Main.main.panel})
     506     * @since 12642
    500507     */
    501508    public static MainPanel getMainPanel() {
     
    515522     * Returns the toolbar preference control to register new actions.
    516523     * @return the toolbar preference control
    517      * @since 12637 (as a replacement to {@code Main.toolbar})
     524     * @since 12637
    518525     */
    519526    public static ToolbarPreferences getToolbar() {
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/AbstractTagPaster.java

    r14134 r14143  
    1414import javax.swing.TransferHandler.TransferSupport;
    1515
    16 import org.openstreetmap.josm.Main;
    1716import org.openstreetmap.josm.command.ChangePropertyCommand;
    1817import org.openstreetmap.josm.command.Command;
     
    2019import org.openstreetmap.josm.data.UndoRedoHandler;
    2120import org.openstreetmap.josm.data.coor.EastNorth;
     21import org.openstreetmap.josm.data.osm.OsmDataManager;
    2222import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2323import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    4949    public boolean importTagsOn(TransferSupport support, Collection<? extends OsmPrimitive> selection)
    5050            throws UnsupportedFlavorException, IOException {
    51         ChangePropertyCommand command = new ChangePropertyCommand(Main.main.getEditDataSet(), selection, getTags(support));
     51        ChangePropertyCommand command = new ChangePropertyCommand(OsmDataManager.getInstance().getEditDataSet(), selection, getTags(support));
    5252        commitCommands(selection, Collections.singletonList(command));
    5353        return true;
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/PrimitiveTagTransferPaster.java

    r12920 r14143  
    1919import org.openstreetmap.josm.data.osm.IPrimitive;
    2020import org.openstreetmap.josm.data.osm.Node;
     21import org.openstreetmap.josm.data.osm.OsmDataManager;
    2122import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2223import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     
    5354            Map<String, String> tags = new HashMap<>(1);
    5455            tags.put(tag.getKey(), "".equals(tag.getValue()) ? null : tag.getValue());
    55             ChangePropertyCommand cmd = new ChangePropertyCommand(Main.main.getEditDataSet(), selection, tags);
     56            ChangePropertyCommand cmd = new ChangePropertyCommand(OsmDataManager.getInstance().getEditDataSet(), selection, tags);
    5657            if (cmd.getObjectsNumber() > 0) {
    5758                commands.add(cmd);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r13649 r14143  
    268268     */
    269269    protected void registerInWindowMenu() {
    270         if (Main.main != null) {
    271             windowMenuItem = MainMenu.addWithCheckbox(MainApplication.getMenu().windowMenu,
    272                     (JosmAction) getToggleAction(),
    273                     MainMenu.WINDOW_MENU_GROUP.TOGGLE_DIALOG);
    274         }
     270        windowMenuItem = MainMenu.addWithCheckbox(MainApplication.getMenu().windowMenu,
     271                (JosmAction) getToggleAction(),
     272                MainMenu.WINDOW_MENU_GROUP.TOGGLE_DIALOG);
    275273    }
    276274
     
    465463            hideNotify();
    466464        }
    467         if (Main.main != null) {
    468             MainApplication.getMenu().windowMenu.remove(windowMenuItem);
    469         }
     465        MainApplication.getMenu().windowMenu.remove(windowMenuItem);
    470466        try {
    471467            Toolkit.getDefaultToolkit().removeAWTEventListener(this);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r14134 r14143  
    1717import java.util.Arrays;
    1818import java.util.Collection;
    19 import java.util.Collections;
    2019import java.util.EnumSet;
    2120import java.util.HashMap;
     
    6968import org.openstreetmap.josm.data.osm.Node;
    7069import org.openstreetmap.josm.data.osm.OsmData;
     70import org.openstreetmap.josm.data.osm.OsmDataManager;
    7171import org.openstreetmap.josm.data.osm.OsmPrimitive;
    7272import org.openstreetmap.josm.data.osm.Relation;
     
    184184    private final PasteValueAction pasteValueAction = new PasteValueAction();
    185185    private final CopyValueAction copyValueAction = new CopyValueAction(
    186             tagTable, editHelper::getDataKey, Main.main::getInProgressISelection);
     186            tagTable, editHelper::getDataKey, OsmDataManager.getInstance()::getInProgressISelection);
    187187    private final CopyKeyValueAction copyKeyValueAction = new CopyKeyValueAction(
    188             tagTable, editHelper::getDataKey, Main.main::getInProgressISelection);
     188            tagTable, editHelper::getDataKey, OsmDataManager.getInstance()::getInProgressISelection);
    189189    private final CopyAllKeyValueAction copyAllKeyValueAction = new CopyAllKeyValueAction(
    190             tagTable, editHelper::getDataKey, Main.main::getInProgressISelection);
     190            tagTable, editHelper::getDataKey, OsmDataManager.getInstance()::getInProgressISelection);
    191191    private final SearchAction searchActionSame = new SearchAction(true);
    192192    private final SearchAction searchActionAny = new SearchAction(false);
     
    568568
    569569        // Ignore parameter as we do not want to operate always on real selection here, especially in draw mode
    570         Collection<? extends IPrimitive> newSel = Main.main.getInProgressISelection();
     570        Collection<? extends IPrimitive> newSel = OsmDataManager.getInstance().getInProgressISelection();
    571571        String selectedTag;
    572572        IRelation<?> selectedRelation = null;
     
    851851        @Override
    852852        public Collection<OsmPrimitive> getSelection() {
    853             return Main.main == null ? Collections.<OsmPrimitive>emptyList() : Main.main.getInProgressSelection();
     853            return OsmDataManager.getInstance().getInProgressSelection();
    854854        }
    855855    }
     
    10111011            }
    10121012
    1013             Collection<OsmPrimitive> sel = Main.main.getInProgressSelection();
     1013            Collection<OsmPrimitive> sel = OsmDataManager.getInstance().getInProgressSelection();
    10141014            UndoRedoHandler.getInstance().add(new ChangePropertyCommand(sel, tags));
    10151015
     
    10401040
    10411041            Relation rel = new Relation(cur);
    1042             for (OsmPrimitive primitive: Main.main.getInProgressSelection()) {
     1042            for (OsmPrimitive primitive: OsmDataManager.getInstance().getInProgressSelection()) {
    10431043                rel.removeMembersFor(primitive);
    10441044            }
     
    10691069        @Override
    10701070        protected final void updateEnabledState() {
    1071             DataSet ds = Main.main.getActiveDataSet();
     1071            DataSet ds = OsmDataManager.getInstance().getActiveDataSet();
    10721072            setEnabled(ds != null && !ds.isLocked() &&
    10731073                    ((tagTable != null && tagTable.getSelectedRowCount() >= 1)
     
    11371137        @Override
    11381138        protected void updateEnabledState() {
    1139             DataSet ds = Main.main.getActiveDataSet();
     1139            DataSet ds = OsmDataManager.getInstance().getActiveDataSet();
    11401140            setEnabled(ds != null && !ds.isLocked() &&
    11411141                    ((tagTable != null && tagTable.getSelectedRowCount() == 1)
     
    11611161                return;
    11621162            String key = editHelper.getDataKey(tagTable.getSelectedRow());
    1163             Collection<OsmPrimitive> sel = Main.main.getInProgressSelection();
     1163            Collection<OsmPrimitive> sel = OsmDataManager.getInstance().getInProgressSelection();
    11641164            String clipboard = ClipboardUtils.getClipboardStringContent();
    11651165            if (sel.isEmpty() || clipboard == null || sel.iterator().next().getDataSet().isLocked())
     
    11881188                return;
    11891189            String key = editHelper.getDataKey(tagTable.getSelectedRow());
    1190             Collection<? extends IPrimitive> sel = Main.main.getInProgressISelection();
     1190            Collection<? extends IPrimitive> sel = OsmDataManager.getInstance().getInProgressISelection();
    11911191            if (sel.isEmpty())
    11921192                return;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java

    r14138 r14143  
    6969import org.openstreetmap.josm.command.SequenceCommand;
    7070import org.openstreetmap.josm.data.UndoRedoHandler;
     71import org.openstreetmap.josm.data.osm.OsmDataManager;
    7172import org.openstreetmap.josm.data.osm.OsmPrimitive;
    7273import org.openstreetmap.josm.data.osm.Tag;
     
    232233    public void addTag() {
    233234        changedKey = null;
    234         sel = Main.main.getInProgressSelection();
     235        sel = OsmDataManager.getInstance().getInProgressSelection();
    235236        if (sel == null || sel.isEmpty())
    236237            return;
     
    263264    public void editTag(final int row, boolean focusOnKey) {
    264265        changedKey = null;
    265         sel = Main.main.getInProgressSelection();
     266        sel = OsmDataManager.getInstance().getInProgressSelection();
    266267        if (sel == null || sel.isEmpty())
    267268            return;
     
    448449            mainPanel.add(p, BorderLayout.CENTER);
    449450
    450             AutoCompletionManager autocomplete = AutoCompletionManager.of(Main.main.getActiveDataSet());
     451            AutoCompletionManager autocomplete = AutoCompletionManager.of(OsmDataManager.getInstance().getActiveDataSet());
    451452            List<AutoCompletionItem> keyList = autocomplete.getTagKeys(DEFAULT_AC_ITEM_COMPARATOR);
    452453
     
    565566        public void setupDialog() {
    566567            super.setupDialog();
    567             buttons.get(0).setEnabled(!Main.main.getActiveDataSet().isLocked());
     568            buttons.get(0).setEnabled(!OsmDataManager.getInstance().getActiveDataSet().isLocked());
    568569            final Dimension size = getSize();
    569570            // Set resizable only in width
     
    701702
    702703            cacheRecentTags();
    703             AutoCompletionManager autocomplete = AutoCompletionManager.of(Main.main.getActiveDataSet());
     704            AutoCompletionManager autocomplete = AutoCompletionManager.of(OsmDataManager.getInstance().getActiveDataSet());
    704705            List<AutoCompletionItem> keyList = autocomplete.getTagKeys(DEFAULT_AC_ITEM_COMPARATOR);
    705706
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java

    r13675 r14143  
    2121import javax.swing.event.ListSelectionListener;
    2222
    23 import org.openstreetmap.josm.Main;
    2423import org.openstreetmap.josm.actions.AutoScaleAction;
    2524import org.openstreetmap.josm.actions.ZoomToAction;
     
    249248
    250249        private void updateEnabledState() {
    251             setEnabled(Main.main != null
    252                     && MainApplication.getLayerManager().getEditLayer() == getLayer()
     250            setEnabled(MainApplication.getLayerManager().getEditLayer() == getLayer()
    253251                    && getSelectedRowCount() == 1
    254252                    && hasGap());
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r13654 r14143  
    1010import javax.swing.table.TableModel;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.UserIdentityManager;
    1413import org.openstreetmap.josm.data.osm.DataSet;
     
    102101        referenceRelationMemberTableModel = new DiffTableModel();
    103102
    104         if (Main.main != null) {
    105             DataSet ds = MainApplication.getLayerManager().getActiveDataSet();
    106             if (ds != null) {
    107                 ds.addDataSetListener(this);
    108             }
     103        DataSet ds = MainApplication.getLayerManager().getActiveDataSet();
     104        if (ds != null) {
     105            ds.addDataSetListener(this);
    109106        }
    110107        MainApplication.getLayerManager().addActiveLayerChangeListener(this);
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

    r14134 r14143  
    4141import org.openstreetmap.josm.data.osm.IPrimitive;
    4242import org.openstreetmap.josm.data.osm.OsmData;
     43import org.openstreetmap.josm.data.osm.OsmDataManager;
    4344import org.openstreetmap.josm.data.osm.OsmPrimitive;
    4445import org.openstreetmap.josm.data.osm.Relation;
     
    383384    @Override
    384385    public void actionPerformed(ActionEvent e) {
    385         if (Main.main == null) {
    386             return;
    387         }
    388         DataSet ds = Main.main.getEditDataSet();
     386        DataSet ds = OsmDataManager.getInstance().getEditDataSet();
    389387        Collection<OsmPrimitive> participants = Collections.emptyList();
    390388        if (ds != null) {
     
    565563
    566564    protected final void updateEnabledState() {
    567         setEnabled(Main.main != null && Main.main.getEditDataSet() != null);
     565        setEnabled(OsmDataManager.getInstance().getEditDataSet() != null);
    568566    }
    569567
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java

    r12846 r14143  
    1717import javax.swing.JPanel;
    1818
    19 import org.openstreetmap.josm.Main;
    2019import org.openstreetmap.josm.data.osm.DataSet;
     20import org.openstreetmap.josm.data.osm.OsmDataManager;
    2121import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2222import org.openstreetmap.josm.data.osm.Tag;
     
    4343
    4444    protected void initAutoCompletionField(AutoCompletingTextField field, List<String> keys) {
    45         if (Main.main == null) return;
    46         DataSet data = Main.main.getEditDataSet();
     45        DataSet data = OsmDataManager.getInstance().getEditDataSet();
    4746        if (data == null) {
    4847            return;
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSelector.java

    r13925 r14143  
    3434import javax.swing.event.ListSelectionListener;
    3535
    36 import org.openstreetmap.josm.Main;
    3736import org.openstreetmap.josm.data.osm.DataSelectionListener;
    3837import org.openstreetmap.josm.data.osm.DataSet;
     38import org.openstreetmap.josm.data.osm.OsmDataManager;
    3939import org.openstreetmap.josm.data.osm.OsmPrimitive;
    4040import org.openstreetmap.josm.data.preferences.BooleanProperty;
     
    240240        boolean inTags = ckSearchInTags != null && ckSearchInTags.isSelected();
    241241
    242         DataSet ds = Main.main.getEditDataSet();
     242        DataSet ds = OsmDataManager.getInstance().getEditDataSet();
    243243        Collection<OsmPrimitive> selected = (ds == null) ? Collections.<OsmPrimitive>emptyList() : ds.getSelected();
    244244        final List<PresetClassification> result = classifications.getMatchingPresets(
     
    360360                typesInSelectionDirty = false;
    361361                typesInSelection.clear();
    362                 if (Main.main == null || Main.main.getEditDataSet() == null) return typesInSelection;
    363                 for (OsmPrimitive primitive : Main.main.getEditDataSet().getSelected()) {
     362                if (OsmDataManager.getInstance().getEditDataSet() == null) return typesInSelection;
     363                for (OsmPrimitive primitive : OsmDataManager.getInstance().getEditDataSet().getSelected()) {
    364364                    typesInSelection.add(TaggingPresetType.forPrimitive(primitive));
    365365                }
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java

    r14134 r14143  
    1313import java.util.Map.Entry;
    1414
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.actions.AutoScaleAction;
    1716import org.openstreetmap.josm.command.AddCommand;
     
    2221import org.openstreetmap.josm.data.osm.DataSet;
    2322import org.openstreetmap.josm.data.osm.Node;
     23import org.openstreetmap.josm.data.osm.OsmDataManager;
    2424import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2525import org.openstreetmap.josm.data.osm.Way;
     
    151151            nd = new Node(ll);
    152152            // Now execute the commands to add this node.
    153             commands.add(new AddCommand(Main.main.getEditDataSet(), nd));
     153            commands.add(new AddCommand(OsmDataManager.getInstance().getEditDataSet(), nd));
    154154            addedNodes.put(ll, nd);
    155155        }
  • trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java

    r14139 r14143  
    153153    }
    154154
     155    @SuppressWarnings("deprecation")
    155156    private void setupGUI() {
    156157        JOSMTestRules.cleanLayerEnvironment();
Note: See TracChangeset for help on using the changeset viewer.