Attached is a test app that reproduces the error. I had to revert the patch 
that Todd sent through to get the exception to occur.

On Wed, 16 Sep 2009 08:04:14 am Scott Lanham wrote:
> There is no threading in the app yet, just doing everything in the main
> thread. I am trying to build a test app to see if I can get it to break in
> another way.
>
> On Wed, 16 Sep 2009 07:51:29 am Greg Brown wrote:
> > If you don't see this exception consistently, a threading issue is
> > certainly a possibility. Are you doing anything in the background, and
> > then possibly closing a window when the operation completes?
> >
> > If you are using threads in your app, you need to make sure that all
> > UI operations execute on the event dispatch thread (same as Swing).
> > You can do this by passing a Runnable to
> > ApplicationContext.queueCallback().
> >
> > Greg
> >
> > On Sep 15, 2009, at 5:42 PM, Scott Lanham wrote:
> > > There is no exception this time but the row editor doesn't appear at
> > > all if
> > > invoked immediately after the new row is inserted.
> > >
> > > On Wed, 16 Sep 2009 07:26:48 am Todd Volkert wrote:
> > >> Very interesting.  The *only* way I could explain this error would
> > >> be if a
> > >> component was mucking with its parent's component collection in the
> > >> body of
> > >> validate().  Can you make the following change locally, re-run your
> > >> test,
> > >> and send us the stack trace:
> > >>
> > >> ===================================================================
> > >> --- wtk/src/org/apache/pivot/wtk/Container.java    (revision 815485)
> > >> +++ wtk/src/org/apache/pivot/wtk/Container.java    (working copy)
> > >> @@ -321,8 +321,7 @@
> > >>             && isVisible()) {
> > >>             super.validate();
> > >>
> > >> -            for (int i = 0, n = components.getLength(); i < n; i+
> > >> +) {
> > >> -                Component component = components.get(i);
> > >> +            for (Component component : components) {
> > >>                 component.validate();
> > >>             }
> > >>         }
> > >>
> > >> Thanks,
> > >> -T
> > >>
> > >> On Tue, Sep 15, 2009 at 5:08 PM, Scott Lanham <[email protected]>
> > >>
> > >> wrote:
> > >>> On Wed, 16 Sep 2009 06:50:51 am Todd Volkert wrote:
> > >>>> Just following up on this thread, are you all set now Scott with
> > >>>> the
> > >>>
> > >>> newest
> > >>>
> > >>>> code from SVN, or are you still getting an exception?
> > >>>>
> > >>>> -T
> > >>>
> > >>> Hi Todd,
> > >>>
> > >>> I still have the problem of adding a new record to the List bound
> > >>> to the
> > >>> TableView and then immediately invoking TableViewRowEditor on the
> > >>> row:
> > >>>
> > >>> Exception in thread "AWT-EventQueue-0"
> > >>> java.lang.IndexOutOfBoundsException at
> > >>> org.apache.pivot.collections.ArrayList.get(ArrayList.java:358) at
> > >>> org.apache.pivot.wtk.Container.validate(Container.java:325) at
> > >>> org.apache.pivot.wtk.Display$ValidateCallback.run(Display.java:30)
> > >>>        at
> > >>> java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
> > >>>       at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
> > >>>       at
> > >>>
> > >>> java.awt.EventDispatchThread.pumpOneEventForFilters
> > >>> (EventDispatchThread.j
> > >>> ava:269) at
> > >>>
> > >>> java.awt.EventDispatchThread.pumpEventsForFilter
> > >>> (EventDispatchThread.java
> > >>>
> > >>> :184) at
> > >>>
> > >>> java.awt.EventDispatchThread.pumpEventsForHierarchy
> > >>> (EventDispatchThread.j
> > >>> ava:174) at
> > >>> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
> > >>> 169)
> > >>>       at
> > >>> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
> > >>> 161)
> > >>>       at java.awt.EventDispatchThread.run(EventDispatchThread.java:
> > >>> 122)

package testing;

import org.apache.pivot.collections.HashMap;
import org.apache.pivot.collections.List;
import org.apache.pivot.collections.Map;
import org.apache.pivot.wtk.Application;
import org.apache.pivot.wtk.Button;
import org.apache.pivot.wtk.ButtonPressListener;
import org.apache.pivot.wtk.DesktopApplicationContext;
import org.apache.pivot.wtk.Display;

import org.apache.pivot.wtk.PushButton;
import org.apache.pivot.wtk.TableView;
import org.apache.pivot.wtk.Window;
import org.apache.pivot.wtk.content.TableViewRowEditor;
import org.apache.pivot.wtkx.WTKXSerializer;

public class testing implements Application
{
    private Window appWindow = null;
    private TableView view = null;
    private PushButton btn = null;
    
    public static void main(String[] args)
    {
        DesktopApplicationContext.main( testing.class, args );
    }

    public void startup( Display display, Map<String, String> properties ) throws Exception
    {        
        WTKXSerializer serial = new WTKXSerializer();
        appWindow = (Window) serial.readObject( this, "testing.xml" );

        view = (TableView) serial.get( "view" );

        TableViewRowEditor editor = new TableViewRowEditor();
        view.setRowEditor( editor );

        btn = (PushButton) serial.get( "btnNewRow" );

        btn.getButtonPressListeners().add( new ButtonPressListener()
        {
            public void buttonPressed( Button button )
            {
                HashMap<String, Object> map = new HashMap<String, Object>();

                map.put( "col1", "newCol1" );
                map.put( "col2", "newCol2" );

                ((List<Object>)(view.getTableData())).add( map );

                //view.getRowEditor().edit( view, ((List<Object>)(view.getTableData())).indexOf( map ), 0 );
                view.getRowEditor().edit( view, 0, 0 );
            }
        });

        appWindow.open(display);
    }

    public boolean shutdown( boolean optional ) throws Exception
    {
        if ( appWindow != null )
            appWindow.close();

        return false;
    }

    public void suspend() throws Exception
    {
    }

    public void resume() throws Exception
    {
    }
}

Attachment: testing.xml
Description: XML document

Reply via email to