Example usage for com.vaadin.ui Panel getContent

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

Introduction

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

Prototype

@Override
    public Component getContent() 

Source Link

Usage

From source file:ac.uk.icl.dell.vaadin.glycanbuilder.VaadinGlycanCanvas.java

License:Open Source License

public void showMessage(String message, String width, String height, String caption) {
    Window window = new Window();
    window.setCaption(caption);//from   w  ww . j  av  a  2  s .  c om
    window.setWidth(width);
    window.setHeight(height);

    window.center();

    Panel panel = new Panel();

    panel.getContent().addComponent(new Label(message));

    window.getContent().addComponent(panel);

    getWindow().addWindow(window);
}

From source file:ac.uk.icl.dell.vaadin.MessageDialogBox.java

License:Open Source License

public void init(String title, String message, Window parent) {
    Label messageLabel = new Label(message);

    Panel panel = new Panel();

    panel.getContent().addComponent(messageLabel);
    ((VerticalLayout) panel.getContent()).setComponentAlignment(messageLabel, Alignment.MIDDLE_CENTER);

    getContent().addComponent(panel);/*from  w w  w.ja v  a2s  .c  o  m*/

    setCaption(title);

    parent.addWindow(this);

    getContent().setWidth("400px");

    center();
}

From source file:com.bellkenz.modules.PersonalInformation.java

public ComponentContainer personalInformation() {
    employeeInformationDAO = new EmployeeInformationDAO(getEmployeeId());
    employeePersonalInformation = new EmployeePersonalInformation();

    GridLayout glayout = new GridLayout(5, 9);
    glayout.setSpacing(true);/*from ww w.j  a  v a  2  s. c om*/
    glayout.setMargin(true);

    final Panel imagePanel = new Panel();
    imagePanel.setStyleName("light");
    AbstractLayout panelLayout = (AbstractLayout) imagePanel.getContent();
    panelLayout.setMargin(false);
    imagePanel.setSizeFull();

    employeeImage = new Embedded(null, new ThemeResource("../myTheme/images/ronnie.jpg"));
    employeeImage.setImmediate(true);
    employeeImage.setWidth(90, Sizeable.UNITS_PIXELS);
    employeeImage.setHeight(90, Sizeable.UNITS_PIXELS);
    employeeImage.setStyleName("logo-img");
    imagePanel.addComponent(employeeImage);
    glayout.addComponent(employeeImage, 0, 0, 0, 1);
    glayout.setComponentAlignment(imagePanel, Alignment.MIDDLE_CENTER);

    firstname = createTextField("Firstname: ");
    glayout.addComponent(firstname, 1, 0, 2, 0);

    final TextField middlename = createTextField("Middlename: ");
    glayout.addComponent(middlename, 3, 0);

    final TextField lastname = createTextField("Lastname: ");
    glayout.addComponent(lastname, 4, 0);

    final TextField houseNo = createTextField("No: ");
    houseNo.setWidth("40px");
    glayout.addComponent(houseNo, 1, 1);

    final TextField street = createTextField("Street: ");
    street.setWidth("118");
    glayout.addComponent(street, 2, 1);

    final TextField city = createTextField("City: ");
    glayout.addComponent(city, 3, 1);

    final TextField zipCode = createTextField("Zip Code:");
    glayout.addComponent(zipCode, 4, 1);

    final TextField nickname = createTextField("Nickname: ");
    nickname.setWidth("90px");
    glayout.addComponent(nickname, 0, 2);

    final TextField permanentAddress = createTextField("Permanent/Provincial Address: ");
    permanentAddress.setWidth("533px");
    glayout.addComponent(permanentAddress, 1, 2, 4, 2);

    Button uploadPicture = new Button("Upload...");
    uploadPicture.setWidth("100%");
    uploadPicture.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (employeeId == null) {
                getWindow().showNotification("You did not select and Employee!",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            Window uploadImage = new UploadImage(imagePanel, employeeImage, employeeId);
            uploadImage.setWidth("450px");
            if (uploadImage.getParent() == null) {
                getWindow().addWindow(uploadImage);
            }
            uploadImage.setModal(true);
            uploadImage.center();
        }
    });
    glayout.addComponent(uploadPicture, 0, 3);

    final TextField landline = createTextField("Landline #: ");
    glayout.addComponent(landline, 1, 3, 2, 3);

    final TextField mobileNo = createTextField("Mobile #: ");
    glayout.addComponent(mobileNo, 3, 3);

    final TextField age = createTextField("Age: ");
    glayout.addComponent(age, 4, 3);

    final TextField emailAddress = createTextField("Email Address: ");
    glayout.addComponent(emailAddress, 1, 4, 2, 4);

    final PopupDateField dob = (PopupDateField) createDateField("Date of Birth: ");
    glayout.addComponent(dob, 3, 4);

    final TextField height = createTextField("Height: ");
    glayout.addComponent(height, 4, 4);

    final ComboBox civilStatus = new ComboBox("Civil Status: ");
    civilStatus.setWidth("100%");
    dropDownBoxList.populateCivilStatusList(civilStatus);
    glayout.addComponent(civilStatus, 1, 5, 2, 5);

    final ComboBox gender = new ComboBox("Gender: ");
    gender.setWidth("100%");
    dropDownBoxList.populateGenderList(gender);
    glayout.addComponent(gender, 3, 5);

    final TextField weight = createTextField("Weigth: ");
    glayout.addComponent(weight, 4, 5);

    final TextField driversLicenseNo = createTextField("Drivers License: ");
    glayout.addComponent(driversLicenseNo, 1, 6, 2, 6);

    final TextField restrictionCode = createTextField("Restriction Code: ");
    glayout.addComponent(restrictionCode, 3, 6);

    final TextField religion = createTextField("Religion: ");
    glayout.addComponent(religion, 4, 6);

    final ComboBox division = new ComboBox("Division: ");
    division.setWidth("100%");
    dropDownBoxList.populateBranchComboBox(division);
    glayout.addComponent(division, 1, 7, 2, 7);

    final ComboBox department = dropDownBoxList.populateDepartment(new ComboBox());
    department.setWidth("100%");
    division.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (division.getValue() == null) {
            } else {
                divisionId = branchDAO.getBranchId(division.getValue().toString());
            }
        }

    });
    glayout.addComponent(department, 3, 7);

    final TextField position = createTextField("Position: ");
    glayout.addComponent(position, 4, 7);
    //glayout.setComponentAlignment(position, Alignment.BOTTOM_LEFT);

    Button transferButton = new Button("Transfer Employee");
    transferButton.setWidth("100%");
    transferButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (getEmployeeId() == null) {
                getWindow().showNotification("You did not select an Employee!",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            Window subWindow = transferEmployee(getEmployeeId(), division, department, position);
            if (subWindow.getParent() == null) {
                getWindow().addWindow(subWindow);
            }
            subWindow.setModal(true);
            subWindow.center();
        }
    });
    glayout.addComponent(transferButton, 1, 8, 2, 8);
    glayout.setComponentAlignment(transferButton, Alignment.BOTTOM_CENTER);

    if (employeeId != null) {
        epiList = employeeInformationDAO.employeePersonalInformation();
        for (EmployeePersonalInformation epi : epiList) {
            final byte[] image = epi.getImage();
            if (image != null) {
                StreamResource.StreamSource imageSource = new StreamResource.StreamSource() {

                    @Override
                    public InputStream getStream() {
                        return new ByteArrayInputStream(image);
                    }

                };

                StreamResource imageResource = new StreamResource(imageSource, epi.getFirstname() + ".jpg",
                        getApplication());
                imageResource.setCacheTime(0);
                employeeImage.setSource(imageResource);
            }
            firstname.setValue(epi.getFirstname());
            middlename.setValue(epi.getMiddlename());
            lastname.setValue(epi.getLastname());
            houseNo.setValue(epi.getHouseNumber());

            street.setValue(epi.getStreet());
            city.setValue(epi.getStreet());
            zipCode.setValue(epi.getZipCode());
            nickname.setValue(epi.getNickname());
            permanentAddress.setValue(epi.getPermanentAddress());
            landline.setValue(epi.getLandlineNumber());
            mobileNo.setValue(epi.getMobileNumber());
            age.setValue(epi.getAge());
            emailAddress.setValue(epi.getEmailAddress());

            if (epi.getDob() != null) {
                dob.setValue(conUtil.parsingDate(epi.getDob()));
            } else {
                dob.setValue(null);
            }

            height.setValue(epi.getHeight());

            if (epi.getCivilStatus() != null) {
                Object civilStatusId = civilStatus.addItem();
                civilStatus.setItemCaption(civilStatusId, epi.getCivilStatus());
                civilStatus.setValue(civilStatusId);
            }

            if (epi.getGender() != null) {
                Object genderId = gender.addItem();
                gender.setItemCaption(genderId, epi.getGender());
                gender.setValue(genderId);
            }

            weight.setValue(epi.getWeight());
            driversLicenseNo.setValue(epi.getDriversLicense());
            restrictionCode.setValue(epi.getRestrictionCode());
            religion.setValue(epi.getReligion());
            position.setValue(epi.getPosition());

            Object divisionObjectId = division.addItem();
            division.setItemCaption(divisionObjectId, epi.getDivision());
            division.setValue(divisionObjectId);

            Object departmentObjectId = department.addItem();
            department.setItemCaption(departmentObjectId, epi.getDepartment());
            department.setValue(departmentObjectId);
        }
    }

    firstname.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            employeePersonalInformation.setFirstname(event.getProperty().getValue().toString());
        }
    });
    firstname.setImmediate(true);
    setInformation(employeePersonalInformation);

    return glayout;
}

From source file:com.expressui.core.view.page.DashboardPage.java

License:Open Source License

private Set<ViewBean> findViewBeanComponents() {
    Set<ViewBean> viewBeans = new HashSet<ViewBean>();

    Iterator<Component> iterator = rootLayout.getComponentIterator();
    while (iterator.hasNext()) {
        Component dashboardComponent = iterator.next();
        if (dashboardComponent instanceof Panel) {
            Panel panel = (Panel) dashboardComponent;
            ComponentContainer layout = panel.getContent();
            Component component = layout.getComponentIterator().next();
            if (component instanceof ViewBean) {
                viewBeans.add((ViewBean) component);
            }//w w  w.  j  a v  a2 s .  c o  m
        }
    }

    return viewBeans;
}

From source file:com.github.peholmst.springsecuritydemo.ui.LoginView.java

License:Apache License

@SuppressWarnings("serial")
protected void init() {
    final Panel loginPanel = new Panel();
    loginPanel.setCaption(getApplication().getMessage("login.title"));
    ((VerticalLayout) loginPanel.getContent()).setSpacing(true);

    final TextField username = new TextField(getApplication().getMessage("login.username"));
    username.setWidth("100%");
    loginPanel.addComponent(username);// w  w  w  . j a  v a  2  s .  c  om

    final TextField password = new TextField(getApplication().getMessage("login.password"));
    password.setSecret(true);
    password.setWidth("100%");
    loginPanel.addComponent(password);

    final Button loginButton = new Button(getApplication().getMessage("login.button"));
    loginButton.setStyleName("primary");
    // TODO Make it possible to submit the form by pressing <Enter> in any
    // of the text fields
    loginPanel.addComponent(loginButton);
    ((VerticalLayout) loginPanel.getContent()).setComponentAlignment(loginButton, Alignment.MIDDLE_RIGHT);
    loginButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            final Authentication auth = new UsernamePasswordAuthenticationToken(username.getValue(),
                    password.getValue());
            try {
                if (logger.isDebugEnabled()) {
                    logger.debug("Attempting authentication for user '" + auth.getName() + "'");
                }
                Authentication returned = getAuthenticationManager().authenticate(auth);
                if (logger.isDebugEnabled()) {
                    logger.debug("Authentication for user '" + auth.getName() + "' succeeded");
                }
                fireEvent(new LoginEvent(LoginView.this, returned));
            } catch (BadCredentialsException e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Bad credentials for user '" + auth.getName() + "'", e);
                }
                getWindow().showNotification(getApplication().getMessage("login.badCredentials.title"),
                        getApplication().getMessage("login.badCredentials.descr"),
                        Notification.TYPE_WARNING_MESSAGE);
            } catch (DisabledException e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Account disabled for user '" + auth.getName() + "'", e);
                }
                getWindow().showNotification(getApplication().getMessage("login.disabled.title"),
                        getApplication().getMessage("login.disabled.descr"), Notification.TYPE_WARNING_MESSAGE);
            } catch (LockedException e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Account locked for user '" + auth.getName() + "'", e);
                }
                getWindow().showNotification(getApplication().getMessage("login.locked.title"),
                        getApplication().getMessage("login.locked.descr"), Notification.TYPE_WARNING_MESSAGE);
            } catch (Exception e) {
                if (logger.isErrorEnabled()) {
                    logger.error("Error while attempting authentication for user '" + auth.getName() + "'");
                }
                ExceptionUtils.handleException(getWindow(), e);
            }
        }
    });

    HorizontalLayout languages = new HorizontalLayout();
    languages.setSpacing(true);
    final Button.ClickListener languageListener = new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Locale locale = (Locale) event.getButton().getData();
            if (logger.isDebugEnabled()) {
                logger.debug("Changing locale to [" + locale + "] and restarting the application");
            }
            getApplication().setLocale(locale);
            getApplication().close();
        }
    };
    for (Locale locale : getApplication().getSupportedLocales()) {
        if (!getLocale().equals(locale)) {
            final Button languageButton = new Button(getApplication().getLocaleDisplayName(locale));
            languageButton.setStyleName(Button.STYLE_LINK);
            languageButton.setData(locale);
            languageButton.addListener(languageListener);
            languages.addComponent(languageButton);
        }
    }
    loginPanel.addComponent(languages);

    loginPanel.setWidth("300px");

    final HorizontalLayout viewLayout = new HorizontalLayout();
    viewLayout.addComponent(loginPanel);
    viewLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
    viewLayout.setSizeFull();
    viewLayout.setMargin(true);

    setCompositionRoot(viewLayout);
    setSizeFull();
}

From source file:com.haulmont.cuba.web.log.LogWindow.java

License:Apache License

private void initUI() {
    ClientConfig clientConfig = AppBeans.<Configuration>get(Configuration.NAME).getConfig(ClientConfig.class);

    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination closeCombination = KeyCombination.create(closeShortcut);

    com.vaadin.event.ShortcutAction closeShortcutAction = new com.vaadin.event.ShortcutAction(
            "closeShortcutAction", closeCombination.getKey().getCode(),
            KeyCombination.Modifier.codes(closeCombination.getModifiers()));

    addActionHandler(new com.vaadin.event.Action.Handler() {
        @Override//from w  w w  .j  a v a  2s.c om
        public com.vaadin.event.Action[] getActions(Object target, Object sender) {
            return new com.vaadin.event.Action[] { closeShortcutAction };
        }

        @Override
        public void handleAction(com.vaadin.event.Action action, Object sender, Object target) {
            if (Objects.equals(action, closeShortcutAction)) {
                close();
            }
        }
    });

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setSizeFull();
    setContent(layout);

    Panel scrollablePanel = new Panel();
    scrollablePanel.setSizeFull();
    VerticalLayout scrollContent = new VerticalLayout();
    scrollContent.setSizeUndefined();
    scrollablePanel.setContent(scrollContent);

    final Label label = new Label();
    label.setContentMode(ContentMode.HTML);
    label.setValue(writeLog());
    label.setSizeUndefined();
    label.setStyleName("c-log-content");

    ((Layout) scrollablePanel.getContent()).addComponent(label);

    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setWidth("100%");
    topLayout.setHeightUndefined();

    Messages messages = AppBeans.get(Messages.NAME);
    Button refreshBtn = new CubaButton(messages.getMessage(getClass(), "logWindow.refreshBtn"),
            (Button.ClickListener) event -> label.setValue(writeLog()));

    topLayout.addComponent(refreshBtn);

    layout.addComponent(topLayout);
    layout.addComponent(scrollablePanel);

    layout.setExpandRatio(scrollablePanel, 1.0f);
}

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 ava  2  s  . c om*/
    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

/**
 * ?//from   w  w w.j  av  a 2  s .  c om
 * 
 * @param roleType ?
 */
public LoginLayout(RoleType roleType, Ec2LoginLayout ec2LoginLayout) {
    // ??
    this.setSpacing(true);
    this.setMargin(true);
    this.roleType = roleType;
    this.ec2LoginLayout = ec2LoginLayout;

    userLoginService = SpringContextHolder.getBean("userLoginService");
    userService = SpringContextHolder.getBean("userService");

    // ?Cookie
    this.getCookies();

    Panel loginPanel = new Panel(roleType.name().toUpperCase() + " LOGIN INTERFACE");
    loginPanel.setWidth("380px");
    loginPanel.setHeight("260px");
    this.addComponent(loginPanel);
    this.setComponentAlignment(loginPanel, Alignment.BOTTOM_CENTER);

    // ?
    VerticalLayout panelContent = (VerticalLayout) loginPanel.getContent();
    createLoginMainComponents(panelContent, roleType);

    // ??? (?, ?)
    createConflictManageWindow();
}

From source file:com.klwork.explorer.ui.custom.UploadComponent.java

License:Apache License

protected void addDropPanel() {
    Panel dropPanel = new Panel();
    dropPanel.setContent(new VerticalLayout());
    DragAndDropWrapper dragAndDropWrapper = new DragAndDropWrapper(dropPanel);
    //WW_TODO ?//from   www. j  a v  a2  s  .  c  om
    dragAndDropWrapper.setDropHandler(this);
    dragAndDropWrapper.setWidth("80%");
    addComponent(dragAndDropWrapper);
    setComponentAlignment(dragAndDropWrapper, Alignment.MIDDLE_CENTER);
    //
    Label dropLabel = new Label(i18nManager.getMessage(Messages.UPLOAD_DROP));
    dropLabel.setSizeUndefined();
    ((VerticalLayout) dropPanel.getContent()).addComponent(dropLabel);
    ((VerticalLayout) dropPanel.getContent()).setComponentAlignment(dropLabel, Alignment.MIDDLE_CENTER);
}

From source file:com.lizardtech.expresszip.vaadin.MapToolbarViewComponent.java

License:Apache License

@Override
public void buttonClick(ClickEvent event) {
    Button b = event.getButton();
    if (b == btnJobQueueStatus) {
        Window subWindow = new Window("Job Manager");
        subWindow.setWidth("500px");
        subWindow.center();//from   w  w  w.j  a  v  a2s.com
        getApplication().getMainWindow().addWindow(subWindow);

        Panel p = new Panel(new JobsStatusViewComponent(getApplication().getURL()));
        p.getContent().setWidth("100%");
        p.setWidth("100%");
        subWindow.addComponent(p);
        subWindow.setModal(true);
    } else if (b == help) {
        String HelpURL = getApplication().getURL().toExternalForm() + "doc";
        getApplication().getMainWindow().open(new ExternalResource(HelpURL), "_blank");
    } else if (b == restart) {
        ((ExpressZipWindow) getApplication().getMainWindow()).getApplication().close();
    }
}