import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Position;
+import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
import com.vaadin.terminal.gwt.client.communication.ServerRpc;
+import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
+import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler;
-public class RootConnector extends AbstractComponentContainerConnector
- implements SimpleManagedLayout {
+public class RootConnector extends AbstractComponentContainerConnector {
public interface RootServerRPC extends ClickRPC, ServerRpc {
private RootServerRPC rpc = GWT.create(RootServerRPC.class);
+ private HandlerRegistration childStateChangeHandlerRegistration;
+
+ private final StateChangeHandler childStateChangeHandler = new StateChangeHandler() {
+ public void onStateChanged(StateChangeEvent stateChangeEvent) {
+ // TODO Should use a more specific handler that only reacts to
+ // size changes
+ onChildSizeChange();
+ }
+ };
+
@Override
protected void init() {
super.init();
if (getWidget().layout != lo) {
// remove old
client.unregisterPaintable(getWidget().layout);
+ if (childStateChangeHandlerRegistration != null) {
+ childStateChangeHandlerRegistration.removeHandler();
+ childStateChangeHandlerRegistration = null;
+ }
// add new
getWidget().setWidget(lo.getWidget());
getWidget().layout = lo;
}
} else {
+ if (getWidget().layout != lo) {
+ childStateChangeHandlerRegistration = lo
+ .addStateChangeHandler(childStateChangeHandler);
+ }
getWidget().setWidget(lo.getWidget());
getWidget().layout = lo;
}
return GWT.create(VView.class);
}
- public void layout() {
+ protected void onChildSizeChange() {
ComponentConnector child = getWidget().layout;
Style childStyle = child.getWidget().getElement().getStyle();
/*