Changeset 10448 in josm for trunk/src/org


Ignore:
Timestamp:
2016-06-21T01:29:31+02:00 (8 years ago)
Author:
Don-vip
Message:

fix more deprecation warnings

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

Legend:

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

    r10409 r10448  
    6464    }
    6565
    66     public static String getCopyString(Collection<? extends OsmPrimitive> primitives) {
     66    static String getCopyString(Collection<? extends OsmPrimitive> primitives) {
    6767        StringBuilder idsBuilder = new StringBuilder();
    6868        for (OsmPrimitive p : primitives) {
     
    8282    }
    8383
    84     private static boolean isEmptySelection() {
    85         Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected();
     84    private boolean isEmptySelection() {
     85        Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected();
    8686        if (sel.isEmpty()) {
    8787            JOptionPane.showMessageDialog(
  • trunk/src/org/openstreetmap/josm/actions/CopyCoordinatesAction.java

    r10043 r10448  
    99import java.util.Collections;
    1010
     11import org.openstreetmap.josm.data.osm.DataSet;
    1112import org.openstreetmap.josm.data.osm.Node;
    1213import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    4748    }
    4849
    49     private static Collection<Node> getSelectedNodes() {
    50         if (getCurrentDataSet() == null || getCurrentDataSet().getSelected() == null) {
     50    private Collection<Node> getSelectedNodes() {
     51        DataSet ds = getLayerManager().getEditDataSet();
     52        if (ds == null || ds.getSelected() == null) {
    5153            return Collections.emptyList();
    5254        } else {
    53             return Utils.filteredCollection(getCurrentDataSet().getSelected(), Node.class);
     55            return Utils.filteredCollection(ds.getSelected(), Node.class);
    5456        }
    5557    }
  • trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java

    r10446 r10448  
    176176    }
    177177
    178     private static Relation getSelectedMultipolygonRelation() {
    179         return getSelectedMultipolygonRelation(getCurrentDataSet().getSelectedWays(), getCurrentDataSet().getSelectedRelations());
     178    private Relation getSelectedMultipolygonRelation() {
     179        DataSet ds = getLayerManager().getEditDataSet();
     180        return getSelectedMultipolygonRelation(ds.getSelectedWays(), ds.getSelectedRelations());
    180181    }
    181182
  • trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java

    r10413 r10448  
    272272        if (cmd != null) {
    273273            Main.main.undoRedo.add(cmd);
    274             getCurrentDataSet().setSelected(target);
     274            layer.data.setSelected(target);
    275275        }
    276276    }
  • trunk/src/org/openstreetmap/josm/actions/MergeSelectionAction.java

    r10383 r10448  
    8989     * @return true if the user wants to cancel, false if they want to continue
    9090     */
    91     public static final boolean warnMergingUploadDiscouragedObjects(Layer targetLayer) {
     91    public final boolean warnMergingUploadDiscouragedObjects(Layer targetLayer) {
    9292        return GuiHelper.warnUser(tr("Merging too many objects with different upload policies"),
    9393                "<html>" +
     
    9696                        "You should instead check and merge each object, <b>one by one</b>.<br /><br />"+
    9797                        "Are you sure you want to continue?",
    98                         getEditLayer().getName(), targetLayer.getName(), targetLayer.getName())+
     98                        getLayerManager().getEditLayer().getName(), targetLayer.getName(), targetLayer.getName())+
    9999                "</html>",
    100100                ImageProvider.get("dialogs", "mergedown"), tr("Ignore this hint and merge anyway"));
  • trunk/src/org/openstreetmap/josm/actions/SelectByInternalPointAction.java

    r9594 r10448  
    3838     */
    3939    public static Collection<OsmPrimitive> getSurroundingObjects(EastNorth internalPoint) {
    40         final DataSet ds = JosmAction.getCurrentDataSet();
     40        final DataSet ds = Main.getLayerManager().getEditDataSet();
    4141        if (ds == null) {
    4242            return Collections.emptySet();
     
    8787    public static void performSelection(EastNorth internalPoint, boolean doAdd, boolean doRemove) {
    8888        final Collection<OsmPrimitive> surroundingObjects = getSurroundingObjects(internalPoint);
    89         final DataSet ds = JosmAction.getCurrentDataSet();
     89        final DataSet ds = Main.getLayerManager().getEditDataSet();
    9090        if (surroundingObjects.isEmpty()) {
    9191            return;
  • trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java

    r10382 r10448  
    196196        final List<List<Node>> wayChunks = buildSplitChunks(selectedWay, selectedNodes);
    197197        if (wayChunks != null) {
    198             List<Relation> selectedRelations =
    199                     OsmPrimitive.getFilteredList(selection, Relation.class);
     198            List<Relation> selectedRelations = OsmPrimitive.getFilteredList(selection, Relation.class);
    200199            final List<OsmPrimitive> sel = new ArrayList<>(selectedWays.size() + selectedRelations.size());
    201200            sel.addAll(selectedWays);
     
    308307            toggleSaveState(); // necessary since #showDialog() does not handle it due to the non-modal dialog
    309308            if (getValue() == 1) {
    310                 final Way wayToKeep = list.getSelectedValue();
    311                 final SplitWayResult result = doSplitWay(getEditLayer(), selectedWay, wayToKeep, newWays, selection);
     309                SplitWayResult result = doSplitWay(Main.getLayerManager().getEditLayer(),
     310                        selectedWay, list.getSelectedValue(), newWays, selection);
    312311                Main.main.undoRedo.add(result.getCommand());
    313                 getCurrentDataSet().setSelected(result.getNewSelection());
     312                Main.getLayerManager().getEditDataSet().setSelected(result.getNewSelection());
    314313            }
    315314        }
  • trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java

    r10420 r10448  
    560560     * @param newNodes New created nodes by this set of command
    561561     */
    562     private static void execCommands(List<Command> cmds, List<Node> newNodes) {
     562    private void execCommands(List<Command> cmds, List<Node> newNodes) {
    563563        Main.main.undoRedo.add(new SequenceCommand(/* for correct i18n of plural forms - see #9110 */
    564564                trn("Dupe into {0} node", "Dupe into {0} nodes", newNodes.size() + 1L, newNodes.size() + 1L), cmds));
    565565        // select one of the new nodes
    566         getCurrentDataSet().setSelected(newNodes.get(0));
     566        getLayerManager().getEditDataSet().setSelected(newNodes.get(0));
    567567    }
    568568
  • trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java

    r10413 r10448  
    4141    public static void handlePrimitiveGoneException(long id, OsmPrimitiveType type) {
    4242        MultiFetchServerObjectReader reader = MultiFetchServerObjectReader.create();
    43         reader.append(getCurrentDataSet(), id, type);
     43        reader.append(Main.getLayerManager().getEditDataSet(), id, type);
    4444        try {
    4545            DataSet ds = reader.parseOsm(NullProgressMonitor.INSTANCE);
     
    5858     */
    5959    public static void updatePrimitives(final Collection<OsmPrimitive> selection) {
    60         UpdatePrimitivesTask task = new UpdatePrimitivesTask(Main.getLayerManager().getEditLayer(), selection);
    61         Main.worker.submit(task);
     60        Main.worker.submit(new UpdatePrimitivesTask(Main.getLayerManager().getEditLayer(), selection));
    6261    }
    6362
     
    7372    public static void updatePrimitive(PrimitiveId id) {
    7473        ensureParameterNotNull(id, "id");
    75         if (getEditLayer() == null)
     74        if (Main.getLayerManager().getEditLayer() == null)
    7675            throw new IllegalStateException(tr("No current dataset found"));
    77         OsmPrimitive primitive = getEditLayer().data.getPrimitiveById(id);
     76        OsmPrimitive primitive = Main.getLayerManager().getEditLayer().data.getPrimitiveById(id);
    7877        if (primitive == null)
    7978            throw new IllegalStateException(tr("Did not find an object with id {0} in the current dataset", id));
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java

    r10382 r10448  
    2525import org.openstreetmap.josm.gui.dialogs.relation.RelationDialogManager;
    2626import org.openstreetmap.josm.gui.layer.Layer;
     27import org.openstreetmap.josm.gui.layer.MainLayerManager;
    2728import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2829import org.openstreetmap.josm.gui.util.HighlightHelper;
     
    138139        boolean alt = (e.getModifiers() & (ActionEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK)) != 0;
    139140
     141        MainLayerManager lm = Main.getLayerManager();
    140142        Command c;
    141143        if (ctrl) {
    142             c = DeleteCommand.deleteWithReferences(getEditLayer(), getCurrentDataSet().getSelected());
     144            c = DeleteCommand.deleteWithReferences(lm.getEditLayer(), lm.getEditDataSet().getSelected());
    143145        } else {
    144             c = DeleteCommand.delete(getEditLayer(), getCurrentDataSet().getSelected(), !alt /* also delete nodes in way */);
     146            c = DeleteCommand.delete(lm.getEditLayer(), lm.getEditDataSet().getSelected(), !alt /* also delete nodes in way */);
    145147        }
    146148        // if c is null, an error occurred or the user aborted. Don't do anything in that case.
    147149        if (c != null) {
    148150            Main.main.undoRedo.add(c);
    149             getCurrentDataSet().setSelected();
     151            lm.getEditDataSet().setSelected();
    150152            Main.map.repaint();
    151153        }
     
    170172     * removes any highlighting that may have been set beforehand.
    171173     */
    172     private static void removeHighlighting() {
     174    private void removeHighlighting() {
    173175        highlightHelper.clear();
    174         DataSet ds = getCurrentDataSet();
     176        DataSet ds = getLayerManager().getEditDataSet();
    175177        if (ds != null) {
    176178            ds.clearHighlightedWaySegments();
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r10413 r10448  
    870870    }
    871871
    872     private static boolean movesHiddenWay() {
    873         final Collection<OsmPrimitive> elementsToTest = new HashSet<>(getCurrentDataSet().getSelected());
    874         for (Way osm : Utils.filteredCollection(getCurrentDataSet().getSelected(), Way.class)) {
     872    private boolean movesHiddenWay() {
     873        DataSet ds = getLayerManager().getEditDataSet();
     874        final Collection<OsmPrimitive> elementsToTest = new HashSet<>(ds.getSelected());
     875        for (Way osm : Utils.filteredCollection(ds.getSelected(), Way.class)) {
    875876            elementsToTest.addAll(osm.getNodes());
    876877        }
  • trunk/src/org/openstreetmap/josm/actions/upload/ValidateUploadHook.java

    r10446 r10448  
    1414
    1515import org.openstreetmap.josm.Main;
    16 import org.openstreetmap.josm.actions.JosmAction;
    1716import org.openstreetmap.josm.data.APIDataSet;
    1817import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    7372            }
    7473        }
    75         OsmDataLayer editLayer = JosmAction.getEditLayer();
     74        OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
    7675        if (editLayer != null) {
    7776            editLayer.validationErrors.clear();
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Coastlines.java

    r9675 r10448  
    1212import java.util.List;
    1313
    14 import org.openstreetmap.josm.actions.JosmAction;
     14import org.openstreetmap.josm.Main;
    1515import org.openstreetmap.josm.command.ChangeCommand;
    1616import org.openstreetmap.josm.command.Command;
     
    4444     */
    4545    public Coastlines() {
    46         super(tr("Coastlines"),
    47                 tr("This test checks that coastlines are correct."));
     46        super(tr("Coastlines"), tr("This test checks that coastlines are correct."));
    4847    }
    4948
     
    5352        super.startTest(monitor);
    5453
    55         OsmDataLayer layer = JosmAction.getEditLayer();
     54        OsmDataLayer layer = Main.getLayerManager().getEditLayer();
    5655
    5756        if (layer != null) {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java

    r10378 r10448  
    88import java.util.Set;
    99
    10 import org.openstreetmap.josm.actions.JosmAction;
     10import org.openstreetmap.josm.Main;
    1111import org.openstreetmap.josm.command.Command;
    1212import org.openstreetmap.josm.data.osm.DataSet;
     
    123123    public void startTest(ProgressMonitor monitor) {
    124124        super.startTest(monitor);
    125         DataSet ds = JosmAction.getCurrentDataSet();
     125        DataSet ds = Main.getLayerManager().getEditDataSet();
    126126        if (ds == null)
    127127            return;
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r10446 r10448  
    268268                // which would make this variable true. Of course we only want the popup to show
    269269                // if the middle mouse button has been pressed in the first place
    270                 boolean mouseNotMoved = oldMousePos != null
    271                         && oldMousePos.equals(ms.mousePos);
     270                boolean mouseNotMoved = oldMousePos != null && oldMousePos.equals(ms.mousePos);
    272271                boolean isAtOldPosition = mouseNotMoved && popup != null;
    273272                boolean middleMouseDown = (ms.modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0;
    274273                try {
    275                     ds = mv.getCurrentDataSet();
     274                    ds = mv.getLayerManager().getEditDataSet();
    276275                    if (ds != null) {
    277276                        // This is not perfect, if current dataset was changed during execution, the lock would be useless
Note: See TracChangeset for help on using the changeset viewer.