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.logicbomb.newschool.MyAppWidgetSet.core.UserDetailsWidgetOld.java

public UserDetailsWidgetOld() {

    setSpacing(true);//from  ww  w  .j  av a  2  s .  c  o  m
    Panel iPanel = new Panel();
    iPanel.setWidth("50px");
    iPanel.setHeight("50px");
    iPanel.setStyleName("backColorWhite");
    addComponent(iPanel);
    String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();

    // Image as a file resource
    FileResource resource = new FileResource(new File(basepath + "/VAADIN/themes/mytheme/img/loginPage.jpg"));

    // Show the image in the application
    Image image = new Image("", resource);
    image.setSizeFull();
    iPanel.setContent(image);

}

From source file:com.logicbomb.newschool.MyAppWidgetSet.LoginWidget.java

public LoginWidget() {
    setMargin(true);//from  w w  w.j av  a  2s.  co m
    setSpacing(true);

    Panel iPanel = new Panel();
    iPanel.addStyleName("backColorWhite");
    iPanel.setSizeUndefined();

    addComponent(iPanel);

    TextField iTextField = new TextField("Username");
    iTextField.setWidth("300px");
    iTextField.setRequired(true);
    iTextField.setInputPrompt("Your username (eg. joe@email.com)");
    iTextField.setIcon(FontAwesome.USER);
    iTextField.addValidator(new EmailValidator("Username must be an email address"));
    iTextField.setInvalidAllowed(true);
    iTextField.focus();

    PasswordField iPasswordField = new PasswordField("Password");
    iPasswordField.setIcon(FontAwesome.KEY);
    iPasswordField.setWidth("300px");
    iPasswordField.setRequired(true);
    iPasswordField.setValue("");
    iPasswordField.setNullRepresentation("");

    Button iButton = new Button("Login");
    iButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            addComponent(new Label("Login Successfully"));
        }
    });

    FormLayout iFormLayout = new FormLayout();
    iFormLayout.setSpacing(true);
    iFormLayout.setMargin(true);
    iFormLayout.addComponent(iTextField);
    iFormLayout.addComponent(iPasswordField);
    iFormLayout.addComponent(iButton);
    iPanel.setContent(iFormLayout);

}

From source file:com.logicbomb.newschool.MyAppWidgetSet.MenuWidget.java

public MenuWidget(String Width) {

    Panel iPanel = new Panel();
    iPanel.setWidth(Width);//from w w  w .  j  a va  2  s .com
    iPanel.setStyleName("backColorWhite");

    addComponent(iPanel);

    VerticalLayout iVerticalLayout = new VerticalLayout();
    for (int i = 1; i <= 8; i++) {
        Button iButton = new Button();
        iButton.setWidth(Width);
        iButton.setHeight("50px");
        iVerticalLayout.addComponent(iButton);
    }
    iPanel.setContent(iVerticalLayout);

}

From source file:com.logicbomb.newschool.pages.masterpages.PrimaryMasterPage.java

public PrimaryMasterPage() {

    //ContextWidget c= new ContextWidget();

    HorizontalLayout iHorizontalLayout = new HorizontalLayout();
    //addComponent(iHorizontalLayout,"top:0px;left:0px");
    iHorizontalLayout.setWidth(String.valueOf(Page.getCurrent().getBrowserWindowWidth()));
    iHorizontalLayout.setHeight(String.valueOf(Page.getCurrent().getBrowserWindowHeight()));
    iHorizontalLayout.setStyleName("backColorBlack");

    //String[] captions1 = {"Logo Here", "My Cool School", "Third"};

    //Layout A and its sub components
    Panel AP = new Panel();
    iHorizontalLayout.addComponent(AP);//from   w ww . j  av a  2s .  c  o  m
    AP.setSizeFull();
    AP.setStyleName("backColorBlack");
    VerticalLayout A1 = new VerticalLayout();
    AP.setContent(A1);
    //A.setSizeFull();
    A1.setSpacing(true);
    iHorizontalLayout.setExpandRatio(AP, 1);

    A1.setStyleName("backColorBlack");
    A1.setMargin(new MarginInfo(true, true, true, true));

    Button logoImage = new Button();
    logoImage.setIcon(FontAwesome.PICTURE_O);
    logoImage.setWidth("80px");
    logoImage.setHeight(logoImage.getWidth(), Unit.PIXELS);
    //logoImage.setWidth("100px");
    A1.addComponent(logoImage);
    A1.setComponentAlignment(logoImage, Alignment.TOP_CENTER);

    Label schoolName = new Label("The School Of Future");
    schoolName.setStyleName("v-label-big");
    A1.addComponent(schoolName);
    //A.setComponentAlignment(schoolName,Alignment.TOP_CENTER);

    Label schoolMinorName = new Label("Random Branch");
    schoolMinorName.setStyleName("v-label-small");
    A1.addComponent(schoolMinorName);

    VerticalLayout A2 = new VerticalLayout();
    A1.addComponent(A2);
    MainMenuWidget iMainMenuWidget = new MainMenuWidget();
    A2.addComponent(iMainMenuWidget);

    //A.setComponentAlignment(schoolName,Alignment.TOP_CENTER);

    //Layout B
    ContextWidgetTop c = new ContextWidgetTop();
    c = ContextWidgetTop.ContextWidgetTransformer(c, new UserDetailsWidget(), SliderMode.TOP,
            SliderPanelStyles.COLOR_RED);
    VerticalLayout B = new VerticalLayout();
    B.setSizeFull();
    //B.setSpacing(true);
    iHorizontalLayout.addComponent(c);
    c.addComponent(B);
    iHorizontalLayout.setExpandRatio(c, 7);

    //Layout B1 and its sub Components
    HorizontalLayout B1 = new HorizontalLayout();
    B.addComponent(B1);
    //B.setExpandRatio(B1, 1);
    //B1.setHeight("70px");
    B1.setSizeFull();
    //B1=ContextWidget.ContextWidgetTransformer(B1, new SliderMasterPage(),SliderMode.RIGHT,SliderPanelStyles.COLOR_RED);

    HorizontalLayout B11 = new HorizontalLayout();
    B1.addComponent(B11);
    B1.setStyleName("backColorBlack");
    B11.setSizeFull();
    B1.setHeight("45px");
    //B1.setStyleName("backColorWhite");
    //B1.setMargin(new MarginInfo(false, true, false, true));

    TextField iTextField = new TextField();
    iTextField.setWidth("200px");
    iTextField.setInputPrompt("Search!");
    iTextField.setStyleName("v-text-type-search");
    iTextField.focus();
    B11.addComponent(iTextField);
    B11.setComponentAlignment(iTextField, Alignment.MIDDLE_LEFT);

    //Layout B2 and its Sub Components
    ContextWidget B2 = new ContextWidget();
    B2.setSizeFull();
    B.addComponent(B2);
    B.setExpandRatio(B2, 10);
    B2 = ContextWidget.ContextWidgetTransformer(B2, new SliderMasterPage(), SliderMode.RIGHT,
            SliderPanelStyles.COLOR_BLUE);
    //B2=ContextWidget.ContextWidgetTransformer(B2, new SliderMasterPage(),SliderMode.TOP,SliderPanelStyles.COLOR_RED);
    VerticalLayout v = new VerticalLayout();
    B2.addComponent(v);

    Button b1111 = new Button(
            "Put all the inner components like this Put all the inner components like this Put all the inner components like this Put all the inner components like this");
    v.addComponent(b1111);
    Button b1112 = new Button("Put all the inner components like this");
    v.addComponent(b1112);

    /*
    Panel p = new Panel();
    VerticalLayout v= new VerticalLayout();
    v.addComponent(new TextField("Name"));
    v.addComponent(new TextField("Street address"));
    v.addComponent(new TextField("Postal code"));
    p.setContent(v);
    B2.addComponent(p);
    v.setWidth(String.valueOf(B2.getWidth()*10)+"px");
    //v.setSizeFull();// <- This will cause issues. Don't do this
    p.setSizeFull();
    */

    //ContextWidget iContextPanel= new ContextWidget(p);
    //B2.addComponent(iContextPanel);
    //setPosition(p, iComponentPositionPanel);

    addComponent(iHorizontalLayout);
}

From source file:com.lst.deploymentautomation.vaadin.core.AppFormConnector.java

License:Open Source License

@Override
public void setContent(Component content) {
    if (content == null) {
        //rendering failed; show a sad face to show how sorry we are
        VerticalLayout layout = new VerticalLayout();
        Label fail = new Label(":-(");
        fail.addStyleName("screen-failed-to-render");
        layout.addComponent(fail);/*from w  w w  .j ava2s  .  c om*/
        layout.setExpandRatio(fail, 1);
        layout.setComponentAlignment(fail, Alignment.MIDDLE_LEFT);
        layout.setSizeFull();

        view.setContent(layout);

    } else {
        //if the component has either natural or absolute size, wrap it
        //in a scrollable panel with full size and nice margin
        if (content.getHeightUnits() != Unit.PERCENTAGE) {
            final Panel panel = new Panel();
            panel.addStyleName("l-border-none");
            panel.setContent(content);
            panel.setSizeFull();
            content = panel;
        }

        view.setContent(content);
    }
}

From source file:com.lst.deploymentautomation.vaadin.page.SettingsView.java

License:Open Source License

private void createView() {
    LspsUI ui = (LspsUI) getUI();//from  w  w  w.  j  a va  2 s .co m
    Person 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.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(ui, user);
    layout.addComponent(substitution);

    Label spacer2 = new Label();
    spacer2.setHeight("10px");
    layout.addComponent(spacer2);

    //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.m4gik.views.component.LicenseScreen.java

/**
 * Method builds license layout with texts.
 * /*from w  ww .j  a  v  a 2  s.  c  o  m*/
 * @return The VerticalLayout with texts.
 * 
 * @see com.m4gik.views.component.ViewScreen#build()
 */
@Override
public Layout build() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.setCaption("Welcome");

    Panel welcome = new Panel("License");
    welcome.setSizeFull();
    welcome.addStyleName(Runo.PANEL_LIGHT);
    layout.addComponent(welcome);
    layout.setExpandRatio(welcome, 1);

    CssLayout margin = new CssLayout();
    // margin.setMargin(true);
    margin.setWidth("100%");
    welcome.setContent(margin);

    Label title = new Label("Music player");
    title.addStyleName(Runo.LABEL_H1);
    // margin.addComponent(title);

    HorizontalLayout texts = new HorizontalLayout();
    texts.setSpacing(true);
    texts.setWidth("100%");
    margin.addComponent(texts);

    addText(texts,
            "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>",
            null);
    addText(texts,
            "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>",
            null);
    addText(texts,
            "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>",
            null);

    layout.addComponent(new Label("<hr />", Label.CONTENT_XHTML));

    return layout;
}

From source file:com.m4gik.views.MainView.java

/**
 * @param left//from   www  . j a  v a 2  s  .co  m
 */
private void addAccordion(Panel left) {
    Accordion accordion = new Accordion();
    accordion.setSizeFull();
    accordion.setHeight("350px");
    left.setContent(accordion);

    accordion.addTab(buildTree(), "Category");
    accordion.addTab(new Label(""), "Discover");
    accordion.addTab(new Label(""), "Quick Search");
}

From source file:com.mycompany.project.components.ContactDetails.java

public ContactDetails() {
    //        setCaption("Contact Details");

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);//from   ww w.jav a 2s .  c  om
    mainVLayout.setSpacing(true);

    setContent(mainVLayout);

    tfName.setSizeFull();
    tfAddress.setSizeFull();
    tfPhone.setSizeFull();
    tfEmail.setSizeFull();

    Panel panel = new Panel("Grupos");
    panel.setWidth("100%");
    panel.setHeight("50px");
    panel.setContent(groupsHLayout);

    mainVLayout.addComponent(tfName);
    mainVLayout.addComponent(tfAddress);
    mainVLayout.addComponent(tfPhone);
    mainVLayout.addComponent(tfEmail);
    mainVLayout.addComponent(groupsHLayout);

    Button btnUpdate = new Button("Actualizar");
    mainVLayout.addComponent(btnUpdate);

    btnUpdate.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            //invoke business logic
            BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic();

            String name = tfName.getValue();
            String address = tfAddress.getValue();
            String phone = tfPhone.getValue();
            String email = tfEmail.getValue();

            ArrayList<String> selectedGroupIds = new ArrayList<String>();
            Set<String> groupIdSet = groupsMap.keySet();
            for (String groupId : groupIdSet) {
                CheckBox cb = groupsMap.get(groupId);
                if (cb.getValue()) {
                    selectedGroupIds.add(groupId);
                }
            }

            boolean success = bl.updateContact(selectedContactId, name, address, phone, email,
                    selectedGroupIds);
            if (success) {
                load(selectedContactId);
                Notification.show("Informacion", "Contacto Actualizado", Notification.Type.TRAY_NOTIFICATION);
            } else {
                Notification.show("Error", "\nSomething bad happened", Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    ContactDetails.this.setVisible(false);
}

From source file:com.ocs.dynamo.ui.component.ErrorView.java

License:Apache License

@Override
public void build() {
    VerticalLayout main = new DefaultVerticalLayout(true, true);

    Panel panel = new Panel();
    panel.setCaption(message("ocs.error.occurred"));
    main.addComponent(panel);//from   www  .  j  ava2 s.  com

    VerticalLayout inside = new DefaultVerticalLayout(true, true);
    panel.setContent(inside);

    Label errorLabel = new Label(message("ocs.view.unknown"));
    inside.addComponent(errorLabel);

    setCompositionRoot(main);
}