Forked from christiangoudreau/gist:42e51a2cbb20dd204f4b
Last active
January 24, 2016 22:22
Revisions
-
rdwallis revised this gist
Sep 5, 2014 . 1 changed file with 13 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,14 @@ /** * Copyright 2014 Richard Wallis. * All rights reserved. */ package com.wallissoftware.wave.client.widgets; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.IsWidget; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; /** * Panel that wraps a GWT simple panel to be replaced by the widgetToAttach. This will make sure that the DIV element * is being replaced rather than having the widget inserted in it. @@ -30,14 +41,14 @@ public void setWidget(final IsWidget widget) { @Override public void setWidget(final Widget widgetToAttach) { final Widget parentAsWidget = asWidget().getParent(); if (!(parentAsWidget instanceof HTMLPanel)) { throw new WrongParentTypeException("The parent of ReplacePanel must be of type HTMLPanel"); } final HTMLPanel parent = (HTMLPanel) parentAsWidget; parent.addAndReplaceElement(widgetToAttach, asWidget().getElement()); widget = widgetToAttach; } -
rdwallis revised this gist
Sep 2, 2014 . 1 changed file with 13 additions and 17 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,45 +4,41 @@ * <p/> * The result of this will be to have a better, cleaner, dom. */ public class ReplacePanel extends SimplePanel { static class WrongParentTypeException extends RuntimeException { public WrongParentTypeException(final String message) { super(message); } } private IsWidget widget; @Override public Widget asWidget() { return widget != null ? widget.asWidget() : super.asWidget(); } @Override public Widget getWidget() { return widget != null ? widget.asWidget() : super.getWidget(); } @Override public void setWidget(final IsWidget widget) { setWidget(widget.asWidget()); } @Override public void setWidget(final Widget widgetToAttach) { final Widget parentAsWidget = widget.asWidget().getParent(); if (!(parentAsWidget instanceof HTMLPanel)) { throw new WrongParentTypeException("The parent of ReplacePanel must be of type HTMLPanel"); } final HTMLPanel parent = (HTMLPanel) parentAsWidget; parent.addAndReplaceElement(widgetToAttach, widget.asWidget().getElement()); widget = widgetToAttach; } } -
christiangoudreau revised this gist
Aug 18, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ public WrongParentTypeException(String message) { private IsWidget widget; public ReplacePanel() { widget = new SimplePanel(); } @Override -
christiangoudreau revised this gist
Aug 12, 2014 . 1 changed file with 10 additions and 24 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ /** * Panel that wraps a GWT simple panel to be replaced by the widgetToAttach. This will make sure that the DIV element * is being replaced rather than having the widget inserted in it. * <p/> * The result of this will be to have a better, cleaner, dom. */ @@ -13,19 +14,7 @@ public WrongParentTypeException(String message) { private IsWidget widget; public ReplacePanel() { widget = new com.google.gwt.user.client.ui.SimplePanel(); } @Override @@ -40,23 +29,20 @@ public Widget getWidget() { @Override public void setWidget(Widget widgetToAttach) { Widget parentAsWidget = widget.asWidget().getParent(); if (!(parentAsWidget instanceof HTMLPanel)) { throw new WrongParentTypeException("The parent of ReplacePanel must be of type HTMLPanel"); } HTMLPanel parent = (HTMLPanel) parentAsWidget; parent.addAndReplaceElement(widgetToAttach, widget.asWidget().getElement()); widget = widgetToAttach; } @Override public void setWidget(IsWidget widget) { setWidget(widget.asWidget()); } } -
christiangoudreau renamed this gist
Aug 12, 2014 . 1 changed file with 25 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,31 @@ /** * 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 { static class WrongParentTypeException extends RuntimeException { public WrongParentTypeException(String message) { super(message); } } private IsWidget widget; public ReplacePanel() { SimplePanel simplePanel = new com.google.gwt.user.client.ui.SimplePanel(); widget = simplePanel; simplePanel.addAttachHandler(new Handler() { @Override public void onAttachOrDetach(AttachEvent event) { Widget parentAsWidget = getParent(); if (!(parentAsWidget instanceof HTMLPanel)) { throw new WrongParentTypeException("The parent of ReplacePanel must be of type HTMLPanel"); } } }); } @Override @@ -24,7 +40,7 @@ public Widget getWidget() { @Override public void setWidget(Widget widgetToAttach) { Widget parentAsWidget = getParent(); if (parentAsWidget != null && parentAsWidget instanceof HTMLPanel) { HTMLPanel parent = (HTMLPanel) parentAsWidget; @@ -39,4 +55,8 @@ public void setWidget(Widget widgetToAttach) { public void setWidget(IsWidget widget) { setWidget(widget.asWidget()); } private Widget getParent() { return widget.asWidget().getParent(); } } -
christiangoudreau revised this gist
Aug 12, 2014 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,6 @@ 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. */ -
christiangoudreau revised this gist
Aug 12, 2014 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,8 +2,7 @@ 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. */ -
christiangoudreau revised this gist
Aug 11, 2014 . 1 changed file with 13 additions and 13 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,10 @@ 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/> * 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. * <p/> * The result of this will be to have a better, cleaner, dom. */ public class ReplacePanel implements IsWidget, HasOneWidget { @@ -31,10 +25,16 @@ public class ReplacePanel implements IsWidget, HasOneWidget { } @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 -
christiangoudreau created this gist
Aug 9, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ 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()); } }