Hello!
Since ULC version 6.1 we have a special problem with clicks on a table, in
particular editing the model. Please see the attached snipped to reproduce
this behaviour. We implemented a checkbox celleditor and cellrenderer to
show what we mean. If you fire up the table frame the first time, you have
to click two times to change the value of the checkbox in column four.
After you close the frame (not the application) and fire up the table
again, you only have to click once. The code worked fine on ULC version
6.04, where you only have to click once - even if it starts up the first
time. If you run the attached snipped on the above mentioned versions you
will see the difference. It seems the table has to focus first. Furthermore
it isn“t possible to active the checkbox by keyboard.
We already tried playing with "ClientContext" delivery mode options with no
result. Btw. we had problems finding any documentation on the different
event category constants from UlcEventCategories. It would be helpful, if
you can update javadocs with the constants and there special meaning.
We will be glad, if you have any hint or idea to solve this problem.
Best regards,
Daniel
+++ Snipped +++
import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.ClientContext;
import com.ulcjava.base.application.IEditorComponent;
import com.ulcjava.base.application.IRendererComponent;
import com.ulcjava.base.application.ULCBoxPane;
import com.ulcjava.base.application.ULCButton;
import com.ulcjava.base.application.ULCCheckBox;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTable;
import com.ulcjava.base.application.event.ActionEvent;
import com.ulcjava.base.application.event.IActionListener;
import com.ulcjava.base.application.table.DefaultTableModel;
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.application.table.ULCTableColumnModel;
import com.ulcjava.base.development.DevelopmentRunner;
/**
* Snipped. Simulates a table cell/click problem.
*/
public class TableClickSnipped extends AbstractApplication {
/**
* Starts the snipped.
*/
public void start() {
final ULCTable table = new ULCTable(new SnippetTableModel());
ULCTableColumnModel columnModel = table.getColumnModel();
// only the last column has a checkbox cell renderer and cell editor
ULCTableColumn column = columnModel.getColumn(3);
// the checkbox cell renderer
column.setCellRenderer(new ITableCellRenderer() {
public IRendererComponent getTableCellRendererComponent(ULCTable
table, Object value, boolean isSelected, boolean hasFocus, int row)
{
final ULCCheckBox cbState = new ULCCheckBox();
cbState.setHorizontalAlignment(ULCCheckBox.CENTER);
if (value instanceof Boolean) {
cbState.setSelected(((Boolean) value).booleanValue());
} else if (value instanceof String) {
cbState.setSelected((((String) value).equalsIgnoreCase("true")) ?
true : false);
}
if (isSelected) {
cbState.setBackground(ClientContext.getColor("Table.selectionBackground"));
} else {
cbState.setBackground(ClientContext.getColor("Table.background"));
}
return cbState;
}
});
// the checkbox cell editor
column.setCellEditor(new ITableCellEditor() {
public IEditorComponent getTableCellEditorComponent(ULCTable table,
Object value, int row) {
final ULCCheckBox cbState = new ULCCheckBox();
cbState.setHorizontalAlignment(ULCCheckBox.CENTER);
if (cbState.isSelected()) {
cbState.setBackground(ClientContext.getColor("Table.selectionBackground"));
} else {
cbState.setBackground(ClientContext.getColor("Table.background"));
}
return cbState;
}
});
ULCButton clickBtn = new ULCButton("Click me!");
clickBtn.addActionListener(new IActionListener() {
public void actionPerformed(ActionEvent event) {
// This is the callable table frame
ULCFrame popup = new ULCFrame("Popup Window");
popup.setDefaultCloseOperation(ULCFrame.DISPOSE_ON_CLOSE);
ULCBoxPane tableContent = new ULCBoxPane(1, 0);
tableContent.add(ULCBoxPane.BOX_EXPAND_EXPAND, new
ULCScrollPane(table));
popup.add(tableContent);
popup.setLocationRelativeTo(null);
popup.setVisible(true);
popup.toFront();
}
});
ULCBoxPane content = new ULCBoxPane(1, 0);
content.add(ULCBoxPane.BOX_CENTER_CENTER, clickBtn);
// This is the calling frame
ULCFrame frame = new ULCFrame("TableClickSnipped");
frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
frame.add(content);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.toFront();
}
/**
* Start method.
*
* @param args - optional
*/
public static void main(String[] args) {
DevelopmentRunner.setApplicationClass(TableClickSnipped.class);
DevelopmentRunner.main(args);
}
// -- TableModel
------------------------------------------------------------
/**
* The TableModel.
*/
private static class SnippetTableModel extends DefaultTableModel {
/** Option-Flag. */
private boolean checkFlag = false;
public Object getValueAt(int row, int column) {
if (column == 3) {
return Boolean.valueOf(checkFlag);
} else {
return "Text";
}
}
public void setValueAt(Object value, int row, int column) {
if (column == 3) {
this.checkFlag = ((Boolean) value).booleanValue();
} else {
super.setValueAt(value, row, column);
}
}
public int getRowCount() {
return 1;
}
public int getColumnCount() {
return 4;
}
public String getColumnName(int column) {
return "C" + column;
}
}
}
_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer