Skip to content

Instantly share code, notes, and snippets.

@rdwallis
Forked from christiangoudreau/gist:42e51a2cbb20dd204f4b
Last active January 24, 2016 22:22
Show Gist options
  • Save rdwallis/27813ab85dd96c69b09c to your computer and use it in GitHub Desktop.
Save rdwallis/27813ab85dd96c69b09c to your computer and use it in GitHub Desktop.
package com.roler.res.client.application.widget;
import com.google.gwt.user.client.ui.HasOneWidget;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import static com.google.gwt.query.client.GQuery.$;
/**
* Simple panel that wraps a GWT simple panel to be replaced by the widget we set while updating the references.
*
* It is not recommended to apply any type to this container as it is meant to be replaced by it's content in the dom.
*
* The result of this will be to have a better, cleaner, dom.
*/
public class ReplacePanel implements IsWidget, HasOneWidget {
private IsWidget widget;
public ReplacePanel() {
this.widget = new com.google.gwt.user.client.ui.SimplePanel();
}
@Override
public Widget asWidget() {
return widget.asWidget();
}
@Override
public Widget getWidget() {
return widget.asWidget();
}
@Override
public void setWidget(Widget widget) {
$(this.widget).replaceWith($(widget));
this.widget = widget;
}
@Override
public void setWidget(IsWidget widget) {
setWidget(widget.asWidget());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment