[ 
https://issues.apache.org/jira/browse/PIVOT-501?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Greg Brown updated PIVOT-501:
-----------------------------

    Attachment: PIVOT-501.patch

The problem here appears to be two-fold:

1) ContainerSkin#getBackgroundColor() was throwing an IllegalStateException 
when the installed background paint was not a color. It should arguably return 
null instead of throwing, since we generally only throw exceptions in mutator 
methods.

2) TerraScrollBarSkin was overriding setBackgroundColor() and converting the 
color to a GradientPaint. This prevented a color from ever being set as the 
background paint and also produced a NullPointerException: calling 
setBackgroundColor(Color) fires a change event that the Component Explorer app 
responded to in order to keep the style color picker in sync with the scroll 
bar's background - however, this ultimate fails because getBackgroundColor() 
would always return null.

The attached patch fixes both issues.


> org.apache.pivot.tutorials.explorer.ComponentExplorer fails to handle 
> exception thrown when 'exploring' ScrollBar
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: PIVOT-501
>                 URL: https://issues.apache.org/jira/browse/PIVOT-501
>             Project: Pivot
>          Issue Type: Bug
>          Components: wtk-terra
>    Affects Versions: 1.4
>         Environment: Java(TM) SE Runtime Environment (build 1.6.0_19-b04)
> Windows XP x64 SP2
>            Reporter: Chris Bartlett
>             Fix For: 1.5
>
>         Attachments: PIVOT-501.patch
>
>
> Using code from revision 946968, the Component Explorer demo fails to handle 
> an exception which is thrown when 'exploring' ScrollBar in the Bounded Range 
> Components section.
> As shown below, the exception is thrown by BeanAdapter when it tries to get 
> the 'backgroundColor' property (of 
> org.apache.pivot.wtk.skin.terra.TerraScrollBarSkin) which happens to be a 
> java.awt.GradientPaint rather than a java.awt.Color.
>  java.lang.RuntimeException: Unable to access property "backgroundColor". 
>       at org.apache.pivot.beans.BeanAdapter.get(BeanAdapter.java:231)
>       at org.apache.pivot.wtk.Component$StyleDictionary.get(Component.java:63)
>       at org.apache.pivot.wtk.Component$StyleDictionary.get(Component.java:1)
>       at 
> org.apache.pivot.tools.wtk.ComponentInspectorSkin.addColorControl(ComponentInspectorSkin.java:1277)
>       at 
> org.apache.pivot.tools.wtk.ComponentInspectorSkin.addControl(ComponentInspectorSkin.java:157)
>       at 
> org.apache.pivot.tools.wtk.ComponentStyleInspectorSkin.sourceChanged(ComponentStyleInspectorSkin.java:75)
>       at 
> org.apache.pivot.tools.wtk.ComponentInspector$ComponentInspectorListenerList.sourceChanged(ComponentInspector.java:33)
>       at 
> org.apache.pivot.tools.wtk.ComponentInspector.setSource(ComponentInspector.java:52)
>       at 
> org.apache.pivot.tutorials.explorer.ComponentExplorer$1.selectedPathsChanged(ComponentExplorer.java:191)
>       at 
> org.apache.pivot.wtk.TreeView$TreeViewSelectionListenerList.selectedPathsChanged(TreeView.java:615)
>       at org.apache.pivot.wtk.TreeView.setSelectedPaths(TreeView.java:1336)
>       at org.apache.pivot.wtk.TreeView.setSelectedPath(TreeView.java:1393)
>       at 
> org.apache.pivot.wtk.skin.terra.TerraTreeViewSkin.mouseDown(TerraTreeViewSkin.java:1606)
>       at 
> org.apache.pivot.wtk.Component$ComponentMouseButtonListenerList.mouseDown(Component.java:451)
>       at org.apache.pivot.wtk.Component.mouseDown(Component.java:2600)
>       at org.apache.pivot.wtk.Container.mouseDown(Container.java:710)
>       at org.apache.pivot.wtk.Container.mouseDown(Container.java:710)
>       at org.apache.pivot.wtk.Container.mouseDown(Container.java:710)
>       at org.apache.pivot.wtk.Container.mouseDown(Container.java:710)
>       at org.apache.pivot.wtk.Container.mouseDown(Container.java:710)
>       at org.apache.pivot.wtk.Container.mouseDown(Container.java:710)
>       at org.apache.pivot.wtk.Container.mouseDown(Container.java:710)
>       at 
> org.apache.pivot.wtk.ApplicationContext$DisplayHost.processMouseEvent(ApplicationContext.java:804)
>       at java.awt.Component.processEvent(Unknown Source)
>       at 
> org.apache.pivot.wtk.ApplicationContext$DisplayHost.processEvent(ApplicationContext.java:656)
>       at java.awt.Component.dispatchEventImpl(Unknown Source)
>       at java.awt.Component.dispatchEvent(Unknown Source)
>       at java.awt.EventQueue.dispatchEvent(Unknown Source)
>       at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>       at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>       at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>       at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>       at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>       at java.awt.EventDispatchThread.run(Unknown Source)
> Caused by: java.lang.IllegalStateException: Background paint is not a Color.
>       at 
> org.apache.pivot.wtk.skin.ContainerSkin.getBackgroundColor(ContainerSkin.java:202)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>       at java.lang.reflect.Method.invoke(Unknown Source)
>       at org.apache.pivot.beans.BeanAdapter.get(BeanAdapter.java:227)
>       ... 33 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to