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.

VCssLayout.java 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.client.ui;
  17. import com.google.gwt.user.client.ui.FlowPanel;
  18. import com.google.gwt.user.client.ui.Widget;
  19. import com.vaadin.client.Profiler;
  20. import com.vaadin.client.StyleConstants;
  21. /**
  22. * VCssLayout is a layout which supports configuring it's children with CSS
  23. * selectors.
  24. */
  25. public class VCssLayout extends FlowPanel {
  26. public static final String CLASSNAME = "v-csslayout";
  27. /**
  28. * Default constructor.
  29. */
  30. public VCssLayout() {
  31. super();
  32. setStyleName(CLASSNAME);
  33. addStyleName(StyleConstants.UI_LAYOUT);
  34. }
  35. /**
  36. * For internal use only. May be removed or replaced in the future.
  37. */
  38. public void addOrMove(Widget child, int index) {
  39. Profiler.enter("VCssLayout.addOrMove");
  40. if (child.getParent() == this) {
  41. Profiler.enter("VCssLayout.addOrMove getWidgetIndex");
  42. int currentIndex = getWidgetIndex(child);
  43. Profiler.leave("VCssLayout.addOrMove getWidgetIndex");
  44. if (index == currentIndex) {
  45. Profiler.leave("VCssLayout.addOrMove");
  46. return;
  47. }
  48. } else if (index == getWidgetCount()) {
  49. // optimized path for appending components - faster especially for
  50. // initial rendering
  51. Profiler.enter("VCssLayout.addOrMove add");
  52. add(child);
  53. Profiler.leave("VCssLayout.addOrMove add");
  54. Profiler.leave("VCssLayout.addOrMove");
  55. return;
  56. }
  57. Profiler.enter("VCssLayout.addOrMove insert");
  58. insert(child, index);
  59. Profiler.leave("VCssLayout.addOrMove insert");
  60. Profiler.leave("VCssLayout.addOrMove");
  61. }
  62. }