Example usage for com.vaadin.ui VerticalLayout setSizeFull

List of usage examples for com.vaadin.ui VerticalLayout setSizeFull

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout setSizeFull.

Prototype

@Override
    public void setSizeFull() 

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   www. j a v a 2s . 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.alump.vibrate.demo.VibrateDemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest vaadinRequest) {
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    setContent(layout);/*from   www . j av  a  2 s  .  com*/

    notifications = new FancyNotifications();
    layout.addComponent(notifications);

    Label label = new Label("This demo works only with Android Chrome");
    layout.addComponent(label);

    Button singleButton = new Button("Single vibrate");
    singleButton.setWidth("100%");
    layout.addComponent(singleButton);
    singleButton.addClickListener(singleClickListener);

    Button patternButton = new Button("Pattern vibrate");
    patternButton.setWidth("100%");
    layout.addComponent(patternButton);
    patternButton.addClickListener(patternClickListener);

    Button stopButton = new Button("End vibrate");
    stopButton.setWidth("100%");
    layout.addComponent(stopButton);
    stopButton.addClickListener(stopClickListener);

    Button notificationButton = new Button("Delayed notification vibrate");
    notificationButton.setWidth("100%");
    layout.addComponent(notificationButton);
    notificationButton.addClickListener(notificationClickListener);

}

From source file:org.vaadin.arborgraph.demo.DemoApplication.java

License:Open Source License

@SuppressWarnings("serial")
@Override//w  w  w. j  a  v  a  2s. c o m
public void init() {
    VerticalLayout aboutLayout = new VerticalLayout();
    aboutLayout.setSizeFull();
    aboutLayout.addComponent(new Label(getBlah(), Label.CONTENT_XHTML));

    final ArborGraph graph = new ArborGraph();
    graph.setSizeFull();

    Button exampleGraphButton = new Button("Show Example", new ClickListener() {

        public void buttonClick(ClickEvent event) {
            graph.showGraph(getDemoBranch());
        }
    });

    Label orLabel = new Label("<i>or</i>", Label.CONTENT_XHTML);
    orLabel.setSizeUndefined();

    final TextField jsonTextfield = new TextField();
    jsonTextfield.setWidth(100, Sizeable.UNITS_PERCENTAGE);
    jsonTextfield.setNullRepresentation("");

    Button jsonBranchButton = new Button("Display Json Branch", new ClickListener() {

        public void buttonClick(ClickEvent event) {
            graph.showGraph(jsonTextfield.getValue().toString());
        }
    });

    Label helpLabel = getHelpLabel(getBranchExplanation());

    HorizontalLayout graphButtonLayout = new HorizontalLayout();
    graphButtonLayout.setWidth(100, Sizeable.UNITS_PERCENTAGE);
    graphButtonLayout.setSpacing(true);
    graphButtonLayout.setMargin(false, false, true, false);
    graphButtonLayout.addComponent(exampleGraphButton);
    graphButtonLayout.addComponent(orLabel);
    graphButtonLayout.setComponentAlignment(orLabel, Alignment.MIDDLE_CENTER);
    graphButtonLayout.addComponent(jsonBranchButton);
    graphButtonLayout.addComponent(helpLabel);
    graphButtonLayout.setComponentAlignment(helpLabel, Alignment.MIDDLE_CENTER);
    graphButtonLayout.addComponent(jsonTextfield);
    graphButtonLayout.setExpandRatio(jsonTextfield, .9f);

    VerticalLayout graphLayout = new VerticalLayout();
    graphLayout.setSizeFull();
    graphLayout.setMargin(true, false, false, false);
    graphLayout.setSpacing(true);
    graphLayout.addComponent(graphButtonLayout);
    graphLayout.addComponent(graph);
    graphLayout.setExpandRatio(graph, .9f);

    TabSheet tabSheet = new TabSheet();
    tabSheet.setStyleName(Reindeer.TABSHEET_MINIMAL);
    tabSheet.setSizeFull();
    tabSheet.addTab(aboutLayout, "About");
    tabSheet.addTab(graphLayout, "Graph");

    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();
    mainLayout.setMargin(true);
    mainLayout.addComponent(tabSheet);
    mainLayout.setExpandRatio(tabSheet, .9f);

    Window mainWindow = new Window("Arbor-Vaadin");
    mainWindow.setSizeFull();
    mainWindow.setContent(mainLayout);

    setTheme("arbor");

    setMainWindow(mainWindow);
}

From source file:org.vaadin.dialogs.DefaultConfirmDialogFactory.java

License:Mozilla Public License

public ConfirmDialog create(final String caption, final String message, final String okCaption,
        final String cancelCaption) {

    // Create a confirm dialog
    final ConfirmDialog confirm = new ConfirmDialog();
    confirm.setCaption(caption != null ? caption : DEFAULT_CAPTION);

    // Close listener implementation
    confirm.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1971800928047045825L;

        public void windowClose(CloseEvent ce) {

            // Only process if still enabled
            if (confirm.isEnabled()) {
                confirm.setEnabled(false); // avoid double processing
                confirm.setConfirmed(false);
                if (confirm.getListener() != null) {
                    confirm.getListener().onClose(confirm);
                }//  w ww .  j a  v a 2s  . c o m
            }
        }
    });

    // Create content
    VerticalLayout c = (VerticalLayout) confirm.getContent();
    c.setSizeFull();
    c.setSpacing(true);

    // Panel for scrolling lengthty messages.
    Panel scroll = new Panel(new VerticalLayout());
    scroll.setScrollable(true);
    c.addComponent(scroll);
    scroll.setWidth("100%");
    scroll.setHeight("100%");
    scroll.setStyleName(Reindeer.PANEL_LIGHT);
    c.setExpandRatio(scroll, 1f);

    // Always HTML, but escape
    Label text = new Label("", Label.CONTENT_RAW);
    scroll.addComponent(text);
    confirm.setMessageLabel(text);
    confirm.setMessage(message);

    HorizontalLayout buttons = new HorizontalLayout();
    c.addComponent(buttons);
    buttons.setSpacing(true);

    buttons.setHeight(format(BUTTON_HEIGHT) + "em");
    buttons.setWidth("100%");
    Label spacerLeft = new Label("");
    buttons.addComponent(spacerLeft);
    spacerLeft.setWidth("100%");
    buttons.setExpandRatio(spacerLeft, 1f);

    final Button cancel = new Button(cancelCaption != null ? cancelCaption : DEFAULT_CANCEL_CAPTION);
    cancel.setData(false);
    cancel.setClickShortcut(KeyCode.ESCAPE, null);
    buttons.addComponent(cancel);

    confirm.setCancelButton(cancel);

    final Button ok = new Button(okCaption != null ? okCaption : DEFAULT_OK_CAPTION);
    ok.setData(true);
    ok.setClickShortcut(KeyCode.ENTER, null);
    ok.focus();
    buttons.addComponent(ok);
    confirm.setOkButton(ok);

    Label spacerRight = new Label("");
    buttons.addComponent(spacerRight);
    spacerRight.setWidth("100%");
    buttons.setExpandRatio(spacerRight, 1f);
    // Create a listener for buttons
    Button.ClickListener cb = new Button.ClickListener() {
        private static final long serialVersionUID = 3525060915814334881L;

        public void buttonClick(ClickEvent event) {
            // Copy the button date to window for passing through either
            // "OK" or "CANCEL". Only process id still enabled.
            if (confirm.isEnabled()) {
                confirm.setEnabled(false); // Avoid double processing

                confirm.setConfirmed(event.getButton() == ok);

                // We need to cast this way, because of the backward
                // compatibility issue in 6.4 series.
                Component parent = confirm.getParent();
                if (parent instanceof Window) {
                    try {
                        Method m = Window.class.getDeclaredMethod("removeWindow", Window.class);
                        m.invoke(parent, confirm);
                    } catch (Exception e) {
                        throw new RuntimeException(
                                "Failed to remove confirmation dialog from the parent window.", e);
                    }
                }

                // This has to be invoked as the window.close
                // event is not fired when removed.
                if (confirm.getListener() != null) {
                    confirm.getListener().onClose(confirm);
                }
            }

        }

    };
    cancel.addListener(cb);
    ok.addListener(cb);

    // Approximate the size of the dialog
    double[] dim = getDialogDimensions(message, ConfirmDialog.CONTENT_TEXT_WITH_NEWLINES);
    confirm.setWidth(format(dim[0]) + "em");
    confirm.setHeight(format(dim[1]) + "em");
    confirm.setResizable(false);

    return confirm;
}

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 a  v  a 2  s. c o  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.vaadin.presentation.views.NewsView.java

@PostConstruct
void init() {//from  w ww.j  av  a2 s  .  c om
    add(new Header("News").setHeaderLevel(2));

    int records = service.findAll().size();
    add(new Label("There are " + records + " new photos."));

    setMargin(new MarginInfo(false, true, true, true));
    setStyleName(ValoTheme.LAYOUT_CARD);
    //        BeanItemContainer<Person> people
    //                = new BeanItemContainer<>(Person.class);
    //
    //        people.addBean(new Person("Nicolaus Copernicus", 1473));
    //        people.addBean(new Person("Galileo Galilei", 1564));
    //        people.addBean(new Person("Johannes Kepler", 1571));
    //
    //// Generate button caption column
    //        GeneratedPropertyContainer gpc
    //                = new GeneratedPropertyContainer(people);
    //        gpc.addGeneratedProperty("delete",
    //                new PropertyValueGenerator<String>() {
    //
    //                    @Override
    //                    public String getValue(Item item, Object itemId,
    //                            Object propertyId) {
    //                        return "Delete"; // The caption
    //                    }
    //
    //                    @Override
    //                    public Class<String> getType() {
    //                        return String.class;
    //                    }
    //                });
    //
    //// Create a grid
    //        Grid grid = new Grid(gpc);
    //// Render a button that deletes the data row (item)
    //        grid.getColumn("delete")
    //                .setRenderer(new ButtonRenderer(e -> // Java 8
    //                                grid.getContainerDataSource()
    //                                .removeItem(e.getItemId())));
    //        add(grid);

    //        Grid grid = new Grid();
    //        grid.setHeaderVisible(false);
    //        grid.addColumn("picture1", Resource.class)
    //                .setRenderer(new ImageRenderer());
    //        grid.addColumn("picture2", Resource.class)
    //                .setRenderer(new ImageRenderer());
    //        grid.addColumn("picture3", Resource.class)
    //                .setRenderer(new ImageRenderer());
    //
    //        grid.addRow(new ExternalResource("http://stanlemmens.nl/wp/wp-content/uploads/2014/07/bill-gates-wealthiest-person.jpg"),
    //                new ExternalResource("http://stanlemmens.nl/wp/wp-content/uploads/2014/07/bill-gates-wealthiest-person.jpg"),
    //                new ExternalResource("http://stanlemmens.nl/wp/wp-content/uploads/2014/07/bill-gates-wealthiest-person.jpg"));
    //        grid.addRow(new ExternalResource("http://stanlemmens.nl/wp/wp-content/uploads/2014/07/bill-gates-wealthiest-person.jpg"),
    //                new ExternalResource("http://stanlemmens.nl/wp/wp-content/uploads/2014/07/bill-gates-wealthiest-person.jpg"),
    //                new ExternalResource("http://stanlemmens.nl/wp/wp-content/uploads/2014/07/bill-gates-wealthiest-person.jpg"));
    //        grid.addRow(new ExternalResource("http://stanlemmens.nl/wp/wp-content/uploads/2014/07/bill-gates-wealthiest-person.jpg"),
    //                new ExternalResource("http://stanlemmens.nl/wp/wp-content/uploads/2014/07/bill-gates-wealthiest-person.jpg"),
    //                new ExternalResource("http://stanlemmens.nl/wp/wp-content/uploads/2014/07/bill-gates-wealthiest-person.jpg"));
    ////        grid.setStyleName("gridwithpics128px");
    ////        grid.getColumn("picture1").setWidth(120);
    //        grid.setCellStyleGenerator(cell
    //                -> cell.getPropertyId().toString().contains("picture")
    //                        ? "imagecol" : null);
    //        add(grid);
    try {
        IndexedContainer container = createContainer();
        Table table = createTable(container);

        VerticalLayout mainLayout = new VerticalLayout();
        mainLayout.addComponent(table);
        mainLayout.setSizeFull();

        add(mainLayout);
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
    }
}

From source file:org.vaadin.spinkit.demo.DemoUI.java

License:Apache License

private Component spinnerSizesContainer() {
    int types = SpinnerSize.values().length;
    GridLayout spinners = new GridLayout(4, (types / 4 + types % 4));
    spinners.setSizeFull();/*from   w w  w .  j  a va  2s .  c om*/
    spinners.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    spinners.setSpacing(true);

    ComboBox selector = new ComboBox("Select spinner type", Arrays.asList(SpinnerType.values()));
    selector.setNullSelectionAllowed(false);
    selector.setPageLength(0);
    selector.setValue(SpinnerType.ROTATING_PLANE);
    selector.addValueChangeListener(e -> {
        for (Component c : spinners) {
            if (c instanceof Spinner) {
                ((Spinner) c).setType((SpinnerType) selector.getValue());
            }
        }
    });

    StringToEnumConverter converter = new StringToEnumConverter();
    for (SpinnerSize size : SpinnerSize.values()) {
        Spinner spinner = new Spinner(SpinnerType.ROTATING_PLANE);
        spinner.setSize(size);
        spinner.setCaption(converter.convertToPresentation(size, String.class, getLocale()));
        spinners.addComponent(spinner);
    }

    VerticalLayout l = new VerticalLayout();
    l.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    l.setSizeFull();
    l.setMargin(false);
    l.setSpacing(true);
    l.addComponents(selector, spinners);
    l.setExpandRatio(spinners, 1);
    return l;
}

From source file:org.vaadin.spring.samples.navigation.NavigationUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    final VerticalLayout root = new VerticalLayout();
    root.setSizeFull();
    root.setMargin(true);/*from  w  ww .j av a2s  .  c  o m*/
    root.setSpacing(true);
    setContent(root);

    final CssLayout navigationBar = new CssLayout();
    navigationBar.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    navigationBar.addComponent(createNavigationButton("Prototype Scoped View", PrototypeScopedView.VIEW_NAME));
    navigationBar.addComponent(createNavigationButton("UI Scoped View", UIScopedView.VIEW_NAME));
    navigationBar.addComponent(createNavigationButton("View Scoped View", ViewScopedView.VIEW_NAME));
    navigationBar.addComponent(createNavigationButton("Access Control", AccessControlView.VIEW_NAME));
    root.addComponent(navigationBar);

    final Panel viewContainer = new Panel();
    viewContainer.setSizeFull();
    root.addComponent(viewContainer);
    root.setExpandRatio(viewContainer, 1.0f);

    viewProvider.setAccessDeniedViewClass(AccessDeniedView.class);

    Navigator navigator = new Navigator(this, viewContainer);
    navigator.setErrorView(new ErrorView()); // You can still create the error view yourself if you want to.
    navigator.addProvider(viewProvider);
}

From source file:org.vaadin.spring.samples.security.shared.LoginUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    getPage().setTitle("Vaadin Shared Security Demo Login");

    FormLayout loginForm = new FormLayout();
    loginForm.setSizeUndefined();/*from  w  w  w  . j av  a 2  s .  co m*/

    userName = new TextField("Username");
    passwordField = new PasswordField("Password");
    rememberMe = new CheckBox("Remember me");
    login = new Button("Login");
    loginForm.addComponent(userName);
    loginForm.addComponent(passwordField);
    loginForm.addComponent(rememberMe);
    loginForm.addComponent(login);
    login.addStyleName(ValoTheme.BUTTON_PRIMARY);
    login.setDisableOnClick(true);
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            login();
        }
    });

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setSpacing(true);
    loginLayout.setSizeUndefined();

    if (request.getParameter("logout") != null) {
        loggedOutLabel = new Label("You have been logged out!");
        loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS);
        loggedOutLabel.setSizeUndefined();
        loginLayout.addComponent(loggedOutLabel);
        loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER);
    }

    loginLayout.addComponent(loginFailedLabel = new Label());
    loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER);
    loginFailedLabel.setSizeUndefined();
    loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE);
    loginFailedLabel.setVisible(false);

    loginLayout.addComponent(loginForm);
    loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER);

    VerticalLayout rootLayout = new VerticalLayout(loginLayout);
    rootLayout.setSizeFull();
    rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER);
    setContent(rootLayout);
    setSizeFull();
}

From source file:org.vaadin.spring.samples.sidebar.AbstractSideBarUI.java

License:Apache License

@Override
protected void init(VaadinRequest vaadinRequest) {
    getPage().setTitle("Vaadin4Spring Side Bar Sample");
    final HorizontalLayout rootLayout = new HorizontalLayout();
    rootLayout.setSizeFull();//from  www.  j  av a2 s  .c  om
    setContent(rootLayout);

    final VerticalLayout viewContainer = new VerticalLayout();
    viewContainer.setSizeFull();

    final Navigator navigator = new Navigator(this, viewContainer);
    navigator.setErrorView(new ErrorView());
    navigator.addProvider(viewProvider);
    setNavigator(navigator);

    rootLayout.addComponent(getSideBar());
    rootLayout.addComponent(viewContainer);
    rootLayout.setExpandRatio(viewContainer, 1.0f);
}