History | Log In     View a printable version of the current page.  

Issue Details (XML | Word | Printable)

Key: UBA-7426
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Janak Mulani
Reporter: Andreas Henle
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
ULCBase

Cell based popup menus do not work correctly in ULCTableTree if the selection is not set before the popup is triggered

Created: 27/Mar/08 03:51 PM   Updated: 18/Jun/08 05:18 PM
Component/s: components
Affects Version/s: ULC 6.2.2
Fix Version/s: UltraLightClient '08


 Description  « Hide
If a popup is triggered on a cell of a ULCTableTree with cell specific popup menus, wrong popups are displayed if the selection is not set to the cell before the popup is triggered (e.g. using the right mouse button for changing the selection and trigger the popup together)

On the client side the renderer component with the corresponding popup menu is called before the new selection is set. This results to wrong popup entries.

The following code demonstrates this behavior:

package com.canoo.ulc.playground.developerlist;

import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.IRendererComponent;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCPopupMenu;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTableTree;
import com.ulcjava.base.application.tabletree.DefaultMutableTableTreeNode;
import com.ulcjava.base.application.tabletree.DefaultTableTreeCellRenderer;
import com.ulcjava.base.application.tabletree.DefaultTableTreeModel;
import com.ulcjava.base.application.tabletree.ULCTableTreeColumn;
import com.ulcjava.base.development.DevelopmentRunner;

public class PR7426 extends AbstractApplication {
    public void start() {
        ULCTableTree tableTree = new ULCTableTree(new SnipetTableTreeModel());
        DefaultTableTreeCellRenderer renderer = new DefaultTableTreeCellRenderer() {
            
            public IRendererComponent getTableTreeCellRendererComponent(ULCTableTree tableTree, Object value, boolean selected,
                    boolean hasFocus, boolean expanded, boolean leaf, Object node) {
                // TODO Auto-generated method stub
                IRendererComponent rendererComponent = super.getTableTreeCellRendererComponent(tableTree, value, selected, hasFocus,
                        expanded, leaf, node);
                
                ULCPopupMenu popupMenu = new ULCPopupMenu();
                popupMenu.add("First test Entry");
                popupMenu.add((String)value);
                
                setComponentPopupMenu(popupMenu);
                
                return rendererComponent;
            }
            
        };
        ULCTableTreeColumn treeColumn = tableTree.getColumnModel().getColumn(0);
        treeColumn.setCellRenderer(renderer);
        ULCFrame frame = new ULCFrame("Snippet");
        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
        frame.getContentPane().add(new ULCScrollPane(tableTree));
        frame.setVisible(true);
    }
    
    public static void main(String[] args) {
        DevelopmentRunner.setApplicationClass(PR7426.class);
        DevelopmentRunner.main(args);
    }
    
    public static class SnipetTableTreeModel extends DefaultTableTreeModel {
        public SnipetTableTreeModel() {
            super(createRoot(), createColumnNames(3));
        }
        
        private static DefaultMutableTableTreeNode createRoot() {
            DefaultMutableTableTreeNode child0 = createNode("root:0", 3);
            child0.add(createNode("root:0:0", 3));
            child0.add(createNode("root:0:1", 3));
            DefaultMutableTableTreeNode child1 = createNode("root:1", 3);
            child1.add(createNode("root:1:0", 3));
            child1.add(createNode("root:1:1", 3));
            child1.add(createNode("root:1:2", 3));
            DefaultMutableTableTreeNode child2 = createNode("root:2", 3);
            child2.add(createNode("root:2:0", 3));
            DefaultMutableTableTreeNode result = createNode("root", 3);
            result.add(child0);
            result.add(child1);
            result.add(child2);
            return result;
        }
        
        private static String[] createColumnNames(int columns) {
            String[] result = new String[columns];
            for (int i = 0; i < result.length; i++) {
                result[i] = "column " + i;
            }
            
            return result;
        }
        
        private static DefaultMutableTableTreeNode createNode(String prefix, int columns) {
            Object[] data = new Object[columns];
            for (int i = 0; i < data.length; i++) {
                data[i] = prefix + ":" + i;
            }
            
            return new DefaultMutableTableTreeNode(data);
        }
    }


 All   Comments   Change History      Sort Order:
There are no comments yet on this issue.