Modify

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#12983 closed enhancement (fixed)

use layer manager in Command

Reported by: anonymous Owned by: team
Priority: normal Milestone: 16.06
Component: Core Version: latest
Keywords: gsoc-core Cc: michael2402

Description (last modified by Don-vip)

The Command class should get the active layer from the layer manager. otherwise it does not seem possible to use the command in a test with JOSMTestRules, because "Main.main" is null.

package org.openstreetmap.josm.command:

    /**
     * Creates a new command in the context of the current edit layer, if any
     */
    public Command() {
        this.layer = Main.main == null ? null : Main.main.getEditLayer();
    }

Attachments (0)

Change History (7)

comment:1 by bastiK, 8 years ago

Could you give a bit more context, what is JOSMTestRules?

comment:2 by Don-vip, 8 years ago

new class in unit tests to speed up/replace JOSMFixtures (part of Michael's work)

comment:3 by Don-vip, 8 years ago

Cc: michael2402 added
Keywords: gsoc-core added

comment:4 by michael2402, 8 years ago

JOSMTestRules sets up the test environment more fine-graned than JOSMFixture does.

The main Idea is that you do not need a whole JOSM instance to get a simple unit test running. This is only possible if we reduce dependencies, e.g. that Command depends on Main.

I would like to deprecate all Main.*Layer*() methods except for getLayerManager() and replace them in the existing source.

You can replace this line:

this.layer = Main.main == null ? null : Main.main.getEditLayer();

With this one:

this.layer = Main.getLayerManager().getEditLayer();

The MainLayerManager will handle the case of an empty layer list automatically.

comment:5 by Don-vip, 8 years ago

Resolution: fixed
Status: newclosed

In 10413/josm:

fix #12983 - replace calls to Main.main.get[Active|Edit]Layer() by Main.getLayerManager().get[Active|Edit]Layer() - gsoc-core

comment:6 by Don-vip, 8 years ago

Milestone: 16.06
Type: defectenhancement

comment:7 by Don-vip, 8 years ago

Description: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.