Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.test7;
- import javax.servlet.annotation.WebServlet;
- import org.vaadin.openesignforms.ckeditor.CKEditorConfig;
- import org.vaadin.openesignforms.ckeditor.CKEditorTextField;
- import com.vaadin.annotations.Theme;
- import com.vaadin.annotations.VaadinServletConfiguration;
- import com.vaadin.data.Item;
- import com.vaadin.data.fieldgroup.FieldGroup;
- import com.vaadin.data.util.ObjectProperty;
- import com.vaadin.data.util.PropertysetItem;
- import com.vaadin.event.FieldEvents.FocusEvent;
- import com.vaadin.event.FieldEvents.FocusListener;
- import com.vaadin.event.MouseEvents;
- import com.vaadin.server.VaadinRequest;
- import com.vaadin.server.VaadinServlet;
- import com.vaadin.server.ClientConnector.AttachEvent;
- import com.vaadin.ui.Button;
- import com.vaadin.ui.Button.ClickEvent;
- import com.vaadin.ui.Button.ClickListener;
- import com.vaadin.ui.Window.ResizeEvent;
- import com.vaadin.ui.FormLayout;
- import com.vaadin.ui.Label;
- import com.vaadin.ui.UI;
- import com.vaadin.ui.VerticalLayout;
- import com.vaadin.ui.Window;
- import com.vaadin.ui.Window.ResizeListener;
- @SuppressWarnings("serial")
- @Theme("test7")
- public class Test7UI extends UI {
- private CKEditorTextField txt;
- @WebServlet(value = "/*", asyncSupported = true)
- @VaadinServletConfiguration(productionMode = false, ui =Test7UI.class, widgetset= "com.example.test7.widgetset.Test7Widgetset" )
- public static class Servlet extends VaadinServlet {
- }
- @Override
- protected void init(VaadinRequest request) {
- final VerticalLayout layout = new VerticalLayout();
- layout.setMargin(true);
- Button btn1 = new Button("Before Fieldgroup bind");
- btn1.addClickListener(new ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- Window w = new Window();
- FormLayout fl = new FormLayout();
- fl.setMargin(true);
- Label lbl = new Label("It is expected behaviour that this CKEditor is not set readonly");
- fl.addComponent(lbl);
- txt = new CKEditorTextField();
- CKEditorConfig config = new CKEditorConfig();
- config.setInPageConfig("{ toolbar: 'custom',"+
- "toolbar_custom: " +
- "[" +
- "{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] }, " +
- "], ignoreEmptyParagraph: false, resize_enabled: false, language: 'nl', enterMode: 2, removePlugins: 'elementspath', customConfig: '', defaultLanguage: 'nl',"+ //enterMode 2 = BR mode naam is niet bruikbaar, getal wel
- "colorButton_enableMore :false, readOnly: true, }");//http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Setting_Configurations
- txt.setConfig(config);
- txt.setReadOnly(true);
- PropertysetItem item = new PropertysetItem();
- item.addItemProperty("ckeditor", new ObjectProperty<String>("Zaphod"));
- FieldGroup fg = new FieldGroup(item);
- fg.bind(txt, "ckeditor");
- fl.addComponent(txt);
- Button button = new Button("SetReadOnly");
- button.addClickListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- txt.setReadOnly(!txt.isReadOnly());
- layout.addComponent(new Label("Thank you for clicking"));
- }
- });
- fl.addComponent(button);
- w.setContent(fl);
- w.setModal(true);
- w.center();
- w.setWidth("400px");
- w.setHeight("500px");
- getUI().addWindow(w);
- }
- });
- layout.addComponent(btn1);
- Button btn2 = new Button("After Fieldgroup bind");
- btn2.addClickListener(new ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- Window w = new Window();
- FormLayout fl = new FormLayout();
- fl.setMargin(true);
- Label lbl = new Label("It is expected behaviour that this CKEditor is set readonly");
- fl.addComponent(lbl);
- txt = new CKEditorTextField();
- CKEditorConfig config = new CKEditorConfig();
- config.setInPageConfig("{ toolbar: 'custom',"+
- "toolbar_custom: " +
- "[" +
- "{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] }, " +
- "], ignoreEmptyParagraph: false, resize_enabled: false, language: 'nl', enterMode: 2, removePlugins: 'elementspath', customConfig: '', defaultLanguage: 'nl',"+ //enterMode 2 = BR mode naam is niet bruikbaar, getal wel
- "colorButton_enableMore :false, readOnly: true, }");//http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Setting_Configurations
- txt.setConfig(config);
- PropertysetItem item = new PropertysetItem();
- item.addItemProperty("ckeditor", new ObjectProperty<String>("Zaphod"));
- FieldGroup fg = new FieldGroup(item);
- fg.bind(txt, "ckeditor");
- txt.setReadOnly(true);
- fl.addComponent(txt);
- Button button = new Button("SetReadOnly");
- button.addClickListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- txt.setReadOnly(!txt.isReadOnly());
- layout.addComponent(new Label("Thank you for clicking"));
- }
- });
- fl.addComponent(button);
- w.setContent(fl);
- w.setModal(true);
- w.center();
- w.setWidth("400px");
- w.setHeight("500px");
- getUI().addWindow(w);
- }
- });
- layout.addComponent(btn2);
- Button btn3 = new Button("After Field add to formlayout");
- btn3.addClickListener(new ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- Window w = new Window();
- FormLayout fl = new FormLayout();
- fl.setMargin(true);
- Label lbl = new Label("It is expected behaviour that this CKEditor is set readonly");
- fl.addComponent(lbl);
- txt = new CKEditorTextField();
- CKEditorConfig config = new CKEditorConfig();
- config.setInPageConfig("{ toolbar: 'custom',"+
- "toolbar_custom: " +
- "[" +
- "{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] }, " +
- "], ignoreEmptyParagraph: false, resize_enabled: false, language: 'nl', enterMode: 2, removePlugins: 'elementspath', customConfig: '', defaultLanguage: 'nl',"+ //enterMode 2 = BR mode naam is niet bruikbaar, getal wel
- "colorButton_enableMore :false, readOnly: true, }");//http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Setting_Configurations
- txt.setConfig(config);
- PropertysetItem item = new PropertysetItem();
- item.addItemProperty("ckeditor", new ObjectProperty<String>("Zaphod"));
- FieldGroup fg = new FieldGroup(item);
- fg.bind(txt, "ckeditor");
- fl.addComponent(txt);
- txt.setReadOnly(true); //XXX READONLY
- Button button = new Button("SetReadOnly");
- button.addClickListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- txt.setReadOnly(!txt.isReadOnly());
- layout.addComponent(new Label("Thank you for clicking"));
- }
- });
- fl.addComponent(button);
- w.setContent(fl);
- w.setModal(true);
- w.center();
- w.setWidth("400px");
- w.setHeight("500px");
- getUI().addWindow(w);
- }
- });
- layout.addComponent(btn3);
- Button btn4 = new Button("After window add");
- btn4.addClickListener(new ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- Window w = new Window();
- FormLayout fl = new FormLayout();
- fl.setMargin(true);
- Label lbl = new Label("It is expected behaviour that this CKEditor is set readonly");
- fl.addComponent(lbl);
- txt = new CKEditorTextField();
- CKEditorConfig config = new CKEditorConfig();
- config.setInPageConfig("{ toolbar: 'custom',"+
- "toolbar_custom: " +
- "[" +
- "{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] }, " +
- "], ignoreEmptyParagraph: false, resize_enabled: false, language: 'nl', enterMode: 2, removePlugins: 'elementspath', customConfig: '', defaultLanguage: 'nl',"+ //enterMode 2 = BR mode naam is niet bruikbaar, getal wel
- "colorButton_enableMore :false, readOnly: true, }");//http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Setting_Configurations
- txt.setConfig(config);
- PropertysetItem item = new PropertysetItem();
- item.addItemProperty("ckeditor", new ObjectProperty<String>("Zaphod"));
- FieldGroup fg = new FieldGroup(item);
- fg.bind(txt, "ckeditor");
- fl.addComponent(txt);
- Button button = new Button("SetReadOnly");
- button.addClickListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- txt.setReadOnly(!txt.isReadOnly());
- layout.addComponent(new Label("Thank you for clicking"));
- }
- });
- fl.addComponent(button);
- w.setContent(fl);
- w.setModal(true);
- w.center();
- w.setWidth("400px");
- w.setHeight("500px");
- getUI().addWindow(w);
- txt.setReadOnly(true);//XXX READONLY
- }
- });
- layout.addComponent(btn4);
- Button btn5 = new Button("With hidden button and button that activates it");
- btn5.addClickListener(new ClickListener() {
- private Button hidden;
- @Override
- public void buttonClick(ClickEvent event) {
- Window w = new Window();
- FormLayout fl = new FormLayout();
- fl.setMargin(true);
- Label lbl = new Label("Hit the button to click the hidden button (in code). It is expected behaviour that this CKEditor is set readonly. ");
- fl.addComponent(lbl);
- txt = new CKEditorTextField();
- CKEditorConfig config = new CKEditorConfig();
- config.setInPageConfig("{ toolbar: 'custom',"+
- "toolbar_custom: " +
- "[" +
- "{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] }, " +
- "], ignoreEmptyParagraph: false, resize_enabled: false, language: 'nl', enterMode: 2, removePlugins: 'elementspath', customConfig: '', defaultLanguage: 'nl',"+ //enterMode 2 = BR mode naam is niet bruikbaar, getal wel
- "colorButton_enableMore :false, readOnly: true, }");//http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Setting_Configurations
- txt.setConfig(config);
- PropertysetItem item = new PropertysetItem();
- item.addItemProperty("ckeditor", new ObjectProperty<String>("Zaphod"));
- FieldGroup fg = new FieldGroup(item);
- fg.bind(txt, "ckeditor");
- fl.addComponent(txt);
- hidden = new Button("hidden");
- hidden.setVisible(false);
- hidden.addClickListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- txt.setReadOnly(!txt.isReadOnly());
- layout.addComponent(new Label("Hidden is clicked!"));
- }
- });
- Button button = new Button("SetReadOnly");
- button.addClickListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- txt.setReadOnly(!txt.isReadOnly());
- layout.addComponent(new Label("SetReadOnly is clicked!"));
- }
- });
- fl.addComponent(button);
- Button button2 = new Button("doAutoClick");
- button2.addClickListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- hidden.click();
- layout.addComponent(new Label("doAutoClick is clicked!"));
- }
- });
- fl.addComponent(button2);
- w.setContent(fl);
- w.setModal(true);
- w.center();
- w.setWidth("400px");
- w.setHeight("500px");
- getUI().addWindow(w);
- }
- });
- layout.addComponent(btn5);
- Button btn6 = new Button("With hidden button and click after window add");
- btn6.addClickListener(new ClickListener() {
- private Button hidden;
- @Override
- public void buttonClick(ClickEvent event) {
- Window w = new Window();
- FormLayout fl = new FormLayout();
- fl.setMargin(true);
- Label lbl = new Label("It is expected behaviour that this CKEditor is set readonly");
- fl.addComponent(lbl);
- txt = new CKEditorTextField();
- CKEditorConfig config = new CKEditorConfig();
- config.setInPageConfig("{ toolbar: 'custom',"+
- "toolbar_custom: " +
- "[" +
- "{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] }, " +
- "], ignoreEmptyParagraph: false, resize_enabled: false, language: 'nl', enterMode: 2, removePlugins: 'elementspath', customConfig: '', defaultLanguage: 'nl',"+ //enterMode 2 = BR mode naam is niet bruikbaar, getal wel
- "colorButton_enableMore :false, readOnly: true, }");//http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Setting_Configurations
- txt.setConfig(config);
- PropertysetItem item = new PropertysetItem();
- item.addItemProperty("ckeditor", new ObjectProperty<String>("Zaphod"));
- FieldGroup fg = new FieldGroup(item);
- fg.bind(txt, "ckeditor");
- fl.addComponent(txt);
- hidden = new Button("hidden");
- hidden.setVisible(false);
- hidden.addClickListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- txt.setReadOnly(true);
- layout.addComponent(new Label("Hidden is clicked!"));
- }
- });
- Button button = new Button("SetReadOnly");
- button.addClickListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- txt.setReadOnly(!txt.isReadOnly());
- layout.addComponent(new Label("SetReadOnly is clicked!"));
- }
- });
- fl.addComponent(button);
- w.setContent(fl);
- w.setModal(true);
- w.center();
- w.setWidth("400px");
- w.setHeight("500px");
- getUI().addWindow(w);
- hidden.click();
- }
- });
- layout.addComponent(btn6);
- Button btn7 = new Button("With window listeners");
- btn7.addClickListener(new ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- Window w = new Window();
- FormLayout fl = new FormLayout();
- fl.setMargin(true);
- Label lbl = new Label("This was a try to fix it. It fixes things but it is not a good way. (Editor only gets readOnly after click in form/textarea)");
- fl.addComponent(lbl);
- txt = new CKEditorTextField();
- CKEditorConfig config = new CKEditorConfig();
- config.setInPageConfig("{ toolbar: 'custom',"+
- "toolbar_custom: " +
- "[" +
- "{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] }, " +
- "], ignoreEmptyParagraph: false, resize_enabled: false, language: 'nl', enterMode: 2, removePlugins: 'elementspath', customConfig: '', defaultLanguage: 'nl',"+ //enterMode 2 = BR mode naam is niet bruikbaar, getal wel
- "colorButton_enableMore :false, readOnly: true, }");//http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Setting_Configurations
- txt.setConfig(config);
- PropertysetItem item = new PropertysetItem();
- item.addItemProperty("ckeditor", new ObjectProperty<String>("Zaphod"));
- FieldGroup fg = new FieldGroup(item);
- fg.bind(txt, "ckeditor");
- fl.addComponent(txt);
- Button button = new Button("SetReadOnly");
- button.addClickListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- txt.setReadOnly(!txt.isReadOnly());
- layout.addComponent(new Label("SetReadOnly is clicked!"));
- }
- });
- fl.addComponent(button);
- w.setContent(fl);
- w.setModal(true);
- w.center();
- w.setWidth("400px");
- w.setHeight("500px");
- w.addResizeListener( new ResizeListener() {
- @Override
- public void windowResized(ResizeEvent e) {
- layout.addComponent(new Label("ResizeEvent happened!"));
- }
- });
- w.addAttachListener(new AttachListener() {
- @Override
- public void attach(AttachEvent event) {
- //txt.setReadOnly(true);// Same problem
- layout.addComponent(new Label("AttachEvent happened!"));
- }
- });
- w.addFocusListener(new FocusListener() {
- @Override
- public void focus(FocusEvent event) {
- layout.addComponent(new Label("FocusEvent happened!"));
- }
- });
- w.addClickListener(new MouseEvents.ClickListener() {
- @Override
- public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
- layout.addComponent(new Label("MouseEvents.ClickEvent happened!"));
- txt.setReadOnly(true);
- }
- });
- txt.addFocusListener( new FocusListener() {
- @Override
- public void focus(FocusEvent event) {
- layout.addComponent(new Label("FocusEvent on txt happened!"));
- txt.setReadOnly(true);
- }
- });
- getUI().addWindow(w);
- }
- });
- layout.addComponent(btn7);
- Button btn8 = new Button("With js config");
- btn8.addClickListener(new ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- Window w = new Window();
- FormLayout fl = new FormLayout();
- fl.setMargin(true);
- Label lbl = new Label("It is expected behaviour that this CKEditor is set readonly");
- fl.addComponent(lbl);
- txt = new CKEditorTextField();
- PropertysetItem item = new PropertysetItem();
- item.addItemProperty("ckeditor", new ObjectProperty<String>("Zaphod"));
- FieldGroup fg = new FieldGroup(item);
- fg.bind(txt, "ckeditor");
- CKEditorConfig config = new CKEditorConfig();
- config.setInPageConfig("{ toolbar: 'custom',"+
- "toolbar_custom: " +
- "[" +
- "{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] }, " +
- "], ignoreEmptyParagraph: false, resize_enabled: false, language: 'nl', enterMode: 2, removePlugins: 'elementspath', customConfig: '', defaultLanguage: 'nl',"+ //enterMode 2 = BR mode naam is niet bruikbaar, getal wel
- "colorButton_enableMore :false, readOnly: true, }");//http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Setting_Configurations
- txt.setConfig(config);
- fl.addComponent(txt);
- Button button = new Button("SetReadOnly");
- button.addClickListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- txt.setReadOnly(!txt.isReadOnly());
- layout.addComponent(new Label("SetReadOnly is clicked!"));
- }
- });
- fl.addComponent(button);
- w.setContent(fl);
- w.setModal(true);
- w.center();
- w.setWidth("400px");
- w.setHeight("500px");
- getUI().addWindow(w);
- }
- });
- layout.addComponent(btn8);
- setContent(layout);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement