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.

ClipContent.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package com.vaadin.tests.components.customcomponent;
  2. import com.vaadin.shared.ui.ContentMode;
  3. import com.vaadin.tests.components.TestBase;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.CustomComponent;
  6. import com.vaadin.ui.Label;
  7. import com.vaadin.v7.data.Property.ValueChangeEvent;
  8. import com.vaadin.v7.ui.TextField;
  9. public class ClipContent extends TestBase {
  10. @Override
  11. protected void setup() {
  12. Label text = new Label(
  13. "1_long_line_that_should_be_clipped<br/>2_long_line_that_should_be_clipped<br/>3_long_line_that_should_be_clipped<br/>4_long_line_that_should_be_clipped<br/>",
  14. ContentMode.HTML);
  15. final CustomComponent cc = new CustomComponent(text);
  16. cc.setWidth("20px");
  17. cc.setHeight("20px");
  18. final TextField w = new TextField("Width");
  19. w.setValue("20px");
  20. w.addListener(new TextField.ValueChangeListener() {
  21. @Override
  22. public void valueChange(ValueChangeEvent event) {
  23. cc.setWidth(w.getValue());
  24. }
  25. });
  26. addComponent(w);
  27. final TextField h = new TextField("Height");
  28. h.setValue("20px");
  29. h.addListener(new TextField.ValueChangeListener() {
  30. @Override
  31. public void valueChange(ValueChangeEvent event) {
  32. cc.setHeight(h.getValue());
  33. }
  34. });
  35. addComponent(h);
  36. Button b = new Button("apply");
  37. addComponent(b);
  38. addComponent(cc);
  39. }
  40. @Override
  41. protected String getDescription() {
  42. return "The text in CustomComponent should be clipped if it has size defined.";
  43. }
  44. @Override
  45. protected Integer getTicketNumber() {
  46. return null;
  47. }
  48. }