Index: /applications/editors/josm/plugins/turnrestrictions/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- /applications/editors/josm/plugins/turnrestrictions/.settings/org.eclipse.jdt.core.prefs	(revision 32374)
+++ /applications/editors/josm/plugins/turnrestrictions/.settings/org.eclipse.jdt.core.prefs	(revision 32375)
@@ -81,4 +81,5 @@
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
 org.eclipse.jdt.core.compiler.problem.unusedImport=warning
 org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
Index: /applications/editors/josm/plugins/turnrestrictions/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- /applications/editors/josm/plugins/turnrestrictions/.settings/org.eclipse.jdt.ui.prefs	(revision 32375)
+++ /applications/editors/josm/plugins/turnrestrictions/.settings/org.eclipse.jdt.ui.prefs	(revision 32375)
@@ -0,0 +1,60 @@
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=false
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_type_arguments=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=true
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+sp_cleanup.use_type_arguments=false
Index: /applications/editors/josm/plugins/turnrestrictions/build.xml
===================================================================
--- /applications/editors/josm/plugins/turnrestrictions/build.xml	(revision 32374)
+++ /applications/editors/josm/plugins/turnrestrictions/build.xml	(revision 32375)
@@ -4,5 +4,5 @@
     <property name="commit.message" value="Adapt to JOSM core change (DefaultNameFormatter)"/>
     <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
-    <property name="plugin.main.version" value="10279"/>
+    <property name="plugin.main.version" value="10369"/>
 
     <!-- Configure these properties (replace "..." accordingly).
Index: /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/CreateOrEditTurnRestrictionAction.java
===================================================================
--- /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/CreateOrEditTurnRestrictionAction.java	(revision 32374)
+++ /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/CreateOrEditTurnRestrictionAction.java	(revision 32375)
@@ -50,6 +50,7 @@
     }
 
+    @Override
     public void actionPerformed(ActionEvent e) {
-        OsmDataLayer layer = Main.main.getEditLayer();
+        OsmDataLayer layer = Main.getLayerManager().getEditLayer();
         if (layer == null) return;
         Collection<Relation> trs = TurnRestrictionSelectionPopupPanel.getTurnRestrictionsParticipatingIn(layer.data.getSelected());
Index: /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionListModel.java
===================================================================
--- /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionListModel.java	(revision 32374)
+++ /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionListModel.java	(revision 32375)
@@ -24,5 +24,6 @@
 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;
 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
-import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
+import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
+import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.plugins.turnrestrictions.dnd.PrimitiveIdListProvider;
@@ -30,11 +31,11 @@
 
 /**
- * JosmSelectionListModel is the model for a list which displays the currently selected 
+ * JosmSelectionListModel is the model for a list which displays the currently selected
  * objects in the current edit layer.
- * 
+ *
  */
-public class JosmSelectionListModel extends AbstractListModel<OsmPrimitive> implements EditLayerChangeListener, SelectionChangedListener, DataSetListener, PrimitiveIdListProvider{
+public class JosmSelectionListModel extends AbstractListModel<OsmPrimitive> implements ActiveLayerChangeListener, SelectionChangedListener, DataSetListener, PrimitiveIdListProvider{
     //static private final Logger logger = Logger.getLogger(JosmSelectionListModel.class.getName());
-    
+
     private final List<OsmPrimitive> selection = new ArrayList<>();
     private final DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
@@ -43,10 +44,10 @@
     /**
      * Constructor
-     * 
+     *
      * @param selectionModel the selection model used in the list. Must not be null.
      * @param layer the layer this model is displaying the selection from. Must not be null.
      * @throws IllegalArgumentException thrown if {@code layer} is null
      */
-    public JosmSelectionListModel(OsmDataLayer layer) throws IllegalArgumentException{
+    public JosmSelectionListModel(OsmDataLayer layer) {
         CheckParameterUtil.ensureParameterNotNull(layer, "layer");
         this.layer = layer;
@@ -54,8 +55,10 @@
     }
 
+    @Override
     public OsmPrimitive getElementAt(int index) {
         return selection.get(index);
     }
 
+    @Override
     public int getSize() {
         return selection.size();
@@ -65,5 +68,5 @@
      * Replies the collection of OSM primitives currently selected in the view
      * of this model
-     * 
+     *
      * @return the selected primitives
      */
@@ -80,5 +83,5 @@
     /**
      * Sets the OSM primitives to be selected in the view of this model
-     * 
+     *
      * @param sel the collection of primitives to select
      */
@@ -103,5 +106,5 @@
     /**
      * Sets the collection of currently selected OSM objects
-     * 
+     *
      * @param selection the collection of currently selected OSM objects
      */
@@ -114,8 +117,8 @@
         }
         this.selection.addAll(selection);
-        fireContentsChanged(this, 0, getSize());       
-        setSelected(sel);       
+        fireContentsChanged(this, 0, getSize());
+        setSelected(sel);
         // if the user selects exactly one primitive (i.e. a way), we automatically
-        // select it in the list of selected JOSM objects too. 
+        // select it in the list of selected JOSM objects too.
         if (getSelected().isEmpty() && this.selection.size() == 1) {
             setSelected(this.selection);
@@ -126,5 +129,5 @@
      * Triggers a refresh of the view for all primitives in {@code toUpdate}
      * which are currently displayed in the view
-     * 
+     *
      * @param toUpdate the collection of primitives to update
      */
@@ -141,5 +144,5 @@
         setSelected(sel);
     }
-        
+
     public ListSelectionModel getListSelectionModel() {
         return selectionModel;
@@ -147,9 +150,11 @@
 
     /* ------------------------------------------------------------------------ */
-    /* interface EditLayerChangeListener                                        */
-    /* ------------------------------------------------------------------------ */
-    public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) {
+    /* interface ActiveLayerChangeListener                                      */
+    /* ------------------------------------------------------------------------ */
+    @Override
+    public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
+        OsmDataLayer newLayer = Main.getLayerManager().getEditLayer();
         if (newLayer == null) {
-            // don't show a JOSM selection if we don't have a data layer 
+            // don't show a JOSM selection if we don't have a data layer
             setJOSMSelection(null);
         } else if (newLayer != layer){
@@ -165,8 +170,9 @@
     /* interface SelectionChangeListener                                        */
     /* ------------------------------------------------------------------------ */
+    @Override
     public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
         // only update the JOSM selection if it is changed in the same data layer
         // this turn restriction editor is working on
-        OsmDataLayer layer = Main.main.getEditLayer();
+        OsmDataLayer layer = Main.getLayerManager().getEditLayer();
         if(layer == null) return;
         if (layer != this.layer) return;
@@ -177,4 +183,5 @@
     /* interface DataSetListener                                                */
     /* ------------------------------------------------------------------------ */
+    @Override
     public void dataChanged(DataChangedEvent event) {
         if (event.getDataset() != layer.data) return;
@@ -182,4 +189,5 @@
     }
 
+    @Override
     public void nodeMoved(NodeMovedEvent event) {
         if (event.getDataset() != layer.data) return;
@@ -188,4 +196,5 @@
     }
 
+    @Override
     public void otherDatasetChange(AbstractDatasetChangedEvent event) {
         if (event.getDataset() != layer.data) return;
@@ -194,4 +203,5 @@
     }
 
+    @Override
     public void relationMembersChanged(RelationMembersChangedEvent event) {
         if (event.getDataset() != layer.data) return;
@@ -200,4 +210,5 @@
     }
 
+    @Override
     public void tagsChanged(TagsChangedEvent event) {
         if (event.getDataset() != layer.data) return;
@@ -206,4 +217,5 @@
     }
 
+    @Override
     public void wayNodesChanged(WayNodesChangedEvent event) {
         if (event.getDataset() != layer.data) return;
@@ -212,10 +224,13 @@
     }
 
+    @Override
     public void primitivesAdded(PrimitivesAddedEvent event) {/* ignored - handled by SelectionChangeListener */}
+    @Override
     public void primitivesRemoved(PrimitivesRemovedEvent event) {/* ignored - handled by SelectionChangeListener*/}
-  
+
     /* ------------------------------------------------------------------------ */
     /* interface PrimitiveIdListProvider                                        */
     /* ------------------------------------------------------------------------ */
+    @Override
     public List<PrimitiveId> getSelectedPrimitiveIds() {
         List<PrimitiveId> ret = new ArrayList<>(getSelected().size());
Index: /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionPanel.java
===================================================================
--- /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionPanel.java	(revision 32374)
+++ /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionPanel.java	(revision 32375)
@@ -21,9 +21,9 @@
 import javax.swing.TransferHandler;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.event.DatasetEventManager;
 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
 import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
-import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
@@ -45,10 +45,10 @@
     /** the model managing the selection */
     private JosmSelectionListModel model;
-    
+
     private CopyAction actCopy;
     private TransferHandler transferHandler;
-    
+
     /**
-     * builds the UI for the panel 
+     * builds the UI for the panel
      */
     protected void build(OsmDataLayer layer) {
@@ -60,16 +60,16 @@
         lstSelection.setTransferHandler(transferHandler = new JosmSelectionTransferHandler(model));
         lstSelection.setDragEnabled(true);
-        
+
         add(new JScrollPane(lstSelection), BorderLayout.CENTER);
         add(new JLabel(tr("Selection")), BorderLayout.NORTH);
-        
-        setBorder(BorderFactory.createEmptyBorder(5,5,5,5));        
+
+        setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
         actCopy = new CopyAction();
         lstSelection.addMouseListener(new PopupLauncher());
     }
-    
+
     /**
      * Creates the JOSM selection panel for the selection in an OSM data layer
-     * 
+     *
      * @param layer the data layer. Must not be null.
      * @exception IllegalArgumentException thrown if {@code layer} is null
@@ -78,32 +78,32 @@
         CheckParameterUtil.ensureParameterNotNull(layer, "layer");
         this.model = model;
-        build(layer); 
+        build(layer);
     }
-    
+
     /**
-     * wires the UI as listener to global event sources 
+     * wires the UI as listener to global event sources
      */
     public void wireListeners() {
-        MapView.addEditLayerChangeListener(model);
+        Main.getLayerManager().addActiveLayerChangeListener(model);
         DatasetEventManager.getInstance().addDatasetListener(model, FireMode.IN_EDT);
         SelectionEventManager.getInstance().addSelectionListener(model, FireMode.IN_EDT_CONSOLIDATED);
     }
-    
+
     /**
-     * removes the UI as listener to global event sources 
+     * removes the UI as listener to global event sources
      */
     public void unwireListeners() {
-        MapView.removeEditLayerChangeListener(model);
+        Main.getLayerManager().removeActiveLayerChangeListener(model);
         DatasetEventManager.getInstance().removeDatasetListener(model);
-        SelectionEventManager.getInstance().removeSelectionListener(model);     
+        SelectionEventManager.getInstance().removeSelectionListener(model);
     }
-    
+
     class PopupLauncher extends PopupMenuLauncher {
         @Override
         public void launch(MouseEvent evt) {
             new PopupMenu().show(lstSelection, evt.getX(), evt.getY());
-        }       
+        }
     }
-    
+
     class PopupMenu extends JPopupMenu {
         public PopupMenu() {
@@ -116,5 +116,5 @@
     class CopyAction extends AbstractAction {
         private Action delegate;
-        
+
         public CopyAction(){
             putValue(NAME, tr("Copy"));
@@ -125,9 +125,10 @@
         }
 
+        @Override
         public void actionPerformed(ActionEvent e) {
             delegate.actionPerformed(e);
         }
     }
-    
+
     static private class JosmSelectionTransferHandler extends PrimitiveIdListTransferHandler {
         public JosmSelectionTransferHandler(PrimitiveIdListProvider provider) {
Index: /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java
===================================================================
--- /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java	(revision 32374)
+++ /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java	(revision 32375)
@@ -58,5 +58,5 @@
 public class TurnRestrictionEditor extends JDialog implements NavigationControler{
     //final private static Logger logger = Logger.getLogger(TurnRestrictionEditor.class.getName());
-    
+
     /** the property name for the current turn restriction
      * @link #setRelation(Relation)
@@ -69,5 +69,5 @@
      */
     static public final String TURN_RESTRICION_SNAPSHOT_PROP = RelationEditor.class.getName() + ".turnRestrictionSnapshot";
-    
+
     /**
      * The turn restriction this editor is working on
@@ -77,5 +77,5 @@
     /**
      * The version of the turn restriction when editing is started.  This is
-     * null if a new turn restriction is created. 
+     * null if a new turn restriction is created.
      */
     protected Relation turnRestrictionSnapshot;
@@ -83,5 +83,5 @@
     /** the data layer the turn restriction belongs to */
     private OsmDataLayer layer;
-    
+
     private JosmSelectionPanel pnlJosmSelection;
     private BasicEditorPanel pnlBasicEditor;
@@ -89,5 +89,5 @@
     private JTabbedPane tpEditors;
     private PreferenceChangeHandler preferenceChangeHandler;
-    
+
     /**
      * builds the panel with the OK and the Cancel button
@@ -108,7 +108,7 @@
         return pnl;
     }
-    
-    /**
-     * builds the panel which displays the JOSM selection 
+
+    /**
+     * builds the panel which displays the JOSM selection
      * @return
      */
@@ -117,9 +117,9 @@
         return pnlJosmSelection;
     }
-    
-    /**
-     * Builds the panel with the editor forms (the left panel in the split pane of 
+
+    /**
+     * Builds the panel with the editor forms (the left panel in the split pane of
      * this dialog)
-     * 
+     *
      * @return
      */
@@ -133,21 +133,21 @@
         tpEditors.setTitleAt(0, tr("Basic"));
         tpEditors.setToolTipTextAt(0, tr("Edit basic attributes of a turn restriction"));
-        
+
         tpEditors.add(new AdvancedEditorPanel(editorModel));
         tpEditors.setTitleAt(1, tr("Advanced"));
         tpEditors.setToolTipTextAt(1, tr("Edit the raw tags and members of this turn restriction"));
-        
+
         tpEditors.add(new IssuesView(editorModel.getIssuesModel()));
         tpEditors.setTitleAt(2, tr("Errors/Warnings"));
         tpEditors.setToolTipTextAt(2, tr("Show errors and warnings related to this turn restriction"));
-        
+
         pnl.add(tpEditors, BorderLayout.CENTER);
         return pnl;
     }
-    
+
     /**
      * Builds the content panel, i.e. the core area of the dialog with the editor
-     * masks and the JOSM selection view 
-     * 
+     * masks and the JOSM selection view
+     *
      * @return
      */
@@ -169,5 +169,5 @@
         return pnl;
     }
-    
+
     /**
      * Creates the toolbar
@@ -193,24 +193,24 @@
         return tb;
     }
-    
+
     /**
      * builds the UI
      */
-    protected void build() {        
+    protected void build() {
         editorModel = new TurnRestrictionEditorModel(getLayer(), this);
         Container c = getContentPane();
         c.setLayout(new BorderLayout());
         c.add(buildToolBar(), BorderLayout.NORTH);
-        c.add(buildContentPanel(), BorderLayout.CENTER);        
+        c.add(buildContentPanel(), BorderLayout.CENTER);
         c.add(buildOkCancelButtonPanel(), BorderLayout.SOUTH);
-        
+
         editorModel.getIssuesModel().addObserver(new IssuesModelObserver());
-        setSize(600,600);       
-    }    
-    
+        setSize(600,600);
+    }
+
     /**
     * Creates a new turn restriction editor
     *
-    * @param owner the component relative to which the dialog is displayed 
+    * @param owner the component relative to which the dialog is displayed
     * @param layer  the {@link OsmDataLayer} in whose context a relation is edited. Must not be null.
     * @throws IllegalArgumentException thrown if layer is null
@@ -219,9 +219,9 @@
         this(owner, layer, null);
     }
-    
+
      /**
      * Creates a new turn restriction editor
      *
-     * @param owner the component relative to which the dialog is displayed 
+     * @param owner the component relative to which the dialog is displayed
      * @param layer  the {@link OsmDataLayer} in whose context a relation is edited. Must not be null.
      * @param turnRestriction the relation. Can be null if a new relation is to be edited.
@@ -235,5 +235,5 @@
         setTurnRestriction(turnRestriction);
     }
-    
+
     /**
      * Replies the currently edited turn restriction
@@ -253,10 +253,10 @@
      * is already assigned to a dataset, the dataset of {@link #getLayer()} is required, otherwise
      * a {@link IllegalArgumentException} is thrown.</p>
-     * 
+     *
      * @param turnRestriction the turn restriction
      * @throws IllegalArgumentException thrown if {@code turnRestriction} belongs to a different dataset than
      * that owned by the layer {@link #getLayer()}
      */
-    protected void setTurnRestriction(Relation turnRestriction) {      
+    protected void setTurnRestriction(Relation turnRestriction) {
         if (turnRestriction == null) {
             editorModel.populate(new Relation());
@@ -271,5 +271,5 @@
         updateTitle();
     }
-    
+
     /**
      * updates the title of the turn restriction editor
@@ -284,5 +284,5 @@
         }
     }
-    
+
     /**
      * Replies the {@link OsmDataLayer} in whose context this relation editor is
@@ -307,12 +307,12 @@
     /**
      * Sets the turn restriction snapshot
-     * 
+     *
      * @param snapshot the snapshot
      */
-    protected void setTurnRestrictionSnapshot(Relation snapshot) {        
+    protected void setTurnRestrictionSnapshot(Relation snapshot) {
         turnRestrictionSnapshot = snapshot;
         support.firePropertyChange(TURN_RESTRICION_SNAPSHOT_PROP, null, turnRestrictionSnapshot);
     }
-    
+
     /**
      * <p>Replies true if the currently edited turn restriction has been changed elsewhere.</p>
@@ -326,12 +326,13 @@
         return ! turnRestriction.hasEqualSemanticAttributes(turnRestrictionSnapshot);
     }
-    
-    /**
-     * Replies the editor model for this editor 
+
+    /**
+     * Replies the editor model for this editor
      */
     public TurnRestrictionEditorModel getModel() {
         return editorModel;
     }
-    
+
+    @Override
     public void setVisible(boolean visible) {
         if (visible && ! isVisible()) {
@@ -350,5 +351,5 @@
         }
     }
-    
+
     /* ----------------------------------------------------------------------- */
     /* property change support                                                 */
@@ -365,16 +366,19 @@
         this.support.removePropertyChangeListener(listener);
     }
-    
+
     /* ----------------------------------------------------------------------- */
     /* interface NavigationControler                                           */
     /* ----------------------------------------------------------------------- */
+    @Override
     public void gotoBasicEditor() {
         tpEditors.setSelectedIndex(0);
     }
 
+    @Override
     public void gotoAdvancedEditor() {
         tpEditors.setSelectedIndex(1);
     }
 
+    @Override
     public void gotoBasicEditor(BasicEditorFokusTargets focusTarget) {
         tpEditors.setSelectedIndex(0);
@@ -386,10 +390,10 @@
      * to the dataset.
      */
-    abstract class SavingAction extends AbstractAction {        
+    abstract class SavingAction extends AbstractAction {
         protected boolean confirmSaveDespiteOfErrorsAndWarnings(){
             int numErrors = editorModel.getIssuesModel().getNumErrors();
             int numWarnings = editorModel.getIssuesModel().getNumWarnings();
             if (numErrors + numWarnings == 0) return true;
-            
+
             StringBuffer sb = new StringBuffer();
             sb.append("<html>");
@@ -418,5 +422,5 @@
                     )
             };
-            
+
             int ret = HelpAwareOptionPane.showOptionDialog(
                     JOptionPane.getFrameForComponent(TurnRestrictionEditor.this),
@@ -429,12 +433,12 @@
                     HelpUtil.ht("/Plugin/TurnRestrictions#PendingErrorsAndWarnings")
             );
-            return ret == 0 /* OK */;           
-        }
-        
+            return ret == 0 /* OK */;
+        }
+
         /**
          * Replies the list of relation members in {@code r} which refer to
          * a deleted or invisible primitives.
-         * 
-         * @param r the relation 
+         *
+         * @param r the relation
          * @return the list of relation members in {@code r} which refer to
          * a deleted or invisible member
@@ -449,9 +453,9 @@
             return ret;
         }
-        
+
         /**
          * Removes all members referring to deleted or invisible primitives
          * from the turn restriction {@code tr}.
-         * 
+         *
          * @param tr  the turn restriction
          */
@@ -466,17 +470,17 @@
             tr.setMembers(members);
         }
-        
+
         /**
          * <p>Asks the user how to proceed if a turn restriction refers to deleted or invisible
          * primitives.</p>
-         * 
+         *
          * <p>If this method returns true the respective members should be removed and the turn
          * restriction should be saved anyway. If it replies false, the turn restriction must not
          * be saved. </p>
-         * 
-         * @param deletedMembers the list of members referring to deleted or invisible primitives  
-         * @return the confirmation 
+         *
+         * @param deletedMembers the list of members referring to deleted or invisible primitives
+         * @return the confirmation
          */
-        protected boolean confirmSaveTurnRestrictionWithDeletePrimitives(List<RelationMember> deletedMembers) {                     
+        protected boolean confirmSaveTurnRestrictionWithDeletePrimitives(List<RelationMember> deletedMembers) {
             StringBuffer sb = new StringBuffer();
             sb.append("<html>");
@@ -496,5 +500,5 @@
             sb.append(tr("Updates to this turn restriction can''t be saved unless deleted members are removed.<br>"
                     + "How to you want to proceed?"));
-            
+
             ButtonSpec[] options = new ButtonSpec[] {
                     new ButtonSpec(
@@ -511,5 +515,5 @@
                        )
             };
-            
+
             int ret = HelpAwareOptionPane.showOptionDialog(
                     TurnRestrictionEditor.this,
@@ -521,12 +525,12 @@
                     options[1], // cancel is default
                     null // FIXME: provide help topic
-            );          
-            return ret == 0 /* OK button */; 
-        }
-        
+            );
+            return ret == 0 /* OK button */;
+        }
+
         /**
          * apply updates to a new turn restriction
          */
-        protected boolean applyNewTurnRestriction() {           
+        protected boolean applyNewTurnRestriction() {
             Relation newTurnRestriction = new Relation();
             editorModel.apply(newTurnRestriction);
@@ -536,6 +540,6 @@
             if (newTurnRestriction.getMembersCount() == 0 && !newTurnRestriction.hasKeys())
                 return true;
-            
-            // check whether the turn restriction refers to new 
+
+            // check whether the turn restriction refers to new
             List<RelationMember> deletedMembers = getDeletedRelationMembers(newTurnRestriction);
             if (!deletedMembers.isEmpty()) {
@@ -545,5 +549,5 @@
                 removeDeletedMembers(newTurnRestriction);
             }
-            
+
             Main.main.undoRedo.add(new AddCommand(getLayer(),newTurnRestriction));
 
@@ -575,5 +579,5 @@
          * outside of the turn restriction editor.
          */
-        protected void applyExistingNonConflictingTurnRestriction() {           
+        protected void applyExistingNonConflictingTurnRestriction() {
             if (getTurnRestriction().getDataSet() == null) {
                 editorModel.apply(getTurnRestriction());
@@ -581,5 +585,5 @@
             } else {
                 Relation toUpdate = new Relation(getTurnRestriction());
-                editorModel.apply(toUpdate);            
+                editorModel.apply(toUpdate);
                 Main.main.undoRedo.add(new ChangeCommand(getTurnRestriction(), toUpdate));
             }
@@ -652,12 +656,12 @@
                 applyNewTurnRestriction();
                 return;
-            } 
-            
+            }
+
             Relation toUpdate = new Relation(getTurnRestriction());
             editorModel.apply(toUpdate);
             if (TurnRestrictionEditorModel.hasSameMembersAndTags(toUpdate, getTurnRestriction()))
-                // nothing to update 
+                // nothing to update
                 return;
-            
+
             if (isDirtyTurnRestriction()) {
                 if (confirmClosingBecauseOfDirtyState()) {
@@ -671,12 +675,13 @@
             } else {
                 applyExistingNonConflictingTurnRestriction();
-            }            
-        }
-
+            }
+        }
+
+        @Override
         public void actionPerformed(ActionEvent e) {
             run();
         }
     }
-    
+
     class OKAction extends SavingAction {
         public OKAction() {
@@ -698,17 +703,17 @@
                 }
                 return;
-            } 
-            
+            }
+
             Relation toUpdate = new Relation(getTurnRestriction());
             editorModel.apply(toUpdate);
             if (TurnRestrictionEditorModel.hasSameMembersAndTags(toUpdate, getTurnRestriction())){
-                // nothing to update 
+                // nothing to update
                 setVisible(false);
                 return;
             }
-            
+
             if (isDirtyTurnRestriction()) {
                 // the turn restriction this editor is working on has changed outside
-                // of the editor. 
+                // of the editor.
                 if (confirmClosingBecauseOfDirtyState()) {
                     if (getLayer().getConflicts().hasConflictForMy(getTurnRestriction())) {
@@ -721,8 +726,9 @@
             } else {
                 applyExistingNonConflictingTurnRestriction();
-            }        
+            }
             setVisible(false);
         }
 
+        @Override
         public void actionPerformed(ActionEvent e) {
             run();
@@ -731,5 +737,5 @@
 
     /**
-     * Action for canceling the current dialog 
+     * Action for canceling the current dialog
      */
     class CancelAction extends AbstractAction {
@@ -743,9 +749,10 @@
         }
 
+        @Override
         public void actionPerformed(ActionEvent e) {
             setVisible(false);
         }
     }
-    
+
     class DeleteAction extends AbstractAction implements PropertyChangeListener{
         public DeleteAction() {
@@ -755,10 +762,11 @@
             updateEnabledState();
         }
-        
-        protected void updateEnabledState() {           
+
+        protected void updateEnabledState() {
             Relation tr = getTurnRestriction();
             setEnabled(tr != null && tr.getDataSet() != null);
         }
 
+        @Override
         public void actionPerformed(ActionEvent e) {
             Relation tr = getTurnRestriction();
@@ -771,4 +779,5 @@
         }
 
+        @Override
         public void propertyChange(PropertyChangeEvent evt) {
             if (evt.getPropertyName().equals(TURN_RESTRICION_PROP)){
@@ -777,5 +786,5 @@
         }
     }
-    
+
     class SelectAction extends AbstractAction implements PropertyChangeListener{
         public SelectAction() {
@@ -785,5 +794,5 @@
             updateEnabledState();
         }
-        
+
         protected void updateEnabledState() {
             Relation tr = getTurnRestriction();
@@ -791,4 +800,5 @@
         }
 
+        @Override
         public void actionPerformed(ActionEvent e) {
             Relation tr = getTurnRestriction();
@@ -797,4 +807,5 @@
         }
 
+        @Override
         public void propertyChange(PropertyChangeEvent evt) {
             if (evt.getPropertyName().equals(TURN_RESTRICION_PROP)){
@@ -803,5 +814,5 @@
         }
     }
-    
+
     class ZoomToAction extends AbstractAction implements PropertyChangeListener{
         public ZoomToAction() {
@@ -811,5 +822,5 @@
             updateEnabledState();
         }
-        
+
         protected void updateEnabledState() {
             Relation tr = getTurnRestriction();
@@ -817,14 +828,16 @@
         }
 
+        @Override
         public void actionPerformed(ActionEvent e) {
-            if (Main.main.getActiveLayer() != getLayer()){
+            if (Main.getLayerManager().getActiveLayer() != getLayer()){
                 Main.getLayerManager().setActiveLayer(getLayer());
             }
             Relation tr = getTurnRestriction();
             if (tr == null || tr.getDataSet() == null) return;
-            getLayer().data.setSelected(tr);            
+            getLayer().data.setSelected(tr);
             AutoScaleAction.zoomToSelection();
         }
 
+        @Override
         public void propertyChange(PropertyChangeEvent evt) {
             if (evt.getPropertyName().equals(TURN_RESTRICION_PROP)){
@@ -833,6 +846,7 @@
         }
     }
-    
+
     class IssuesModelObserver implements Observer {
+        @Override
         public void update(Observable o, Object arg) {
             int numWarnings = editorModel.getIssuesModel().getNumWarnings();
@@ -861,11 +875,11 @@
             tpEditors.setTitleAt(2, title);
             tpEditors.setEnabledAt(2, numWarnings + numErrors > 0);
-        }       
-    }
-    
+        }
+    }
+
     /**
      * <p>Listens to changes of the preference {@link PreferenceKeys#ROAD_SIGNS}
      * and refreshes the set of road icons.</p>
-     * 
+     *
      * <p>Listens to changes of the preference {@link PreferenceKeys#SHOW_VIAS_IN_BASIC_EDITOR}
      * and toggles the visibility of the list of via-objects in the Basic
@@ -873,15 +887,16 @@
      *
      */
-    class PreferenceChangeHandler implements PreferenceChangedListener {        
+    class PreferenceChangeHandler implements PreferenceChangedListener {
         public void refreshIconSet() {
             pnlBasicEditor.initIconSetFromPreferences(Main.pref);
         }
-        
-        public void preferenceChanged(PreferenceChangeEvent evt) {          
+
+        @Override
+        public void preferenceChanged(PreferenceChangeEvent evt) {
             if (evt.getKey().equals(PreferenceKeys.ROAD_SIGNS)){
                 refreshIconSet();
             } else if (evt.getKey().equals(PreferenceKeys.SHOW_VIAS_IN_BASIC_EDITOR)) {
                 pnlBasicEditor.initViasVisibilityFromPreferences(Main.pref);
-            }           
+            }
         }
     }
Index: /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorManager.java
===================================================================
--- /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorManager.java	(revision 32374)
+++ /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorManager.java	(revision 32375)
@@ -11,8 +11,12 @@
 import java.util.Map.Entry;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.PrimitiveId;
 import org.openstreetmap.josm.data.osm.Relation;
-import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
+import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
+import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
+import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 
@@ -21,5 +25,5 @@
  *
  */
-public class TurnRestrictionEditorManager extends WindowAdapter implements MapView.LayerChangeListener{
+public class TurnRestrictionEditorManager extends WindowAdapter implements LayerChangeListener {
     //static private final Logger logger = Logger.getLogger(TurnRestrictionEditorManager.class.getName());
 
@@ -35,5 +39,5 @@
         if (TurnRestrictionEditorManager.instance == null) {
             TurnRestrictionEditorManager.instance = new TurnRestrictionEditorManager();
-            MapView.addLayerChangeListener(TurnRestrictionEditorManager.instance);
+            Main.getLayerManager().addLayerChangeListener(TurnRestrictionEditorManager.instance);
         }
         return TurnRestrictionEditorManager.instance;
@@ -103,5 +107,5 @@
      */
     public TurnRestrictionEditorManager(){}
-    
+
     /**
      * Register the editor for a turn restriction managed by a
@@ -268,13 +272,12 @@
         }
     }
-    
+
     /* ----------------------------------------------------------------------------------- */
-    /* interface MapView.LayerChangeListener                                               */
+    /* interface LayerChangeListener                                               */
     /* ----------------------------------------------------------------------------------- */
-    /**
-     * called when a layer is removed
-     *
-     */
-    public void layerRemoved(Layer oldLayer) {
+
+    @Override
+    public void layerRemoving(LayerRemoveEvent e) {
+        Layer oldLayer = e.getRemovedLayer();
         if (oldLayer == null || ! (oldLayer instanceof OsmDataLayer))
             return;
@@ -293,5 +296,12 @@
     }
 
-    public void activeLayerChange(Layer oldLayer, Layer newLayer) {/* irrelevant in this context */}
-    public void layerAdded(Layer newLayer) {/* irrelevant in this context */}
+    @Override
+    public void layerAdded(LayerAddEvent e) {
+        // irrelevant in this context
+    }
+
+    @Override
+    public void layerOrderChanged(LayerOrderChangeEvent e) {
+        // irrelevant in this context
+    }
 }
Index: /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsInDatasetListModel.java
===================================================================
--- /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsInDatasetListModel.java	(revision 32374)
+++ /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsInDatasetListModel.java	(revision 32375)
@@ -19,30 +19,31 @@
 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;
 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
-import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
+import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
+import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 
 /**
  * <p>This is the list model for the list of turn restrictions in the current data set.</p>
- * 
- * <p>The model is a {@link EditLayerChangeListener}. It initializes itself from the data set of
+ *
+ * <p>The model is a {@link ActiveLayerChangeListener}. It initializes itself from the data set of
  * the current edit layer.</p>
- * 
+ *
  * <p>The model is a {@link DataSetListener}. It updates itself to reflect the list of turn
- * restrictions in the current data set.</p> 
+ * restrictions in the current data set.</p>
  *
  */
-public class TurnRestrictionsInDatasetListModel extends TurnRestrictionsListModel implements EditLayerChangeListener, DataSetListener {
+public class TurnRestrictionsInDatasetListModel extends TurnRestrictionsListModel implements ActiveLayerChangeListener, DataSetListener {
     //private static final Logger logger = Logger.getLogger(TurnRestrictionsInDatasetListModel.class.getName());
-    
+
     public TurnRestrictionsInDatasetListModel(
             DefaultListSelectionModel selectionModel) {
         super(selectionModel);
     }
-    
+
     /**
      * Filters the list of turn restrictions from a collection of OSM primitives.
-     * 
-     * @param primitives the primitives 
-     * @return the list of turn restrictions 
+     *
+     * @param primitives the primitives
+     * @return the list of turn restrictions
      */
     protected List<Relation> filterTurnRestrictions(Collection<? extends OsmPrimitive> primitives) {
@@ -55,9 +56,11 @@
         return ret;
     }
-    
+
     /* --------------------------------------------------------------------------- */
-    /* interface EditLayerChangeListener                                           */
+    /* interface ActiveLayerChangeListener                                           */
     /* --------------------------------------------------------------------------- */
-    public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) {
+    @Override
+    public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
+        OsmDataLayer newLayer = Main.getLayerManager().getEditLayer();
         if (newLayer == null) {
             setTurnRestrictions(null);
@@ -72,10 +75,11 @@
         setTurnRestrictions(turnRestrictions);
     }
-    
+
     /* --------------------------------------------------------------------------- */
     /* interface DataSetListener                                                   */
-    /* --------------------------------------------------------------------------- */   
-    public void dataChanged(DataChangedEvent event) {       
-        OsmDataLayer layer = Main.main.getEditLayer();
+    /* --------------------------------------------------------------------------- */
+    @Override
+    public void dataChanged(DataChangedEvent event) {
+        OsmDataLayer layer = Main.getLayerManager().getEditLayer();
         if (layer == null) {
             setTurnRestrictions(null);
@@ -86,4 +90,5 @@
     }
 
+    @Override
     public void primitivesAdded(PrimitivesAddedEvent event) {
         List<Relation> turnRestrictions = filterTurnRestrictions(event.getPrimitives());
@@ -93,4 +98,5 @@
     }
 
+    @Override
     public void primitivesRemoved(PrimitivesRemovedEvent event) {
         List<Relation> turnRestrictions = filterTurnRestrictions(event.getPrimitives());
@@ -100,9 +106,10 @@
     }
 
+    @Override
     public void relationMembersChanged(RelationMembersChangedEvent event) {
         List<Relation> turnRestrictions = filterTurnRestrictions(event.getPrimitives());
         if (!turnRestrictions.isEmpty()) {
             List<Relation> sel = getSelectedTurnRestrictions();
-            for(Relation tr: turnRestrictions) {    
+            for(Relation tr: turnRestrictions) {
                 // enforce a repaint of the respective turn restriction
                 int idx = getTurnRestrictionIndex(tr);
@@ -113,9 +120,10 @@
     }
 
+    @Override
     public void tagsChanged(TagsChangedEvent event) {
         List<Relation> turnRestrictions = filterTurnRestrictions(event.getPrimitives());
         if (!turnRestrictions.isEmpty()) {
             List<Relation> sel = getSelectedTurnRestrictions();
-            for(Relation tr: turnRestrictions) {    
+            for(Relation tr: turnRestrictions) {
                 // enforce a repaint of the respective turn restriction
                 int idx = getTurnRestrictionIndex(tr);
@@ -123,9 +131,12 @@
             }
             setSelectedTurnRestrictions(sel);
-        }       
+        }
     }
 
+    @Override
     public void wayNodesChanged(WayNodesChangedEvent event) {/* ignore */}
+    @Override
     public void nodeMoved(NodeMovedEvent event) {/* ignore */}
+    @Override
     public void otherDatasetChange(AbstractDatasetChangedEvent event) {/* ignore */}
 }
Index: /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsInDatasetView.java
===================================================================
--- /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsInDatasetView.java	(revision 32374)
+++ /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsInDatasetView.java	(revision 32375)
@@ -12,11 +12,10 @@
 import org.openstreetmap.josm.data.osm.event.DatasetEventManager;
 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
-import org.openstreetmap.josm.gui.MapView;
-import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
+import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
 
 /**
  * This is the view for the list of turn restrictions in the current data set.
  */
-public class TurnRestrictionsInDatasetView extends AbstractTurnRestrictionsListView {    
+public class TurnRestrictionsInDatasetView extends AbstractTurnRestrictionsListView {
     protected void build() {
         DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
@@ -26,5 +25,5 @@
         lstTurnRestrictions.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
         lstTurnRestrictions.setCellRenderer(new TurnRestrictionCellRenderer());
-        
+
         setLayout(new BorderLayout());
         add(new JScrollPane(lstTurnRestrictions), BorderLayout.CENTER);
@@ -32,13 +31,13 @@
 
     protected void registerAsListener() {
-        MapView.addEditLayerChangeListener((EditLayerChangeListener)model);
+        Main.getLayerManager().addActiveLayerChangeListener((ActiveLayerChangeListener)model);
         DatasetEventManager.getInstance().addDatasetListener((DataSetListener)model, FireMode.IN_EDT);
-        if (Main.main.getEditLayer() != null) {
-            model.setTurnRestrictions(Main.main.getEditLayer().data.getRelations());
+        if (Main.getLayerManager().getEditLayer() != null) {
+            model.setTurnRestrictions(Main.getLayerManager().getEditLayer().data.getRelations());
         }
     }
 
     protected void unregisterAsListener() {
-        MapView.removeEditLayerChangeListener((EditLayerChangeListener)model);
+        Main.getLayerManager().removeActiveLayerChangeListener((ActiveLayerChangeListener)model);
         DatasetEventManager.getInstance().removeDatasetListener((DataSetListener)model);
     }
Index: /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsInSelectionListModel.java
===================================================================
--- /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsInSelectionListModel.java	(revision 32374)
+++ /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsInSelectionListModel.java	(revision 32375)
@@ -7,8 +7,10 @@
 import javax.swing.DefaultListSelectionModel;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.SelectionChangedListener;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Relation;
-import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
+import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
+import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 
@@ -17,16 +19,16 @@
  * objects in the current selection.
  */
-public class TurnRestrictionsInSelectionListModel extends TurnRestrictionsListModel implements EditLayerChangeListener, SelectionChangedListener {
+public class TurnRestrictionsInSelectionListModel extends TurnRestrictionsListModel implements ActiveLayerChangeListener, SelectionChangedListener {
     //private static final Logger logger = Logger.getLogger(TurnRestrictionsInSelectionListModel.class.getName());
-    
+
     public TurnRestrictionsInSelectionListModel(
             DefaultListSelectionModel selectionModel) {
         super(selectionModel);
     }
-    
+
     /**
-     * Initializes the model with the turn restrictions the primitives in 
+     * Initializes the model with the turn restrictions the primitives in
      * {@code selection} participate.
-     * 
+     *
      * @param selection the collection of selected primitives
      */
@@ -44,7 +46,9 @@
 
     /* --------------------------------------------------------------------------- */
-    /* interface EditLayerChangeListener                                           */
+    /* interface ActiveLayerChangeListener                                         */
     /* --------------------------------------------------------------------------- */
-    public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) {
+    @Override
+    public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
+        OsmDataLayer newLayer = Main.getLayerManager().getEditLayer();
         if (newLayer == null) {
             setTurnRestrictions(null);
@@ -53,8 +57,9 @@
         initFromSelection(newLayer.data.getSelected());
     }
-    
+
     /* --------------------------------------------------------------------------- */
     /* interface SelectionChangedListener                                          */
-    /* --------------------------------------------------------------------------- */   
+    /* --------------------------------------------------------------------------- */
+    @Override
     public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
         initFromSelection(newSelection);
Index: /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsInSelectionView.java
===================================================================
--- /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsInSelectionView.java	(revision 32374)
+++ /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsInSelectionView.java	(revision 32375)
@@ -14,11 +14,10 @@
 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
 import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
-import org.openstreetmap.josm.gui.MapView;
-import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
+import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
 
 /**
- * This is the view for the list of turn restrictions related to objects in the 
+ * This is the view for the list of turn restrictions related to objects in the
  * current selection.
- * 
+ *
  */
 public class TurnRestrictionsInSelectionView extends AbstractTurnRestrictionsListView {
@@ -31,5 +30,5 @@
         lstTurnRestrictions.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
         lstTurnRestrictions.setCellRenderer(new TurnRestrictionCellRenderer());
-        
+
         setLayout(new BorderLayout());
         add(new JScrollPane(lstTurnRestrictions), BorderLayout.CENTER);
@@ -37,9 +36,9 @@
 
     protected void registerAsListener() {
-        MapView.addEditLayerChangeListener((EditLayerChangeListener)model);
+        Main.getLayerManager().addActiveLayerChangeListener((ActiveLayerChangeListener)model);
         SelectionEventManager.getInstance().addSelectionListener((SelectionChangedListener)model, FireMode.IN_EDT_CONSOLIDATED);
         TurnRestrictionsInSelectionListModel m = (TurnRestrictionsInSelectionListModel)model;
-        if (Main.main.getEditLayer() != null){
-            m.initFromSelection(Main.main.getEditLayer().data.getSelected());
+        if (Main.getLayerManager().getEditLayer() != null){
+            m.initFromSelection(Main.getLayerManager().getEditLayer().data.getSelected());
         } else {
             m.initFromSelection(Collections.<OsmPrimitive>emptyList());
@@ -48,6 +47,6 @@
 
     protected void unregisterAsListener() {
-        MapView.removeEditLayerChangeListener((EditLayerChangeListener)model);
-        SelectionEventManager.getInstance().removeSelectionListener((SelectionChangedListener)model);       
+        Main.getLayerManager().removeActiveLayerChangeListener((ActiveLayerChangeListener)model);
+        SelectionEventManager.getInstance().removeSelectionListener((SelectionChangedListener)model);
     }
 
Index: /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsListDialog.java
===================================================================
--- /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsListDialog.java	(revision 32374)
+++ /applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsListDialog.java	(revision 32375)
@@ -29,9 +29,9 @@
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.RelationMember;
-import org.openstreetmap.josm.gui.MapView;
-import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
 import org.openstreetmap.josm.gui.SideButton;
 import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
 import org.openstreetmap.josm.gui.help.HelpUtil;
+import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
+import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
@@ -49,5 +49,5 @@
  *   <li>the list of turn restrictions related to OSM objects in the current selection</li>
  * </ol>
- * 
+ *
  */
 public class TurnRestrictionsListDialog extends ToggleDialog{
@@ -60,24 +60,24 @@
     /** the view for the turn restrictions related to the current selection */
     private TurnRestrictionsInSelectionView pnlTurnRestrictionsInSelection;
-    
+
     /** three actions */
     private NewAction actNew;
     private EditAction actEdit;
-    private DeleteAction actDelete;  
+    private DeleteAction actDelete;
     private SelectSelectedTurnRestrictions actSelectSelectedTurnRestrictions;
     private ZoomToAction actZoomTo;
     private SwitchListViewHandler switchListViewHandler;
-    
+
     private AbstractTurnRestrictionsListView currentListView = null;
-    
+
     /** the main content panel in this toggle dialog */
     private JPanel pnlContent;
     private PreferenceChangeHandler preferenceChangeHandler;
-    
+
     @Override
     public void showNotify() {
-        pnlTurnRestrictionsInDataSet.registerAsListener();      
+        pnlTurnRestrictionsInDataSet.registerAsListener();
         pnlTurnRestrictionsInSelection.registerAsListener();
-        MapView.addEditLayerChangeListener(actNew);
+        Main.getLayerManager().addActiveLayerChangeListener(actNew);
         actNew.updateEnabledState();
         Main.pref.addPreferenceChangeListener(preferenceChangeHandler);
@@ -89,5 +89,5 @@
         pnlTurnRestrictionsInDataSet.unregisterAsListener();
         pnlTurnRestrictionsInSelection.unregisterAsListener();
-        MapView.removeEditLayerChangeListener(actNew);
+        Main.getLayerManager().removeActiveLayerChangeListener(actNew);
         Main.pref.removePreferenceChangeListener(preferenceChangeHandler);
     }
@@ -119,23 +119,23 @@
             new SideButton(actDelete, false /* don't show the name */)
         }));
-        
-        // create the two list views 
+
+        // create the two list views
         pnlTurnRestrictionsInDataSet = new TurnRestrictionsInDatasetView();
         pnlTurnRestrictionsInSelection = new TurnRestrictionsInSelectionView();
-        
-        // wire the handler for switching between list views 
+
+        // wire the handler for switching between list views
         switchListViewHandler = new SwitchListViewHandler();
         switchListViewHandler.activateListView(pnlTurnRestrictionsInDataSet);
         cbInSelectionOnly.addItemListener(switchListViewHandler);
-        
-        // wire the popup menu launcher to the two turn restriction lists  
+
+        // wire the popup menu launcher to the two turn restriction lists
         TurnRestrictionsPopupLauncher launcher = new TurnRestrictionsPopupLauncher();
         pnlTurnRestrictionsInDataSet.getList().addMouseListener(launcher);
         pnlTurnRestrictionsInSelection.getList().addMouseListener(launcher);
-        
+
         preferenceChangeHandler = new PreferenceChangeHandler();
-        
-    }
-    
+
+    }
+
     /**
      * Constructor
@@ -143,5 +143,5 @@
     public TurnRestrictionsListDialog() {
         super(
-                tr("Turn Restrictions"), 
+                tr("Turn Restrictions"),
                 "turnrestrictions",
                 tr("Display and manage turn restrictions in the current data set"),
@@ -151,6 +151,6 @@
         build();
         HelpUtil.setHelpContext(this, HelpUtil.ht("/Plugin/TurnRestrictions#TurnRestrictionToggleDialog"));
-    }   
-    
+    }
+
     /**
      * Switches between the two list view.
@@ -166,5 +166,5 @@
             }
             pnlContent.add(view,BorderLayout.CENTER);
-            currentListView = view;                     
+            currentListView = view;
             view.addListSelectionListener(actEdit);
             view.addListSelectionListener(actDelete);
@@ -176,7 +176,8 @@
             actZoomTo.updateEnabledState();
             currentListView.revalidate();
-            currentListView.repaint();          
-        }
-
+            currentListView.repaint();
+        }
+
+        @Override
         public void itemStateChanged(ItemEvent e) {
             switch(e.getStateChange()) {
@@ -184,6 +185,6 @@
                 activateListView(pnlTurnRestrictionsInSelection);
                 break;
-                
-            case ItemEvent.DESELECTED:      
+
+            case ItemEvent.DESELECTED:
                 activateListView(pnlTurnRestrictionsInDataSet);
                 break;
@@ -191,5 +192,5 @@
         }
     }
-    
+
      /**
      * The edit action
@@ -199,5 +200,5 @@
         public EditAction() {
             putValue(SHORT_DESCRIPTION,tr("Open an editor for the selected turn restriction"));
-            putValue(SMALL_ICON, ImageProvider.get("dialogs", "edit"));
+            new ImageProvider("dialogs", "edit").getResource().attachImageIcon(this);
             putValue(NAME, tr("Edit"));
             setEnabled(false);
@@ -205,5 +206,5 @@
         protected Collection<RelationMember> getMembersForCurrentSelection(Relation r) {
             Collection<RelationMember> members = new HashSet<>();
-            Collection<OsmPrimitive> selection = Main.main.getEditLayer().data.getSelected();
+            Collection<OsmPrimitive> selection = Main.getLayerManager().getEditLayer().data.getSelected();
             for (RelationMember member: r.getMembers()) {
                 if (selection.contains(member.getMember())) {
@@ -217,5 +218,5 @@
             if (toEdit == null)
                 return;
-            OsmDataLayer layer = Main.main.getEditLayer();
+            OsmDataLayer layer = Main.getLayerManager().getEditLayer();
             TurnRestrictionEditorManager manager = TurnRestrictionEditorManager.getInstance();
             TurnRestrictionEditor editor = manager.getEditorForRelation(layer, toEdit);
@@ -232,4 +233,5 @@
         }
 
+        @Override
         public void actionPerformed(ActionEvent e) {
             if (!isEnabled())
@@ -243,5 +245,6 @@
             setEnabled(currentListView!= null && currentListView.getModel().getSelectedTurnRestrictions().size() == 1);
         }
-        
+
+        @Override
         public void valueChanged(ListSelectionEvent e) {
             updateEnabledState();
@@ -258,5 +261,5 @@
         public DeleteAction() {
             putValue(SHORT_DESCRIPTION,tr("Delete the selected turn restriction"));
-            putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));
+            new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this);
             putValue(NAME, tr("Delete"));
             setEnabled(false);
@@ -267,9 +270,10 @@
                 return;
             org.openstreetmap.josm.actions.mapmode.DeleteAction.deleteRelation(
-                    Main.main.getEditLayer(),
+                    Main.getLayerManager().getEditLayer(),
                     toDelete
             );
         }
 
+        @Override
         public void actionPerformed(ActionEvent e) {
             if (!isEnabled()) return;
@@ -279,9 +283,10 @@
             }
         }
-        
+
         public void updateEnabledState() {
             setEnabled(currentListView != null && !currentListView.getModel().getSelectedTurnRestrictions().isEmpty());
         }
 
+        @Override
         public void valueChanged(ListSelectionEvent e) {
             updateEnabledState();
@@ -293,8 +298,8 @@
      *
      */
-     class NewAction extends AbstractAction implements EditLayerChangeListener{
+     class NewAction extends AbstractAction implements ActiveLayerChangeListener {
         public NewAction() {
             putValue(SHORT_DESCRIPTION,tr("Create a new turn restriction"));
-            putValue(SMALL_ICON, ImageProvider.get("new"));
+            new ImageProvider("new").getResource().attachImageIcon(this);
             putValue(NAME, tr("New"));
             updateEnabledState();
@@ -302,13 +307,14 @@
 
         public void run() {
-             OsmDataLayer layer =  Main.main.getEditLayer();
+             OsmDataLayer layer = Main.getLayerManager().getEditLayer();
              if (layer == null) return;
              Relation tr = new TurnRestrictionBuilder().buildFromSelection(layer);
              TurnRestrictionEditor editor = new TurnRestrictionEditor(TurnRestrictionsListDialog.this, layer, tr);
-             TurnRestrictionEditorManager.getInstance().positionOnScreen(editor);             
+             TurnRestrictionEditorManager.getInstance().positionOnScreen(editor);
              TurnRestrictionEditorManager.getInstance().register(layer, tr, editor);
              editor.setVisible(true);
         }
 
+        @Override
         public void actionPerformed(ActionEvent e) {
             run();
@@ -316,15 +322,15 @@
 
         public void updateEnabledState() {
-            setEnabled(Main.main != null && Main.main.hasEditLayer());
-        }
-
-        public void editLayerChanged(OsmDataLayer oldLayer,
-                OsmDataLayer newLayer) {
-            updateEnabledState();
-        }
-    }
-    
-    /**
-     * Sets the selection of the current data set to the currently selected 
+            setEnabled(Main.getLayerManager().getEditLayer() != null);
+        }
+
+        @Override
+        public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
+            updateEnabledState();
+        }
+    }
+
+    /**
+     * Sets the selection of the current data set to the currently selected
      * turn restrictions.
      *
@@ -340,24 +346,26 @@
         }
 
+        @Override
         public void actionPerformed(ActionEvent e) {
             if (!isEnabled()) return;
             List<Relation> toSelect = currentListView.getModel().getSelectedTurnRestrictions();
             if (toSelect.isEmpty()) return;
-            OsmDataLayer layer= Main.main.getEditLayer();
+            OsmDataLayer layer= Main.getLayerManager().getEditLayer();
             if (layer == null) return;
             layer.data.setSelected(toSelect);
         }
-        
+
         public void updateEnabledState() {
             setEnabled(currentListView != null && !currentListView.getModel().getSelectedTurnRestrictions().isEmpty());
         }
 
+        @Override
         public void valueChanged(ListSelectionEvent e) {
             updateEnabledState();
         }
     }
-    
-    /**
-     * Sets the selection of the current data set to the currently selected 
+
+    /**
+     * Sets the selection of the current data set to the currently selected
      * turn restrictions.
      *
@@ -373,26 +381,28 @@
         }
 
+        @Override
         public void actionPerformed(ActionEvent e) {
             if (!isEnabled()) return;
             List<Relation> toSelect = currentListView.getModel().getSelectedTurnRestrictions();
             if (toSelect.isEmpty()) return;
-            OsmDataLayer layer= Main.main.getEditLayer();
+            OsmDataLayer layer= Main.getLayerManager().getEditLayer();
             if (layer == null) return;
             layer.data.setSelected(toSelect);
             new AutoScaleAction("selection").autoScale();
         }
-        
+
         public void updateEnabledState() {
             setEnabled(currentListView != null && !currentListView.getModel().getSelectedTurnRestrictions().isEmpty());
         }
 
+        @Override
         public void valueChanged(ListSelectionEvent e) {
             updateEnabledState();
         }
     }
-    
+
     /**
      * The launcher for the popup menu.
-     * 
+     *
      */
     class TurnRestrictionsPopupLauncher extends PopupMenuLauncher {
@@ -412,5 +422,5 @@
 
     /**
-     * The popup menu 
+     * The popup menu
      *
      */
@@ -425,11 +435,11 @@
         }
     }
-    
+
     /**
      * Listens the changes of the preference {@link PreferenceKeys#ROAD_SIGNS}
-     * and refreshes the set of road icons 
-     *
-     */
-    class PreferenceChangeHandler implements PreferenceChangedListener {        
+     * and refreshes the set of road icons
+     *
+     */
+    class PreferenceChangeHandler implements PreferenceChangedListener {
         public void refreshIconSet() {
             pnlTurnRestrictionsInDataSet.initIconSetFromPreferences(Main.pref);
@@ -437,6 +447,7 @@
             repaint();
         }
-        
-        public void preferenceChanged(PreferenceChangeEvent evt) {          
+
+        @Override
+        public void preferenceChanged(PreferenceChangeEvent evt) {
             if (!evt.getKey().equals(PreferenceKeys.ROAD_SIGNS)) return;
             refreshIconSet();
