Example usage for com.vaadin.ui HorizontalLayout setHeight

List of usage examples for com.vaadin.ui HorizontalLayout setHeight

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout setHeight.

Prototype

@Override
    public void setHeight(String height) 

Source Link

Usage

From source file:com.mycollab.vaadin.web.ui.StyleCalendarExp.java

License:Open Source License

public StyleCalendarExp() {
    this.setWidth("230px");
    this.setHeightUndefined();
    this.setSpacing(false);
    this.setStyleName("stylecalendar-ext");
    this.setMargin(new MarginInfo(true, false, false, false));

    styleCalendar.setRenderHeader(false);
    styleCalendar.setRenderWeekNumbers(false);
    styleCalendar.setImmediate(true);/*from  w  w  w  .  j  a v a2 s  .  co  m*/
    styleCalendar.setWidth("100%");
    setDateOptionsGenerator();

    btnShowNextYear = new Button();
    btnShowNextYear.setIcon(
            new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_year_next.png")));
    btnShowNextYear.setStyleName(WebThemes.BUTTON_LINK);

    btnShowNextMonth = new Button();
    btnShowNextMonth.setIcon(
            new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_month_next.png")));
    btnShowNextMonth.setStyleName(WebThemes.BUTTON_LINK);

    btnShowPreviousMonth = new Button();
    btnShowPreviousMonth.setIcon(
            new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_month_pre.png")));
    btnShowPreviousMonth.setStyleName(WebThemes.BUTTON_LINK);

    btnShowPreviousYear = new Button();
    btnShowPreviousYear.setIcon(
            new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_year_pre.png")));
    btnShowPreviousYear.setStyleName(WebThemes.BUTTON_LINK);

    lbSelectedDate.setValue(UserUIContext.formatDate(new Date()));
    lbSelectedDate.addStyleName("calendarDateLabel");
    lbSelectedDate.setWidth("80");

    HorizontalLayout layoutControl = new HorizontalLayout();
    layoutControl.setStyleName("calendarHeader");
    layoutControl.setWidth("100%");
    layoutControl.setHeight("35px");

    HorizontalLayout layoutButtonPrevious = new HorizontalLayout();
    layoutButtonPrevious.setSpacing(true);
    layoutButtonPrevious.addComponent(btnShowPreviousYear);
    layoutButtonPrevious.setComponentAlignment(btnShowPreviousYear, Alignment.MIDDLE_LEFT);
    layoutButtonPrevious.addComponent(btnShowPreviousMonth);
    layoutButtonPrevious.setComponentAlignment(btnShowPreviousMonth, Alignment.MIDDLE_LEFT);
    layoutControl.addComponent(layoutButtonPrevious);
    layoutControl.setComponentAlignment(layoutButtonPrevious, Alignment.MIDDLE_LEFT);

    layoutControl.addComponent(lbSelectedDate);
    layoutControl.setComponentAlignment(lbSelectedDate, Alignment.MIDDLE_CENTER);

    MHorizontalLayout layoutButtonNext = new MHorizontalLayout();
    layoutButtonNext.addComponent(btnShowNextMonth);
    layoutButtonNext.setComponentAlignment(btnShowNextMonth, Alignment.MIDDLE_RIGHT);
    layoutButtonNext.addComponent(btnShowNextYear);
    layoutButtonNext.setComponentAlignment(btnShowNextYear, Alignment.MIDDLE_RIGHT);
    layoutControl.addComponent(layoutButtonNext);
    layoutControl.setComponentAlignment(layoutButtonNext, Alignment.MIDDLE_RIGHT);

    this.addComponent(layoutControl);
    this.setComponentAlignment(layoutControl, Alignment.TOP_CENTER);

    this.addComponent(styleCalendar);
    this.setExpandRatio(styleCalendar, 1.0f);
}

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

License:Open Source License

/**
 * Instantiates a new charts dialog.//w  w  w  .  java2  s . c om
 *
 * @param chartsLayout the charts layout
 * @param chartButton the chart button
 */
public ChartsDialog(final ChartsLayout chartsLayout, final ChartButton chartButton) {

    this.chartButton = chartButton;
    this.chartsLayout = chartsLayout;

    dialogWindow = new ModalWindow("Monitors to Chart mapping", "775px");

    HorizontalLayout wrapper = new HorizontalLayout();
    //wrapper.setWidth("100%");
    wrapper.setMargin(true);

    UI.getCurrent().addWindow(dialogWindow);

    newUserChart = (chartButton != null) ? new UserChart((UserChart) chartButton.getData()) : newUserChart();

    ArrayList<String> monitorIDs = newUserChart.getMonitorIDs();
    MonitorsLayout monitorsLayout = new MonitorsLayout(monitorIDs);
    wrapper.addComponent(monitorsLayout);

    VerticalLayout separator = new VerticalLayout();
    separator.setSizeFull();
    Embedded rightArrow = new Embedded(null, new ThemeResource("img/right_arrow.png"));
    separator.addComponent(rightArrow);
    separator.setComponentAlignment(rightArrow, Alignment.MIDDLE_CENTER);
    wrapper.addComponent(separator);

    ChartPreviewLayout chartPreviewLayout = new ChartPreviewLayout(newUserChart, chartsLayout.getTime(),
            chartsLayout.getInterval());
    wrapper.addComponent(chartPreviewLayout);
    monitorsLayout.addChartPreview(chartPreviewLayout);

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Cancel");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            dialogWindow.close();
        }
    });

    Button okButton = new Button(chartButton != null ? "Save Changes" : "Add Chart");
    okButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            try {
                ChartButton newChartButton = new ChartButton(newUserChart);
                newChartButton.setChartsLayout(chartsLayout);
                newChartButton.setEditable(true);
                if (chartButton != null) {
                    chartsLayout.replaceComponent(chartButton, newChartButton);
                } else {
                    chartsLayout.addComponent(newChartButton);
                }

            } catch (Exception e) {
                ManagerUI.error(e.getMessage());
            }

            dialogWindow.close();
        }
    });
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) dialogWindow.getContent();
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(wrapper);
    windowLayout.addComponent(buttonsBar);

}

From source file:com.skysql.manager.ui.components.SystemLayout.java

License:Open Source License

/**
 * Instantiates a new system layout.// w  w w  .j av a  2 s  . c om
 *
 * @param systemRecord the system record
 */
public SystemLayout(SystemRecord systemRecord) {

    addStyleName("systemLayout");
    setWidth(Sizeable.SIZE_UNDEFINED, Sizeable.Unit.PERCENTAGE);
    setMargin(new MarginInfo(false, true, false, false));

    final HorizontalLayout systemHeader = new HorizontalLayout();
    systemHeader.addStyleName("panelHeaderLayout");
    systemHeader.setSpacing(true);
    systemHeader.setWidth("100%");
    systemHeader.setHeight("23px");
    addComponent(systemHeader);

    backButton = new NativeButton();
    backButton.setStyleName("backButton");
    backButton.setDescription("Back to Systems");
    systemHeader.addComponent(backButton);
    backButton.addClickListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {

            VaadinSession session = getSession();
            SystemInfo systemInfo = session.getAttribute(SystemInfo.class);
            OverviewPanel overviewPanel = session.getAttribute(OverviewPanel.class);
            ComponentButton button = systemInfo.getCurrentSystem().getButton();
            String parentID = systemInfo.getCurrentSystem().getParentID();
            systemInfo.setCurrentSystem(parentID);
            session.setAttribute(SystemInfo.class, systemInfo);
            ManagerUI.log("new systemID: " + parentID);
            overviewPanel.clickLayout(button, false);
            overviewPanel.refresh();
        }

    });

    final Label systemLabel = new Label("Systems");
    systemLabel.setSizeUndefined();
    systemHeader.addComponent(systemLabel);
    systemHeader.setComponentAlignment(systemLabel, Alignment.MIDDLE_LEFT);
    systemHeader.setExpandRatio(systemLabel, 1.0f);

    systemSlot = new HorizontalLayout();
    addComponent(systemSlot);

    // initialize System button
    refresh(null, null);

}

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

License:Open Source License

/**
 * Instantiates a new error dialog.//from  w  w w  . j av  a  2 s.c om
 *
 * @param e the exception
 * @param humanizedError the humanized error
 */
public ErrorDialog(Exception e, String humanizedError) {

    if (e != null) {
        ManagerUI.error(e.getMessage());
    }

    dialogWindow = new ModalWindow("An Error has occurred", "775px");
    dialogWindow.setHeight("340px");
    dialogWindow.addCloseListener(this);
    UI current = UI.getCurrent();
    if (current.getContent() == null) {
        current.setContent(new ErrorView(Notification.Type.ERROR_MESSAGE, null));
    }
    current.addWindow(dialogWindow);

    HorizontalLayout wrapper = new HorizontalLayout();
    wrapper.setSizeFull();
    wrapper.setMargin(true);

    VerticalLayout iconLayout = new VerticalLayout();
    iconLayout.setWidth("100px");
    wrapper.addComponent(iconLayout);
    Embedded image = new Embedded(null, new ThemeResource("img/error.png"));
    iconLayout.addComponent(image);

    VerticalLayout textLayout = new VerticalLayout();
    textLayout.setHeight("100%");
    textLayout.setSpacing(true);
    wrapper.addComponent(textLayout);
    wrapper.setExpandRatio(textLayout, 1.0f);

    if (humanizedError != null || e != null) {
        String error = (humanizedError != null) ? humanizedError : e.toString();
        ManagerUI.error(error);
        Label label = new Label(error, ContentMode.HTML);
        label.addStyleName("warning");
        textLayout.addComponent(label);
        textLayout.setComponentAlignment(label, Alignment.TOP_CENTER);
    }

    if (e != null) {
        TextArea stackTrace = new TextArea("Error Log");
        stackTrace.setSizeFull();
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        stackTrace.setValue(sw.toString());
        textLayout.addComponent(stackTrace);
        textLayout.setComponentAlignment(stackTrace, Alignment.TOP_LEFT);
        textLayout.setExpandRatio(stackTrace, 1.0f);
    }

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Close");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            dialogWindow.close();
            //UI.getCurrent().close();
        }
    });

    Button okButton = new Button("Send Error");
    okButton.setEnabled(false);
    okButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            dialogWindow.close();
        }
    });
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) dialogWindow.getContent();
    windowLayout.setHeight("100%");
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(wrapper);
    windowLayout.setExpandRatio(wrapper, 1.0f);
    windowLayout.addComponent(buttonsBar);

}

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

License:Open Source License

/**
 * Monitor form./*  w  w  w .ja  v  a2s  .com*/
 *
 * @param monitor the monitor
 * @param title the title
 * @param description the description
 * @param button the button
 */
public void monitorForm(final MonitorRecord monitor, String title, String description, String button) {
    final TextField monitorName = new TextField("Monitor Name");
    final TextField monitorDescription = new TextField("Description");
    final TextField monitorUnit = new TextField("Measurement Unit");
    final TextArea monitorSQL = new TextArea("SQL Statement");
    final CheckBox monitorDelta = new CheckBox("Is Delta");
    final CheckBox monitorAverage = new CheckBox("Is Average");
    final NativeSelect validationTarget = new NativeSelect("Validate SQL on");
    final NativeSelect monitorInterval = new NativeSelect("Sampling interval");
    final NativeSelect monitorChartType = new NativeSelect("Default display");

    secondaryDialog = new ModalWindow(title, null);
    UI.getCurrent().addWindow(secondaryDialog);
    secondaryDialog.addCloseListener(this);

    final VerticalLayout formContainer = new VerticalLayout();
    formContainer.setMargin(new MarginInfo(true, true, false, true));
    formContainer.setSpacing(false);

    final Form form = new Form();
    formContainer.addComponent(form);
    form.setImmediate(false);
    form.setFooter(null);
    form.setDescription(description);

    String value;

    if ((value = monitor.getName()) != null) {
        monitorName.setValue(value);
    }
    form.addField("monitorName", monitorName);
    form.getField("monitorName").setRequired(true);
    form.getField("monitorName").setRequiredError("Monitor Name is missing");
    monitorName.focus();
    monitorName.setImmediate(true);
    monitorName.addValidator(new MonitorNameValidator(monitor.getName()));

    if ((value = monitor.getDescription()) != null) {
        monitorDescription.setValue(value);
    }
    monitorDescription.setWidth("24em");
    form.addField("monitorDescription", monitorDescription);

    if ((value = monitor.getUnit()) != null) {
        monitorUnit.setValue(value);
    }
    form.addField("monitorUnit", monitorUnit);

    if ((value = monitor.getSql()) != null) {
        monitorSQL.setValue(value);
    }
    monitorSQL.setWidth("24em");
    monitorSQL.addValidator(new SQLValidator());
    form.addField("monitorSQL", monitorSQL);

    final String noValidation = "None - Skip Validation";
    validationTarget.setImmediate(true);
    validationTarget.setNullSelectionAllowed(false);
    validationTarget.addItem(noValidation);
    validationTarget.select(noValidation);
    OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class);
    ArrayList<NodeInfo> nodes = overviewPanel.getNodes();

    if (nodes == null || nodes.isEmpty()) {
        SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class);
        String systemID = systemInfo.getCurrentID();
        String systemType = systemInfo.getCurrentSystem().getSystemType();
        if (systemID.equals(SystemInfo.SYSTEM_ROOT)) {
            ClusterComponent clusterComponent = VaadinSession.getCurrent().getAttribute(ClusterComponent.class);
            systemID = clusterComponent.getID();
            systemType = clusterComponent.getSystemType();
        }
        nodes = new ArrayList<NodeInfo>();
        for (String nodeID : systemInfo.getSystemRecord(systemID).getNodes()) {
            NodeInfo nodeInfo = new NodeInfo(systemID, systemType, nodeID);
            nodes.add(nodeInfo);
        }

    }

    for (NodeInfo node : nodes) {
        validationTarget.addItem(node.getID());
        validationTarget.setItemCaption(node.getID(), node.getName());
    }
    validationTarget.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void valueChange(ValueChangeEvent event) {
            nodeID = (String) event.getProperty().getValue();
            validateSQL = nodeID.equals(noValidation) ? false : true;
        }

    });
    form.addField("validationTarget", validationTarget);

    monitorDelta.setValue(monitor.isDelta());
    form.addField("monitorDelta", monitorDelta);

    monitorAverage.setValue(monitor.isAverage());
    form.addField("monitorAverage", monitorAverage);

    SettingsValues intervalValues = new SettingsValues(SettingsValues.SETTINGS_MONITOR_INTERVAL);
    String[] intervals = intervalValues.getValues();
    for (String interval : intervals) {
        monitorInterval.addItem(Integer.parseInt(interval));
    }

    Collection<?> validIntervals = monitorInterval.getItemIds();
    if (validIntervals.contains(monitor.getInterval())) {
        monitorInterval.select(monitor.getInterval());
    } else {
        SystemInfo systemInfo = getSession().getAttribute(SystemInfo.class);
        String defaultInterval = systemInfo.getSystemRecord(systemID).getProperties()
                .get(SystemInfo.PROPERTY_DEFAULTMONITORINTERVAL);
        if (defaultInterval != null && validIntervals.contains(Integer.parseInt(defaultInterval))) {
            monitorInterval.select(Integer.parseInt(defaultInterval));
        } else if (!validIntervals.isEmpty()) {
            monitorInterval.select(validIntervals.toArray()[0]);
        } else {
            new ErrorDialog(null, "No set of permissible monitor intervals found");
        }

        monitorInterval.setNullSelectionAllowed(false);
        form.addField("monitorInterval", monitorInterval);
    }

    for (UserChart.ChartType type : UserChart.ChartType.values()) {
        monitorChartType.addItem(type.name());
    }
    monitorChartType
            .select(monitor.getChartType() == null ? UserChart.ChartType.values()[0] : monitor.getChartType());
    monitorChartType.setNullSelectionAllowed(false);
    form.addField("monitorChartType", monitorChartType);

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Cancel");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            form.discard();
            secondaryDialog.close();
        }
    });

    Button okButton = new Button(button);
    okButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            try {
                form.setComponentError(null);
                form.commit();
                monitor.setName(monitorName.getValue());
                monitor.setDescription(monitorDescription.getValue());
                monitor.setUnit(monitorUnit.getValue());
                monitor.setSql(monitorSQL.getValue());
                monitor.setDelta(monitorDelta.getValue());
                monitor.setAverage(monitorAverage.getValue());
                monitor.setInterval((Integer) monitorInterval.getValue());
                monitor.setChartType((String) monitorChartType.getValue());
                String ID;
                if ((ID = monitor.getID()) == null) {
                    if (Monitors.setMonitor(monitor)) {
                        ID = monitor.getID();
                        select.addItem(ID);
                        select.select(ID);
                        Monitors.reloadMonitors();
                        monitorsAll = Monitors.getMonitorsList(systemType);
                    }
                } else {
                    Monitors.setMonitor(monitor);
                    ChartProperties chartProperties = getSession().getAttribute(ChartProperties.class);
                    chartProperties.setDirty(true);
                    settingsDialog.setRefresh(true);
                }

                if (ID != null) {
                    select.setItemCaption(ID, monitor.getName());
                    displayMonitorRecord(ID);
                    secondaryDialog.close();
                }

            } catch (EmptyValueException e) {
                return;
            } catch (InvalidValueException e) {
                return;
            } catch (Exception e) {
                ManagerUI.error(e.getMessage());
                return;
            }
        }
    });
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) secondaryDialog.getContent();
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(formContainer);
    windowLayout.addComponent(buttonsBar);

}

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

License:Open Source License

/**
 * Removes the user./* www  . j  a  v a 2s  .  c  o  m*/
 *
 * @param event the event
 */
public void removeUser(Button.ClickEvent event) {
    secondaryDialog = new ModalWindow("Delete User", null);
    UI.getCurrent().addWindow(secondaryDialog);
    secondaryDialog.addCloseListener(this);

    final VerticalLayout formContainer = new VerticalLayout();
    formContainer.setMargin(new MarginInfo(true, true, false, true));
    formContainer.setSpacing(false);

    final Form form = new Form();
    formContainer.addComponent(form);
    form.setFooter(null);
    form.setDescription("Delete user " + userInfo.completeNamesByID(selectedUserID) + " from the system");

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Cancel");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            form.discard();
            secondaryDialog.close();
        }
    });

    Button okButton = new Button("Delete User");
    okButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            try {
                form.setComponentError(null);
                form.commit();
                boolean success = userInfo.deleteUser(selectedUserID);
                if (success) {
                    select.removeItem(selectedUserID);
                } else {
                    return;
                }
            } catch (EmptyValueException e) {
                return;
            } catch (Exception e) {
                ManagerUI.error(e.getMessage());
                return;
            }
            secondaryDialog.close();
        }
    });
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) secondaryDialog.getContent();
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(formContainer);
    windowLayout.addComponent(buttonsBar);

}

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

License:Open Source License

/**
 * Instantiates a new warning window.//from w ww . ja v a 2  s .com
 *
 * @param caption the caption
 * @param message the message
 * @param label the label
 * @param okListener the ok listener
 */
public WarningWindow(String caption, String message, String label, Button.ClickListener okListener) {
    super(caption, "60%");

    HorizontalLayout wrapper = new HorizontalLayout();
    wrapper.setWidth("100%");
    wrapper.setMargin(true);
    VerticalLayout iconLayout = new VerticalLayout();
    iconLayout.setWidth("100px");
    wrapper.addComponent(iconLayout);
    Embedded image = new Embedded(null, new ThemeResource("img/warning.png"));
    iconLayout.addComponent(image);
    VerticalLayout textLayout = new VerticalLayout();
    textLayout.setSizeFull();
    wrapper.addComponent(textLayout);
    wrapper.setExpandRatio(textLayout, 1.0f);

    Label msgLabel = new Label(message);
    msgLabel.addStyleName("warning");
    textLayout.addComponent(msgLabel);
    textLayout.setComponentAlignment(msgLabel, Alignment.MIDDLE_CENTER);

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Cancel");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(Button.ClickEvent event) {
            warningWindow.close();
        }
    });

    Button okButton = new Button(label);
    okButton.addClickListener(okListener);
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) this.getContent();
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(wrapper);
    windowLayout.addComponent(buttonsBar);

}

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

public static HorizontalLayout createDateLayout(ChatMessage mess) {
    HorizontalLayout dateLayout = new HorizontalLayout();
    Label dateLabel = new Label(mess.getFormattedDate());
    dateLabel.addStyleName("dateLabel");
    dateLayout.addComponent(dateLabel);/* w w  w .  j  a va2 s .  c o  m*/
    dateLayout.setWidth("100px");
    dateLayout.setHeight("50px");
    return dateLayout;
}

From source file:com.squadd.UI.MenuLayout.java

private void configureLayout() {
    //AWT toolkit doesn't want to work so there are hardcoded screen variables
    HorizontalLayout zLa = new HorizontalLayout();
    VerticalLayout panels = new VerticalLayout(mainPagePanel, groupsPanel, messagesPanel);
    panels.setWidth(0.1 * Display.width + "px");
    zLa.setWidth(0.1 * Display.width + "px");
    zLa.setHeight(0.2 * Display.height + "px");

    this.setMargin(false);
    this.setSpacing(false);
    addComponents(zLa, panels);/*from w w w.j  a v a  2 s.  c o m*/
}

From source file:com.zklogtool.web.components.OpenSnapshotFileDialog.java

License:Apache License

public OpenSnapshotFileDialog(final TabSheet displayTabSheet, final Window windowHandle) {

    buildMainLayout();/* ww  w.  j a v a 2 s.  co m*/
    setCompositionRoot(mainLayout);

    openButton.addClickListener(new ClickListener() {

        DataState dataState;

        @Override
        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {

            File snapshot = new File(snapshotFileLabel.getValue());

            SnapshotFileReader snapReader = new SnapshotFileReader(snapshot, 0);

            SnapshotView snapshotView;

            if (!validateInputs()) {
                return;
            }

            try {

                dataState = snapReader.readFuzzySnapshot();

                snapshotView = new SnapshotView(dataState);

            } catch (CRCValidationException e) {

                snapshotFileLabel
                        .setComponentError(new UserError("CRC validation problem. File is probably corrupted"));
                return;

            } catch (IOException e) {

                snapshotFileLabel.setComponentError(new UserError("IO problem with file"));
                return;

            }

            HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setCaption(tabNameLabel.getValue());
            horizontalLayout.addComponent(snapshotView);
            horizontalLayout.setWidth("100%");
            horizontalLayout.setHeight("100%");
            Tab snapshotTab = displayTabSheet.addTab(horizontalLayout);
            snapshotTab.setClosable(true);
            displayTabSheet.setSelectedTab(snapshotTab);

            windowHandle.close();

        }

    });

}