/* 
@ITMillApache2LicenseForJavaFiles@
 */

package com.itmill.toolkit.tests;

import com.itmill.toolkit.data.Property.ValueChangeEvent;
import com.itmill.toolkit.data.Property.ValueChangeListener;
import com.itmill.toolkit.ui.Button;
import com.itmill.toolkit.ui.CustomComponent;
import com.itmill.toolkit.ui.Label;
import com.itmill.toolkit.ui.OrderedLayout;
import com.itmill.toolkit.ui.RichTextArea;

/**
 * 
 * @author IT Mill Ltd.
 */
public class TestForRichTextEditor extends CustomComponent implements
        ValueChangeListener {

    private final OrderedLayout main = new OrderedLayout();

    private Label l;

    private RichTextArea rte;

    public TestForRichTextEditor() {

        setCompositionRoot(main);
        createNewView();
    }

    public void createNewView() {
        main.removeAllComponents();
        main.addComponent(new Label(
                "RTE uses google richtextArea and their examples toolbar."));

        rte = new RichTextArea();
        rte.addListener(this);

        main.addComponent(rte);

        main.addComponent(new Button("commit content to label below"));

        l = new Label("", Label.CONTENT_XHTML);
        main.addComponent(l);

    }

    public void valueChange(ValueChangeEvent event) {
        l.setValue(rte.getValue());
    }

}

@@ -396,16 +396,64 @@
 extArea;
+%0Aimport com.itmill.toolkit.ui.Button.ClickEvent;
 %0A%0A/**%0A *
@@ -1234,24 +1234,341 @@
 ponent(l);%0A%0A
+        Button b = new Button(%22enabled%22);%0A        b.setSwitchMode(true);%0A        b.setImmediate(true);%0A        b.addListener(new Button.ClickListener() %7B%0A            public void buttonClick(ClickEvent event) %7B%0A                rte.setEnabled(!rte.isEnabled());%0A            %7D%0A        %7D);%0A        main.addComponent(b);%0A%0A
     %7D%0A%0A    p

Test update: added toggle to edit enabled field