[jsword-devel] SwordBookMetaData
Joe Walker
jsword-devel@crosswire.org
Mon, 29 Mar 2004 22:05:43 +0100
Thanks DM, that's excellent.
I made a few tweaks, Some of the local variables were called the same
names as class variables, which makes accidental error a bit more
likely. I only know because I've got that warning turned on in eclipse.
There were a few comments in MapTable in //'s just before a bit of
JavaDoc so I put one in the other. I hope that's OK
I'm editing the build file to make the jnlp build do nightly updates
properly, and to fix some of the breakage there is at the moment.
Having done that I'm going to fix the default Bible, which is the bug I
find most annoying at the moment.
Joe.
DM Smith wrote:
> Fixed the bug, made a few more changes and tested:
>
> I undid the line wrap as it did not work fully. The problem was that the
> computation of a cell's height was static based upon initial content and
> not on the content and the current width of the cell. I think it can be
> managed with listeners, but I left it as a future todo.
>
> I modified MapTableModel some more:
>
> Because Map keys can be objects, I called toString().trim() on them.
>
> I made "" an invalid key and null an invalid value.
>
> I copied the map into a list for direct access. The getValueAt used an
> iterator over the map, once per cell to find the content and assumed
> that it would always return the same data in the same order. This
> required a trivial helper class, StringPair.
>
> I eliminated getMap as it was being used badly by MapField (violated
> information hiding) to directly modify the map without causing and added
> methods to provide the needed behavior. I modified MapField to use these
> new MapTableModel methods. I don't think MapField is being used
> anywhere, so I could not figure out how to test the changes.
>
> I made getColumnCount return 0 if the map was null, 2 otherwise. This
> fixed problems with code like
> for (int c = 0; c < getColumnCount(); c++) { do something on the column;
> } when the map was null, which is the case between a default TableModel
> constructor call and a call to setModel().
>
> I removed setValueAt since it was a bit buggy, in that if a key were
> changed, the order of the cells in the table would change and it did not
> fire changes to listeners. Also, because editing was turned off.
>
> DM Smith" wrote:
>
>> The patch has a fatal bug. Dumb last minute change. I will fix and
>> resend.
>>
>> DM Smith wrote:
>>
>>>
>>> Attached is a patch for BookMetaData and its display.
>>> Here is a summary of the changes I made:
>>> MapTableModel returns a string of the object held in the iterator.
>>> This allows it to be used by any map and not just Properties.
>>>
>>> BookMetaData used to return Properties from getProperties. Now it
>>> returns Map. Perhaps the named should be changed as well.
>>>
>>> SwordBookMetadata:
>>> When a line ended with \, I concatenated the next line with \n as a
>>> separator. I added the method getContinuation as a helper.
>>>
>>> When creating the props map, which has strings for values, I use \n
>>> to separate elements in the list.
>>>
>>> Changed props from a Properties to a LinkedHashMap. This required
>>> changing from setProperty to put.
>>>
>>> In parseLine, I trimed the value. (The key was already trimmed.)
>>>
>>> There is still an opportunity to eliminate duplicate input lines. But
>>> that probably should be a cleanup in the input.
>>>
>>> Modified getFullName to output parts only if they existed. This
>>> eliminated the trailing ','.
>>>
>>> Removed BOOK and DRIVER from the props since they were objects and
>>> not strings. Nothing was using it. They could be added back in as
>>> strings.
>>>
>>> Changed "table" from a HashMap to a LinkedHashMap to preserve the
>>> input order. This allows for save to lossless wrt order.
>>>
>>> To DefaultBookMetaData
>>> The properties member variable was used to store both strings and
>>> objects for the same key. I changed it that it only stored strings.
>>> For each pair of set functions setX(Object x) and setX(String x), I
>>> made the second call the first and the first set the member variable
>>> and stored the field in the map.
>>>
>>> I changed getFullName to be the same as for SwordBookMetaData.
>>>
>>> I changed props from a Properties to a LinkedHashMap to preserve
>>> insertion order.
>>>
>>> I added two new classes: MapTable and MapCellRenderer. The MapTable
>>> works with a MapTableModel to present multiline data in rows that are
>>> tall enough to show the entire contents. The MapCellRenderer differs
>>> from the DefaultTableCellRenderer in that it uses a JTextArea to
>>> render text instead of a JLabel. This allows for it to render html,
>>> if we ever decide to go there. JLabel's support for html is really
>>> weak. I set it up to wrap text if the column is too narrow.
>>>
>>> I modified SitePane to use MapTable rather than JTable. It might make
>>> sense to use it where ever MapTableModel is used. I only used it here.
>
>
> _________________________________________________________________
> MSN Toolbar provides one-click access to Hotmail from any Web page
> FREE download! http://toolbar.msn.com/go/onm00200413ave/direct/01/