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.

ComponentContainer.java 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright 2000-2018 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.ui;
  17. import java.util.Iterator;
  18. import com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier;
  19. /**
  20. * A special type of parent which allows the user to add and remove components
  21. * to it. Typically does not have any restrictions on the number of children it
  22. * can contain.
  23. *
  24. * @author Vaadin Ltd.
  25. * @since 3.0
  26. */
  27. public interface ComponentContainer
  28. extends HasComponents, ComponentAttachDetachNotifier {
  29. /**
  30. * Adds the component into this container.
  31. *
  32. * @param c
  33. * the component to be added.
  34. */
  35. public void addComponent(Component c);
  36. /**
  37. * Adds the components in the given order to this component container.
  38. *
  39. * @param components
  40. * The components to add.
  41. */
  42. public void addComponents(Component... components);
  43. /**
  44. * Removes the component from this container.
  45. *
  46. * @param c
  47. * the component to be removed.
  48. */
  49. public void removeComponent(Component c);
  50. /**
  51. * Removes all components from this container.
  52. */
  53. public void removeAllComponents();
  54. /**
  55. * Replaces the component in the container with another one without changing
  56. * position.
  57. *
  58. * <p>
  59. * This method replaces component with another one is such way that the new
  60. * component overtakes the position of the old component. If the old
  61. * component is not in the container, the new component is added to the
  62. * container. If the both component are already in the container, their
  63. * positions are swapped. Component attach and detach events should be taken
  64. * care as with add and remove.
  65. * </p>
  66. *
  67. * @param oldComponent
  68. * the old component that will be replaced.
  69. * @param newComponent
  70. * the new component to be replaced.
  71. */
  72. public void replaceComponent(Component oldComponent,
  73. Component newComponent);
  74. /**
  75. * Gets an iterator to the collection of contained components. Using this
  76. * iterator it is possible to step through all components contained in this
  77. * container.
  78. *
  79. * @return the component iterator.
  80. *
  81. * @deprecated As of 7.0, use {@link #iterator()} instead.
  82. */
  83. @Deprecated
  84. public Iterator<Component> getComponentIterator();
  85. /**
  86. * Gets the number of children this {@link ComponentContainer} has. This
  87. * must be symmetric with what {@link #getComponentIterator()} returns.
  88. *
  89. * @return The number of child components this container has.
  90. * @since 7.0.0
  91. */
  92. public int getComponentCount();
  93. /**
  94. * Moves all components from an another container into this container. The
  95. * components are removed from <code>source</code>.
  96. *
  97. * @param source
  98. * the container which contains the components that are to be
  99. * moved to this container.
  100. */
  101. public void moveComponentsFrom(ComponentContainer source);
  102. }