I am working on a part of an application that displays tables with statistical data about video files represented by the class FrameInfo. Now after I initially just had a table model that would do everything including some formatting, I refactored it to the other extreme and had the table model only return FrameInfo instance for each row and then let the CellRenderer decide what field to render and how for each column. This was great as I could do nice things like switching the display of e.g. timecode values between ticks, seconds or timecodes ("00:01:02:03") only by a repaint. I was happy until I copied and pasted table contents into a gdocs spreadsheet and noticed that I only got the output of toString() of my model objects in all cells (which was logical when I started thinking about it but obviously not what I want).
My options, as far as I can see them now:
1) Put everything back into the model
Pros: I would have everything in the clipboard as it is displayed, when I copy
Cons: - means triggering model events when switching the display mode of timecodes - writing highlighters (I am using JXTables btw.) would become messy again, as I would have to do string matching, where I now can use my model objects
2) Leave as it is now and build a custom copy action that uses the renderer and then extracts the text from the rendered label
Pros: - Table code stays clean
Cons: - Amount of work(?) - For stuff like rounded number I would lose accuracy
3) Put all but the dynamic stuff (timecodes) into the model and do the timecodes in the renderer and live with the fact that I do not get WYSIWYG for copy & paste for those columns
Pros & Cons: - More or less a half-assed compromise
Any advice or maybe even some exiting code that I could use, anyone?
Thanks for your time!