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.

AbstractSingleComponentContainerConnector.java 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.client.ui;
  17. import java.util.List;
  18. import com.google.gwt.user.client.ui.Widget;
  19. import com.vaadin.client.ComponentConnector;
  20. /**
  21. * Client side connector for subclasses of AbstractSingleComponentConnector.
  22. *
  23. * @since 7.0
  24. */
  25. public abstract class AbstractSingleComponentContainerConnector
  26. extends AbstractHasComponentsConnector {
  27. /**
  28. * Returns the content (only/first child) of the container.
  29. *
  30. * @return child connector or null if none (e.g. invisible or not set on
  31. * server)
  32. */
  33. protected ComponentConnector getContent() {
  34. List<ComponentConnector> children = getChildComponents();
  35. if (children.isEmpty()) {
  36. return null;
  37. } else {
  38. return children.get(0);
  39. }
  40. }
  41. /**
  42. * Returns the widget (if any) of the content of the container.
  43. *
  44. * @return widget of the only/first connector of the container, null if no
  45. * content or if there is no widget for the connector
  46. */
  47. protected Widget getContentWidget() {
  48. ComponentConnector content = getContent();
  49. if (null != content) {
  50. return content.getWidget();
  51. } else {
  52. return null;
  53. }
  54. }
  55. }