Forked from christiangoudreau/gist:42e51a2cbb20dd204f4b
Last active
January 24, 2016 22:22
-
-
Save rdwallis/27813ab85dd96c69b09c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.google.gwt.user.client.ui; | |
/** | |
* Simple panel that wraps a GWT simple panel to be replaced by the widgetToAttach we set while updating the references. | |
* <p/> | |
* 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 widgetToAttach) { | |
Widget parentAsWidget = widget.asWidget().getParent(); | |
if (parentAsWidget != null && parentAsWidget instanceof HTMLPanel) { | |
HTMLPanel parent = (HTMLPanel) parentAsWidget; | |
parent.addAndReplaceElement(widgetToAttach, widget.asWidget().getElement()); | |
widget = widgetToAttach; | |
} | |
} | |
@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