Index: trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java	(revision 9925)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java	(revision 9926)
@@ -115,7 +115,4 @@
     private final LayerList layerList;
 
-    private final SideButton opacityButton;
-    private final SideButton gammaButton;
-
     private final ActivateLayerAction activateLayerAction;
     private final ShowHideLayerAction showHideLayerAction;
@@ -268,12 +265,14 @@
 
         // -- layer opacity action
-        LayerOpacityAction layerOpacityAction = new LayerOpacityAction();
+        LayerOpacityAction layerOpacityAction = new LayerOpacityAction(model);
         adaptTo(layerOpacityAction, selectionModel);
-        opacityButton = new SideButton(layerOpacityAction, false);
+        SideButton opacityButton = new SideButton(layerOpacityAction, false);
+        layerOpacityAction.setCorrespondingSideButton(opacityButton);
 
         // -- layer gamma action
-        LayerGammaAction layerGammaAction = new LayerGammaAction();
+        LayerGammaAction layerGammaAction = new LayerGammaAction(model);
         adaptTo(layerGammaAction, selectionModel);
-        gammaButton = new SideButton(layerGammaAction, false);
+        SideButton gammaButton = new SideButton(layerGammaAction, false);
+        layerGammaAction.setCorrespondingSideButton(gammaButton);
 
         // -- delete layer action
@@ -533,10 +532,13 @@
      */
     public abstract static class AbstractLayerPropertySliderAction extends AbstractAction implements IEnabledStateUpdating, LayerAction {
+        protected final LayerListModel model;
         protected final JPopupMenu popup;
         protected final JSlider slider;
         private final double factor;
-
-        public AbstractLayerPropertySliderAction(String name, final double factor) {
+        private SideButton sideButton;
+
+        protected AbstractLayerPropertySliderAction(LayerListModel model, String name, final double factor) {
             super(name);
+            this.model = model;
             this.factor = factor;
             updateEnabledState();
@@ -551,5 +553,4 @@
             });
             popup.add(slider);
-
         }
 
@@ -558,9 +559,14 @@
         protected abstract double getValue();
 
-        protected abstract SideButton getCorrespondingSideButton();
+        /**
+         * Sets the corresponding side button.
+         * @param sideButton the corresponding side button
+         */
+        final void setCorrespondingSideButton(SideButton sideButton) {
+            this.sideButton = sideButton;
+        }
 
         @Override
         public void actionPerformed(ActionEvent e) {
-            final SideButton sideButton = getCorrespondingSideButton();
             slider.setValue((int) (getValue() * factor));
             if (e.getSource() == sideButton) {
@@ -577,5 +583,4 @@
             return new JMenuItem(this);
         }
-
     }
 
@@ -583,16 +588,16 @@
      * Action which allows to change the opacity of one or more layers.
      */
-    public final class LayerOpacityAction extends AbstractLayerPropertySliderAction {
+    public static final class LayerOpacityAction extends AbstractLayerPropertySliderAction {
         private transient Layer layer;
 
         /**
-         * Creates a {@link LayerOpacityAction} which allows to change the
-         * opacity of one or more layers.
-         *
+         * Creates a {@link LayerOpacityAction} which allows to change the opacity of one or more layers.
+         *
+         * @param model layer list model
          * @param layer  the layer. Must not be null.
          * @throws IllegalArgumentException if layer is null
          */
-        public LayerOpacityAction(Layer layer) {
-            this();
+        public LayerOpacityAction(LayerListModel model, Layer layer) {
+            this(model);
             CheckParameterUtil.ensureParameterNotNull(layer, "layer");
             this.layer = layer;
@@ -601,10 +606,9 @@
 
         /**
-         * Creates a {@link ShowHideLayerAction} which will toggle the visibility of
-         * the currently selected layers
-         *
-         */
-        public LayerOpacityAction() {
-            super(tr("Opacity"), 100);
+         * Creates a {@link ShowHideLayerAction} which will toggle the visibility of the currently selected layers
+         * @param model layer list model
+         */
+        public LayerOpacityAction(LayerListModel model) {
+            super(model, tr("Opacity"), 100);
             putValue(SHORT_DESCRIPTION, tr("Adjust opacity of the layer."));
             putValue(SMALL_ICON, ImageProvider.get("dialogs/layerlist", "transparency"));
@@ -617,6 +621,6 @@
                 layer.setOpacity(value);
             } else {
-                for (Layer layer: model.getSelectedLayers()) {
-                    layer.setOpacity(value);
+                for (Layer l : model.getSelectedLayers()) {
+                    l.setOpacity(value);
                 }
             }
@@ -630,14 +634,9 @@
                 double opacity = 0;
                 List<Layer> layers = model.getSelectedLayers();
-                for (Layer layer: layers) {
-                    opacity += layer.getOpacity();
+                for (Layer l : layers) {
+                    opacity += l.getOpacity();
                 }
                 return opacity / layers.size();
             }
-        }
-
-        @Override
-        protected SideButton getCorrespondingSideButton() {
-            return opacityButton;
         }
 
@@ -645,5 +644,5 @@
         public void updateEnabledState() {
             if (layer == null) {
-                setEnabled(!getModel().getSelectedLayers().isEmpty());
+                setEnabled(!model.getSelectedLayers().isEmpty());
             } else {
                 setEnabled(true);
@@ -660,8 +659,12 @@
      * Action which allows to change the gamma of one imagery layer.
      */
-    public final class LayerGammaAction extends AbstractLayerPropertySliderAction {
-
-        public LayerGammaAction() {
-            super(tr("Gamma"), 50);
+    public static final class LayerGammaAction extends AbstractLayerPropertySliderAction {
+
+        /**
+         * Constructs a new {@code LayerGammaAction}.
+         * @param model layer list model
+         */
+        public LayerGammaAction(LayerListModel model) {
+            super(model, tr("Gamma"), 50);
             putValue(SHORT_DESCRIPTION, tr("Adjust gamma value of the layer."));
             putValue(SMALL_ICON, ImageProvider.get("dialogs/layerlist", "gamma"));
@@ -678,9 +681,4 @@
         protected double getValue() {
             return Utils.filteredCollection(model.getSelectedLayers(), ImageryLayer.class).iterator().next().getGamma();
-        }
-
-        @Override
-        protected SideButton getCorrespondingSideButton() {
-            return gammaButton;
         }
 
@@ -1112,5 +1110,5 @@
             Layer layer = (Layer) value;
             if (layer instanceof NativeScaleLayer) {
-                boolean active = layer != null && layer == Main.map.mapView.getNativeScaleLayer();
+                boolean active = ((NativeScaleLayer) layer) == Main.map.mapView.getNativeScaleLayer();
                 cb.setSelected(active);
                 cb.setToolTipText(active
@@ -1271,8 +1269,9 @@
      * the properties {@link Layer#VISIBLE_PROP} and {@link Layer#NAME_PROP}.
      */
-    public final class LayerListModel extends AbstractTableModel implements MapView.LayerChangeListener, PropertyChangeListener {
+    public static final class LayerListModel extends AbstractTableModel implements MapView.LayerChangeListener, PropertyChangeListener {
         /** manages list selection state*/
         private final DefaultListSelectionModel selectionModel;
         private final CopyOnWriteArrayList<LayerListModelListener> listeners;
+        private LayerList layerList;
 
         /**
@@ -1281,7 +1280,11 @@
          * @param selectionModel the list selection model
          */
-        private LayerListModel(DefaultListSelectionModel selectionModel) {
+        LayerListModel(DefaultListSelectionModel selectionModel) {
             this.selectionModel = selectionModel;
             listeners = new CopyOnWriteArrayList<>();
+        }
+
+        void setlayerList(LayerList layerList) {
+            this.layerList = layerList;
         }
 
@@ -1732,6 +1735,7 @@
 
     static class LayerList extends JTable {
-        LayerList(TableModel dataModel) {
+        LayerList(LayerListModel dataModel) {
             super(dataModel);
+            dataModel.setlayerList(this);
         }
 
Index: trunk/test/unit/org/openstreetmap/josm/gui/dialogs/LayerListDialogTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/dialogs/LayerListDialogTest.java	(revision 9926)
+++ trunk/test/unit/org/openstreetmap/josm/gui/dialogs/LayerListDialogTest.java	(revision 9926)
@@ -0,0 +1,71 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.dialogs;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.dialogs.LayerListDialog.LayerGammaAction;
+import org.openstreetmap.josm.gui.dialogs.LayerListDialog.LayerListModel;
+import org.openstreetmap.josm.gui.dialogs.LayerListDialog.LayerOpacityAction;
+import org.openstreetmap.josm.gui.layer.TMSLayer;
+import org.openstreetmap.josm.gui.layer.TMSLayerTest;
+
+/**
+ * Unit tests of {@link LayerListDialog} class.
+ */
+public class LayerListDialogTest {
+
+    /**
+     * Setup tests
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        JOSMFixture.createUnitTestFixture().init(true);
+    }
+
+    /**
+     * Unit test of {@link LayerGammaAction} class.
+     */
+    @Test
+    public void testLayerGammaAction() {
+        TMSLayer layer = TMSLayerTest.createTmsLayer();
+        try {
+            Main.map.mapView.addLayer(layer);
+            LayerListModel model = LayerListDialog.getInstance().getModel();
+            LayerGammaAction action = new LayerGammaAction(model);
+            action.updateEnabledState();
+            assertTrue(action.isEnabled());
+            assertTrue(action.supportLayers(model.getSelectedLayers()));
+            assertEquals(1.0, action.getValue(), 1e-15);
+            action.setValue(0.5);
+            assertEquals(0.5, action.getValue(), 1e-15);
+        } finally {
+            Main.map.mapView.removeLayer(layer);
+        }
+    }
+
+    /**
+     * Unit test of {@link LayerOpacityAction} class.
+     */
+    @Test
+    public void testLayerOpacityAction() {
+        TMSLayer layer = TMSLayerTest.createTmsLayer();
+        try {
+            Main.map.mapView.addLayer(layer);
+            LayerListModel model = LayerListDialog.getInstance().getModel();
+            LayerOpacityAction action = new LayerOpacityAction(model);
+            action.updateEnabledState();
+            assertTrue(action.isEnabled());
+            assertTrue(action.supportLayers(model.getSelectedLayers()));
+            assertEquals(1.0, action.getValue(), 1e-15);
+            action.setValue(0.5);
+            assertEquals(0.5, action.getValue(), 1e-15);
+        } finally {
+            Main.map.mapView.removeLayer(layer);
+        }
+    }
+}
