Example usage for com.vaadin.ui Panel setContent

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

Introduction

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

Prototype

@Override
public void setContent(Component content) 

Source Link

Document

Sets the content of this container.

Usage

From source file:com.rex.components.valo.CommonParts.java

License:Apache License

Panel loadingIndicators() {
    Panel p = new Panel("Loading Indicator");
    final VerticalLayout content = new VerticalLayout();
    p.setContent(content);
    content.setSpacing(true);/*from   w ww.  j av  a  2 s . co  m*/
    content.setMargin(true);
    content.addComponent(new Label("You can test the loading indicator by pressing the buttons."));

    CssLayout group = new CssLayout();
    group.setCaption("Show the loading indicator for");
    group.addStyleName("v-component-group");
    content.addComponent(group);
    Button loading = new Button("0.8");
    loading.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(800);
            } catch (InterruptedException e) {
            }
        }
    });
    group.addComponent(loading);

    Button delay = new Button("3");
    delay.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
            }
        }
    });
    group.addComponent(delay);

    Button wait = new Button("15");
    wait.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(15000);
            } catch (InterruptedException e) {
            }
        }
    });
    wait.addStyleName("last");
    group.addComponent(wait);
    Label label = new Label("   seconds", ContentMode.HTML);
    label.setSizeUndefined();
    group.addComponent(label);

    Label spinnerDesc = new Label(
            "The theme also provides a mixin that you can use to include a spinner anywhere in your application. The button below reveals a Label with a custom style name, for which the spinner mixin is added.");
    spinnerDesc.addStyleName("small");
    spinnerDesc.setCaption("Spinner");
    content.addComponent(spinnerDesc);

    if (!ReportEngineUI.isTestMode()) {
        final Label spinner = new Label();
        spinner.addStyleName("spinner");

        Button showSpinnerButton = new Button("Show spinner", new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                content.replaceComponent(event.getComponent(), spinner);
            }
        });
        content.addComponent(showSpinnerButton);
    }

    return p;
}

From source file:com.save.global.ErrorLoggedNotification.java

public static void showWarningLoggedOnWindow(String warning, String className) {
    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();//from   w ww. j a v  a2 s .  c  o m
    v.setMargin(true);

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

    Panel panel = new Panel();
    panel.setSizeFull();
    panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    panel.setContent(new Label(warning + " on \n" + className, ContentMode.HTML));
    panel.getContent().setHeightUndefined();
    v.addComponent(panel);

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

From source file:com.selzlein.lojavirtual.vaadin.page.SettingsView.java

License:Open Source License

private void createView() {
    ui = (LspsUI) getUI();//from   w w w . j  a  v a  2s . c  om
    user = ui.getUser().getPerson();
    userRights = user.getRights();

    setTitle(ui.getMessage(TITLE));

    Panel panel = new Panel();
    panel.addStyleName("l-border-none");
    setContent(panel);

    VerticalLayout layout = new VerticalLayout();
    layout.addStyleName("l-settings");
    layout.setSizeFull();
    layout.setSpacing(true);
    layout.setMargin(true);
    panel.setContent(layout);

    //user data and settings will be laid out next to each other
    HorizontalLayout topSection = new HorizontalLayout();
    topSection.setSpacing(true);
    topSection.setWidth("100%");
    layout.addComponent(topSection);

    VerticalLayout userData = createUserDataSection(ui, user);
    topSection.addComponent(userData);
    topSection.setExpandRatio(userData, 1);

    Label spacer = new Label();
    spacer.setWidth("20px");
    topSection.addComponent(spacer);

    VerticalLayout settings = createSettingsSection(ui);
    topSection.addComponent(settings);
    topSection.setExpandRatio(settings, 1);

    //substitution section
    VerticalLayout substitution = createSubstitutionSection();
    layout.addComponent(substitution);
    layout.setExpandRatio(substitution, 2);

    //buttons
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    Button saveButton = new Button(ui.getMessage("action.save"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (save()) {
                if (requestReload) {
                    JavaScript.getCurrent().execute("window.location.reload()");
                } else {
                    close();
                }
            }
        }
    });
    saveButton.setData(BUTTON_TYPE_SAVE);
    buttons.addComponent(saveButton);
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
    layout.addComponent(buttons);
}

From source file:com.selzlein.lojavirtual.vaadin.page.SettingsView.java

License:Open Source License

private VerticalLayout createSubstitutionSection() {
    VerticalLayout substitution = new VerticalLayout();
    substitution.addStyleName("l-substitutes");
    substitution.setSpacing(true);/* w  w  w .j a  v a 2 s .  c  o m*/
    substitution.setSizeFull();

    Label substitutionHeader = new Label("<h2>" + ui.getMessage("settings.substitutionSection") + "</h2>",
            ContentMode.HTML);
    substitution.addComponent(substitutionHeader);

    Label substitutionHelp = new Label(ui.getMessage("settings.substitutionHelp"));
    substitutionHelp.setStyleName("form-help");
    substitution.addComponent(substitutionHelp);

    this.substitutionActive = new CheckBox(ui.getMessage("settings.substitutionActive"));
    substitutionActive.addStyleName("ui-spacing");
    substitutionActive.setValue(user.isSubstitutionActive());
    substitution.addComponent(substitutionActive);

    //substitutes
    selectedPersons = user.getDirectSubstitutes();
    this.substitutes = new OptionGroup(ui.getMessage("settings.substitutes"));
    refreshSubstitutes("");

    TextField substituteFilter = new TextField(ui.getMessage("action.filter"));
    substituteFilter.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            substitutes.removeAllItems();
            refreshSubstitutes(event.getProperty().getValue().toString());
        }
    });
    substitution.addComponent(substituteFilter);
    Panel substitutesPanel = new Panel();
    substitutesPanel.addStyleName("l-border-none");
    substitutesPanel.setSizeFull();
    substitutesPanel.setContent(substitutes);
    substitution.addComponent(substitutesPanel);
    substitution.setExpandRatio(substitutesPanel, 2);

    return substitution;
}

From source file:com.skysql.manager.ui.OverviewPanel.java

License:Open Source License

/**
 * Instantiates a new overview panel./*w ww.  java2s.c  om*/
 */
public OverviewPanel() {

    HorizontalLayout overviewContainer = new HorizontalLayout();
    overviewContainer.addStyleName("overviewPanel");
    overviewContainer.setWidth("100%");
    setContent(overviewContainer);

    systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class);
    systemRecord = systemInfo.getCurrentSystem();
    systemLayout = new SystemLayout(systemRecord);
    overviewContainer.addComponent(systemLayout);

    VerticalLayout nodesSlot = new VerticalLayout();
    nodesSlot.addStyleName("nodesSlot");
    nodesSlot.setMargin(new MarginInfo(false, false, false, false));
    overviewContainer.addComponent(nodesSlot);
    overviewContainer.setExpandRatio(nodesSlot, 1.0f);

    final HorizontalLayout nodesHeader = new HorizontalLayout();
    nodesHeader.setStyleName("panelHeaderLayout");
    nodesHeader.setWidth("100%");
    nodesSlot.addComponent(nodesHeader);
    nodesLabel = new Label(" ");
    nodesLabel.setSizeUndefined();
    nodesHeader.addComponent(nodesLabel);
    nodesHeader.setComponentAlignment(nodesLabel, Alignment.MIDDLE_CENTER);
    nodesHeader.setExpandRatio(nodesLabel, 1.0f);

    final HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setSpacing(true);
    buttonsLayout.setMargin(new MarginInfo(false, true, false, false));
    nodesHeader.addComponent(buttonsLayout);
    nodesHeader.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_RIGHT);

    addSystemButton = new Button("Add System...");
    addSystemButton.setDescription("Add System");
    addSystemButton.setVisible(false);
    buttonsLayout.addComponent(addSystemButton);
    addSystemButton.addClickListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            new SystemDialog(null, null);
        }
    });

    addNodeButton = new Button("Add Node...");
    addNodeButton.setDescription("Add Node to the current System");
    addNodeButton.setVisible(false);
    buttonsLayout.addComponent(addNodeButton);
    addNodeButton.addClickListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            new NodeDialog(null, null);
        }
    });

    final Button editButton = new Button("Edit");
    editButton.setDescription("Enter Editing mode");
    final Button saveButton = new Button("Done");
    saveButton.setDescription("Exit Editing mode");
    buttonsLayout.addComponent(editButton);

    editButton.addClickListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            buttonsLayout.replaceComponent(editButton, saveButton);
            isEditable = true;
            systemLayout.setEditable(true);
            nodesLayout.setEditable(true);
            nodesHeader.setStyleName("panelHeaderLayout-editable");
            if (systemRecord != null && !SystemInfo.SYSTEM_ROOT.equals(systemRecord.getID())) {
                addNodeButton.setVisible(true);
            } else {
                addSystemButton.setVisible(true);
            }
            if (systemRecord == null || (systemRecord != null && systemRecord.getNodes().length == 0)) {
                nodesLayout.placeholderLayout(null);
            }
        }
    });

    saveButton.addClickListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            buttonsLayout.replaceComponent(saveButton, editButton);
            isEditable = false;
            systemLayout.setEditable(false);
            nodesLayout.setEditable(false);
            nodesHeader.setStyleName("panelHeaderLayout");
            if (systemRecord != null && systemRecord.getNodes().length == 0) {
                nodesLayout.placeholderLayout(null);
            }
            addNodeButton.setVisible(false);
            addSystemButton.setVisible(false);
        }
    });

    Panel panel = new Panel();
    panel.setHeight(PANEL_HEIGHT, Unit.PIXELS);
    panel.addStyleName(Runo.PANEL_LIGHT);
    nodesSlot.addComponent(panel);

    nodesLayout = new NodesLayout(systemRecord);
    nodesLayout.addStyleName("nodesLayout");
    nodesLayout.setWidth("100%");
    panel.setContent(nodesLayout);

}

From source file:com.squadd.chat.ChatController.java

public Panel createPhotoPanel(Embedded image) {
    Panel photoPanel = new Panel();
    photoPanel.setContent(image);
    //photoPanel.setWidth("50px");
    //photoPanel.setHeight("50px");

    UserInfoBean use = man.get(userTo.getId(), UserInfo.class, UserInfoBean.class);

    MouseEvents.ClickListener showUserButtonListener = new MouseEvents.ClickListener() {
        @Override/*from  w w w.  j  a  v a  2s.com*/
        public void click(MouseEvents.ClickEvent event) {
            if (use != null) {
                System.out.println(use.getId());
                view.setAnotherUser(use);
                UI.getCurrent().getNavigator().navigateTo(UserPageView.NAME);
            }
        }
    };
    if (use != null) {
        photoPanel.addClickListener(showUserButtonListener);
    }

    return photoPanel;
}

From source file:com.squadd.chat.ChatController.java

public static Panel createDatePanel(ChatMessage mess) {
    Panel datePanel = new Panel();
    //FormLayout form = new FormLayout();
    //form.setMargin(false);
    Label dateLabel = new Label(mess.getFormattedDate());
    dateLabel.addStyleName("dateLabel");
    dateLabel.setValue("YrMOOOm");
    //form.addComponent(dateLabel);
    //datePanel.setContent(form);
    datePanel.setContent(dateLabel);
    datePanel.setWidth("100px");
    datePanel.setHeight("50px");
    return datePanel;
}

From source file:com.squadd.chat.ChatController.java

public static Panel createMessagePanel(ChatMessage message) {
    Panel chatLine = new Panel();
    Integer from = message.getIdFrom();
    Integer to = message.getIdTo();
    String body = message.getBody();

    VerticalLayout messageLayout = new VerticalLayout();
    Label nameLabel = new Label(from.toString() + " said:");//!!! ?
    nameLabel.setStyleName("messageHeader");
    Label messageLabel = new Label(body);
    messageLabel.setStyleName("messageBody");
    messageLayout.addComponents(nameLabel, messageLabel);
    chatLine.setContent(messageLayout);
    chatLine.setWidth("500px");
    return chatLine;
}

From source file:com.squadd.chat.UserInfoFace.java

public Panel getUserPanel() {
    Panel contactPanel = new Panel();
    FormLayout contactLine = new FormLayout();
    contactPanel.addClickListener(upd);//w  ww.j a  va 2  s  .  c o m
    Label nameLabel = new Label(user.getName());
    nameLabel.setStyleName("userPanel");
    contactLine.addComponent(nameLabel);
    contactPanel.setContent(contactLine);
    contactPanel.setId(user.getId().toString());
    return contactPanel;
    //contactsContent.addComponent(look);
    //contactsPanel.setContent(contactsContent);
}

From source file:com.squadd.chat.UserInfoFace.java

public Panel getUserPanel(Integer userId) {
    Panel contactPanel = new Panel();
    FormLayout contactLine = new FormLayout();
    user = new UserInfoBean();
    user.setId(userId);/*  w ww .  j  a  v a 2s.  c o m*/
    user.setName("id" + userId);
    contactPanel.addClickListener(upd);
    Label nameLabel = new Label(user.getName());
    nameLabel.setStyleName("userPanel");
    contactLine.addComponent(nameLabel);
    contactPanel.setContent(contactLine);
    contactPanel.setId(userId.toString());
    return contactPanel;
    //contactsContent.addComponent(look);
    //contactsPanel.setContent(contactsContent);
}