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.

BaseAlignment.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.tests.layouts.layouttester;
  17. import com.vaadin.server.VaadinRequest;
  18. import com.vaadin.ui.AbstractOrderedLayout;
  19. /**
  20. *
  21. * @since
  22. * @author Vaadin Ltd
  23. */
  24. abstract public class BaseAlignment extends BaseLayoutTestUI {
  25. @Override
  26. protected void setup(VaadinRequest request) {
  27. // create two columns of components with different
  28. // alignment. Used to test alignment in layouts
  29. init();
  30. buildLayout();
  31. super.setup(request);
  32. }
  33. public BaseAlignment(Class<? extends AbstractOrderedLayout> layoutClass) {
  34. super(layoutClass);
  35. }
  36. /**
  37. * Build Layout for test
  38. */
  39. private void buildLayout() {
  40. for (int i = 0; i < components.length; i++) {
  41. AbstractOrderedLayout layout = null;
  42. try {
  43. layout = (AbstractOrderedLayout) layoutClass.newInstance();
  44. } catch (InstantiationException e) {
  45. // TODO Auto-generated catch block
  46. e.printStackTrace();
  47. } catch (IllegalAccessException e) {
  48. // TODO Auto-generated catch block
  49. e.printStackTrace();
  50. }
  51. layout.setHeight("100px");
  52. layout.setWidth("200px");
  53. layout.addComponent(components[i]);
  54. layout.setComponentAlignment(components[i], alignments[i]);
  55. if (i < components.length / 2) {
  56. l1.addComponent(layout);
  57. } else {
  58. l2.addComponent(layout);
  59. }
  60. }
  61. }
  62. }