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.

ComponentConnectorLayoutSlot.java 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client.ui.layout;
  5. import com.vaadin.terminal.gwt.client.ComponentConnector;
  6. import com.vaadin.terminal.gwt.client.LayoutManager;
  7. import com.vaadin.terminal.gwt.client.VCaption;
  8. import com.vaadin.terminal.gwt.client.ui.ManagedLayout;
  9. public class ComponentConnectorLayoutSlot extends VLayoutSlot {
  10. final ComponentConnector paintable;
  11. private LayoutManager layoutManager;
  12. public ComponentConnectorLayoutSlot(String baseClassName,
  13. ComponentConnector paintable) {
  14. super(baseClassName, paintable.getWidget());
  15. this.paintable = paintable;
  16. layoutManager = paintable.getLayoutManager();
  17. }
  18. public ComponentConnector getPaintable() {
  19. return paintable;
  20. }
  21. @Override
  22. protected int getCaptionHeight() {
  23. VCaption caption = getCaption();
  24. return caption != null ? layoutManager.getOuterHeight(caption
  25. .getElement()) : 0;
  26. }
  27. @Override
  28. protected int getCaptionWidth() {
  29. VCaption caption = getCaption();
  30. return caption != null ? layoutManager.getOuterWidth(caption
  31. .getElement()) : 0;
  32. }
  33. @Override
  34. public void setCaption(VCaption caption) {
  35. VCaption oldCaption = getCaption();
  36. if (oldCaption != null) {
  37. layoutManager.unregisterDependency(
  38. (ManagedLayout) paintable.getParent(),
  39. oldCaption.getElement());
  40. }
  41. super.setCaption(caption);
  42. if (caption != null) {
  43. layoutManager
  44. .registerDependency((ManagedLayout) paintable.getParent(),
  45. caption.getElement());
  46. }
  47. }
  48. @Override
  49. public int getWidgetHeight() {
  50. return layoutManager.getOuterHeight(paintable.getWidget().getElement());
  51. }
  52. @Override
  53. public int getWidgetWidth() {
  54. return layoutManager.getOuterWidth(paintable.getWidget().getElement());
  55. }
  56. @Override
  57. public boolean isUndefinedHeight() {
  58. return paintable.isUndefinedHeight();
  59. }
  60. @Override
  61. public boolean isUndefinedWidth() {
  62. return paintable.isUndefinedWidth();
  63. }
  64. @Override
  65. public boolean isRelativeHeight() {
  66. return paintable.isRelativeHeight();
  67. }
  68. @Override
  69. public boolean isRelativeWidth() {
  70. return paintable.isRelativeWidth();
  71. }
  72. }