Example usage for com.vaadin.ui Window setHeight

List of usage examples for com.vaadin.ui Window setHeight

Introduction

In this page you can find the example usage for com.vaadin.ui Window setHeight.

Prototype

@Override
    public void setHeight(String height) 

Source Link

Usage

From source file:org.vaadin.alump.ckeditor.demo.VaadinCKEditorUI.java

License:LGPL

@Override
public void init(VaadinRequest request) {

    //Enable to test effects of other UIDL calls to cursor position
    //setPollInterval(5000);

    getPage().setTitle("Vaadin CKEditor UI");

    VerticalLayout mainView = new VerticalLayout();
    setContent(mainView);/*from  w  ww.j av a2  s .  c  o  m*/

    /*
    enablePushEvents = new CheckBox("Enable push events");
    enablePushEvents.addValueChangeListener(this::enablePushEvents);
    mainView.addComponents(new HorizontalLayout(enablePushEvents, pushUpdateLabel));
    */

    /* See http://ckeditor.com/latest/samples/plugins/toolbar/toolbar.html for the official info.
     * This is the full list as we know it in CKEditor 4.x
    [
    { name: 'document', items : [ 'Source','-','NewPage','Preview','Print','-','Templates' ] },
    { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
    { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
    { name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
    '/',
    { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
    { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
    { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
    { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
    '/',
    { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
    { name: 'colors', items : [ 'TextColor','BGColor' ] },
    { name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] }
    ]
     */

    final String editor1InitialValue = "<p>Thanks TinyMCEEditor for getting us started on the CKEditor integration.</p>\n\n<h1>Like TinyMCEEditor said, &quot;Vaadin rocks!&quot;</h1>\n\n<h1>And CKEditor is no slouch either.</h1>\n";

    CKEditorConfig config1 = new CKEditorConfig();
    config1.useCompactTags();
    config1.disableElementsPath();
    config1.setResizeDir(CKEditorConfig.RESIZE_DIR.HORIZONTAL);
    config1.disableSpellChecker();
    config1.setHeight("300px");
    config1.addToExtraPlugins("exampleplugin");

    //final CKEditorTextField ckEditorTextField1 = new CKEditorTextField(config1);
    final AbstractCKEditorTextField ckEditorTextField1 = new CKEditorPluginExample(config1);
    ckEditorTextField1.setImmediate(true);
    ckEditorTextField1.setHeight("440px"); // account for 300px editor plus toolbars
    mainView.addComponent(ckEditorTextField1);

    ckEditorTextField1.setValue(editor1InitialValue);
    ckEditorTextField1.addValueChangeListener(e -> {
        System.out.println("CKEditor v" + ckEditorTextField1.getVersion() + "/" + getVersion()
                + " - #1 contents: " + e.getValue());
    });

    Button resetTextButton1 = new Button("Reset editor #1");
    resetTextButton1.addClickListener(event -> {
        if (!ckEditorTextField1.isReadOnly()) {
            ckEditorTextField1.setValue(editor1InitialValue);
        }
    });

    Button toggleReadOnlyButton1 = new Button("Toggle read-only editor #1");
    toggleReadOnlyButton1.addClickListener(event -> {
        ckEditorTextField1.setReadOnly(!ckEditorTextField1.isReadOnly());
    });

    Button toggleViewWithoutEditorButton1 = new Button("Toggle view-without-editor #1");
    toggleViewWithoutEditorButton1.addClickListener(event -> {
        ckEditorTextField1.setViewWithoutEditor(!ckEditorTextField1.isViewWithoutEditor());
    });

    Button toggleVisibleButton1 = new Button("Toggle visible editor #1");
    toggleVisibleButton1.addClickListener(event -> {
        ckEditorTextField1.setVisible(!ckEditorTextField1.isVisible());
    });
    HorizontalLayout buttonsLayout = new HorizontalLayout(resetTextButton1, toggleReadOnlyButton1,
            toggleViewWithoutEditorButton1, toggleVisibleButton1);
    buttonsLayout.setSpacing(true);
    mainView.addComponent(buttonsLayout);

    mainView.addComponent(createSeparator());

    // Now add in a second editor....
    final String editor2InitialValue = "<p>Here is editor #2.</p>\n\n<p>Hope you find this useful in your Vaadin projects.</p>\n";

    //final CKEditorTextField ckEditorTextField2 = new CKEditorTextField();
    final AbstractCKEditorTextField ckEditorTextField2 = new CKEditorTextField();
    ckEditorTextField2.setWidth("600px");
    mainView.addComponent(ckEditorTextField2);

    CKEditorConfig config2 = new CKEditorConfig();
    config2.addCustomToolbarLine(
            "{ items : ['Source','Styles','Bold','VaadinSave','-','Undo','Redo','-','NumberedList','BulletedList'] }");
    config2.enableCtrlSWithVaadinSavePlugin();
    config2.addToRemovePlugins("scayt");
    ckEditorTextField2.setConfig(config2);
    ckEditorTextField2.setValue(editor2InitialValue);

    ckEditorTextField2.addValueChangeListener(event -> {
        Notification.show("CKEditor v" + ckEditorTextField2.getVersion() + "/" + getVersion()
                + " - #2 contents: " + event.getValue());
    });

    ckEditorTextField2.addVaadinSaveListener(editor -> {
        Notification.show("CKEditor v" + ckEditorTextField2.getVersion() + "/" + getVersion()
                + " - #2 VaadinSave button pressed.");
    });

    Button resetTextButton2 = new Button("Reset editor #2");
    resetTextButton2.addClickListener(event -> {
        if (!ckEditorTextField2.isReadOnly()) {
            ckEditorTextField2.setValue(editor2InitialValue);
        }
    });

    Button toggleReadOnlyButton2 = new Button("Toggle read-only editor #2");
    toggleReadOnlyButton2.addClickListener(event -> {
        ckEditorTextField2.setReadOnly(!ckEditorTextField2.isReadOnly());
    });

    Button toggleViewWithoutEditorButton2 = new Button("Toggle view-without-editor #2");
    toggleViewWithoutEditorButton2.addClickListener(event -> {
        ckEditorTextField2.setViewWithoutEditor(!ckEditorTextField2.isViewWithoutEditor());
    });

    Button toggleVisibleButton2 = new Button("Toggle visible editor #2");
    toggleVisibleButton2.addClickListener(event -> {
        ckEditorTextField2.setVisible(!ckEditorTextField2.isVisible());
    });

    buttonsLayout = new HorizontalLayout(resetTextButton2, toggleReadOnlyButton2,
            toggleViewWithoutEditorButton2, toggleVisibleButton2);
    buttonsLayout.setSpacing(true);
    mainView.addComponent(buttonsLayout);

    buttonsLayout = new HorizontalLayout();
    buttonsLayout.setSpacing(true);
    mainView.addComponent(buttonsLayout);

    buttonsLayout.addComponent(new Button("Open Modal Subwindow", event -> {

        Window sub = new Window("Subwindow modal");
        VerticalLayout subLayout = new VerticalLayout();
        sub.setContent(subLayout);

        CKEditorConfig config = new CKEditorConfig();
        config.useCompactTags();
        config.disableElementsPath();
        config.disableSpellChecker();
        config.enableVaadinSavePlugin();
        // set BaseFloatZIndex 1000 higher than CKEditor's default of 10000; probably a result of an editor opening
        // in a window that's on top of the main two editors of this demo app
        config.setBaseFloatZIndex(11000);
        config.setHeight("150px");

        final CKEditorTextField ckEditorTextField = new CKEditorTextField(config);
        ckEditorTextField.addValueChangeListener(event2 -> {
            Notification.show("CKEditor v" + ckEditorTextField2.getVersion() + "/" + getVersion()
                    + " - POPUP MODAL contents: " + event2.getValue());
        });
        ckEditorTextField.focus();

        subLayout.addComponent(ckEditorTextField);

        sub.setWidth("80%");
        sub.setModal(true);
        sub.center();

        event.getButton().getUI().addWindow(sub);
    }));

    buttonsLayout.addComponent(new Button("Open Non-Modal Subwindow with 100% Height", event -> {
        Window sub = new Window("Subwindow non-modal 100% height");
        VerticalLayout subLayout = new VerticalLayout();
        sub.setContent(subLayout);
        sub.setWidth("80%");
        sub.setHeight("500px");

        subLayout.setSizeFull();

        CKEditorConfig config = new CKEditorConfig();
        config.useCompactTags();
        config.disableElementsPath();
        config.disableSpellChecker();
        config.enableVaadinSavePlugin();
        // set BaseFloatZIndex 1000 higher than CKEditor's default of 10000; probably a result of an editor opening
        // in a window that's on top of the main two editors of this demo app
        config.setBaseFloatZIndex(11000);
        config.setStartupFocus(true);
        config.setReadOnly(true);

        final CKEditorTextField ckEditorTextField = new CKEditorTextField(config);
        ckEditorTextField.setHeight("100%");
        ckEditorTextField.addValueChangeListener(event2 -> {
            Notification.show("CKEditor v" + ckEditorTextField.getVersion() + "/" + getVersion()
                    + " - POPUP NON-MODAL 100% HEIGHT contents: " + event2.getValue());
        });
        subLayout.addComponent(ckEditorTextField);
        subLayout.setExpandRatio(ckEditorTextField, 10);

        final TextField textField = new TextField("TextField");
        textField.addValueChangeListener(event2 -> {
            Notification.show("TextField - POPUP NON-MODAL 100% HEIGHT contents: " + event2.getValue());
        });
        subLayout.addComponent(textField);

        sub.center();

        event.getButton().getUI().addWindow(sub);
    }));
}

From source file:org.vaadin.openesignforms.ckeditor.VaadinCKEditorUI.java

License:Open Source License

@Override
public void init(VaadinRequest request) {

    getPage().setTitle("Vaadin7 CKEditor UI");

    VerticalLayout mainView = new VerticalLayout();
    setContent(mainView);/*from w  w  w  . j ava  2s  . co  m*/

    mainView.addComponent(new Button("Hit server"));

    Label separator = new Label("&nbsp;");
    separator.setContentMode(ContentMode.HTML);
    mainView.addComponent(separator);

    /* See http://ckeditor.com/latest/samples/plugins/toolbar/toolbar.html for the official info.
     * This is the full list as we know it in CKEditor 4.x
    [
    { name: 'document', items : [ 'Source','-','NewPage','Preview','Print','-','Templates' ] },
    { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
    { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
    { name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
    '/',
    { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
    { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
    { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
    { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
    '/',
    { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
    { name: 'colors', items : [ 'TextColor','BGColor' ] },
    { name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] }
    ]
     */

    final String editor1InitialValue = "<p>Thanks TinyMCEEditor for getting us started on the CKEditor integration.</p>\n\n<h1>Like TinyMCEEditor said, &quot;Vaadin rocks!&quot;</h1>\n\n<h1>And CKEditor is no slouch either.</h1>\n";

    CKEditorConfig config1 = new CKEditorConfig();
    config1.useCompactTags();
    config1.disableElementsPath();
    config1.setResizeDir(CKEditorConfig.RESIZE_DIR.HORIZONTAL);
    config1.disableSpellChecker();
    config1.setHeight("300px");

    final CKEditorTextField ckEditorTextField1 = new CKEditorTextField(config1);
    ckEditorTextField1.setHeight("440px"); // account for 300px editor plus toolbars
    mainView.addComponent(ckEditorTextField1);

    ckEditorTextField1.setValue(editor1InitialValue);
    ckEditorTextField1.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -761434593559159149L;

        public void valueChange(ValueChangeEvent event) {
            Notification.show("CKEditor v" + ckEditorTextField1.getVersion() + "/" + getVersion()
                    + " - #1 contents: " + event.getProperty().getValue().toString());
        }
    });
    // This selection change listener is commented out for general use, but it does appear to work in preliminary testing as of 
    // version 7.10.2 (15 July 2015) if you need it.
    /*
    ckEditorTextField1.addSelectionChangeListener(new SelectionChangeListener() {
       private static final long serialVersionUID = 1270295222444271706L;
            
       public void selectionChange(SelectionChangeEvent event) {
    if ( event.hasSelectedHtml() ) {
       Notification.show("CKEditor selected HTML: " + event.getSelectedHtml(), Type.ERROR_MESSAGE);
       ckEditorTextField1.focus();
    } else {
       Notification.show("CKEditor un-select reported", Type.ERROR_MESSAGE);
    }
       }
    });
    */

    Button resetTextButton1 = new Button("Reset editor #1");
    resetTextButton1.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 2872667648717255301L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (!ckEditorTextField1.isReadOnly()) {
                ckEditorTextField1.setValue(editor1InitialValue);
            }
        }
    });

    Button toggleReadOnlyButton1 = new Button("Toggle read-only editor #1");
    toggleReadOnlyButton1.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 8462908141468254844L;

        @Override
        public void buttonClick(ClickEvent event) {
            ckEditorTextField1.setReadOnly(!ckEditorTextField1.isReadOnly());
        }
    });

    Button toggleViewWithoutEditorButton1 = new Button("Toggle view-without-editor #1");
    toggleViewWithoutEditorButton1.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 8122286299515325693L;

        @Override
        public void buttonClick(ClickEvent event) {
            ckEditorTextField1.setViewWithoutEditor(!ckEditorTextField1.isViewWithoutEditor());
        }
    });

    Button toggleVisibleButton1 = new Button("Toggle visible editor #1");
    toggleVisibleButton1.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = -6715135605688427318L;

        @Override
        public void buttonClick(ClickEvent event) {
            ckEditorTextField1.setVisible(!ckEditorTextField1.isVisible());
        }
    });
    HorizontalLayout buttonsLayout = new HorizontalLayout(resetTextButton1, toggleReadOnlyButton1,
            toggleViewWithoutEditorButton1, toggleVisibleButton1);
    buttonsLayout.setSpacing(true);
    mainView.addComponent(buttonsLayout);

    separator = new Label("&nbsp;");
    separator.setContentMode(ContentMode.HTML);
    mainView.addComponent(separator);

    // Now add in a second editor....
    final String editor2InitialValue = "<p>Here is editor #2.</p>\n\n<p>Hope you find this useful in your Vaadin projects.</p>\n";

    final CKEditorTextField ckEditorTextField2 = new CKEditorTextField();
    ckEditorTextField2.setWidth("600px");
    mainView.addComponent(ckEditorTextField2);

    CKEditorConfig config2 = new CKEditorConfig();
    config2.addCustomToolbarLine(
            "{ items : ['Source','Styles','Bold','VaadinSave','-','Undo','Redo','-','NumberedList','BulletedList'] }");
    config2.enableCtrlSWithVaadinSavePlugin();
    config2.addToRemovePlugins("scayt");
    ckEditorTextField2.setConfig(config2);
    ckEditorTextField2.setValue(editor2InitialValue);

    ckEditorTextField2.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1522230917891035997L;

        public void valueChange(ValueChangeEvent event) {
            Notification.show("CKEditor v" + ckEditorTextField2.getVersion() + "/" + getVersion()
                    + " - #2 contents: " + event.getProperty().getValue().toString());
        }
    });

    ckEditorTextField2.addVaadinSaveListener(new CKEditorTextField.VaadinSaveListener() {
        private static final long serialVersionUID = 3763779235559050613L;

        @Override
        public void vaadinSave(CKEditorTextField editor) {
            Notification.show("CKEditor v" + ckEditorTextField2.getVersion() + "/" + getVersion()
                    + " - #2 VaadinSave button pressed.");
        }

    });

    Button resetTextButton2 = new Button("Reset editor #2");
    resetTextButton2.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 4877506990872691752L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (!ckEditorTextField2.isReadOnly()) {
                ckEditorTextField2.setValue(editor2InitialValue);
            }
        }
    });

    Button toggleReadOnlyButton2 = new Button("Toggle read-only editor #2");
    toggleReadOnlyButton2.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 7388801260896778551L;

        @Override
        public void buttonClick(ClickEvent event) {
            ckEditorTextField2.setReadOnly(!ckEditorTextField2.isReadOnly());
        }
    });

    Button toggleViewWithoutEditorButton2 = new Button("Toggle view-without-editor #2");
    toggleViewWithoutEditorButton2.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 6042124118599379679L;

        @Override
        public void buttonClick(ClickEvent event) {
            ckEditorTextField2.setViewWithoutEditor(!ckEditorTextField2.isViewWithoutEditor());
        }
    });

    Button toggleVisibleButton2 = new Button("Toggle visible editor #2");
    toggleVisibleButton2.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = -3804977370320346348L;

        @Override
        public void buttonClick(ClickEvent event) {
            ckEditorTextField2.setVisible(!ckEditorTextField2.isVisible());
        }
    });

    buttonsLayout = new HorizontalLayout(resetTextButton2, toggleReadOnlyButton2,
            toggleViewWithoutEditorButton2, toggleVisibleButton2);
    buttonsLayout.setSpacing(true);
    mainView.addComponent(buttonsLayout);

    separator = new Label("&nbsp;");
    separator.setContentMode(ContentMode.HTML);
    mainView.addComponent(separator);

    buttonsLayout = new HorizontalLayout();
    buttonsLayout.setSpacing(true);
    mainView.addComponent(buttonsLayout);

    buttonsLayout.addComponent(new Button("Open Modal Subwindow", new ClickListener() {
        private static final long serialVersionUID = 7661931879334525618L;

        @Override
        public void buttonClick(ClickEvent event) {
            Window sub = new Window("Subwindow modal");
            VerticalLayout subLayout = new VerticalLayout();
            sub.setContent(subLayout);

            CKEditorConfig config = new CKEditorConfig();
            config.useCompactTags();
            config.disableElementsPath();
            config.disableSpellChecker();
            config.enableVaadinSavePlugin();
            // set BaseFloatZIndex 1000 higher than CKEditor's default of 10000; probably a result of an editor opening
            // in a window that's on top of the main two editors of this demo app
            config.setBaseFloatZIndex(11000);
            config.setHeight("150px");

            final CKEditorTextField ckEditorTextField = new CKEditorTextField(config);
            ckEditorTextField.addValueChangeListener(new Property.ValueChangeListener() {
                private static final long serialVersionUID = -1308863170484877239L;

                public void valueChange(ValueChangeEvent event) {
                    Notification.show("CKEditor v" + ckEditorTextField2.getVersion() + "/" + getVersion()
                            + " - POPUP MODAL contents: " + event.getProperty().getValue().toString());
                }
            });
            ckEditorTextField.focus();

            subLayout.addComponent(ckEditorTextField);

            sub.setWidth("80%");
            sub.setModal(true);
            sub.center();

            event.getButton().getUI().addWindow(sub);
        }
    }));

    buttonsLayout.addComponent(new Button("Open Non-Modal Subwindow with 100% Height", new ClickListener() {
        private static final long serialVersionUID = 8895747367120494167L;

        @Override
        public void buttonClick(ClickEvent event) {
            Window sub = new Window("Subwindow non-modal 100% height");
            VerticalLayout subLayout = new VerticalLayout();
            sub.setContent(subLayout);
            sub.setWidth("80%");
            sub.setHeight("500px");

            subLayout.setSizeFull();

            CKEditorConfig config = new CKEditorConfig();
            config.useCompactTags();
            config.disableElementsPath();
            config.disableSpellChecker();
            config.enableVaadinSavePlugin();
            // set BaseFloatZIndex 1000 higher than CKEditor's default of 10000; probably a result of an editor opening
            // in a window that's on top of the main two editors of this demo app
            config.setBaseFloatZIndex(11000);
            config.setStartupFocus(true);
            config.setReadOnly(true);

            final CKEditorTextField ckEditorTextField = new CKEditorTextField(config);
            ckEditorTextField.setHeight("100%");
            ckEditorTextField.addValueChangeListener(new Property.ValueChangeListener() {
                private static final long serialVersionUID = 5592423527258867304L;

                public void valueChange(ValueChangeEvent event) {
                    Notification.show("CKEditor v" + ckEditorTextField.getVersion() + "/" + getVersion()
                            + " - POPUP NON-MODAL 100% HEIGHT contents: "
                            + event.getProperty().getValue().toString());
                }
            });
            subLayout.addComponent(ckEditorTextField);
            subLayout.setExpandRatio(ckEditorTextField, 10);

            final TextField textField = new TextField("TextField");
            textField.addValueChangeListener(new Property.ValueChangeListener() {
                private static final long serialVersionUID = 6686202497483757206L;

                public void valueChange(ValueChangeEvent event) {
                    Notification.show("TextField - POPUP NON-MODAL 100% HEIGHT contents: "
                            + event.getProperty().getValue().toString());
                }
            });
            subLayout.addComponent(textField);

            sub.center();

            event.getButton().getUI().addWindow(sub);
        }
    }));
}

From source file:org.yozons.vaadin.ckeditor.CKEditorForVaadin7UI.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    getPage().setTitle("CKEditor for Vaadin 7");

    final VerticalLayout layout = new VerticalLayout();
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setMargin(true);//from   ww  w.j a  va 2 s.co  m
    layout.setSpacing(true);
    setContent(layout);

    layout.addComponent(new Button("Hit server"));

    final String editor1InitialValue = "<p>CKEditor for Vaadin 7 is an entirely new JavaScriptComponent add-on.</p>";

    CKEditorConfig config1 = new CKEditorConfig();
    config1.useCompactTags();
    config1.disableElementsPath();
    config1.setResizeDir(CKEditorConfig.RESIZE_DIR.HORIZONTAL);
    config1.disableSpellChecker();
    final CKEditor editor1 = new CKEditor(config1, editor1InitialValue);
    layout.addComponent(editor1);

    editor1.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(String newValue) {
            if (!newValue.equals(editor1.getValue()))
                Notification.show("ERROR - Event value does not match editor #1's current value");
            else
                Notification.show("ValueChangeListener CKEditor v" + editor1.getVersion() + "/" + getVersion()
                        + " - #1 contents: " + newValue);
            editor1.focus();
        }
    });

    Button testButton = new Button("Reset editor #1");
    testButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (!editor1.isReadOnly()) {
                editor1.setValue(editor1InitialValue);
                Notification.show("Reset CKEditor v" + editor1.getVersion() + "/" + getVersion()
                        + " - #1 contents: " + editor1.getValue());
            }
        }

    });
    layout.addComponent(testButton);

    Button toggleReadOnlyButton1 = new Button("Toggle read-only editor #1");
    toggleReadOnlyButton1.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            editor1.setReadOnly(!editor1.isReadOnly());
        }
    });
    layout.addComponent(toggleReadOnlyButton1);

    Button toggleViewWithoutEditorButton1 = new Button("Toggle view-without-editor #1");
    toggleViewWithoutEditorButton1.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            editor1.setViewWithoutEditor(!editor1.isViewWithoutEditor());
        }
    });
    layout.addComponent(toggleViewWithoutEditorButton1);

    // Now add in a second editor....
    final String editor2InitialValue = "<p>Here is editor #2.</p><h1>Hope you find this useful in your Vaadin 7 projects.</h1>";

    CKEditorConfig config2 = new CKEditorConfig();
    config2.addCustomToolbarLine(
            "{ items : ['Source','Styles','Bold','VaadinSave','-','Undo','Redo','-','NumberedList','BulletedList'] }");
    config2.enableVaadinSavePlugin();
    config2.addToRemovePlugins("scayt");

    final CKEditor editor2 = new CKEditor(config2);
    editor2.setWidth(600, Unit.PIXELS);
    layout.addComponent(editor2);
    editor2.setValue(editor2InitialValue);

    editor2.addValueChangeListener(new ValueChangeListener() {

        public void valueChange(String newValue) {
            if (!newValue.equals(editor2.getValue()))
                Notification.show("ERROR - Event value does not match editor #2's current value");
            else
                Notification.show("ValueChangeListener CKEditor v" + editor2.getVersion() + "/" + getVersion()
                        + " - #2 contents: " + newValue);
        }
    });

    Button resetTextButton2 = new Button("Reset editor #2");
    resetTextButton2.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (!editor2.isReadOnly()) {
                editor2.setValue(editor2InitialValue);
                Notification.show("Reset CKEditor v" + editor1.getVersion() + "/" + getVersion()
                        + " - #2 contents: " + editor2.getValue());
            }
        }
    });
    layout.addComponent(resetTextButton2);

    Button toggleReadOnlyButton2 = new Button("Toggle read-only editor #2");
    toggleReadOnlyButton2.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            editor2.setReadOnly(!editor2.isReadOnly());
        }
    });
    layout.addComponent(toggleReadOnlyButton2);

    Button toggleViewWithoutEditorButton2 = new Button("Toggle view-without-editor #2");
    toggleViewWithoutEditorButton2.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            editor2.setViewWithoutEditor(!editor2.isViewWithoutEditor());
        }
    });
    layout.addComponent(toggleViewWithoutEditorButton2);

    // Now some extra tests for modal windows, etc.
    layout.addComponent(new Button("Open Modal Subwindow", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Window sub = new Window("Subwindow modal");
            VerticalLayout subLayout = new VerticalLayout();
            sub.setContent(subLayout);

            CKEditorConfig config = new CKEditorConfig();
            config.useCompactTags();
            config.disableElementsPath();
            config.disableSpellChecker();
            config.enableVaadinSavePlugin();
            // set BaseFloatZIndex 1000 higher than CKEditor's default of 10000; probably a result of an editor opening
            // in a window that's on top of the main two editors of this demo app
            config.setBaseFloatZIndex(11000);
            config.setHeight("150px");

            final CKEditor ckEditor = new CKEditor(config);
            ckEditor.addValueChangeListener(new ValueChangeListener() {

                public void valueChange(String newValue) {
                    Notification.show("CKEditor v" + ckEditor.getVersion() + "/" + getVersion()
                            + " - POPUP MODAL contents: " + newValue);
                }
            });
            ckEditor.focus();

            subLayout.addComponent(ckEditor);

            sub.setWidth("80%");
            sub.setModal(true);
            sub.center();

            event.getButton().getUI().addWindow(sub);
        }
    }));

    layout.addComponent(new Button("Open Non-Modal Subwindow with 100% Height", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Window sub = new Window("Subwindow non-modal 100% height");
            VerticalLayout subLayout = new VerticalLayout();
            sub.setContent(subLayout);
            sub.setWidth("80%");
            sub.setHeight("500px");

            subLayout.setSizeFull();

            CKEditorConfig config = new CKEditorConfig();
            config.useCompactTags();
            config.disableElementsPath();
            config.disableSpellChecker();
            config.enableVaadinSavePlugin();
            // set BaseFloatZIndex 1000 higher than CKEditor's default of 10000; probably a result of an editor opening
            // in a window that's on top of the main two editors of this demo app
            config.setBaseFloatZIndex(11000);
            config.setStartupFocus(true);

            final CKEditor ckEditor = new CKEditor(config);
            ckEditor.setHeight("100%");
            ckEditor.addValueChangeListener(new ValueChangeListener() {

                public void valueChange(String newValue) {
                    Notification.show("CKEditor v" + ckEditor.getVersion() + "/" + getVersion()
                            + " - POPUP NON-MODAL 100% HEIGHT contents: " + ckEditor.getValue());
                }
            });
            subLayout.addComponent(ckEditor);
            subLayout.setExpandRatio(ckEditor, 1.0f);

            final TextField textField = new TextField("TextField");
            textField.setImmediate(true);
            textField.addValueChangeListener(new Property.ValueChangeListener() {

                public void valueChange(ValueChangeEvent event) {
                    Notification.show("TextField - POPUP NON-MODAL 100% HEIGHT contents: "
                            + event.getProperty().getValue().toString());
                }
            });
            subLayout.addComponent(textField);

            sub.center();

            event.getButton().getUI().addWindow(sub);
        }
    }));
}

From source file:ro.zg.netcell.vaadin.action.user.LoginHandler.java

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    Window w = new Window();
    w.setModal(true);// www  .  j a  v  a 2 s. c o m
    OpenGroupsApplication app = actionContext.getApp();
    if (app.getAppConfigManager().isInstancePrivate()) {
        w.setClosable(false);
    }

    OpenGroupsMainWindow mainWindow = actionContext.getWindow();

    UserAction ua = actionContext.getUserAction();
    w.setWidth("600px");
    w.setHeight("300px");
    w.center();
    w.setCaption(getMessage(ua.getActionName() + ".window.caption"));
    mainWindow.addWindow(w);

    ComponentContainer loginView = getLoginView(actionContext);

    w.setContent(loginView);

}

From source file:ro.zg.netcell.vaadin.action.user.RegisterUserHandler.java

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    Window w = new Window();
    w.setModal(true);//w w w . j a  va2  s .com
    OpenGroupsApplication app = actionContext.getApp();
    OpenGroupsMainWindow mainWindow = actionContext.getWindow();
    UserAction ua = actionContext.getUserAction();
    w.setWidth("400px");
    w.setHeight("300px");
    w.center();
    w.setCaption(getMessage(ua.getActionName() + ".window.caption"));
    mainWindow.addWindow(w);

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    Form form = getRegisterForm(actionContext.getUserAction(), app, actionContext.getWindow(),
            actionContext.getEntity(), actionContext);
    w.setContent(layout);
    layout.addComponent(form);
    form.setWidth("60%");
    //   form.setHeight("30%");
    layout.setComponentAlignment(form, Alignment.MIDDLE_CENTER);

}

From source file:ro.zg.netcell.vaadin.action.user.RequestPasswordResetHandler.java

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    Window w = new Window();
    w.setModal(true);/*  ww  w  .j a v a  2  s .  c om*/
    OpenGroupsApplication app = actionContext.getApp();
    OpenGroupsMainWindow mainWindow = actionContext.getWindow();
    UserAction ua = actionContext.getUserAction();
    w.setWidth("400px");
    w.setHeight("300px");
    w.center();
    w.setCaption(getMessage(ua.getActionName() + ".window.caption"));
    mainWindow.addWindow(w);

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    Form form = getForm(actionContext.getUserAction(), app, actionContext);
    w.setContent(layout);
    layout.addComponent(form);
    form.setWidth("60%");
    // form.setHeight("30%");
    layout.setComponentAlignment(form, Alignment.MIDDLE_CENTER);
}

From source file:ro.zg.netcell.vaadin.action.user.ResetPasswordHandler.java

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    Window w = new Window();
    w.setModal(true);//from   w ww . ja v a2s. c om
    OpenGroupsApplication app = actionContext.getApp();
    OpenGroupsMainWindow mainWindow = actionContext.getWindow();
    UserAction ua = actionContext.getUserAction();
    w.setWidth("400px");
    w.setHeight("300px");
    w.center();
    w.setCaption(getMessage(ua.getActionName() + ".window.caption"));
    mainWindow.addWindow(w);

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    Form form = getForm(actionContext.getUserAction(), app, actionContext.getParams(), actionContext);
    w.setContent(layout);
    layout.addComponent(form);
    form.setWidth("60%");
    // form.setHeight("30%");
    layout.setComponentAlignment(form, Alignment.MIDDLE_CENTER);

    /* hide the content of the main window */
    mainWindow.setContentVisible(false);

}

From source file:roart.client.MyVaadinUI.java

private Window getLoginWindow() {
    final Window window = new Window("Login");
    window.setWidth("30%");
    window.setHeight("30%");
    window.center();// ww  w. ja  va  2 s.c om
    final TextField login = new TextField("Username");
    final PasswordField password = new PasswordField("Password");
    Button button = new Button("Login");
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            tryLogin(login.getValue(), password.getValue());
            window.close();
        }
    });
    VerticalLayout vert = new VerticalLayout();
    vert.addComponent(login);
    vert.addComponent(password);
    vert.addComponent(button);
    window.setContent(vert);
    return window;
}

From source file:ru.codeinside.gses.webui.components.ShowDiagramComponent.java

License:Mozilla Public License

private void buildLayout(final ShowDiagramComponentParameterObject param) {
    setSizeFull();/* w  w  w . j a v a2  s  .co  m*/
    setSpacing(true);
    final Panel panel = new Panel();
    panel.getContent().setSizeUndefined();
    panel.setCaption(param.caption);
    TaskGraph tg = new TaskGraph(param.processDefinitionId, param.executionId);
    if (param.height != null) {
        tg.setHeight(param.height);
    }
    if (param.width != null) {
        tg.setWidth(param.width);
    }
    tg.setStyleName("scheme-image");
    final TaskGraph bigGraph = new TaskGraph(param.processDefinitionId, param.executionId);
    tg.addListener(new MouseEvents.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void click(MouseEvents.ClickEvent event) {
            final Window schemeWindow = new Window(param.windowHeader);
            getWindow().addWindow(schemeWindow);
            schemeWindow.addComponent(bigGraph);
            schemeWindow.setWidth("90%");
            schemeWindow.setHeight("90%");
            schemeWindow.center();
            schemeWindow.focus();
            schemeWindow.setCloseShortcut(ShortcutAction.KeyCode.ESCAPE, 0);
            bigGraph.addListener(new MouseEvents.ClickListener() {
                @Override
                public void click(MouseEvents.ClickEvent event) {
                    getWindow().removeWindow(schemeWindow);
                }
            });
        }
    });
    panel.addComponent(tg);
    addComponent(panel);
}

From source file:ui.button.ShowAchievementsButton.java

License:Apache License

private void showOnWindow() {
    final Window window = new Window();
    window.setWidth("95%");
    window.setHeight("95%");
    window.center();//w w  w. ja v  a  2 s  .c o m
    window.setResizable(true);
    window.setModal(true);
    window.addCloseListener(new Window.CloseListener() {

        @Override
        public void windowClose(Window.CloseEvent e) {
            window.close();
        }
    });
    window.setContent(new UserTabSheet(userId, language));
    getUI().addWindow(window);
    window.setStyleName("window");
}