Example usage for com.vaadin.ui Window setContent

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

Introduction

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

Prototype

@Override
public void setContent(Component content) 

Source Link

Document

Sets the content of this container.

Usage

From source file:org.universAAL.ucc.controller.desktop.ToolController.java

public void buttonClick(ClickEvent event) {
    if (event.getButton() == toolWin.getuStoreButton()) {
        Embedded em = new Embedded("", new ExternalResource(createLink()));
        em.setType(Embedded.TYPE_BROWSER);
        em.setWidth("100%");
        em.setHeight("850px");
        Window w = new Window("uStore");
        w.setWidth("1250px");
        w.setHeight("800px");
        VerticalLayout v = new VerticalLayout();
        w.center();//from   w  w  w.  ja v a  2 s .  co m
        v.addComponent(em);
        w.setContent(v);
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(w);
    }
    if (event.getButton() == toolWin.getOpenAAL()) {
        //         Embedded em = new Embedded("", new ExternalResource(
        //               "http://wiki.openaal.org"));
        //         em.setType(Embedded.TYPE_BROWSER);
        //         em.setWidth("100%");
        //         em.setHeight("800px");
        //         Window w = new Window("openAAL");
        //         w.setWidth("1250px");
        //         w.setHeight("800px");
        //         VerticalLayout v = new VerticalLayout();
        //         w.center();
        //         v.addComponent(em);
        //         w.setContent(v);
        BrowseServicesWindow pw = new BrowseServicesWindow(app);
        PurchasedServicesController pc = new PurchasedServicesController(pw, app);
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(pw);
    }
    if (event.getButton() == toolWin.getInstallButton()) {
        // Later uncomment again only for testing commented out!
        Upload up = new Upload("", new AALServiceReceiver());
        up.setButtonCaption(res.getString("install.button"));
        up.addListener((Upload.FinishedListener) this);
        up.addListener((Upload.FailedListener) this);
        installWindow = new Window(res.getString("install.win.caption"));
        installWindow.setResizable(false);
        installWindow.center();
        installWindow.setWidth("400px");
        VerticalLayout v = new VerticalLayout();
        v.setSizeFull();
        v.setSpacing(true);
        v.setMargin(true);
        v.addComponent(up);
        installWindow.setContent(v);

        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(installWindow);
    }
    if (event.getButton() == toolWin.getLogoutButton()) {
        DesktopController.setCurrentPassword("");
        DesktopController.setCurrentUser("");
        //         if(!DesktopController.web.getSocket().isClosed()) {
        //            try {
        //               DesktopController.web.getSocket().close();
        //            } catch (IOException e) {
        //               e.printStackTrace();
        //            }
        //         }
        app.close();
    }

    if (event.getButton() == toolWin.getUninstallButton()) {
        app.getMainWindow().removeWindow(toolWin);
        List<RegisteredService> ids = new ArrayList<RegisteredService>();
        Document doc = Model.getSrvDocument();
        NodeList nodeList = doc.getElementsByTagName("service");
        for (int i = 0; i < nodeList.getLength(); i++) {
            RegisteredService srv = new RegisteredService();
            Element element = (Element) nodeList.item(i);
            System.err.println(element.getAttribute("serviceId"));
            srv.setServiceId(element.getAttribute("serviceId"));
            NodeList srvChilds = element.getChildNodes();
            for (int j = 0; j < srvChilds.getLength(); j++) {
                Node n = srvChilds.item(j);
                if (n.getNodeName().equals("application")) {
                    Element e = (Element) n;
                    srv.getAppId().add(e.getAttribute("appId"));
                }
                if (n.getNodeName().equals("bundle")) {
                    Element b = (Element) n;
                    srv.getBundleId().add(b.getAttribute("id"));
                    srv.setBundleVersion(b.getAttribute("version"));
                }
                if (n.getNodeName().equals("menuEntry")) {
                    Element e = (Element) n;
                    srv.setMenuName(e.getAttribute("entryName"));
                    srv.setIconURL(e.getAttribute("iconURL"));
                    srv.setProvider(e.getAttribute("vendor"));
                    srv.setServiceClass(e.getAttribute("serviceClass"));
                    srv.setUserID(e.getAttribute("userID"));
                }
            }
            ids.add(srv);
        }
        DeinstallWindow dw = new DeinstallWindow(ids);
        app.getMainWindow().addWindow(dw);
        DeinstallController dc = new DeinstallController(dw, app);
        //         frontend.uninstallService(Activator.getSessionKey(), "28002");
        //         frontend.getInstalledUnitsForService(Activator.getSessionKey(), "28002");
    }

    if (event.getButton() == toolWin.getPersonButton()) {
        AddNewPersonWindow apw = null;
        try {
            apw = new AddNewPersonWindow(null, null, app);
        } catch (JAXBException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(apw);
    }
    if (event.getButton() == toolWin.getConfigButton()) {
        AddNewHardwareWindow anhw = null;
        try {
            anhw = new AddNewHardwareWindow(null, null, app);
        } catch (JAXBException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(anhw);
    }
    if (event.getButton() == toolWin.getEditHW()) {
        RoomsWindow hardWare = null;
        try {
            hardWare = new RoomsWindow(app);
        } catch (JAXBException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(hardWare);

    }

    if (event.getButton() == toolWin.getEditPerson()) {
        HumansWindow hw = null;
        try {
            hw = new HumansWindow(app);
        } catch (JAXBException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(hw);
    }
    if (event.getButton() == toolWin.getEditUC()) {
        WhichBundleShouldBeConfiguredWindow uc = new WhichBundleShouldBeConfiguredWindow("Use Cases");
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(uc);

    }

}

From source file:org.vaadin.addons.criteriacontainersample.AbstractBeanTupleApplication.java

License:Apache License

@Override
public void init() {

    Window mainWindow = new Window("Tuple Application");
    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setMargin(true);//from   w w  w  .j a va2  s.co m
    mainLayout.setSpacing(true);
    mainWindow.setContent(mainLayout);

    Panel filterPanel = new Panel();
    createTopPanel(mainWindow, filterPanel);

    entityManager = ENTITY_MANAGER_FACTORY.createEntityManager();
    criteriaContainer = createTupleContainer();
    int size = criteriaContainer.size();
    if (size == 0) {
        createEntities();
        // must refresh container to recompute size (table would be empty otherwise)
        criteriaContainer.refresh();
        size = criteriaContainer.size();
    }

    createTable(criteriaContainer);
    mainWindow.addComponent(table);
    setMainWindow(mainWindow);
}

From source file:org.vaadin.addons.criteriacontainersample.AbstractEntityApplication.java

License:Apache License

@Override
public void init() {

    Window mainWindow = new Window("Lazycontainer Application");

    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();//from   w  w  w.  ja va2  s .  co m
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);

    createFilterPanel(mainLayout);

    entityManager = ENTITY_MANAGER_FACTORY.createEntityManager();
    criteriaContainer = createTaskContainer();

    int size = criteriaContainer.size();
    if (size == 0 && TESTING) {
        createEntities();
        criteriaContainer.refresh();
        size = criteriaContainer.size();
    }

    createTable(criteriaContainer);
    table.setPageLength(0);
    table.setSizeUndefined();
    table.setHeight("100%");
    mainLayout.addComponent(table);
    mainLayout.setExpandRatio(table, 100.0F);

    mainWindow.setContent(mainLayout);
    setMainWindow(mainWindow);
}

From source file:org.vaadin.addons.locationtextfield.LocationUpdateApplication.java

License:Apache License

public void init() {
    Window mainWindow = new Window("Location update");

    VerticalLayout vl = new VerticalLayout();
    vl.setWidth("500px");
    vl.setHeight("250px");
    vl.setMargin(true);/* ww w .j av  a  2 s.  com*/

    final LocationTextField ltf = new LocationTextField(OpenStreetMapGeocoder.getInstance(), "Address: ");
    ltf.setWidth("100%");
    vl.addComponent(ltf);

    final TextField lat = new TextField("Latitude: ");
    final TextField lon = new TextField("Longitude: ");
    vl.addComponent(lat);
    vl.addComponent(lon);

    ltf.addListener(new Property.ValueChangeListener() {
        public void valueChange(Property.ValueChangeEvent event) {
            GeocodedLocation loc = ltf.getValue();
            if (loc != null) {
                lat.setValue("" + loc.getLat());
                lon.setValue("" + loc.getLon());
            } else {
                lat.setValue("");
                lon.setValue("");
            }
        }
    });

    mainWindow.setContent(vl);
    setMainWindow(mainWindow);
}

From source file:org.vaadin.addons.serverpush.samples.chat.ManualPushChatApplication.java

License:Apache License

public void init() {
    Window mainWindow = new Window("Chat Application");
    setMainWindow(mainWindow);/*from   w w w  .  j  av  a2s  .c o m*/

    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();

    vl.addComponent(this.header);

    this.comboBox.setWidth("400px");
    this.comboBox.addListener(new Container.ItemSetChangeListener() {
        public void containerItemSetChange(Container.ItemSetChangeEvent event) {
            push();
        }
    });
    this.comboBox.addListener(new Property.ValueChangeListener() {
        public void valueChange(Property.ValueChangeEvent event) {
            fireNewTab((User) event.getProperty().getValue(), (User) getUser());
        }
    });
    this.comboBox.setItemCaptionPropertyId("username");
    this.comboBox.setImmediate(true);
    vl.addComponent(this.comboBox);

    this.tabSheet.setSizeFull();
    vl.addComponent(this.tabSheet);
    vl.setExpandRatio(this.tabSheet, 1);

    mainWindow.setContent(vl);
    mainWindow.addComponent(this.pusher);
    mainWindow.addListener(new Window.CloseListener() {
        public void windowClose(Window.CloseEvent e) {
            OnlineUsersManager.getInstance().deregisterUser((User) getUser());
        }
    });

    fireLoginWindow();
}

From source file:org.vaadin.addons.serverpush.samples.chat.ManualPushChatApplication.java

License:Apache License

private void fireLoginWindow() {
    final Window window = new Window("Login");
    window.setModal(true);/*from w  w w.ja  va 2 s .  com*/
    window.setWidth("640px");
    window.setHeight("480px");
    LoginForm loginForm = new LoginForm();
    loginForm.setSizeFull();
    loginForm.addListener(new LoginForm.LoginListener() {
        public void onLogin(LoginForm.LoginEvent event) {
            doLogin(event);
            getMainWindow().removeWindow(window);
        }
    });
    window.setContent(loginForm);
    getMainWindow().addWindow(window);
    window.bringToFront();
}

From source file:org.vaadin.addons.serverpush.samples.sales.SalesApplication.java

License:Apache License

public void init() {
    Window mainWindow = new Window("Sales Application");
    setMainWindow(mainWindow);//from  ww w  . ja v a2s  .co  m

    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth("100%");
    final Label label = new Label("<h1>Sales Application</h1><hr/>", Label.CONTENT_XHTML);
    hl.addComponent(label);
    hl.addComponent(this.header);
    hl.setComponentAlignment(this.header, Alignment.MIDDLE_RIGHT);
    hl.setExpandRatio(label, 1);
    vl.addComponent(hl);

    this.table.setSizeFull();
    vl.addComponent(this.table);
    vl.setExpandRatio(this.table, 1);

    mainWindow.setContent(vl);

    fireLoginWindow();
}

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);//w  w  w . j  av a 2  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.arborgraph.demo.DemoApplication.java

License:Open Source License

@SuppressWarnings("serial")
@Override//  w  w  w.  j av  a 2  s .  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.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);/*  w  ww  .jav a2 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);
        }
    }));
}