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

Issue Details (XML | Word | Printable)

Key: UBA-7444
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Janak Mulani
Reporter: Daniel Grob
Votes: 0
Watchers: 0
Operations

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

Editors are not loaded to the client side

Created: 20/May/08 02:33 PM   Updated: 18/Jun/08 05:18 PM
Component/s: components
Affects Version/s: None
Fix Version/s: UltraLightClient '08


 Description  « Hide
When setting a new editor on a table column then it is possible that the editor components are not immediately loaded to the client-side.

 All   Comments   Change History      Sort Order:
Daniel Grob - [20/May/08 02:36 PM ]
As a workaround you can use the following ULCTable extension:
import com.ulcjava.base.application.DefaultCellEditor;
import com.ulcjava.base.application.ULCBorderLayoutPane;
import com.ulcjava.base.application.ULCButton;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTable;
import com.ulcjava.base.application.ULCTextField;
import com.ulcjava.base.application.event.ActionEvent;
import com.ulcjava.base.application.event.IActionListener;
import com.ulcjava.base.application.table.AbstractTableModel;
import com.ulcjava.base.application.table.DefaultTableCellRenderer;
import com.ulcjava.base.application.util.Color;
import com.ulcjava.base.client.UITable;
import com.ulcjava.testframework.development.AbstractSimpleDevelopmentTestCase;
import com.ulcjava.testframework.operator.ULCButtonOperator;
import com.ulcjava.testframework.operator.ULCFrameOperator;
import com.ulcjava.testframework.operator.ULCTableOperator;

import java.util.Random;

public class PR7444 extends AbstractSimpleDevelopmentTestCase {
    public void start() {
        final ULCTable table = new ULCTable(new SnippetTableModel()) {
            protected String typeString() {
                return UISnippetTable.class.getName();
            }
        };
        
        ULCButton button = new ULCButton("Replace Editor");
        button.addActionListener(new IActionListener() {
            public void actionPerformed(ActionEvent event) {
                Random random = new Random();
                
                DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
                renderer.setBackground(new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)));
                renderer.setOpaque(true);
                
                ULCTextField editor = new ULCTextField();
                editor.setBackground(new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)));
                table.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(editor));
            }
        });
        
        ULCFrame frame = new ULCFrame("Snippet");
        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
        frame.getContentPane().add(new ULCScrollPane(table));
        frame.getContentPane().add(button, ULCBorderLayoutPane.SOUTH);
        frame.pack();
        frame.setVisible(true);
    }
    
    public void testEditors() throws InterruptedException {
        ULCFrameOperator frame = new ULCFrameOperator();
        ULCTableOperator table = new ULCTableOperator(frame);
        ULCButtonOperator button = new ULCButtonOperator(frame, "Replace Editor");
        
        table.clickForEdit(10, 2);
        assertNotNull(table.getEditorComponent());
        
        button.push();
        
        table.clickForEdit(10, 2);
        assertNotNull(table.getEditorComponent());
    }
    
    public static class SnippetTableModel extends AbstractTableModel {
        public Object getValueAt(int row, int column) {
            return row + ":" + column;
        }
        
        public int getRowCount() {
            return 100;
        }
        
        public int getColumnCount() {
            return 5;
        }
        
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return true;
        }
        
        public void setValueAt(Object value, int rowIndex, int columnIndex) {
            fireTableCellUpdated(rowIndex, columnIndex);
        }
    }
    
    
    public static class UISnippetTable extends UITable {
        protected Object createBasicObject(Object[] arguments) {
            return new BasicSnippetTable();
        }
        
        public class BasicSnippetTable extends BasicTable {
            public void addPendingRequests() {
                // this is the workaround
                // => forces invalidation of the cache
                editCellAt(0, 0);
                
                super.addPendingRequests();
            }
        }
    }
}