Thanks. Maybe I should have been more specific. One thing I did for practice was create a simple table model using an Object[][] array. I created my own table model based on the DefaultTableModel and also created ny own TableModelListener. It was just a
test, so I had two rows the user could edit and when one of these cells was changed, I put the sum (if applicable) in a third non-editable column. So I think I understand the basics enough to handle straight-forward cases.
The table I have been asked to produce requires that certain columns (optionally) are filled by pulling data from all rows with the same values in the first two columns as the column being updated. Then once the new value is computed, it gets placed in appropriate cells for all the columns with that (a,b) pair.
Before I can compute the value, I need to compute another value that requires data from all rows where the first three columns are the same as the current row. Again, I need to write the updated data back to all the rows used in the calculation.
Perhaps more problematic, if the cell that is changing is in column A for example, I need to update all the rows that had the old (a,b) value and then update all the rows that have the new (a,b) value. If the value in column c changes, I need to update ol (a,b,c), new (a,b,c) old (a,b) and new (a,b)
Because my data has a hierarchy of (a,b) and then c, I created a hashmap using (a,b) as the key and the value is an object that includes a hashmap on c. When an object is instantiated in this data hierarchy, all the needed intermediate values get updated. So in a 'batch' processing mode this works great. For example, it's easy to extract the value associated with any given (a,b) pair ot (a,b,c) triplet. BUT, these classes don't know anything about the table or what rows the data came from. So implementing a getRow or getColumn is problematic.
I am trying to learn how to approach this problem in an intelligent fashion. There are lots of options I have been considering.
1. Take my data model class which is now independent of a table representation and add lists indicating what row the information came from. I think I might need to duplicate this at several levels, i.e., add to the (a,b) value class a list of rows, add to the (a,b,c) value class a list of rows, add to the (a,b,c,d,e) value class the specific row that this data item came from (duplicate rows are allowed). I think this could get messy when the user changes an existing value of a or deletes a row, but I think I could end up implementing a getRow and getColumn.
2. Bail on having a separate data model. Instead of trying to be clever, just loop through the table whenever a cell is changed and construct the list of rows that need to be updated on the fly. The only thing that I think this would have trouble with, besides rapid retrieval of the computed values, is knowing what the old value of the row was, so I can update those rows. I'm thinking this might mean keeping two sets of books or some simpler hashmap of what rows were used to calculate the values in the previous iteration.
3. Some other major paradigm change like rebuilding the whole data model each time the table data changes. Then I don't have to worry about adding or changing items in the data model and a fairly simple table model can manage the user input, but building the data model is a bit time intensive.
Then when all this is resolved, each time a cell is updated, the request is that a method be run which uses the unique set of (a,b,e,f) and (r,s) from a different table to create or update a graph. The request is the graph updates anytime a value is added or modified in the table.
My confusion there is perhaps deepest. Let's say I take my datamodel and add arrays to track rows and get methods. I can tell the table to use it as my table data model. But, when the cell data changes, I have to get data from other tables and update graphs. The order has to be right or the graphs are wrong. That seems to argue for a control program where I would keep a data model for the (a,b,c) data and a data model for the (r,s) data and the control program would be handed the table objects and the graph objects. Then it could register as a listener to both tables (data could also change in the other table or in the graph panes themselves that would require updates all around). But then, if the data is a control class, I'm not sure what the appropriate way is for that control class to communicate with the table that rows and cells need to change or for the table to let the control program know rows are added or deleted.
The tutorials are helpful, but cover very simple cases and really I am trying to get my head around the right way to approach a situation where a data change triggers a lot of actions that must be run in a specific order and some of these actions result in the data being changed.