Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

TestForRichTextEditor.java 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright 2000-2013 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;
  18. import com.vaadin.data.Property.ValueChangeEvent;
  19. import com.vaadin.data.Property.ValueChangeListener;
  20. import com.vaadin.shared.ui.label.ContentMode;
  21. import com.vaadin.ui.Button;
  22. import com.vaadin.ui.CheckBox;
  23. import com.vaadin.ui.CustomComponent;
  24. import com.vaadin.ui.Label;
  25. import com.vaadin.ui.RichTextArea;
  26. import com.vaadin.ui.VerticalLayout;
  27. /**
  28. *
  29. * @author Vaadin Ltd.
  30. */
  31. public class TestForRichTextEditor extends CustomComponent implements
  32. ValueChangeListener {
  33. private final VerticalLayout main = new VerticalLayout();
  34. private Label l;
  35. private RichTextArea rte;
  36. public TestForRichTextEditor() {
  37. setCompositionRoot(main);
  38. createNewView();
  39. }
  40. public void createNewView() {
  41. main.removeAllComponents();
  42. main.addComponent(new Label(
  43. "RTE uses google richtextArea and their examples toolbar."));
  44. rte = new RichTextArea();
  45. rte.addListener(this);
  46. main.addComponent(rte);
  47. main.addComponent(new Button("commit content to label below"));
  48. l = new Label("", ContentMode.HTML);
  49. main.addComponent(l);
  50. CheckBox b = new CheckBox("enabled");
  51. b.setImmediate(true);
  52. b.addListener(new Property.ValueChangeListener() {
  53. @Override
  54. public void valueChange(ValueChangeEvent event) {
  55. rte.setEnabled(!rte.isEnabled());
  56. }
  57. });
  58. main.addComponent(b);
  59. }
  60. @Override
  61. public void valueChange(ValueChangeEvent event) {
  62. l.setValue(rte.getValue());
  63. }
  64. }