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:com.hivesys.dashboard.view.search.TextualView.java

public void UpdateSearchPane(String searchString) {
    css.removeAllComponents();/*from  w w  w .  j  a  v a 2s.c  o  m*/

    SearchResponse response = ElasticSearchContext.getInstance().searchSimpleQuery(searchString);
    logResponse(response);
    SearchHits results = response.getHits();

    Label labelResultSummary = new Label("About " + results.getHits().length + " results found <br><br>",
            ContentMode.HTML);
    css.addComponent(labelResultSummary);

    for (SearchHit hit : results) {
        CssLayout cssResult = new CssLayout();
        cssResult.setStyleName("search-result");

        try {
            String filename = DocumentDB.getInstance().getDocumentNameFromHash(hit.getId());
            String boxviewID = DocumentDB.getInstance().getBoxViewIDFromHash(hit.getId());

            String highlight = "";
            HighlightField objhighlight = hit.highlightFields().get("file");
            if (objhighlight != null) {
                for (Text fgmt : objhighlight.getFragments()) {
                    highlight += fgmt.string() + "<br>";
                }
            }

            Button lblfileName = new Button(filename);
            lblfileName.addClickListener((Button.ClickEvent event) -> {
                if (boxviewID != null) {
                    String url = BoxViewDocuments.getInstance().getViewURL(boxviewID);
                    if (url != null || !url.equals("")) {
                        url = BoxViewDocuments.getInstance().getViewURL(boxviewID);
                        BrowserFrame bframe = new BrowserFrame(filename, new ExternalResource(url));
                        VerticalLayout vlayout = new VerticalLayout(bframe);

                        final Window w = new Window();
                        w.setSizeFull();
                        w.setModal(true);
                        w.setWindowMode(WindowMode.MAXIMIZED);
                        w.setContent(vlayout);
                        vlayout.setSizeFull();
                        vlayout.setMargin(true);
                        w.setResizable(false);
                        w.setDraggable(false);

                        UI.getCurrent().addWindow(w);
                        bframe.setSizeFull();
                        return;
                    }
                    Notification.show("Preview not available for this document!");
                }
            });
            lblfileName.setPrimaryStyleName("filename");

            Label lblHighlight = new Label(highlight, ContentMode.HTML);
            lblHighlight.setStyleName("highlight");

            cssResult.addComponent(lblfileName);
            cssResult.addComponent(lblHighlight);

            css.addComponent(cssResult);
            css.addComponent(new Label("<br>", ContentMode.HTML));

        } catch (SQLException ex) {
        }

    }

}

From source file:com.hris.connection.ErrorLoggedNotification.java

public static void showErrorLoggedOnWindow(String error, String className) {
    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();/*w w w .  j a  v a2s.  c o m*/
    v.setMargin(true);

    Window sub = new Window("ERROR MESSAGE!", v);
    sub.setWidth("500px");
    if (sub.getParent() == null) {
        UI.getCurrent().addWindow(sub);
    }
    sub.setModal(true);

    Panel panel = new Panel();
    panel.setSizeFull();
    panel.setContent(new Label(error + " on \n" + className, ContentMode.HTML));
    panel.getContent().setHeightUndefined();

    sub.setContent(panel);
    sub.getContent().setHeightUndefined();
}

From source file:com.jiangyifen.ec2.ui.LoginLayout.java

/**
 * ???//  w w  w . j a  v a  2s  .  c  om
 * 
 * @param webBrowser
 * @param exten
 */
private void handleAfterLogin(WebBrowser webBrowser, String exten) {
    // ??
    Window mainWindow = app.getMainWindow();
    // ??
    if (loginUser == null) {
        warningLabel.setValue("<font color='red'>????</font>");
        warningLabel.setVisible(true);
        return;
    }

    // jrh cookie
    saveCookies();

    // ----------------? ?Session??  -------------------------------- //

    // ?
    Integer[] screenResolution = new Integer[2];
    screenResolution[0] = webBrowser.getScreenWidth();
    screenResolution[1] = webBrowser.getScreenHeight();

    HttpSession session = SpringContextHolder.getHttpSession();
    session.setAttribute("screenResolution", screenResolution);

    // ??
    ArrayList<String> businessModels = new ArrayList<String>();
    if (isValid == false) { //?licence ??
        businessModels.add(MgrAccordion.SYSTEM_INFO_MANAGEMENT);
        businessModels.add(MgrAccordion.SYSTEM_INFO_MANAGEMENT_SYSTEM_LISCENCE);
        session.setAttribute("businessModels", businessModels);
    } else {
        HashMap<String, BusinessModel> ownBusinessModleMap = new HashMap<String, BusinessModel>();
        for (Role role : loginUser.getRoles()) {
            if (role.getType().equals(roleType)) { // ?????Csr
                Set<BusinessModel> businessModelSet = role.getBusinessModels(); // 
                for (BusinessModel model : businessModelSet) {
                    if (model.getModule() != null) { // ???application?
                        ownBusinessModleMap.put(model.toString(), model);
                    }
                }
            }
        }
        businessModels.addAll(ownBusinessModleMap.keySet());
        session.setAttribute("businessModels", businessModels);
    }

    // 
    session.setAttribute("loginUser", loginUser);
    // ?
    session.setAttribute("roleType", roleType);

    // -------- ? ------------- //

    if (roleType.equals(RoleType.csr)) {
        // ?vaadin application ,
        ShareData.userToApp.put(loginUser.getId(), app);
        // SessionCSRSession??
        ShareData.userToSession.put(loginUser.getId(), session);

        // Session
        session.setAttribute("exten", exten);

        mainWindow.setContent(new CsrMainView(this));
    } else if (roleType.equals(RoleType.manager)) {
        mainWindow.removeAllComponents();
        mainWindow.setContent(new MgrMain(this));
    }
}

From source file:com.liferay.mail.vaadin.PreferencesView.java

License:Open Source License

private void editAccount(Account account) {

    String windowTitle = Lang.get(account == null ? "add-mail-account" : "edit-account");
    final Window editorWindow = new Window(windowTitle);
    editorWindow.setSizeUndefined();//from  w w w. j a v  a2 s . c om
    editorWindow.center();
    editorWindow.setModal(true);
    editorWindow.setResizable(false);

    AccountEditor.AccountEditorListener listener = new SaveAccountListener(editorWindow);

    // show a pre-filled edit dialog
    AccountEditor editor = new AccountEditor(account, controller, listener);
    editorWindow.setContent(editor);
    controller.getApplication().getMainWindow().addWindow(editorWindow);
}

From source file:com.liferay.mail.vaadin.PreferencesView.java

License:Open Source License

private void editGmailAccount(Account account) {
    String windowTitle = Lang.get(account == null ? "add-gmail-account" : "edit-gmail-account");
    final Window editorWindow = new Window(windowTitle);
    editorWindow.setSizeUndefined();//from  www. jav a  2  s  . c o m
    editorWindow.center();
    editorWindow.setModal(true);
    editorWindow.setResizable(false);

    AccountEditor.AccountEditorListener listener = new SaveAccountListener(editorWindow);

    // show a pre-filled edit dialog
    AccountEditor editor = new GMailAccountEditor(account, controller, listener);
    editorWindow.setContent(editor);
    controller.getApplication().getMainWindow().addWindow(editorWindow);
}

From source file:com.mechanicshop.components.TableLayout.java

public void createCustomMessage() {
    final TextArea textArea = new TextArea();
    textArea.setImmediate(true);/*  ww w.  j  a v a2 s  .co  m*/
    textArea.setColumns(30);
    textArea.setRows(10);
    textArea.addStyleName(ValoTheme.TEXTAREA_SMALL);
    textArea.setRequired(true);
    final Window subWindow = new Window();
    subWindow.setModal(true);
    subWindow.setHeight("350px");
    subWindow.setWidth("500px");
    subWindow.setCaption("Insert Message");
    subWindow.setStyleName(ValoTheme.WINDOW_TOP_TOOLBAR);
    subWindow.setClosable(false);
    subWindow.setResizable(false);

    HorizontalLayout layoutButtons = new HorizontalLayout();
    layoutButtons.setMargin(false);
    Button sendBtn = new Button("Send");
    sendBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                textArea.validate();
                String message = textArea.getValue();
                smsSenderService.sendMessageMassive(message);
                subWindow.close();
                Notification.show("Message Sent");
            } catch (Exception e) {

            }
        }
    });
    sendBtn.setImmediate(true);
    sendBtn.setStyleName(ValoTheme.BUTTON_TINY);
    sendBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    Button cancelBtn = new Button("Cancel");
    cancelBtn.setStyleName(ValoTheme.BUTTON_TINY);
    cancelBtn.addStyleName(ValoTheme.BUTTON_DANGER);
    cancelBtn.setImmediate(true);
    cancelBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            subWindow.close();

        }
    });

    layoutButtons.setSizeUndefined();
    layoutButtons.setSpacing(true);
    layoutButtons.addComponents(cancelBtn, sendBtn);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.addComponent(textArea);
    layout.addComponent(layoutButtons);
    layout.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(layoutButtons, Alignment.MIDDLE_RIGHT);
    layout.setExpandRatio(textArea, 3);

    layout.setSizeFull();

    subWindow.setContent(layout);
    subWindow.center();

    getUI().addWindow(subWindow);
}

From source file:com.morevaadin.vaadin.theming.ThemingApplication.java

License:Apache License

@Override
public void init() {

    setTheme("reindeer");

    Window window = new Window();

    ThemingContent content = new ThemingContent();

    window.setContent(content);

    setMainWindow(window);//www .  jav a 2  s  .c o m

    content.afterApplicationSet();
}

From source file:com.naoset.framework.frontend.component.profile.CustomerEditWindowView.java

private void openWindow() {
    Window myWindow = new Window("Cliente");
    myWindow.addStyleName("profile-window");
    myWindow.setId(ID);/*from  ww w.j a v a 2s . c o m*/
    Responsive.makeResponsive(this);

    myWindow.setModal(true);
    myWindow.setCloseShortcut(ShortcutAction.KeyCode.ESCAPE, null);
    myWindow.setResizable(false);
    myWindow.setClosable(false);
    myWindow.setHeight(90.0f, Unit.PERCENTAGE);
    VerticalLayout layout = new VerticalLayout();
    CustomerPanelView customerPanelView = new CustomerPanelView();

    layout.addComponent(customerPanelView.buildCustomerPanel(null));
    layout.addComponent(builtButton());

    myWindow.setContent(layout);
    myWindow.setVisible(true);
    UI.getCurrent().addWindow(myWindow);
    myWindow.focus();
}

From source file:com.oodrive.nuage.webui.component.window.AbstractConfirmationWindow.java

License:Apache License

@SuppressWarnings("serial")
@Override//from   w  w w. j a v  a  2s. c om
public Window init(final AbstractItemModel model) {

    // Add new window
    final Window vvrConfirmationWindow = new Window("Confirmation");
    vvrConfirmationWindow.center();
    vvrConfirmationWindow.setResizable(false);
    final VerticalLayout vvrConfirmationLayout = new VerticalLayout();
    vvrConfirmationLayout.setMargin(true);
    vvrConfirmationWindow.setContent(vvrConfirmationLayout);

    // Message to display before buttons
    final Label confirmationMessage = new Label(confirmation);
    vvrConfirmationLayout.addComponent(confirmationMessage);
    vvrConfirmationLayout.setComponentAlignment(confirmationMessage, Alignment.MIDDLE_CENTER);
    vvrConfirmationLayout.setSpacing(true);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    vvrConfirmationLayout.addComponent(buttonLayout);
    // Button OK
    final Button okButton = new Button("OK");
    buttonLayout.setSizeFull();
    buttonLayout.addComponent(okButton);
    buttonLayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER);
    okButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                action.execute(model);
                vvrConfirmationWindow.close();
            } catch (final Exception e) {
                vvrConfirmationWindow.close();
            }
        }
    });

    // Button cancel
    final Button cancelButton = new Button("Cancel");
    buttonLayout.addComponent(cancelButton);
    buttonLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);
    cancelButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            // Just close the window
            vvrConfirmationWindow.close();
        }
    });
    return vvrConfirmationWindow;
}

From source file:com.oodrive.nuage.webui.component.window.ErrorWindow.java

License:Apache License

@SuppressWarnings("serial")
@Override//www. j  av  a  2s.co m
public final Window init(final AbstractItemModel model) {
    // Add new window with title "Error"
    final Window vvrErrorWindow = new Window("Error");
    vvrErrorWindow.center();
    vvrErrorWindow.setResizable(false);
    final VerticalLayout vvrErrorLayout = new VerticalLayout();
    vvrErrorLayout.setMargin(true);
    vvrErrorWindow.setContent(vvrErrorLayout);

    // Display message
    final Label errorMessage = new Label(message);
    vvrErrorLayout.addComponent(errorMessage);
    vvrErrorLayout.setComponentAlignment(errorMessage, Alignment.MIDDLE_CENTER);
    vvrErrorLayout.setSpacing(true);

    // Button OK
    final Button okButton = new Button("OK");
    vvrErrorLayout.addComponent(okButton);
    vvrErrorLayout.setComponentAlignment(okButton, Alignment.BOTTOM_CENTER);
    okButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            // Just close the window
            vvrErrorWindow.close();
        }
    });
    return vvrErrorWindow;
}