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.

GridLayoutExtraSpacing.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright 2000-2014 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.tests.components.gridlayout;
  17. import com.vaadin.data.Property.ValueChangeEvent;
  18. import com.vaadin.data.Property.ValueChangeListener;
  19. import com.vaadin.server.VaadinRequest;
  20. import com.vaadin.tests.components.AbstractTestUI;
  21. import com.vaadin.ui.CheckBox;
  22. import com.vaadin.ui.CssLayout;
  23. import com.vaadin.ui.GridLayout;
  24. public class GridLayoutExtraSpacing extends AbstractTestUI {
  25. @Override
  26. protected void setup(VaadinRequest request) {
  27. getUI().getPage()
  28. .getStyles()
  29. .add(".v-gridlayout {background: red;} .v-csslayout {background: white;}");
  30. final GridLayout gl = new GridLayout(4, 4);
  31. final CheckBox cb = new CheckBox("spacing");
  32. cb.addValueChangeListener(new ValueChangeListener() {
  33. @Override
  34. public void valueChange(ValueChangeEvent event) {
  35. gl.setSpacing(cb.getValue());
  36. }
  37. });
  38. cb.setValue(true);
  39. addComponent(cb);
  40. final CheckBox cb2 = new CheckBox("hide empty rows/columns");
  41. cb2.addValueChangeListener(new ValueChangeListener() {
  42. @Override
  43. public void valueChange(ValueChangeEvent event) {
  44. gl.setHideEmptyRowsAndColumns(cb2.getValue());
  45. }
  46. });
  47. addComponent(cb2);
  48. gl.setWidth("1000px");
  49. gl.setHeight("500px");
  50. CssLayout ta = new CssLayout();
  51. ta.setSizeFull();
  52. // Only on last row
  53. gl.addComponent(ta, 0, 3, 3, 3);
  54. gl.setRowExpandRatio(3, 1);
  55. addComponent(gl);
  56. }
  57. /*
  58. * (non-Javadoc)
  59. *
  60. * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
  61. */
  62. @Override
  63. protected String getTestDescription() {
  64. // TODO Auto-generated method stub
  65. return null;
  66. }
  67. /*
  68. * (non-Javadoc)
  69. *
  70. * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
  71. */
  72. @Override
  73. protected Integer getTicketNumber() {
  74. // TODO Auto-generated method stub
  75. return null;
  76. }
  77. }