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.

TestForWindowing.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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;
  17. import com.vaadin.data.Property.ValueChangeEvent;
  18. import com.vaadin.data.Property.ValueChangeListener;
  19. import com.vaadin.ui.AbstractSelect;
  20. import com.vaadin.ui.Button;
  21. import com.vaadin.ui.Button.ClickEvent;
  22. import com.vaadin.ui.Button.ClickListener;
  23. import com.vaadin.ui.CheckBox;
  24. import com.vaadin.ui.CustomComponent;
  25. import com.vaadin.ui.Label;
  26. import com.vaadin.ui.OptionGroup;
  27. import com.vaadin.ui.Select;
  28. import com.vaadin.ui.Slider;
  29. import com.vaadin.ui.UI;
  30. import com.vaadin.ui.VerticalLayout;
  31. import com.vaadin.ui.Window;
  32. public class TestForWindowing extends CustomComponent {
  33. private Select s2;
  34. public TestForWindowing() {
  35. final VerticalLayout main = new VerticalLayout();
  36. main.addComponent(
  37. new Label("Click the button to create a new inline window."));
  38. final CheckBox asModal = new CheckBox("As modal");
  39. main.addComponent(asModal);
  40. final Button create = new Button("Create a new window",
  41. new ClickListener() {
  42. @Override
  43. public void buttonClick(ClickEvent event) {
  44. VerticalLayout layout = new VerticalLayout();
  45. layout.setMargin(true);
  46. Window w = new Window("Testing Window", layout);
  47. if (asModal.getValue().booleanValue()) {
  48. w.setModal(true);
  49. }
  50. AbstractSelect s1 = new OptionGroup();
  51. s1.setCaption("1. Select output format");
  52. s1.addItem("Excel sheet");
  53. s1.addItem("CSV plain text");
  54. s1.setValue("Excel sheet");
  55. s1.setImmediate(true);
  56. s2 = new Select();
  57. s2.addItem("Separate by comma (,)");
  58. s2.addItem("Separate by colon (:)");
  59. s2.addItem("Separate by semicolon (;)");
  60. s2.setEnabled(false);
  61. s1.addListener(new ValueChangeListener() {
  62. @Override
  63. public void valueChange(ValueChangeEvent event) {
  64. String v = (String) event.getProperty()
  65. .getValue();
  66. if (v.equals("CSV plain text")) {
  67. s2.setEnabled(true);
  68. } else {
  69. s2.setEnabled(false);
  70. }
  71. }
  72. });
  73. layout.addComponent(s1);
  74. layout.addComponent(s2);
  75. Slider s = new Slider();
  76. s.setCaption("Volume");
  77. s.setMax(13);
  78. s.setMin(12);
  79. s.setResolution(2);
  80. s.setImmediate(true);
  81. // s.setOrientation(Slider.ORIENTATION_VERTICAL);
  82. // s.setArrows(false);
  83. layout.addComponent(s);
  84. UI.getCurrent().addWindow(w);
  85. }
  86. });
  87. main.addComponent(create);
  88. setCompositionRoot(main);
  89. }
  90. }