Hi Daniel
The ULCTextComponent (or rather UITextComponent) triggers a beep because the
initial data is not valid (with regard to its IDataType). I added
http://www.canoo.com/jira/browse/UBA-7131 "Datatypes on text components should
not trigger a beep for initial data from server" to our issue database. Please
note that cell editors are always empty initially. Data is filled in whenever
cell editing starts for a specific cell.
Two things worth mentioning in your example:
a) You are creating a new ULCTextField for every single cell. You can actually
reuse the same textfield for all cells. Actually, you can use the
DefaultCellEditor class to simplify and optimize your code:
ULCTextField tf = new ULCTextField();
tf.setDataType(new ULCRegularExpressionDataType("[09]", "[09]*"));
column.setCellEditor(new DefaultCellEditor(tf));
b) I am not sure what your usage scenario for the regular expression datatype
looks like, but keep in mind: The first regular expression is used to match the
text whenever editing is completed (e.g. focus lost). The second expression is
used to match text which is entered into the text field. Note that this might
also contain multiple characters because of a copy/paste or drag/drop operation.
Cheers
Rolf
**************************************
Rolf Pfenninger
Canoo Engineering AG
Kirschgartenstrasse 7
CH-4051 Basel
Tel +41 61 228 9444
Fax +41 61 228 9449
mailto:[EMAIL PROTECTED]
http://www.canoo.com
ULC - Rich Clients for J2EE
http://www.canoo.com/ulc
**************************************
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of
> [EMAIL PROTECTED]
> Sent: Dienstag, 19. Dezember 2006 08:59
> To: [email protected]
> Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: [ULC-developer] Problem using DataType
> (ULCRegularExpressionDataType) for TableCell-Validation
>
>
>
> Hello.
>
> We have a little problem using a ULCRegularExpressionDataType for
> validating the user input in tables. When trying to integrate the datatype
> as cell editor for a table and starting the application with speakers
> turned on, you hear the warning audio sound from Windows (XP). When
> scrolling down the sound appears multiple for each table row. This
> behaviour only seems to come up the first time a row is "loaded". Please
> see the snipped below to rebuild the situation. We use ULC version 6.1.1
> and the default sound configuration for Windows XP.
>
> May be we are integrating the datatype the wrong way, so 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.IEditorComponent;
> import com.ulcjava.base.application.ULCBoxPane;
> 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.datatype.ULCRegularExpressionDataType;
> 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.ULCTableColumn;
> import com.ulcjava.base.application.table.ULCTableColumnModel;
> import com.ulcjava.base.development.DevelopmentRunner;
>
> public class TableValidationEditorSnipped extends AbstractApplication {
>
> public void start() {
> final SnippetTableModel tableModel = new SnippetTableModel();
> final ULCTable table = new ULCTable(tableModel);
>
> // only the last column has a checkbox cell renderer and cell editor
> ULCTableColumnModel columnModel = table.getColumnModel();
> ULCTableColumn column = columnModel.getColumn(1);
>
> // default typed cell editor
> column.setCellEditor(new ITableCellEditor() {
> public IEditorComponent getTableCellEditorComponent(ULCTable table,
> Object value, int row) {
> final ULCTextField tf = new ULCTextField();
> ULCRegularExpressionDataType validator = new
> ULCRegularExpressionDataType("[09]", "[09]*");
> tf.setDataType(validator);
> return tf;
> }
> });
>
> 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.TERMINATE_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("TableValidationEditorSnipped");
> frame.setDefaultCloseOperation(ULCFrame.DISPOSE_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(TableValidationEditorSnipped.class);
>
> DevelopmentRunner.main(args);
> }
>
> // -- TableModel
> ------------------------------------------------------------
>
> /**
> * The TableModel.
> */
> private static class SnippetTableModel extends DefaultTableModel {
> public Object getValueAt(int row, int column) {
> return "0";
> }
>
> public void setValueAt(Object value, int row, int column) {
> super.setValueAt(value, row, column);
> }
>
> public int getRowCount() {
> return 250;
> }
>
> public int getColumnCount() {
> return 2;
> }
>
> public String getColumnName(int column) {
> return "C" + column;
> }
> }
> }Pz"
>
> ,=%
> q!2jr
> ~u
_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer