harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r517207 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/plaf/basic/BasicSliderUI.java test/api/java/common/javax/swing/plaf/basic/BasicSliderUITest.java
Date Mon, 12 Mar 2007 13:21:16 GMT
Author: apetrenko
Date: Mon Mar 12 06:21:15 2007
New Revision: 517207

URL: http://svn.apache.org/viewvc?view=rev&rev=517207
Log:
Patch for HARMONY-2879 "[classlib][swing] j.s.plaf.basic.BasicSliderUI.createXXXListener()
methods modify slider field"

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSliderUI.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSliderUITest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSliderUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSliderUI.java?view=diff&rev=517207&r1=517206&r2=517207
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSliderUI.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSliderUI.java
Mon Mar 12 06:21:15 2007
@@ -92,7 +92,6 @@
         }
     }
 
-
     public class ComponentHandler extends ComponentAdapter {
         @Override
         public void componentResized(final ComponentEvent e) {
@@ -383,6 +382,12 @@
     private Color focusColor;
 
     private boolean isDragging;
+
+    private ChangeListener changeHandler;
+    private ComponentListener componentHandler;
+    private FocusListener focusHandler;
+    private PropertyChangeListener propertyChangeHandler;
+
     private static final int THUMB_WIDTH = 11;
     private static final int THUMB_HEIGHT = 20;
     private static final int TRACK_SIZE = 2;
@@ -434,7 +439,6 @@
     @Override
     public void uninstallUI(final JComponent c) {
         if (c != slider) {
-            // TODO Perform i18n after HARMONY-1320 is applied
             throw new IllegalComponentStateException(Messages.getString("swing.0E",new Object[]{this,
c, slider})); //$NON-NLS-1$
         }
         uninstallListeners(slider);
@@ -452,23 +456,28 @@
     }
 
     protected TrackListener createTrackListener(final JSlider slider) {
-        this.slider = slider;
         return new TrackListener();
     }
 
     protected ChangeListener createChangeListener(final JSlider slider) {
-        this.slider = slider;
-        return new ChangeHandler();
+        if (changeHandler == null) {
+            changeHandler = new ChangeHandler();
+        }
+        return changeHandler;
     }
 
     protected ComponentListener createComponentListener(final JSlider slider) {
-        this.slider = slider;
-        return new ComponentHandler();
+        if (componentHandler == null) {
+            componentHandler = new ComponentHandler();
+        }
+        return componentHandler;
     }
 
     protected FocusListener createFocusListener(final JSlider slider) {
-        this.slider = slider;
-        return new FocusHandler();
+        if (focusHandler == null) {
+            focusHandler = new FocusHandler();
+        }
+        return focusHandler;
     }
 
     protected ScrollListener createScrollListener(final JSlider slider) {
@@ -478,8 +487,10 @@
     }
 
     protected PropertyChangeListener createPropertyChangeListener(final JSlider slider) {
-        this.slider = slider;
-        return new PropertyChangeHandler();
+        if (propertyChangeHandler == null) {
+            propertyChangeHandler = new PropertyChangeHandler();
+        }
+        return propertyChangeHandler;
     }
 
     protected void installListeners(final JSlider slider) {

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSliderUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSliderUITest.java?view=diff&rev=517207&r1=517206&r2=517207
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSliderUITest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicSliderUITest.java
Mon Mar 12 06:21:15 2007
@@ -14,10 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Sergey Burlak
- * @version $Revision$
- */
 package javax.swing.plaf.basic;
 
 import java.awt.IllegalComponentStateException;
@@ -84,31 +80,68 @@
 
     public void testCreateUI() throws Exception {
         assertNotNull(BasicSliderUI.createUI(slider));
-        assertFalse(BasicSliderUI.createUI(slider) == BasicSliderUI.createUI(slider));
+        assertNotSame(BasicSliderUI.createUI(slider),
+                      BasicSliderUI.createUI(slider));
     }
 
     public void testCreateTrackListener() throws Exception {
+        assertNull(sliderUI.slider);
         assertNotNull(sliderUI.createTrackListener(slider));
-        assertFalse(sliderUI.createTrackListener(slider) == sliderUI
-                .createTrackListener(slider));
+        assertNull(sliderUI.slider);
+        assertNull(sliderUI.trackListener);
+        assertNotSame(sliderUI.createTrackListener(slider),
+                      sliderUI.createTrackListener(new JSlider()));
     }
 
     public void testCreateChangeListener() throws Exception {
+        assertNull(sliderUI.slider);
         assertNotNull(sliderUI.createChangeListener(slider));
-        assertFalse(sliderUI.createChangeListener(slider) == sliderUI
-                .createChangeListener(slider));
+        assertNull(sliderUI.slider);
+        assertNull(sliderUI.changeListener);
+        assertSame(sliderUI.createChangeListener(slider),
+                   sliderUI.createChangeListener(new JSlider()));
+    }
+
+    public void testCreateChangeListenerNotSame() throws Exception {
+        assertNotSame(sliderUI.createChangeListener(slider),
+                      new BasicSliderUI(slider).createChangeListener(slider));
     }
 
     public void testCreateComponentListener() throws Exception {
+        assertNull(sliderUI.slider);
         assertNotNull(sliderUI.createComponentListener(slider));
-        assertFalse(sliderUI.createComponentListener(slider) == sliderUI
-                .createComponentListener(slider));
+        assertNull(sliderUI.slider);
+        assertNull(sliderUI.componentListener);
+        assertSame(sliderUI.createComponentListener(slider),
+                   sliderUI.createComponentListener(new JSlider()));
+    }
+
+    public void testCreateComponentListenerNotSame() throws Exception {
+        assertNotSame(sliderUI.createComponentListener(slider),
+                      new BasicSliderUI(slider).createComponentListener(slider));
+    }
+
+    public void testCreateFocusListener() throws Exception {
+        assertNull(sliderUI.slider);
+        assertNotNull(sliderUI.createFocusListener(slider));
+        assertNull(sliderUI.slider);
+        assertNull(sliderUI.focusListener);
+        assertSame(sliderUI.createFocusListener(slider),
+                   sliderUI.createFocusListener(new JSlider()));
+    }
+
+    public void testCreateFocusListenerNotSame() throws Exception {
+        assertNotSame(sliderUI.createFocusListener(slider),
+                      new BasicSliderUI(slider).createFocusListener(slider));
     }
 
     public void testCreateScrollListener() throws Exception {
+        assertNull(sliderUI.slider);
         assertNotNull(sliderUI.createScrollListener(slider));
-        assertFalse(sliderUI.createScrollListener(slider) == sliderUI
-                .createScrollListener(slider));
+        assertNull(sliderUI.slider);
+        assertNull(sliderUI.scrollListener);
+        assertNotSame(sliderUI.createScrollListener(slider),
+                      sliderUI.createScrollListener(slider));
     }
 
     // Regression for HARMONY-2878
@@ -117,9 +150,17 @@
     }
 
     public void testCreatePropertyChangeListener() throws Exception {
+        assertNull(sliderUI.slider);
         assertNotNull(sliderUI.createPropertyChangeListener(slider));
-        assertFalse(sliderUI.createPropertyChangeListener(slider) == sliderUI
-                .createPropertyChangeListener(slider));
+        assertNull(sliderUI.slider);
+        assertNull(sliderUI.propertyChangeListener);
+        assertSame(sliderUI.createPropertyChangeListener(slider),
+                   sliderUI.createPropertyChangeListener(new JSlider()));
+    }
+
+    public void testCreatePropertyChangeListenerNotSame() throws Exception {
+        assertNotSame(sliderUI.createPropertyChangeListener(slider),
+                      new BasicSliderUI(slider).createPropertyChangeListener(slider));
     }
 
     public void testGetShadowColor() throws Exception {



Mime
View raw message