Our application (Eclipse RCP-based, using a JFace/SWT-based interface) needs to support editing of mathematical matrices. The matrices are always square and can be any size from 2x2 to 11x11. Additionally, buttons will be placed on the interface to allow the user to grow or shrink the matrix.
We use JFace TableViewers and TreeViewers throughout our code for editing the non-matrix data. If at all possible I'd like to use the same general structure for editing the matrices.
I persist the data in the MySQL database using one row per matrix element, as such:
+----------------------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+------------+------+-----+---------+-------+
| id | bigint(20) | NO | PRI | NULL | |
| rowNum | bigint(20) | NO | | NULL | |
| columnNum | bigint(20) | NO | | NULL | |
| value | double | NO | | NULL | |
| matrix_id | bigint(20) | NO | MUL | NULL | |
+----------------------+------------+------+-----+---------+-------+
The problem I'm running into is that the JFace "input" seems to correspond to a single table row in the rendered table. In my case, a single database row corresponds with a cell in the table, not an entire row.
The only thing I can think of is to somehow store an object behind the scenes that keeps the matrix-ified state and effectively translates database rows into an appropriately JFace-able model. (E.g., if I have a 3x3 matrix, pass in the nine rows into the proxy object and have it call viewer.setInput(Object)
with a three-by-three array. This seems like a nightmare to support though, as I'll need to keep this object in sync with both the internal model and the database.
Does anyone here have experience with this kind of thing and could possibly lend me some suggestions?