You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ICustomComponent.java 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. package com.itmill.toolkit.terminal.gwt.client.ui;
  5. import com.google.gwt.user.client.ui.SimplePanel;
  6. import com.google.gwt.user.client.ui.Widget;
  7. import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
  8. import com.itmill.toolkit.terminal.gwt.client.Container;
  9. import com.itmill.toolkit.terminal.gwt.client.Paintable;
  10. import com.itmill.toolkit.terminal.gwt.client.UIDL;
  11. public class ICustomComponent extends SimplePanel implements Container {
  12. private static final String CLASSNAME = "i-customcomponent";
  13. public ICustomComponent() {
  14. super();
  15. setStyleName(CLASSNAME);
  16. }
  17. public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
  18. if (client.updateComponent(this, uidl, true)) {
  19. return;
  20. }
  21. final UIDL child = uidl.getChildUIDL(0);
  22. if (child != null) {
  23. final Paintable p = client.getPaintable(child);
  24. if (p != getWidget()) {
  25. if (getWidget() != null) {
  26. client.unregisterPaintable((Paintable) getWidget());
  27. clear();
  28. }
  29. setWidget((Widget) p);
  30. }
  31. p.updateFromUIDL(child, client);
  32. }
  33. }
  34. public boolean hasChildComponent(Widget component) {
  35. if (getWidget() == component) {
  36. return true;
  37. } else {
  38. return false;
  39. }
  40. }
  41. public void replaceChildComponent(Widget oldComponent, Widget newComponent) {
  42. if (hasChildComponent(oldComponent)) {
  43. clear();
  44. setWidget(newComponent);
  45. } else {
  46. throw new IllegalStateException();
  47. }
  48. }
  49. public void updateCaption(Paintable component, UIDL uidl) {
  50. // TODO custom component could handle its composition roots caption
  51. }
  52. public boolean childComponentSizesUpdated() {
  53. // TODO Auto-generated method stub
  54. return false;
  55. }
  56. }