Example usage for com.vaadin.ui VerticalLayout setComponentAlignment

List of usage examples for com.vaadin.ui VerticalLayout setComponentAlignment

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout setComponentAlignment.

Prototype

@Override
    public void setComponentAlignment(Component childComponent, Alignment alignment) 

Source Link

Usage

From source file:de.fzi.fhemapi.view.vaadin.ui.DeviceDetailsPanel.java

License:Apache License

private void addDeviceDetails(List<DeviceDetailEntry> entries, VerticalLayout mainLayout) {
    for (DeviceDetailEntry entry : entries) {
        HorizontalLayout layout = UIHelper.buildAttributePanel(entry.caption, entry.component);
        mainLayout.addComponent(layout);
        mainLayout.setComponentAlignment(layout, Alignment.TOP_CENTER);
        mainLayout.setExpandRatio(layout, 1);
    }/* w  ww.ja v  a2s . com*/
}

From source file:de.fzi.fhemapi.view.vaadin.ui.HWindow.java

License:Apache License

private void openConfig() {
    VerticalLayout layout = new VerticalLayout();

    final TextArea area = new TextArea(null, server.getConfigManager().getConfigFile());
    //      area.setHeight("100%");
    area.setRows(100);//from   w ww.  j  av  a2 s.  c  o  m
    area.setWidth("100%");

    layout.addComponent(area);

    Button saveButton = new Button("Speichern");
    saveButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            server.setFHEMCfg(((String) area.getValue()));
            getWindow().showNotification(server.rereadConfiguration().toString(),
                    Notification.TYPE_TRAY_NOTIFICATION);
            server.getConfigManager().update();
        }
    });
    layout.addComponent(saveButton);
    layout.setComponentAlignment(saveButton, Alignment.TOP_CENTER);
    mainSplitPanel.setSecondComponent(layout);
}

From source file:de.fzi.fhemapi.view.vaadin.ui.NewDevicePanel.java

License:Apache License

@AutoGenerated
private VerticalLayout buildMainLayout() {
    VerticalLayout layout = new VerticalLayout();

    HorizontalLayout titleLabel = getTitlePanel();
    layout.addComponent(titleLabel);//from w  ww  . j  a v a 2  s  .  c  om
    layout.setComponentAlignment(titleLabel, Alignment.TOP_CENTER);

    nameField = new TextField();
    HorizontalLayout nameLayout = UIHelper.buildAttributePanel("Name", nameField);
    layout.addComponent(nameLayout);
    layout.setComponentAlignment(nameLayout, Alignment.TOP_CENTER);

    typeComboBox = new ComboBox();
    for (String name : DeviceFactory.getAvailableDevicetypes()) {
        typeComboBox.addItem(name);
    }

    HorizontalLayout typelayout = UIHelper.buildAttributePanel("Typ", typeComboBox);
    layout.addComponent(typelayout);
    layout.setComponentAlignment(typelayout, Alignment.TOP_CENTER);

    parameterType = new ComboBox();
    String[] manufacturers = ManufacturerManager.getClassNames();
    for (String name : manufacturers) {
        parameterType.addItem(name);
    }

    parameterType.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            fillManufacturerDetails((String) event.getProperty().getValue());
        }
    });
    parameterType.setImmediate(true);

    HorizontalLayout parameterTypeLayout = UIHelper.buildAttributePanel("Hersteller", parameterType);
    layout.addComponent(parameterTypeLayout);
    layout.setComponentAlignment(parameterTypeLayout, Alignment.TOP_CENTER);

    manufacturerLayout = new VerticalLayout();
    layout.addComponent(manufacturerLayout);
    layout.setComponentAlignment(manufacturerLayout, Alignment.TOP_CENTER);

    Button saveButton = new Button("Speichern");
    layout.addComponent(saveButton);
    layout.setComponentAlignment(saveButton, Alignment.TOP_CENTER);
    saveButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (allParametersMatches()) {
                String[] parameters = new String[currentManufacturerTextFields.size() + 1];
                parameters[0] = (String) nameField.getValue();
                for (int i = 1; i < parameters.length; i++) {
                    parameters[i] = (String) currentManufacturerTextFields.get(i - 1).getValue();
                }

                ActuatorParameters params = ParameterExtractor
                        .getJavaParameters((String) parameterType.getValue(), parameters);

                MessageResponse response = parent.server.getDeviceManager().createNewActuatorAsMessage(params);
                getWindow().showNotification(response.toString(), Notification.TYPE_TRAY_NOTIFICATION);
                parent.server.getDeviceManager().update();
                parent.server.getDeviceManager().getDevice(params.get(FHEMParameters.NAME))
                        .setDeviceType((String) typeComboBox.getValue());
                parent.reloadTree();
            }
        }
    });
    return layout;
}

From source file:de.fzi.fhemapi.view.vaadin.ui.NewRoomPanel.java

License:Apache License

private VerticalLayout buildMainLayout() {
    VerticalLayout layout = new VerticalLayout();

    nameTextField = new TextField();
    HorizontalLayout nameLay = UIHelper.buildAttributePanel("Name", nameTextField);
    layout.addComponent(nameLay);/*  ww w .  j av a2 s  . co m*/

    typeComboBox = new ComboBox();
    for (String type : roomTypes) {
        typeComboBox.addItem(type);
    }

    HorizontalLayout typeLay = UIHelper.buildAttributePanel("Typ", typeComboBox);
    layout.addComponent(typeLay);
    layout.setComponentAlignment(typeLay, Alignment.TOP_CENTER);

    Label devicesLabel = new Label();
    devicesLabel.setImmediate(false);
    devicesLabel.setWidth("100%");
    devicesLabel.setHeight("50");
    devicesLabel.setValue("<b>Gerte</b>");
    devicesLabel.setContentMode(Label.CONTENT_XHTML);
    layout.addComponent(devicesLabel);
    layout.setComponentAlignment(devicesLabel, Alignment.TOP_CENTER);

    List<Device> deviceList = parent.server.getDeviceManager().getDevices();
    devicesCheckBox = new CheckBox[deviceList.size()];
    for (int i = 0; i < deviceList.size(); i++) {
        devicesCheckBox[i] = new CheckBox(deviceList.get(i).getName());
        layout.addComponent(devicesCheckBox[i]);
        layout.setComponentAlignment(devicesCheckBox[i], Alignment.MIDDLE_CENTER);
    }

    Button saveButton = new Button("Speichern");
    saveButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            List<String> names = new LinkedList<String>();
            for (CheckBox checkbox : devicesCheckBox) {
                if (checkbox.booleanValue())
                    names.add(checkbox.getCaption());
            }

            Structure struc = new Structure((String) nameTextField.getValue(), (String) typeComboBox.getValue(),
                    names);
            MessageResponse response = parent.server.getStructureManager().createNewStructure(struc);
            getWindow().showNotification(response.toString(), Notification.TYPE_TRAY_NOTIFICATION);
            parent.server.getStructureManager().rereadFromFHEM();
            parent.reloadTree();
        }
    });
    layout.addComponent(saveButton);
    layout.setComponentAlignment(saveButton, Alignment.MIDDLE_CENTER);

    return layout;
}

From source file:de.lmu.ifi.dbs.knowing.vaadin.MainApplication.java

License:Apache License

private Window getAboutDialog() {
    if (aboutWindow == null) {
        aboutWindow = new Window("About...");
        aboutWindow.setModal(true);/*from  w  w w  .ja  va 2  s.  c  o m*/
        aboutWindow.setWidth("400px");

        VerticalLayout layout = (VerticalLayout) aboutWindow.getContent();
        layout.setMargin(true);
        layout.setSpacing(true);
        layout.setStyleName("grey");

        CssLayout titleLayout = new CssLayout();
        H2 title = new H2("Knowing Vaadin Application");
        titleLayout.addComponent(title);
        SmallText description = new SmallText("<br>Copyright (c) Nepomuk Seiler, LMU Database <br>"
                + "Licensed under Apache Software Foundation 2.0 license (ASF).<br><br>"
                + "This software contains modules licenced under<br>"
                + " the Apache Software Foundation 2.0 license (ASF) and EPL<br><br>"
                + "Many thanks to Kai Tdter, Chris Brind, Neil Bartlett and<br>"
                + " Petter Holmstrm for their OSGi and Vaadin<br>"
                + " related work, blogs, and bundles.<br><br>"
                + "The icons are from the Silk icon set by Mark James<br>"
                + "<a href=\"http://www.famfamfam.com/lab/icons/silk/\">http://www.famfamfam.com/lab/icons/silk/</a>");
        description.setSizeUndefined();
        description.setContentMode(Label.CONTENT_XHTML);

        titleLayout.addComponent(description);
        aboutWindow.addComponent(titleLayout);

        @SuppressWarnings("serial")
        Button close = new Button("Close", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                (aboutWindow.getParent()).removeWindow(aboutWindow);
            }

        });
        layout.addComponent(close);
        layout.setComponentAlignment(close, Alignment.TOP_RIGHT);
    }
    return aboutWindow;
}

From source file:de.symeda.sormas.ui.login.LoginScreen.java

License:Open Source License

private CssLayout buildLoginInformation() {
    CssLayout loginInformation = new CssLayout();
    loginInformation.setStyleName("login-information");

    VerticalLayout innerLayout = new VerticalLayout();
    innerLayout.setSizeFull();//from   w  ww. ja va 2  s .c  o m

    Image img = new Image(null, new ThemeResource("img/sormas-logo-big.png"));
    img.setHeight(240, Unit.PIXELS);
    innerLayout.addComponent(img);
    innerLayout.setComponentAlignment(img, Alignment.TOP_CENTER);
    innerLayout.setExpandRatio(img, 0);

    Label loginInfoText = new Label("<h1>SORMAS</h1>"
            + "<h2 style='color:white'>Surveillance, Outbreak Response Management and Analysis System</h2>"
            + "<h3 style='color:white; text-transform:uppercase'>&#9679; Disease Prevention<br>&#9679; Disease Detection<br>&#9679; Outbreak Response</h3>",
            ContentMode.HTML);
    loginInfoText.setWidth(100, Unit.PERCENTAGE);
    innerLayout.addComponent(loginInfoText);
    innerLayout.setExpandRatio(loginInfoText, 1);

    Label loginInfoCopyright = new Label(" 2019 SORMAS. All Rights Reserved.");
    loginInfoCopyright.setWidth(100, Unit.PERCENTAGE);
    innerLayout.addComponent(loginInfoCopyright);
    innerLayout.setExpandRatio(loginInfoCopyright, 0);
    innerLayout.setComponentAlignment(loginInfoCopyright, Alignment.BOTTOM_LEFT);

    loginInformation.addComponent(innerLayout);
    return loginInformation;
}

From source file:de.symeda.sormas.ui.samples.SampleController.java

License:Open Source License

private void requestSampleCollectionTaskCreation(SampleDto dto, SampleEditForm form) {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*from ww w.  j  a va 2s .c o m*/

    ConfirmationComponent requestTaskComponent = VaadinUiUtil.buildYesNoConfirmationComponent();

    Label description = new Label(I18nProperties.getString(Strings.messageCreateCollectionTask),
            ContentMode.HTML);
    description.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(description);
    layout.addComponent(requestTaskComponent);
    layout.setComponentAlignment(requestTaskComponent, Alignment.BOTTOM_RIGHT);
    layout.setSizeUndefined();
    layout.setSpacing(true);

    Window popupWindow = VaadinUiUtil.showPopupWindow(layout);
    popupWindow.setSizeUndefined();
    popupWindow.setCaption(I18nProperties.getString(Strings.headingCreateNewTaskQuestion));
    requestTaskComponent.getConfirmButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            popupWindow.close();
            ControllerProvider.getTaskController().createSampleCollectionTask(TaskContext.CASE,
                    dto.getAssociatedCase(), dto);
        }
    });
    requestTaskComponent.getCancelButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

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

From source file:de.symeda.sormas.ui.samples.SampleController.java

License:Open Source License

public void showChangePathogenTestResultWindow(CommitDiscardWrapperComponent<SampleEditForm> editComponent,
        String sampleUuid, PathogenTestResultType newResult) {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*from ww w.jav a 2  s.c  om*/

    ConfirmationComponent confirmationComponent = VaadinUiUtil.buildYesNoConfirmationComponent();

    Label description = new Label(String
            .format(I18nProperties.getString(Strings.messageChangePathogenTestResult), newResult.toString()));
    description.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(description);
    layout.addComponent(confirmationComponent);
    layout.setComponentAlignment(confirmationComponent, Alignment.BOTTOM_RIGHT);
    layout.setSizeUndefined();
    layout.setSpacing(true);

    Window popupWindow = VaadinUiUtil.showPopupWindow(layout);
    popupWindow.setSizeUndefined();
    popupWindow.setCaption(I18nProperties.getString(Strings.headingChangePathogenTestResult));
    confirmationComponent.getConfirmButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            editComponent.commit();
            SampleDto sample = FacadeProvider.getSampleFacade().getSampleByUuid(sampleUuid);
            sample.setPathogenTestResult(newResult);
            FacadeProvider.getSampleFacade().saveSample(sample);
            popupWindow.close();
            SormasUI.refreshView();
        }
    });
    confirmationComponent.getCancelButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

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

From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java

License:Open Source License

public static Window showSimplePopupWindow(String caption, String contentText) {
    Window window = new Window(null);
    window.setModal(true);//from  w w  w  . j ava2  s .  c o m
    window.setSizeUndefined();
    window.setResizable(false);
    window.center();

    VerticalLayout popupLayout = new VerticalLayout();
    popupLayout.setMargin(true);
    popupLayout.setSpacing(true);
    popupLayout.setSizeUndefined();
    Label contentLabel = new Label(contentText);
    contentLabel.setWidth(100, Unit.PERCENTAGE);
    popupLayout.addComponent(contentLabel);
    Button okayButton = new Button(I18nProperties.getCaption(Captions.actionOkay));
    okayButton.addClickListener(e -> {
        window.close();
    });
    CssStyles.style(okayButton, ValoTheme.BUTTON_PRIMARY);
    popupLayout.addComponent(okayButton);
    popupLayout.setComponentAlignment(okayButton, Alignment.BOTTOM_RIGHT);

    window.setCaption(caption);
    window.setContent(popupLayout);

    UI.getCurrent().addWindow(window);

    return window;
}

From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java

License:Open Source License

public static Window showConfirmationPopup(String caption, Component content, String confirmCaption,
        String cancelCaption, Integer width, Consumer<Boolean> resultConsumer) {
    Window popupWindow = VaadinUiUtil.createPopupWindow();
    if (width != null) {
        popupWindow.setWidth(width, Unit.PIXELS);
    } else {//from w w  w.  ja  v a 2 s. c  om
        popupWindow.setWidthUndefined();
    }
    popupWindow.setCaption(caption);

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    content.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(content);

    ConfirmationComponent confirmationComponent = new ConfirmationComponent(false) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onConfirm() {
            popupWindow.close();
            resultConsumer.accept(true);
        }

        @Override
        protected void onCancel() {
            popupWindow.close();
            resultConsumer.accept(false);
        }
    };
    confirmationComponent.getConfirmButton().setCaption(confirmCaption);
    confirmationComponent.getCancelButton().setCaption(cancelCaption);

    popupWindow.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            confirmationComponent.getCancelButton().click();
        }
    });

    layout.addComponent(confirmationComponent);
    layout.setComponentAlignment(confirmationComponent, Alignment.BOTTOM_RIGHT);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setSpacing(true);
    popupWindow.setContent(layout);

    UI.getCurrent().addWindow(popupWindow);
    return popupWindow;
}