Hi Daniel,
Since ULC 6.1/6.1.1, the default model update event delivery mode for
ULCTable has changed to Deferred.
To achieve the desired behavior kindly add the following statements to your
code:
DummyTableModel model = new DummyTableModel();
table.setModel(model);
// Set the model update event delivery mode to synchronous
ClientContext.setModelUpdateMode(model,
UlcEventConstants.SYNCHRONOUS_MODE);
We have created an issue about documentation of the default model update
event delivery mode: https://www.canoo.com/jira/browse/UBA-7069.
Thanks and regards,
Janak
>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] Behalf Of
>[EMAIL PROTECTED]
>Sent: Friday, October 06, 2006 1:15 PM
>To: [email protected]
>Subject: [ULC-developer] Problem, using a CheckBox CellEditor/-Renderer
>
>
>
>Hello!
>
>We encountered a problem using checkboxes as cell editor/renderer. For
>unknown reason, checking the boxes doesn't work so well since the newest
>ULC version (6.1/6.1.1). We have several checkboxes in a table, to set
>options to different entries. The first column works like a radio button,
>where only one tableentry may have that option checked.
>
>May be the attached snipped will help you to show the problem. You have to
>play with it and try to uncheck the only checkbox of the first column.
>After the alert window is shown, the checkboxs' de-/selection doesn't
>work(!) so fine any longer. It seems, the 'fireTableDataChanged()' doesn't
>make his job because of a focus problem.
>
>
>Thank you and best regards,
>Daniel Backhausen
>
>
>------------------ BEGIN: SNIPPED ------------------
>
>package com.canoo.snipped;
>
>import java.awt.event.MouseListener;
>import java.util.Enumeration;
>
>import com.ulcjava.base.application.AbstractApplication;
>import com.ulcjava.base.application.ApplicationContext;
>import com.ulcjava.base.application.IEditorComponent;
>import com.ulcjava.base.application.IRendererComponent;
>import com.ulcjava.base.application.ULCAlert;
>import com.ulcjava.base.application.ULCCheckBox;
>import com.ulcjava.base.application.ULCDialog;
>import com.ulcjava.base.application.ULCFrame;
>import com.ulcjava.base.application.ULCListSelectionModel;
>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.application.table.AbstractTableModel;
>import com.ulcjava.base.application.table.ITableCellEditor;
>import com.ulcjava.base.application.table.ITableCellRenderer;
>import com.ulcjava.base.application.table.ULCTableColumn;
>import com.ulcjava.base.client.UITable;
>import com.ulcjava.base.development.DevelopmentRunner;
>
>public class ULCCheckBoxCellEditorSnipped extends AbstractApplication {
> private ULCFrame frame;
>
> public void start() {
> this.frame = new ULCFrame("ULCTable CheckBox CellEditor Sample");
>
> frame.setSize(100, 250);
>
> ULCMyTable table = new ULCMyTable();
> table.setModel(new DummyTableModel());
>
> ULCPopupMenu pop = new ULCPopupMenu("Test");
> pop.add(new ULCMenuItem("ABC"));
> table.setComponentPopupMenu(pop);
> table.getSelectionModel().addListSelectionListener(new
> IListSelectionListener() {
> public void valueChanged(ListSelectionEvent event) {
> System.out.println("Selection changed -> "
> + "Row: " +
> ((ULCListSelectionModel)event.getSource()).getMinSelectionIndex());
> }
> });
>
> for (Enumeration columns = table.getColumnModel().getColumns();
> columns.hasMoreElements() ;) {
> final ULCTableColumn column = (ULCTableColumn) columns.nextElement();
> column.setCellRenderer(new ITableCellRenderer() {
> public IRendererComponent getTableCellRendererComponent(ULCTable
> arg0, Object arg1, boolean arg2, boolean arg3, int arg4) {
> return new ULCCheckBox();
> }
> });
> column.setCellEditor(new ITableCellEditor() {
> public IEditorComponent getTableCellEditorComponent(ULCTable arg0,
> Object arg1, int arg2) {
> return new ULCCheckBox();
> }
> });
> }
>
> 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(ULCCheckBoxCellEditorSnipped.class);
>
> DevelopmentRunner.main(args);
> }
>
> private class DummyTableModel extends AbstractTableModel {
> private int currentRow = 0;
>
> public int getRowCount() {
> return 10;
> }
>
> public int getColumnCount() {
> return 5;
> }
>
> public Object getValueAt(int row, int column) {
> switch (column) {
> case 0:
> return (row == currentRow) ? Boolean.TRUE : Boolean.FALSE;
> default:
> return (Math.random() < 0.5) ? Boolean.TRUE : Boolean.FALSE;
> }
> }
>
> public boolean isCellEditable(int rowIndex, int columnIndex) {
> return true;
> }
>
> public void setValueAt(Object value, int row, int column) {
> if (column == 0) {
> if (row == currentRow) {
> final ULCAlert alert = new ULCAlert(frame, "Warning", "You can“t
> uncheck me!", "Okidoki");
> alert.show();
> fireTableCellUpdated(row, column);
> } else {
> this.currentRow = row;
> fireTableDataChanged();
> }
> }
> }
> }
>
> public static class ULCMyTable extends ULCTable {
> 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]);
> }
> }
> }
>}
>
>------------------ END: SNIPPED ------------------
>
>_______________________________________________
>ULC-developer mailing list
>[email protected]
>http://lists.canoo.com/mailman/listinfo/ulc-developer
_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer