Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 17830 invoked from network); 6 Jun 2007 12:35:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Jun 2007 12:35:37 -0000 Received: (qmail 82050 invoked by uid 500); 6 Jun 2007 12:35:41 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 81957 invoked by uid 500); 6 Jun 2007 12:35:40 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 81948 invoked by uid 99); 6 Jun 2007 12:35:40 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Jun 2007 05:35:40 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Jun 2007 05:35:36 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 18C0D1A981A; Wed, 6 Jun 2007 05:35:16 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r544826 - in /harmony/enhanced/classlib/trunk/modules/beans/src: main/java/org/apache/harmony/beans/editors/ColorEditor.java test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerRegressionTest.java Date: Wed, 06 Jun 2007 12:35:15 -0000 To: commits@harmony.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070606123516.18C0D1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tellison Date: Wed Jun 6 05:35:15 2007 New Revision: 544826 URL: http://svn.apache.org/viewvc?view=rev&rev=544826 Log: Apply patch HARMONY-4062 ([classlib][beans]org.apache.harmony.beans.editors.ColorEditor lacks support for setAsText) Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ColorEditor.java harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerRegressionTest.java Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ColorEditor.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ColorEditor.java?view=diff&rev=544826&r1=544825&r2=544826 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ColorEditor.java (original) +++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ColorEditor.java Wed Jun 6 05:35:15 2007 @@ -67,6 +67,31 @@ super.setValue(value); } } + + @Override + public void setAsText(String text) { + if (null == text) { + throw new NullPointerException(); + } + + int r = 0; + int g = 0; + int b = 0; + + try { + int index = text.indexOf(","); + r = Integer.parseInt(text.substring(0, index)); + text = text.substring(index + 1); + index = text.indexOf(","); + g = Integer.parseInt(text.substring(0, index)); + text = text.substring(index + 1); + b = Integer.parseInt(text); + setValue(new Color(r, g, b)); + } catch (Exception e) { + throw new IllegalArgumentException(text); + } + } + @Override public boolean isPaintable() { Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerRegressionTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerRegressionTest.java?view=diff&rev=544826&r1=544825&r2=544826 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerRegressionTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerRegressionTest.java Wed Jun 6 05:35:15 2007 @@ -17,6 +17,7 @@ package org.apache.harmony.beans.tests.java.beans; +import java.awt.Color; import java.beans.PropertyEditor; import java.beans.PropertyEditorManager; @@ -72,5 +73,36 @@ editor.setAsText(text); assertEquals(text, editor.getAsText()); + } + + // Regression for HARMONY-4062 + public void testColorEditor() { + PropertyEditor propertyEditor = PropertyEditorManager + .findEditor(Color.class); + propertyEditor.setValue(new Color(0, 0, 0)); + propertyEditor.setAsText("1,2,3"); + Color newColor = new Color(1, 2, 3); + assertEquals(newColor, propertyEditor.getValue()); + + try { + propertyEditor.setAsText(null); + fail("should throw NullPointerException"); + } catch (NullPointerException e) { + // expected. + } + + try { + propertyEditor.setAsText("illegalArugment"); + fail("should throw IllegalArgumentException"); + } catch (IllegalArgumentException e) { + // expected. + } + + try { + propertyEditor.setAsText("1,2,3,4"); + fail("should throw IllegalArgumentException"); + } catch (IllegalArgumentException e) { + //expected. + } } }