Pivot
  1. Pivot
  2. PIVOT-501

org.apache.pivot.tutorials.explorer.ComponentExplorer fails to handle exception thrown when 'exploring' ScrollBar

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 1.5
    • Component/s: wtk-terra
    • Environment:
      Java(TM) SE Runtime Environment (build 1.6.0_19-b04)
      Windows XP x64 SP2

      Description

      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

        Activity

        Hide
        Greg Brown added a comment -

        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.

        Show
        Greg Brown added a comment - 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.
        Hide
        Chris Bartlett added a comment -

        Apologies - I included the wrong stack trace
        Correct one below (I hope!)

        java.lang.RuntimeException: Unable to access property "backgroundColor".
        at org.apache.pivot.beans.BeanAdapter.get(BeanAdapter.java:229)
        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:225)
        ... 33 more

        Show
        Chris Bartlett added a comment - Apologies - I included the wrong stack trace Correct one below (I hope!) java.lang.RuntimeException: Unable to access property "backgroundColor". at org.apache.pivot.beans.BeanAdapter.get(BeanAdapter.java:229) 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:225) ... 33 more

          People

          • Assignee:
            Todd Volkert
            Reporter:
            Chris Bartlett
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development