Hi Paolo,

Thanks for finding out the bug. I have created an issue:
https://www.canoo.com/jira/browse/UBA-7068

Please see the snippet at the end of this mail for a workaround.

Let me know if this helped.

Thanks and regards,

Janak

>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] Behalf Of Paolo Scaffardi
>Sent: Friday, September 29, 2006 1:43 PM
>To: [email protected]
>Subject: [ULC-developer] ULCTable listSelectionChange bug...
>
>
>Hi there!
>I have problems when i try to catch table listSelectionChange events
>when a popup menu is set on a that table (using setComponentPopupMenu).
>When i right-click on a unselected row i see it selected, the popup is
>shown but no listSelectionChange event is sent to the server. If i right
>click again on that cell/row i got that event.
>
>I think this is a bug.
>I'm using last ULC version.
>
>Do you confirm that issue using attached sample application?
>How can be fixed?
>
>Best regards,
>Paolo Scaffardi
>GFP Lab s.r.l.
>http://www.gfplab.com
>fax 178 2258454
>

-----------------------------


import java.awt.event.MouseListener;
import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.ApplicationContext;
import com.ulcjava.base.application.ULCDialog;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCMenuItem;
import com.ulcjava.base.application.ULCPopupMenu;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTable;
import com.ulcjava.base.application.event.IListSelectionListener;
import com.ulcjava.base.application.event.IWindowListener;
import com.ulcjava.base.application.event.ListSelectionEvent;
import com.ulcjava.base.application.event.WindowEvent;
import com.ulcjava.base.client.UITable;
import com.ulcjava.base.development.DevelopmentRunner;

public class ULCTableSelectionChangeBugSampleApp extends AbstractApplication
{

    public void start() {
        ULCFrame frame = new ULCFrame( "ULCTable SelectionChange bug");

        ULCMyTable table = new ULCMyTable(
                new Object[][] {
                        { "0,0", "1,0" },
                        { "0,1", "1,1" }
                }, new String[] {
                        "Header1",
                        "Header2"}
            );

        ULCPopupMenu pop = new ULCPopupMenu("Test");
        pop.add(new ULCMenuItem("ABC"));
        table.setComponentPopupMenu(pop);
        table.getSelectionModel().addListSelectionListener(new
IListSelectionListener() {
            public void valueChanged(ListSelectionEvent arg0) {
                System.out.println("Selection changed");
            }
        });

        frame.add(new ULCScrollPane(table));
        frame.setVisible(true);
        frame.setDefaultCloseOperation(ULCDialog.DISPOSE_ON_CLOSE);
        frame.addWindowListener(new IWindowListener() {
            public void windowClosing(WindowEvent arg0) {
                ApplicationContext.terminate() ;
            }
        });
    }

    public static void main(String[] args) {
        DevelopmentRunner.setApplicationClass(ULCTableSelectionChangeBugSamp
leApp.class);
        DevelopmentRunner.main(args);
    }

    public static class ULCMyTable extends ULCTable {

                public ULCMyTable(Object[][] objects, String[] strings) {
                        super(objects, strings);
                }

                protected String typeString() {
                        return UIMyTable.class.getName();
                }
    }

    public static class UIMyTable extends UITable {

                protected void postInitializeState() {
                        super.postInitializeState();
                        MouseListener[] list = 
getBasicComponent().getMouseListeners();
                        for (int i = 0; i < list.length; i++) {
                                MouseListener l = list[i];
                                getBasicComponent().removeMouseListener(l);
                                if (i == 4) {
                                        list[4] = list[3];
                                        list[3] = l;
                                }
                        }
                        for (int j = 0; j < list.length; j++) {
                                getBasicComponent().addMouseListener(list[j]);
                        }
                }
    }
}

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to