com.vaadin.ui.CssLayout.addComponent()

Here are the examples of the java api com.vaadin.ui.CssLayout.addComponent() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

16 Examples 7

18 Source : LoginComponent.java
with Apache License 2.0
from ijazfx

private Component buildLabels() {
    CssLayout labels = new CssLayout();
    labels.addStyleName("labels");
    if (dashboardSetup.loginFormLogo() != null) {
        Image logoImage = dashboardSetup.loginFormLogo();
        logoImage.addStyleName("logo-image");
        logoImage.setHeight(logoImageHeight());
        labels.addComponent(logoImage);
    } else {
        Label welcome = new Label("Welcome");
        welcome.setSizeUndefined();
        welcome.addStyleName(ValoTheme.LABEL_H4);
        welcome.addStyleName(ValoTheme.LABEL_COLORED);
        labels.addComponent(welcome);
    }
    Label replacedle = new Label(dashboardSetup.loginFormreplacedle());
    replacedle.setSizeUndefined();
    replacedle.addStyleName(ValoTheme.LABEL_H3);
    labels.addComponent(replacedle);
    return labels;
}

18 Source : AbstractCardListPanel.java
with Apache License 2.0
from ijazfx

private void prepareCardList(List<T> enreplacedies) {
    enreplacedies.forEach(enreplacedy -> {
        MPanel cardPanel = new MPanel().withStyleName(cardStyleName());
        MButton editButton = new MButton(FontAwesome.PENCIL, localizedSingularValue("Edit"), event -> {
            preEdit(enreplacedy);
            openEditorForm(enreplacedy);
        });
        MButton deleteButton = new MButton(FontAwesome.TRASH, localizedSingularValue("Delete"), event -> {
            if (shouldShowDeleteConfirmation()) {
                ConfirmDialog.show(UI.getCurrent(), "Are you sure to delete selected records", e -> {
                    if (e.isConfirmed()) {
                        if (onDeleteEnreplacedy(enreplacedy)) {
                            contentLayout.removeComponent(cardPanel);
                            if (delegate != null) {
                                delegate.onDelete(enreplacedy);
                            }
                        }
                    }
                });
            } else {
                if (onDeleteEnreplacedy(enreplacedy)) {
                    contentLayout.removeComponent(cardPanel);
                    if (delegate != null) {
                        delegate.onDelete(enreplacedy);
                    }
                }
            }
        });
        AbstractCardComponent<T> cardLayout = getCardComponent(enreplacedy).withEditButton(editButton).withDeleteButton(deleteButton);
        cardPanel.setContent(cardLayout.build());
        cardPanel.setWidth(cardLayout.getCardWidth());
        contentLayout.addComponent(cardPanel);
    });
}

17 Source : MainUI.java
with Apache License 2.0
from opensecuritycontroller

private void buildSubmenu(CssLayout submenu, Set<OSCViewProvider<?>> views) {
    for (final OSCViewProvider<?> view : views) {
        String viewName = view.getName();
        NativeButton b = new NativeButton(viewName);
        // selecting default menu button
        if (view.getName().equals(VIEW_FRAGMENT_ALERTS)) {
            b.addStyleName("selected");
        }
        b.addClickListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                clearMenuSelection();
                event.getButton().addStyleName("selected");
                if (!MainUI.this.nav.getState().equals(viewName)) {
                    MainUI.this.nav.navigateTo(viewName);
                }
            }
        });
        submenu.setSizeFull();
        submenu.addComponent(b);
    }
}

17 Source : AbstractDashboardView.java
with Apache License 2.0
from ijazfx

private Component buildContent() {
    dashboardPanels = new CssLayout();
    dashboardPanels.addStyleName("dashboard-panels");
    Responsive.makeResponsive(dashboardPanels);
    if (dashlets() != null) {
        dashlets().forEach(dashlet -> {
            dashboardPanels.addComponent(dashlet.getWrappedComponent());
        });
    }
    return dashboardPanels;
}

17 Source : AbstractDashboardView.java
with Apache License 2.0
from ijazfx

private Component buildSparkline(List<Spark> sparks) {
    CssLayout sparksLayout = new CssLayout();
    sparksLayout.addStyleName("sparks");
    sparksLayout.setWidth("100%");
    Responsive.makeResponsive(sparksLayout);
    if (sparks != null) {
        sparks.forEach(spark -> {
            Component sparkComponent = spark.build().getWrappedComponent();
            sparksLayout.addComponent(sparkComponent);
        });
    }
    return sparksLayout;
}

16 Source : AbstractDashboardMenu.java
with Apache License 2.0
from ijazfx

private Component buildContent() {
    final CssLayout menuContent = new CssLayout();
    menuContent.addStyleName("sidebar");
    menuContent.addStyleName(ValoTheme.MENU_PART);
    menuContent.addStyleName("no-vertical-drag-hints");
    menuContent.addStyleName("no-horizontal-drag-hints");
    menuContent.setWidth(null);
    menuContent.setHeight("100%");
    menuContent.addComponent(buildreplacedle());
    menuContent.addComponent(buildUserMenu());
    menuContent.addComponent(buildToggleButton());
    menuContent.addComponent(buildMenuItems());
    return menuContent;
}

16 Source : AbstractDashboardMenu.java
with Apache License 2.0
from ijazfx

private Component buildMenuItems() {
    CssLayout menuItemsLayout = new CssLayout();
    menuItemsLayout.addStyleName("valo-menuitems");
    Collection<TRMenuItem> items = menuItems();
    backButton = new ValoMenuItemButton("Back", GrapheneeTheme.BACK_ICON);
    backButton.setVisible(false);
    backButton.withListener(new TRButtonClickListener() {

        @Override
        public void onButtonClick(ClickEvent event) {
            String viewName = null;
            focusedMenuItem = focusedMenuItem.getParent() != null ? focusedMenuItem.getParent().getParent() : null;
            if (focusedMenuItem == null) {
                buttonsMap.keySet().forEach(mi -> {
                    buttonsMap.get(mi).setVisible(mi.getParent() == null);
                });
                backButton.setVisible(false);
                viewName = menuItems().get(0).viewName();
            } else {
                buttonsMap.values().forEach(vmib -> vmib.setVisible(false));
                focusedMenuItem.getChildren().forEach(mi -> {
                    buttonsMap.get(mi).setVisible(true);
                });
                backButton.setVisible(true);
                viewName = focusedMenuItem.getChildren().iterator().next().viewName();
            }
            // if (viewName == null)
            // viewName = dashboardSetup().dashboardViewName();
            if (viewName != null)
                UI.getCurrent().getNavigator().navigateTo(viewName);
        }
    });
    generateValoMenuItemButtons(menuItemsLayout, items);
    menuItemsLayout.addComponent(backButton, 0);
    buttonsMap.keySet().forEach(mi -> {
        buttonsMap.get(mi).setVisible(mi.getParent() == null);
    });
    return menuItemsLayout;
}

15 Source : GxMeetingHost.java
with Apache License 2.0
from ijazfx

private Component getRoomComponent() {
    roomPanel = new CardCollectionPanel<GxMeetingUser>() {

        @Override
        protected void layoutCard(MPanel cardPanel, GxMeetingUser item) {
            cardPanel.setId(getVideoTagId(item.getUserId()) + "_container");
            cardPanel.setStyleName("hidden");
            cardPanel.removeStyleName("card-item");
            if (!item.getUserId().equals(user.getUserId())) {
                GxMeetingUserCardComponent component = new GxMeetingUserCardComponent(item);
                cardPanel.setContent(component.rebuild());
                cardPanel.setWidth("200px");
            }
        }
    };
    roomPanel.setSizeFull();
    CssLayout roomLayout = new CssLayout();
    roomLayout.setSizeFull();
    roomLayout.addComponent(roomPanel);
    Label localVideo = new Label();
    localVideo.setWidthUndefined();
    localVideo.setContentMode(ContentMode.HTML);
    String localVideoHtml = "<video id=\"localVideo\" width=\"200px\" height=\"150px\" autoplay muted></video>";
    localVideo.setValue(localVideoHtml);
    roomLayout.addComponent(localVideo);
    meetingContainer = new BeanItemContainer<>(GxMeetingUser.clreplaced);
    roomPanel.setCollectionContainer(meetingContainer);
    return roomLayout;
}

14 Source : VaadinAbstractLoginComponent.java
with Apache License 2.0
from ijazfx

private Component buildLabels() {
    CssLayout labels = new CssLayout();
    labels.addStyleName("labels");
    if (dashboardSetup().loginFormLogo() != null) {
        Image logoImage = dashboardSetup().loginFormLogo();
        logoImage.addStyleName("logo-image");
        logoImage.setHeight(logoImageHeight());
        labels.addComponent(logoImage);
    } else {
        Label welcome = new Label("Welcome");
        welcome.setSizeUndefined();
        welcome.addStyleName(ValoTheme.LABEL_H4);
        welcome.addStyleName(ValoTheme.LABEL_COLORED);
        labels.addComponent(welcome);
    }
    Label replacedle = new Label(dashboardSetup().loginFormreplacedle());
    replacedle.setSizeUndefined();
    replacedle.addStyleName(ValoTheme.LABEL_H3);
    labels.addComponent(replacedle);
    return labels;
}

14 Source : AbstractDashboardView.java
with Apache License 2.0
from ijazfx

private Component buildDashlet(final Component content) {
    final CssLayout slot = new CssLayout();
    slot.setWidth("100%");
    slot.addStyleName("dashboard-panel-slot");
    CssLayout card = new CssLayout();
    card.setWidth("100%");
    card.addStyleName(ValoTheme.LAYOUT_CARD);
    MHorizontalLayout toolbar = new MHorizontalLayout();
    toolbar.addStyleName("dashboard-panel-toolbar");
    toolbar.setWidth("100%");
    Label caption = new Label(content.getCaption());
    caption.addStyleName(ValoTheme.LABEL_H4);
    caption.addStyleName(ValoTheme.LABEL_COLORED);
    caption.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    content.setCaption(null);
    MenuBar tools = new MenuBar();
    tools.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    MenuItem max = tools.addItem("", FontAwesome.EXPAND, new Command() {

        @Override
        public void menuSelected(final MenuItem selectedItem) {
            if (!slot.getStyleName().contains("max")) {
                selectedItem.setIcon(FontAwesome.COMPRESS);
                toggleMaximized(slot, true);
            } else {
                slot.removeStyleName("max");
                selectedItem.setIcon(FontAwesome.EXPAND);
                toggleMaximized(slot, false);
            }
        }
    });
    max.setStyleName("icon-only");
    MenuItem root = tools.addItem("", FontAwesome.ELLIPSIS_V, null);
    root.addItem("Configure", new Command() {

        @Override
        public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    });
    root.addSeparator();
    root.addItem("Close", new Command() {

        @Override
        public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    });
    toolbar.addComponents(caption, tools);
    toolbar.setExpandRatio(caption, 1);
    toolbar.setComponentAlignment(caption, Alignment.MIDDLE_LEFT);
    card.addComponents(toolbar, content);
    slot.addComponent(card);
    return slot;
}

14 Source : AbstractDashboardMenu.java
with Apache License 2.0
from ijazfx

private void generateValoMenuItemButtons(CssLayout menuItemsLayout, Collection<TRMenuItem> items) {
    if (items != null && !items.isEmpty()) {
        for (TRMenuItem menuItem : items) {
            if (buttonsMap.containsKey(menuItem))
                continue;
            ValoMenuItemButton valoMenuItemButton = new ValoMenuItemButton(menuItem.hasChildren() ? null : menuItem.viewName(), menuItem.caption(), menuItem.icon()).withListener(event -> {
                focusedMenuItem = menuItem;
                if (menuItem.viewName() != null)
                    UI.getCurrent().getNavigator().navigateTo(menuItem.viewName());
                if (menuItem.hasChildren()) {
                    buttonsMap.values().forEach(vmib -> vmib.setVisible(false));
                    menuItem.getChildren().forEach(mi -> {
                        buttonsMap.get(mi).setVisible(true);
                    });
                    backButton.setVisible(true);
                }
            });
            valoMenuItemButton.setBadgeId(menuItem.badgeId());
            valoMenuItemButton.setBadge(menuItem.badge());
            menuItemsLayout.addComponent(valoMenuItemButton);
            buttonsMap.put(menuItem, valoMenuItemButton);
            if (menuItem.hasChildren()) {
                generateValoMenuItemButtons(menuItemsLayout, menuItem.getChildren());
            }
        }
    }
}

14 Source : AbstractCardListPanel.java
with Apache License 2.0
from ijazfx

private void buildCardList(List<T> enreplacedies) {
    if (enreplacedies.isEmpty()) {
        contentLayout.removeAllComponents();
        MPanel cardPanel = new MPanel().withStyleName(cardStyleName());
        cardPanel.setContent(new MVerticalLayout(new MLabel("No data available").withStyleName(ValoTheme.LABEL_NO_MARGIN)).withMargin(true));
        contentLayout.addComponent(cardPanel);
    } else {
        contentLayout.removeAllComponents();
        if (enreplacedies != null) {
            if (shouldGroupByCards()) {
                AtomicInteger index = new AtomicInteger(0);
                Map<Integer, String> keyOrders = new HashMap<>();
                Map<String, List<T>> groupedEnreplacedies = new HashMap<>();
                enreplacedies.stream().forEach(e -> {
                    String key = groupByFunction(e);
                    List<T> grouped = groupedEnreplacedies.get(key);
                    if (grouped == null) {
                        grouped = new ArrayList<>();
                        groupedEnreplacedies.put(key, grouped);
                        keyOrders.put(index.getAndIncrement(), key);
                    }
                    grouped.add(e);
                });
                Stream<Integer> indexes = keyOrders.keySet().stream().sorted();
                indexes.forEach(i -> {
                    String key = keyOrders.get(i);
                    List<T> grouped = groupedEnreplacedies.get(key);
                    MLabel headerLabel = new MLabel(key).withHeight("-1px").withStyleName(ValoTheme.LABEL_H3);
                    contentLayout.addComponent(new MVerticalLayout(headerLabel));
                    prepareCardList(grouped);
                    MLabel dummyLabel = new MLabel().withHeight("-1px");
                    contentLayout.addComponent(dummyLabel);
                });
            } else {
                prepareCardList(enreplacedies);
                MLabel dummyLabel = new MLabel().withHeight("-1px");
                contentLayout.addComponent(dummyLabel);
            }
        }
    }
}

12 Source : GxMeetingClient.java
with Apache License 2.0
from ijazfx

private Component getRoomComponent() {
    CssLayout roomLayout = new CssLayout();
    roomLayout.setSizeFull();
    Label hostVideo = new Label();
    hostVideo.setSizeFull();
    hostVideo.setContentMode(ContentMode.HTML);
    String hostVideoHtml = "<video id=\"remoteVideo\" width=\"100%\" height=\"100%\" autoplay></video>";
    hostVideo.setValue(hostVideoHtml);
    roomLayout.addComponent(hostVideo);
    Label localVideo = new Label();
    localVideo.setWidthUndefined();
    localVideo.setContentMode(ContentMode.HTML);
    String localVideoHtml = "<video id=\"localVideo\" width=\"200px\" height=\"150px\" autoplay muted></video>";
    localVideo.setValue(localVideoHtml);
    roomLayout.addComponent(localVideo);
    return roomLayout;
}

10 Source : MainUI.java
with Apache License 2.0
from opensecuritycontroller

private void buildLoginForm() {
    addStyleName("login");
    this.loginLayout = new VerticalLayout();
    this.loginLayout.setSizeFull();
    this.loginLayout.addStyleName("login-layout");
    this.root.addComponent(this.loginLayout);
    final CssLayout loginPanel = new CssLayout();
    loginPanel.addStyleName("login-panel");
    HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth("100%");
    labels.setMargin(true);
    labels.addStyleName("labels");
    loginPanel.addComponent(labels);
    Label product = new Label(this.server.getProductName());
    product.addStyleName("product-label-login");
    labels.addComponent(new Image(null, new ThemeResource("img/logo.png")));
    labels.addComponent(product);
    labels.setComponentAlignment(product, Alignment.MIDDLE_LEFT);
    labels.setExpandRatio(product, 1);
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.setMargin(true);
    fields.addStyleName("fields");
    final TextField username = new TextField("Login ID");
    username.focus();
    username.setImmediate(true);
    username.setRequired(true);
    username.setRequiredError("Login ID or Preplacedword cannot be empty");
    fields.addComponent(username);
    final PreplacedwordField preplacedword = new PreplacedwordField("Preplacedword");
    preplacedword.setRequired(true);
    preplacedword.setImmediate(true);
    preplacedword.setRequiredError("Login ID or Preplacedword cannot be empty");
    fields.addComponent(preplacedword);
    final Button login = new Button("Log In");
    login.addStyleName("default");
    fields.addComponent(login);
    fields.setComponentAlignment(login, Alignment.BOTTOM_LEFT);
    final ShortcutListener enter = new ShortcutListener("Login", KeyCode.ENTER, null) {

        @Override
        public void handleAction(Object sender, Object target) {
            login.click();
        }
    };
    login.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                username.validate();
                preplacedword.validate();
                LoginRequest request = new LoginRequest();
                request.setLoginName(username.getValue().trim());
                request.setPreplacedword(preplacedword.getValue());
                LoginResponse response = MainUI.this.loginService.dispatch(request);
                if (response != null) {
                    login.removeShortcutListener(enter);
                    if (getSession() != null) {
                        getSession().setAttribute("user", username.getValue());
                    }
                    MainUI.this.root.removeComponent(MainUI.this.loginLayout);
                    buildMainView();
                }
            } catch (EmptyValueException e) {
                ViewUtil.iscNotification(e.getMessage() + ".", Notification.Type.ERROR_MESSAGE);
                username.focus();
            } catch (Exception e) {
                username.focus();
                ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
            }
        }
    });
    login.addShortcutListener(enter);
    loginPanel.addComponent(fields);
    this.loginLayout.addComponent(loginPanel);
    this.loginLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
}

10 Source : MetroStyleDashboardPanel.java
with Apache License 2.0
from ijazfx

private void generateTiles(CssLayout mainLayout, Collection<TRMenuItem> menuItems) {
    Iterator<TRMenuItem> iter = menuItems.iterator();
    // MHorizontalLayout rowLayout = new MHorizontalLayout();
    Random random = new Random(menuItems.size());
    Random colorRandom = new Random(System.currentTimeMillis());
    Set<Integer> colorUsedSet = new HashSet<>();
    int tileCount = 0;
    int color = 0;
    int maxColors = 8;
    int lastColor = 0;
    while (iter.hasNext()) {
        TRMenuItem menuItem = iter.next();
        MPanel panel = new MPanel();
        Image icon = new Image(null, menuItem.icon());
        // MLabel icon = new MLabel().withStyleName(ValoTheme.LABEL_NO_MARGIN, "tile-icon").withWidthUndefined();
        // icon.setIcon(menuItem.icon());
        icon.setWidth("52px");
        MLabel label = new MLabel(menuItem.caption()).withStyleName(ValoTheme.LABEL_NO_MARGIN, ValoTheme.LABEL_BOLD).withWidthUndefined();
        MVerticalLayout iconLabelLayout = new MVerticalLayout(icon, label).withMargin(true);
        iconLabelLayout.setComponentAlignment(icon, Alignment.TOP_CENTER);
        iconLabelLayout.setComponentAlignment(label, Alignment.BOTTOM_CENTER);
        iconLabelLayout.setExpandRatio(label, 1);
        iconLabelLayout.setHeight("120px");
        panel.setContent(iconLabelLayout);
        panel.addClickListener(event -> {
            if (menuItem.hasChildren()) {
                mainLayout.removeAllComponents();
                List<TRMenuItem> subMenuItems = new ArrayList<>(menuItem.getChildren());
                TRSimpleMenuItem backMenuItem = TRSimpleMenuItem.createMenuItem("Back", GrapheneeTheme.BACK_ICON, event2 -> {
                    mainLayout.removeAllComponents();
                    if (menuItem.getParent() != null) {
                        generateTiles(mainLayout, menuItem.getParent().getChildren());
                    } else {
                        generateTiles(mainLayout, dashboardSetup.menuItems());
                    }
                });
                subMenuItems.add(0, backMenuItem);
                generateTiles(mainLayout, subMenuItems);
            } else {
                if (menuItem.viewName() != null)
                    UI.getCurrent().getNavigator().navigateTo(menuItem.viewName());
                else
                    UI.getCurrent().getNavigator().navigateTo(dashboardSetup.dashboardViewName());
            }
        });
        // random.nextInt(2) + 1;
        int value = 1;
        if (colorUsedSet.size() == maxColors) {
            colorUsedSet.clear();
        }
        do {
            color = colorRandom.nextInt(maxColors) + 1;
        } while (colorUsedSet.contains(color) || color == lastColor);
        colorUsedSet.add(color);
        lastColor = color;
        // if (value + tileCount == 5) {
        // value = 1;
        // }
        // tileCount += value;
        // System.err.print(value + ",");
        panel.setStyleName("metro-tile");
        panel.addStyleName("metro-tile-" + value);
        panel.addStyleName(GrapheneeTheme.STYLE_MARGIN_TOP);
        panel.addStyleName(GrapheneeTheme.STYLE_MARGIN_LEFT);
        panel.setWidth(value == 1 ? "120px" : "250px");
        panel.setHeight("120px");
        if (shouldShowColoredTiles()) {
            panel.addStyleName("color-" + color);
        } else {
            panel.addStyleName("color-default");
        }
        mainLayout.addComponent(panel);
    // rowLayout.add(panel);
    // if (tileCount >= maxTileCount) {
    // mainLayout.add(rowLayout);
    // rowLayout = new MHorizontalLayout();
    // tileCount = 0;
    // // System.err.println();
    // }
    }
// mainLayout.add(rowLayout);
}

7 Source : MTimeField.java
with Apache License 2.0
from ijazfx

@Override
protected Component initContent() {
    CssLayout layout = new CssLayout();
    layout.setCaption(getCaption());
    layout.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    hourComboBox = new ComboBox() {

        public String gereplacedemCaption(Object itemId) {
            return String.format("%02d", itemId);
        }
    };
    hourComboBox.setWidth("60px");
    hourComboBox.setInputPrompt("hh");
    hourComboBox.setStyleName(ValoTheme.COMBOBOX_SMALL);
    hourComboBox.setStyleName(ValoTheme.COMBOBOX_ALIGN_CENTER);
    hourComboBox.addValueChangeListener(event -> {
        if (getValue() != null) {
            Calendar gcal = GregorianCalendar.getInstance();
            gcal.setTime(getValue());
            Integer hour = (Integer) hourComboBox.getValue();
            if (hour == null) {
                gcal.set(Calendar.HOUR_OF_DAY, 0);
            } else {
                gcal.set(Calendar.HOUR_OF_DAY, hour);
            }
            setValue(new Timestamp(gcal.getTime().getTime()));
        }
    });
    minuteComboBox = new ComboBox() {

        public String gereplacedemCaption(Object itemId) {
            return String.format("%02d", itemId);
        }
    };
    minuteComboBox.setWidth("60px");
    minuteComboBox.setInputPrompt("mm");
    minuteComboBox.setStyleName(ValoTheme.COMBOBOX_SMALL);
    minuteComboBox.setStyleName(ValoTheme.COMBOBOX_ALIGN_CENTER);
    minuteComboBox.addValueChangeListener(event -> {
        if (getValue() != null) {
            Calendar gcal = GregorianCalendar.getInstance();
            gcal.setTime(getValue());
            Integer hour = (Integer) minuteComboBox.getValue();
            if (hour == null) {
                gcal.set(Calendar.MINUTE, 0);
            } else {
                gcal.set(Calendar.MINUTE, hour);
            }
            setValue(new Timestamp(gcal.getTime().getTime()));
        }
    });
    secondComboBox = new ComboBox() {

        public String gereplacedemCaption(Object itemId) {
            return String.format("%02d", itemId);
        }
    };
    secondComboBox.setWidth("60px");
    secondComboBox.setInputPrompt("ss");
    secondComboBox.setStyleName(ValoTheme.COMBOBOX_SMALL);
    secondComboBox.setStyleName(ValoTheme.COMBOBOX_ALIGN_CENTER);
    secondComboBox.addValueChangeListener(event -> {
        if (getValue() != null) {
            Calendar gcal = GregorianCalendar.getInstance();
            gcal.setTime(getValue());
            Integer hour = (Integer) secondComboBox.getValue();
            if (hour == null) {
                gcal.set(Calendar.SECOND, 0);
            } else {
                gcal.set(Calendar.SECOND, hour);
            }
            setValue(new Timestamp(gcal.getTime().getTime()));
        }
    });
    for (int i = 0; i < 24; i++) {
        hourComboBox.addItem(i);
    }
    for (int i = 0; i < 60; i += minuteStepSize) {
        minuteComboBox.addItem(i);
    }
    for (int i = 0; i < 60; i += secondStepSize) {
        secondComboBox.addItem(i);
    }
    layout.addComponent(hourComboBox);
    if (resolution == Resolution.MINUTE || resolution == Resolution.SECOND) {
        MLabel label = new MLabel(TIME_SEPARATOR).withWidthUndefined().withContentMode(ContentMode.HTML).withStyleName(ValoTheme.LABEL_BOLD);
        layout.addComponents(label, minuteComboBox);
    }
    if (resolution == Resolution.SECOND) {
        MLabel label = new MLabel(TIME_SEPARATOR).withWidthUndefined().withContentMode(ContentMode.HTML).withStyleName(ValoTheme.LABEL_BOLD);
        layout.addComponents(label, secondComboBox);
    }
    addValueChangeListener(event -> {
        if (getValue() == null) {
            hourComboBox.setValue(null);
            minuteComboBox.setValue(null);
            secondComboBox.setValue(null);
        } else {
            Calendar gcal = GregorianCalendar.getInstance();
            gcal.setTime(getValue());
            hourComboBox.setValue(gcal.get(Calendar.HOUR_OF_DAY));
            int minute = gcal.get(Calendar.MINUTE);
            minute = (minute / minuteStepSize) * minuteStepSize;
            minuteComboBox.setValue(minute);
            int second = gcal.get(Calendar.SECOND);
            second = (second / secondStepSize) * secondStepSize;
            secondComboBox.setValue(second);
        }
    });
    fireValueChange(true);
    return layout;
}