Skip to content

Commit

Permalink
Bugfix: Make sure to setActiveTab
Browse files Browse the repository at this point in the history
Add an override for the new typed setInSlot (> GWTP 1.5.x) method and
make sure to call setActivTab on the corresponding tab.
The old untyped setInSlot will delegate to the new method.
This should fix #744
  • Loading branch information
timeu authored and Chris-V committed Mar 4, 2016
1 parent 56aff77 commit 9143c11
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.GwtEvent.Type;
import com.google.web.bindery.event.shared.EventBus;
import com.gwtplatform.mvp.client.presenter.slots.IsSlot;
import com.gwtplatform.mvp.client.presenter.slots.LegacySlotConvertor;
import com.gwtplatform.mvp.client.proxy.Proxy;
import com.gwtplatform.mvp.client.proxy.RevealContentHandler;
import com.gwtplatform.mvp.client.proxy.TabContentProxy;
Expand Down Expand Up @@ -210,15 +212,20 @@ public Tab addTab(final TabContentProxy<?> tabProxy) {

@Override
public void setInSlot(Object slot, PresenterWidget<?> content) {
super.setInSlot(slot, content);
setInSlot(LegacySlotConvertor.convert(slot), content);
}

@Override
public <T extends PresenterWidget<?>> void setInSlot(IsSlot<T> slot, T child) {
super.setInSlot(slot, child);

// TODO: Consider switching this to an event bus based mechanism where the
// child presenter fires an event when it is revealed and the parent highlights the tab.

// If we're setting a presenter attached to an actual slot, then highlight the tab
if (slot == tabContentSlot) {
try {
Presenter<?, ?> presenter = (Presenter<?, ?>) content;
Presenter<?, ?> presenter = (Presenter<?, ?>) child;
TabContentProxy<?> proxy = (TabContentProxy<?>) presenter.getProxy();
getView().setActiveTab(proxy.getTab());
} catch (Exception e) {
Expand Down

0 comments on commit 9143c11

Please sign in to comment.