ArcBees/GWTP — pull request #568 by rdwallis (2014-09-01 10:39:14+00:00)
Title: Type safe slots

I had to do some shameful things with generics in order to maintain backwards compatibility and this code is excessively complex because of it. If we break backwards compatibility the code can be a lot simpler, so maybe start on GWTP 2.0 if the feeling is that this is unmaintainable.

This adds a lot of useful features:
You can get the current children of any presenter with the following methods:
```
getSlotChildren(slot); \\ gets the children of a slot.
getOrderedSlotChildren(slot); \\ gets the children of an ordered slot in order.
getSlotChild(slot); \\ gets the child of a single slot or null if the slot is empty.
```

To do this slots are type safe now. Ordered slots require comparable presenters. And you declare slots like so:
```
static class SLOT_MESSAGES_CONTENT extends SingleSlot {
}
```
Replace `SingleSlot` with `Slot` if the slot can take multiple presenters and with `OrderedSlot` if the presenters have a natural ordering.

In your view you can automatically manage slots by calling:
```
// links a slot to a panel
registerSlot(slot, panel);

// helper for HasOneWidget, equivelent to registerSlot
registerHasOneWidget(slot, hasOneWidget);

// Use an insertpanel like vertical panel and your views will be added in order automatically.
registerOrderedSlot(orderedSlot, InsertPanel.ForIsWidget);
```

---

I've also created an `@Slottable` annotation that will take a slot and a field.

I imagine it being used with a generator to automatically call the correct registerSlot method in the view.
Either annotated on a class with the ui:field and no actual field in the view like so:
```
@Slottable(value = MySlot.class, field = "fieldName")
class MyView {
}
```

Or on a field itself maybe even replacing `@UiField` or combined with it.
```
@Slottable(MySlot.class) ForIsWidget myField;
```
---
But I've never written a generator so I'm looking for a volunteer to help me with that.