Created
October 13, 2011 22:02
-
-
Save edwardsmatt/1285670 to your computer and use it in GitHub Desktop.
Patch the GXT {@link WidgetComponent#setParent(Widget, Widget) } method for gwt-test-utls-gxt
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.octo.gxt.test.internal.patchers; | |
import com.extjs.gxt.ui.client.widget.WidgetComponent; | |
import com.google.gwt.user.client.ui.Widget; | |
import com.octo.gwt.test.patchers.PatchClass; | |
import com.octo.gwt.test.patchers.PatchMethod; | |
import com.octo.gwt.test.utils.GwtReflectionUtils; | |
/** | |
* Patch the GXT {@link WidgetComponent#setParent(Widget, Widget) } method. | |
* Usage that caused error: | |
* <p> | |
* <pre> | |
* final FormPanel panel = new FormPanel(); | |
* panel.add(new Image(Resources.ICONS.formIcon())); | |
* </pre> | |
* </p> | |
* @author Matthew Edwards | |
* @see com.extjs.gxt.ui.client.widget.LayoutContainer#wrapWidget(Widget) | |
* @see com.extjs.gxt.ui.client.widget.Container#wrapWidget(Widget) | |
* @see WidgetComponent#setParent(Widget, Widget) | |
*/ | |
@PatchClass(WidgetComponent.class) | |
final class WidgetComponentPatcher { | |
/** Private Constructor to prevent Instantiation and appease Checkstyle. */ | |
private WidgetComponentPatcher() { | |
} | |
/** | |
* Patch {@link WidgetComponent#setParent(Widget, Widget) } to set the {@code parent} on the {@link child}. | |
* @param component the component {@link WidgetComponent} to replace the {@code setParent} method on. | |
* @param parent the parent {@link Widget}. | |
* @param child the child {@link Widget}. | |
*/ | |
@PatchMethod | |
public static void setParent(final WidgetComponent component, final Widget parent, final Widget child) { | |
GwtReflectionUtils.setPrivateFieldValue(child, "parent", parent); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixes UnsatisfiedLinkError when adding an Image to a Panel using GwtTestWithEasyMock.
Dependencies: