Tuesday, June 26, 2007

This is the end (for now)




The thing is done. The database is fairly stable, the edit perspective is basically done, and most importantly, I'll never use it.

Todos:

  • Feat special rules need to be implemented

  • MainPerspective calculated values (melee, damage, etc.)

  • Create charactersheet print out

Monday, June 25, 2007

CheckboxTableViewer.setChecked() fails silently

Took me a while to figure this out:

If you have a CheckboxTableViewer and want to set the initial state of the table contents as (un)checked, you cannot do the initialization in the LabelProvider. It seemed like the most logical place, and the viewer does enter the code for setChecked(element, true), but nothing is displayed. Turns you have to let the table draw first (I don't understand why):

public void update() {
// inputs the same
tableViewer.setInput("");
tableViewer.refresh();

List weapons = WeaponHome.inst.findAll();
for (DAO weapon : weapons) {
if (Ctx.getChar().weapons.contains(weapon)) {
((CheckboxTableViewer) tableViewer).setChecked(weapon, true);
}
}
}


For the record, this is the code that does not work:

public String getColumnText(Object element, int columnIndex) {
String value = "";
Weapon weapon = (Weapon) element;
if (isEditable()) {
if (Ctx.getChar().weapons.contains(weapon)) {
((CheckboxTableViewer) tableViewer).setChecked(element, true);
}
}