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.

PrimaryStyle.java 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.abstractcomponent;
  17. import com.vaadin.server.VaadinRequest;
  18. import com.vaadin.tests.components.AbstractTestUI;
  19. import com.vaadin.ui.Button;
  20. import com.vaadin.ui.Button.ClickEvent;
  21. import com.vaadin.ui.Label;
  22. import com.vaadin.ui.TextField;
  23. public class PrimaryStyle extends AbstractTestUI {
  24. @Override
  25. protected void setup(VaadinRequest request) {
  26. // Use a set of three common components as a test.
  27. final Label label = new Label("Test Label");
  28. label.setPrimaryStyleName("initial");
  29. label.setStyleName("state");
  30. addComponent(label);
  31. final Button button = new Button("Test Button");
  32. button.setPrimaryStyleName("initial");
  33. button.setStyleName("state");
  34. addComponent(button);
  35. final TextField tf = new TextField("Test TextField");
  36. tf.setPrimaryStyleName("initial");
  37. tf.setStyleName("state");
  38. addComponent(tf);
  39. Button updateButton = new Button("Update styles",
  40. new Button.ClickListener() {
  41. @Override
  42. public void buttonClick(ClickEvent event) {
  43. label.setPrimaryStyleName("updated");
  44. label.setStyleName("correctly");
  45. button.setPrimaryStyleName("updated");
  46. button.setStyleName("correctly");
  47. tf.setPrimaryStyleName("updated");
  48. tf.setStyleName("correctly");
  49. }
  50. });
  51. updateButton.setId("update-button");
  52. addComponent(updateButton);
  53. }
  54. @Override
  55. protected String getTestDescription() {
  56. return "Test that setPrimaryStyleName followed by setStyleName results in correct class names.";
  57. }
  58. @Override
  59. protected Integer getTicketNumber() {
  60. return 12190;
  61. }
  62. }