Example usage for com.vaadin.ui VerticalLayout addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:org.opennms.features.topology.app.internal.ui.icons.IconSelectionDialog.java

License:Open Source License

public IconSelectionDialog(String selectedIconId) {
    setCaption("Change Icon");
    setModal(true);//from ww  w  .ja v  a 2s  .  c om
    setResizable(false);
    setClosable(false);
    setWidth(700, Unit.PIXELS);
    setHeight(600, Sizeable.Unit.PIXELS);
    addCloseListener(this);

    okButton = new Button("Ok", this);
    okButton.setId("iconSelectionDialog.button.ok");
    cancelButton = new Button("Cancel", this);
    cancelButton.setId("iconSelectionDialog.button.cancel");

    iconSelectionComponent = new IconSelectionComponent(getElementsToShow(), selectedIconId);
    VerticalLayout iconLayout = new VerticalLayout();
    iconLayout.addStyleName("icon-selection-component");
    iconLayout.setSpacing(true);
    iconLayout.setSizeFull();
    iconLayout.addComponent(iconSelectionComponent);

    final HorizontalLayout buttonLayout = new HorizontalLayout(okButton, cancelButton);
    buttonLayout.setSpacing(true);

    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSpacing(true);
    mainLayout.setMargin(true);
    mainLayout.setSizeFull();
    mainLayout.addComponent(iconLayout);
    mainLayout.addComponent(buttonLayout);
    mainLayout.setExpandRatio(iconLayout, 1);
    mainLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);

    setContent(mainLayout);
    center();
}

From source file:org.opennms.features.topology.app.internal.ui.ToolbarPanel.java

License:Open Source License

private void handleLayerButton(GraphContainer graphContainer) {
    // Toggle layer button
    boolean enableLayerButton = graphContainer.getMetaTopologyProvider().getGraphProviders().size() > 1;
    layerButton.setEnabled(enableLayerButton);

    // update the layer layout
    layerLayout.removeAllComponents();//from  w w w.j  a  v a  2s.  c o m
    if (enableLayerButton) {
        graphContainer.getMetaTopologyProvider().getGraphProviders().forEach(topologyProvider -> {
            boolean selected = topologyProvider.getVertexNamespace()
                    .equals(graphContainer.getBaseTopology().getVertexNamespace());
            final TopologyProviderInfo topologyProviderInfo = topologyProvider.getTopologyProviderInfo();

            final Label nameLabel = new Label(topologyProviderInfo.getName());
            VerticalLayout verticalLayout = new VerticalLayout();
            verticalLayout.addComponent(nameLabel);
            verticalLayout.addStyleName(Styles.LAYOUT);
            if (selected) {
                verticalLayout.addStyleName(Styles.SELECTED);
            }
            verticalLayout.addLayoutClickListener((event) -> graphContainer
                    .selectTopologyProvider(topologyProvider, Callbacks.applyDefaults()));
            layerLayout.addComponent(verticalLayout);
        });
    } else {
        setLayerLayoutVisible(false);
    }
}

From source file:org.opennms.features.vaadin.dashboard.dashlets.KscDashlet.java

License:Open Source License

@Override
public DashletComponent getWallboardComponent() {
    if (m_wallboardComponent == null) {
        m_wallboardComponent = new AbstractDashletComponent() {
            private GridLayout m_gridLayout = new GridLayout();

            {//from w  w w .j  a  va  2  s  .co m
                m_gridLayout.setCaption(getName());
                m_gridLayout.setSizeFull();
                m_gridLayout.setColumns(1);
                m_gridLayout.setRows(1);
            }

            @Override
            public void refresh() {
                m_gridLayout.removeAllComponents();

                /**
                 * initializing the parameters
                 */
                int columns = 0;
                int rows = 0;

                String kscReportName = getDashletSpec().getParameters().get("kscReport");

                if (kscReportName == null || "".equals(kscReportName)) {
                    return;
                }

                KSC_PerformanceReportFactory kscPerformanceReportFactory = KSC_PerformanceReportFactory
                        .getInstance();

                Map<Integer, String> reportsMap = kscPerformanceReportFactory.getReportList();

                int kscReportId = -1;

                for (Map.Entry<Integer, String> entry : reportsMap.entrySet()) {

                    if (kscReportName.equals(entry.getValue())) {
                        kscReportId = entry.getKey();
                        break;
                    }
                }

                if (kscReportId == -1) {
                    return;
                }

                Report kscReport = kscPerformanceReportFactory.getReportByIndex(kscReportId);

                columns = kscReport.getGraphs_per_line();

                if (columns == 0) {
                    columns = 1;
                }

                rows = kscReport.getGraphCount() / columns;

                if (rows == 0) {
                    rows = 1;
                }

                if (kscReport.getGraphCount() % columns > 0) {
                    rows++;
                }

                /**
                 * setting new columns/rows
                 */
                m_gridLayout.setColumns(columns);
                m_gridLayout.setRows(rows);

                int i = 0;

                /**
                 * adding the components
                 */

                Page.getCurrent().getStyles().add(
                        ".box { margin: 5px; background-color: #444; border: 1px solid #999; border-top: 0; overflow: auto; }");
                Page.getCurrent().getStyles().add(
                        ".text { color:#ffffff; line-height: 11px; font-size: 9px; font-family: 'Lucida Grande', Verdana, sans-serif; font-weight: bold; }");
                Page.getCurrent().getStyles().add(".margin { margin:5px; }");

                for (int y = 0; y < m_gridLayout.getRows(); y++) {
                    for (int x = 0; x < m_gridLayout.getColumns(); x++) {

                        if (i < kscReport.getGraphCount()) {
                            Graph graph = kscReport.getGraph(i);

                            Map<String, String> data = getDataForResourceId(graph.getNodeId(),
                                    graph.getResourceId());

                            Calendar beginTime = Calendar.getInstance();
                            Calendar endTime = Calendar.getInstance();

                            KSC_PerformanceReportFactory.getBeginEndTime(graph.getTimespan(), beginTime,
                                    endTime);

                            GraphContainer graphContainer = getGraphContainer(graph, beginTime.getTime(),
                                    endTime.getTime());

                            VerticalLayout verticalLayout = new VerticalLayout();

                            HorizontalLayout horizontalLayout = new HorizontalLayout();
                            horizontalLayout.addStyleName("box");
                            horizontalLayout.setWidth("100%");
                            horizontalLayout.setHeight("42px");

                            VerticalLayout leftLayout = new VerticalLayout();
                            leftLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
                            leftLayout.addStyleName("margin");

                            Label labelTitle;

                            if (graph.getTitle() == null || "".equals(graph.getTitle())) {
                                labelTitle = new Label("&nbsp;");
                                labelTitle.setContentMode(ContentMode.HTML);
                            } else {
                                labelTitle = new Label(graph.getTitle());
                            }

                            labelTitle.addStyleName("text");

                            Label labelFrom = new Label("From: " + beginTime.getTime().toString());
                            labelFrom.addStyleName("text");

                            Label labelTo = new Label("To: " + endTime.getTime().toString());
                            labelTo.addStyleName("text");

                            Label labelNodeLabel = new Label(data.get("nodeLabel"));
                            labelNodeLabel.addStyleName("text");

                            Label labelResourceLabel = new Label(
                                    data.get("resourceTypeLabel") + ": " + data.get("resourceLabel"));
                            labelResourceLabel.addStyleName("text");

                            leftLayout.addComponent(labelTitle);
                            leftLayout.addComponent(labelFrom);
                            leftLayout.addComponent(labelTo);

                            VerticalLayout rightLayout = new VerticalLayout();
                            rightLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
                            rightLayout.addStyleName("margin");

                            rightLayout.addComponent(labelNodeLabel);
                            rightLayout.addComponent(labelResourceLabel);

                            horizontalLayout.addComponent(leftLayout);
                            horizontalLayout.addComponent(rightLayout);

                            horizontalLayout.setExpandRatio(leftLayout, 1.0f);
                            horizontalLayout.setExpandRatio(rightLayout, 1.0f);

                            verticalLayout.addComponent(horizontalLayout);
                            verticalLayout.addComponent(graphContainer);
                            verticalLayout.setWidth(DEFAULT_GRAPH_WIDTH_PX, Unit.PIXELS);

                            m_gridLayout.addComponent(verticalLayout, x, y);

                            verticalLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER);
                            verticalLayout.setComponentAlignment(graphContainer, Alignment.MIDDLE_CENTER);
                            m_gridLayout.setComponentAlignment(verticalLayout, Alignment.MIDDLE_CENTER);
                        }
                        i++;
                    }
                }
            }

            @Override
            public Component getComponent() {
                return m_gridLayout;
            }
        };
    }

    return m_wallboardComponent;
}

From source file:org.opennms.features.vaadin.dashboard.dashlets.KscDashlet.java

License:Open Source License

@Override
public DashletComponent getDashboardComponent() {
    if (m_dashboardComponent == null) {
        m_dashboardComponent = new AbstractDashletComponent() {
            private VerticalLayout m_verticalLayout = new VerticalLayout();

            {/* w w w .ja  va2s  .c  o m*/
                m_verticalLayout.setCaption(getName());
                m_verticalLayout.setSizeFull();
            }

            @Override
            public void refresh() {
                m_verticalLayout.removeAllComponents();

                String kscReportName = getDashletSpec().getParameters().get("kscReport");

                if (kscReportName == null || "".equals(kscReportName)) {
                    return;
                }

                KSC_PerformanceReportFactory kscPerformanceReportFactory = KSC_PerformanceReportFactory
                        .getInstance();

                Map<Integer, String> reportsMap = kscPerformanceReportFactory.getReportList();

                int kscReportId = -1;

                for (Map.Entry<Integer, String> entry : reportsMap.entrySet()) {

                    if (kscReportName.equals(entry.getValue())) {
                        kscReportId = entry.getKey();
                        break;
                    }
                }

                if (kscReportId == -1) {
                    return;
                }

                Report kscReport = kscPerformanceReportFactory.getReportByIndex(kscReportId);

                Page.getCurrent().getStyles().add(
                        ".box { margin: 5px; background-color: #444; border: 1px solid #999; border-top: 0; overflow: auto; }");
                Page.getCurrent().getStyles().add(
                        ".text { color:#ffffff; line-height: 11px; font-size: 9px; font-family: 'Lucida Grande', Verdana, sans-serif; font-weight: bold; }");
                Page.getCurrent().getStyles().add(".margin { margin:5px; }");

                Accordion accordion = new Accordion();
                accordion.setSizeFull();
                m_verticalLayout.addComponent(accordion);

                for (Graph graph : kscReport.getGraph()) {
                    Map<String, String> data = getDataForResourceId(graph.getNodeId(), graph.getResourceId());

                    Calendar beginTime = Calendar.getInstance();
                    Calendar endTime = Calendar.getInstance();

                    KSC_PerformanceReportFactory.getBeginEndTime(graph.getTimespan(), beginTime, endTime);

                    GraphContainer graphContainer = getGraphContainer(graph, beginTime.getTime(),
                            endTime.getTime());

                    VerticalLayout verticalLayout = new VerticalLayout();

                    HorizontalLayout horizontalLayout = new HorizontalLayout();
                    horizontalLayout.addStyleName("box");
                    horizontalLayout.setWidth("100%");
                    horizontalLayout.setHeight("42px");

                    VerticalLayout leftLayout = new VerticalLayout();
                    leftLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
                    leftLayout.addStyleName("margin");

                    Label labelTitle;

                    if (graph.getTitle() == null || "".equals(graph.getTitle())) {
                        labelTitle = new Label("&nbsp;");
                        labelTitle.setContentMode(ContentMode.HTML);
                    } else {
                        labelTitle = new Label(graph.getTitle());
                    }

                    labelTitle.addStyleName("text");

                    Label labelFrom = new Label("From: " + beginTime.getTime().toString());
                    labelFrom.addStyleName("text");

                    Label labelTo = new Label("To: " + endTime.getTime().toString());
                    labelTo.addStyleName("text");

                    Label labelNodeLabel = new Label(data.get("nodeLabel"));
                    labelNodeLabel.addStyleName("text");

                    Label labelResourceLabel = new Label(
                            data.get("resourceTypeLabel") + ": " + data.get("resourceLabel"));
                    labelResourceLabel.addStyleName("text");

                    leftLayout.addComponent(labelTitle);
                    leftLayout.addComponent(labelFrom);
                    leftLayout.addComponent(labelTo);

                    VerticalLayout rightLayout = new VerticalLayout();
                    rightLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
                    rightLayout.addStyleName("margin");

                    rightLayout.addComponent(labelNodeLabel);
                    rightLayout.addComponent(labelResourceLabel);

                    horizontalLayout.addComponent(leftLayout);
                    horizontalLayout.addComponent(rightLayout);

                    horizontalLayout.setExpandRatio(leftLayout, 1.0f);
                    horizontalLayout.setExpandRatio(rightLayout, 1.0f);

                    verticalLayout.addComponent(horizontalLayout);
                    verticalLayout.addComponent(graphContainer);
                    verticalLayout.setWidth(DEFAULT_GRAPH_WIDTH_PX, Unit.PIXELS);

                    accordion.addTab(verticalLayout, data.get("nodeLabel") + "/" + data.get("resourceTypeLabel")
                            + ": " + data.get("resourceLabel"));

                    verticalLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER);
                    verticalLayout.setComponentAlignment(graphContainer, Alignment.MIDDLE_CENTER);
                    verticalLayout.setMargin(true);
                }
            }

            @Override
            public Component getComponent() {
                return m_verticalLayout;
            }
        };
    }

    return m_dashboardComponent;
}

From source file:org.opennms.features.vaadin.dashboard.dashlets.RrdDashlet.java

License:Open Source License

/**
 * Returns the graph component for a given graph of the {@link DashletSpec}.
 *
 * @param i              the entry id//from   w w  w  .j ava 2  s  .  c o  m
 * @param width          the width
 * @param height         the height
 * @param timeFrameType  the timeframe type
 * @param timeFrameValue the timeframe value
 * @return the component
 */
private Component getGraphComponent(int i, int width, int height, int timeFrameType, int timeFrameValue) {
    String graphTitle = getDashletSpec().getParameters().get("graphLabel" + i);
    String graphName = RrdGraphHelper
            .getGraphNameFromQuery(getDashletSpec().getParameters().get("graphUrl" + i));
    String resourceId = getDashletSpec().getParameters().get("resourceId" + i);

    GraphContainer graph = new GraphContainer(graphName, resourceId);
    graph.setTitle(graphTitle);
    // Setup the time span
    Calendar cal = new GregorianCalendar();
    graph.setEnd(cal.getTime());
    cal.add(timeFrameType, -timeFrameValue);
    graph.setStart(cal.getTime());
    // Use all of the available width
    graph.setWidthRatio(1.0d);

    VerticalLayout verticalLayout = new VerticalLayout();

    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.addStyleName("box");
    horizontalLayout.setWidth("100%");
    horizontalLayout.setHeight("42px");

    VerticalLayout leftLayout = new VerticalLayout();
    leftLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    leftLayout.addStyleName("margin");

    Label labelFrom = new Label(getDashletSpec().getParameters().get("nodeLabel" + i));
    labelFrom.addStyleName("text");

    Label labelTo = new Label(getDashletSpec().getParameters().get("resourceTypeLabel" + i) + ": "
            + getDashletSpec().getParameters().get("resourceLabel" + i));
    labelTo.addStyleName("text");

    leftLayout.addComponent(labelFrom);
    leftLayout.addComponent(labelTo);

    horizontalLayout.addComponent(leftLayout);
    horizontalLayout.setExpandRatio(leftLayout, 1.0f);

    verticalLayout.addComponent(horizontalLayout);
    verticalLayout.addComponent(graph);
    verticalLayout.setWidth(width, Unit.PIXELS);

    verticalLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER);
    verticalLayout.setComponentAlignment(graph, Alignment.MIDDLE_CENTER);
    verticalLayout.setMargin(true);

    return verticalLayout;
}

From source file:org.opennms.features.vaadin.dashboard.dashlets.SummaryDashlet.java

License:Open Source License

/**
 * Returns the component showing the alarms and the trends by severity
 *
 * @return the {@link Component}// w  ww  .  j a  v a  2  s .com
 */
private Component getComponentSeverity(int width) {
    VerticalLayout verticalLayout = new VerticalLayout();

    int overallSum = 0;
    int severitySum = 0;

    verticalLayout.addComponent(getLegend("Severity"));

    for (OnmsSeverity onmsSeverity : OnmsSeverity.values()) {
        HorizontalLayout horizontalLayout = new HorizontalLayout();
        horizontalLayout.setSpacing(true);
        horizontalLayout.addStyleName("summary");
        horizontalLayout.addStyleName(onmsSeverity.name().toLowerCase());

        int acknowledged = countBySeverity(true, m_timeslot, onmsSeverity);
        int notAcknowledged = countBySeverity(false, m_timeslot, onmsSeverity);

        Label labelSeverity = new Label(onmsSeverity.getLabel());
        labelSeverity.addStyleName("summary-font");
        Label labelAcknowledge = new Label(String.valueOf(acknowledged));
        labelAcknowledge.addStyleName("summary-font");
        Label labelNotAcknowledged = new Label(String.valueOf(notAcknowledged));
        labelNotAcknowledged.addStyleName("summary-font");

        horizontalLayout.addComponent(labelSeverity);
        horizontalLayout.addComponent(labelAcknowledge);
        horizontalLayout.addComponent(labelNotAcknowledged);

        int status = computeTrend(acknowledged, notAcknowledged);

        severitySum += onmsSeverity.getId();
        overallSum += onmsSeverity.getId() * status;

        Image image = new Image(null, new ThemeResource("img/a" + status + ".png"));
        image.setWidth(width, Sizeable.Unit.PIXELS);
        horizontalLayout.addComponent(image);

        horizontalLayout.setExpandRatio(labelSeverity, 4.0f);
        horizontalLayout.setExpandRatio(labelAcknowledge, 1.0f);
        horizontalLayout.setExpandRatio(labelNotAcknowledged, 1.0f);
        horizontalLayout.setExpandRatio(image, 1.0f);

        horizontalLayout.setComponentAlignment(image, Alignment.TOP_CENTER);

        horizontalLayout.setWidth(375, Sizeable.Unit.PIXELS);
        verticalLayout.addComponent(horizontalLayout);
    }

    int globalTrend = (int) Math.max(0,
            Math.min(4, Math.round(((double) overallSum) / ((double) severitySum))));

    Image image = new Image(null, new ThemeResource("img/a" + globalTrend + ".png"));
    image.setWidth(width * 8, Sizeable.Unit.PIXELS);

    VerticalLayout globalTrendLayout = new VerticalLayout();
    globalTrendLayout.setSpacing(true);
    globalTrendLayout.addStyleName("summary");
    globalTrendLayout.addStyleName("global");
    globalTrendLayout.setSizeFull();

    Label labelTitle = new Label("Alarms trend by severity");
    labelTitle.addStyleName("summary-font");
    labelTitle.setSizeUndefined();

    Label labelTimeslot = new Label("(" + getHumanReadableFormat(m_timeslot) + ")");
    labelTimeslot.addStyleName("summary-font");
    labelTimeslot.setSizeUndefined();

    globalTrendLayout.addComponent(labelTitle);
    globalTrendLayout.addComponent(labelTimeslot);
    globalTrendLayout.addComponent(image);

    globalTrendLayout.setWidth(375, Sizeable.Unit.PIXELS);

    globalTrendLayout.setComponentAlignment(labelTitle, Alignment.MIDDLE_CENTER);
    globalTrendLayout.setComponentAlignment(labelTimeslot, Alignment.MIDDLE_CENTER);
    globalTrendLayout.setComponentAlignment(image, Alignment.MIDDLE_CENTER);

    globalTrendLayout.setExpandRatio(labelTitle, 1.0f);

    verticalLayout.addComponent(globalTrendLayout, 0);

    m_boosted = (globalTrend > 2);

    return verticalLayout;
}

From source file:org.opennms.features.vaadin.dashboard.dashlets.SummaryDashlet.java

License:Open Source License

/**
 * Returns the component showing the alarms and the trends by severity
 *
 * @return the {@link Component}/* www  .j  a  va  2  s.c  o  m*/
 */
private Component getComponentUei(int width) {
    VerticalLayout verticalLayout = new VerticalLayout();

    int overallSum = 0;
    int severitySum = 0;

    verticalLayout.addComponent(getLegend("UEI"));

    String[] ueis = { "uei.opennms.org/nodes/nodeLostService", "uei.opennms.org/nodes/interfaceDown",
            "uei.opennms.org/nodes/nodeDown" };

    for (int i = 0; i < ueis.length; i++) {
        String uei = ueis[i];
        HorizontalLayout horizontalLayout = new HorizontalLayout();
        horizontalLayout.setSpacing(true);
        horizontalLayout.addStyleName("summary");

        if (i == 0) {
            horizontalLayout.addStyleName(OnmsSeverity.MINOR.name().toLowerCase());
        } else {
            if (i == 1) {
                horizontalLayout.addStyleName(OnmsSeverity.MINOR.name().toLowerCase());
            } else {
                horizontalLayout.addStyleName(OnmsSeverity.MAJOR.name().toLowerCase());
            }
        }

        int acknowledged = countByUei(true, m_timeslot, uei);
        int notAcknowledged = countByUei(false, m_timeslot, uei);

        Label labelSeverity = new Label(uei.replace("uei.opennms.org/nodes/", ""));
        labelSeverity.addStyleName("summary-font");
        Label labelAcknowledge = new Label(String.valueOf(acknowledged));
        labelAcknowledge.addStyleName("summary-font");
        Label labelNotAcknowledged = new Label(String.valueOf(notAcknowledged));
        labelNotAcknowledged.addStyleName("summary-font");

        horizontalLayout.addComponent(labelSeverity);
        horizontalLayout.addComponent(labelAcknowledge);
        horizontalLayout.addComponent(labelNotAcknowledged);

        int status = computeTrend(acknowledged, notAcknowledged);

        severitySum += i;
        overallSum += i * status;

        Image image = new Image(null, new ThemeResource("img/a" + status + ".png"));
        image.setWidth(width, Sizeable.Unit.PIXELS);
        horizontalLayout.addComponent(image);

        horizontalLayout.setExpandRatio(labelSeverity, 4.0f);
        horizontalLayout.setExpandRatio(labelAcknowledge, 1.0f);
        horizontalLayout.setExpandRatio(labelNotAcknowledged, 1.0f);
        horizontalLayout.setExpandRatio(image, 1.0f);

        horizontalLayout.setComponentAlignment(image, Alignment.TOP_CENTER);

        horizontalLayout.setWidth(375, Sizeable.Unit.PIXELS);
        verticalLayout.addComponent(horizontalLayout);
    }

    int globalTrend = (int) Math.max(0,
            Math.min(4, Math.round(((double) overallSum) / ((double) severitySum))));

    Image image = new Image(null, new ThemeResource("img/a" + globalTrend + ".png"));
    image.setWidth(width * 8, Sizeable.Unit.PIXELS);

    VerticalLayout globalTrendLayout = new VerticalLayout();
    globalTrendLayout.setSpacing(true);
    globalTrendLayout.addStyleName("summary");
    globalTrendLayout.addStyleName("global");
    globalTrendLayout.setSizeFull();

    Label labelTitle = new Label("Alarms trend by UEI");
    labelTitle.addStyleName("summary-font");
    labelTitle.setSizeUndefined();

    Label labelTimeslot = new Label("(" + getHumanReadableFormat(m_timeslot) + ")");
    labelTimeslot.addStyleName("summary-font");
    labelTimeslot.setSizeUndefined();

    globalTrendLayout.addComponent(labelTitle);
    globalTrendLayout.addComponent(labelTimeslot);
    globalTrendLayout.addComponent(image);

    globalTrendLayout.setWidth(375, Sizeable.Unit.PIXELS);

    globalTrendLayout.setComponentAlignment(labelTitle, Alignment.MIDDLE_CENTER);
    globalTrendLayout.setComponentAlignment(labelTimeslot, Alignment.MIDDLE_CENTER);
    globalTrendLayout.setComponentAlignment(image, Alignment.MIDDLE_CENTER);

    globalTrendLayout.setExpandRatio(labelTitle, 1.0f);

    verticalLayout.addComponent(globalTrendLayout, 0);

    m_boosted = (globalTrend > 2);

    return verticalLayout;
}

From source file:org.vaadin.alump.offlinebuilder.demo.DemoUI.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {

    OfflineUIExtension offlineExtension = OfflineUIExtension.get(this);

    // As Panel is half legacy component, using OfflineCssLayout to make content scrollable
    OfflineCssLayout panel = new OfflineCssLayout();
    panel.addStyleName("scrollable-wrapper");
    panel.setSizeFull();//w w w .j  a v a2 s .c  om
    setContent(panel);
    offlineExtension.setOfflineRoot(panel);

    VerticalLayout layout = new OfflineVerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.addStyleName("main-layout");
    panel.addComponent(layout);

    Label header = new OfflineLabel("OfflineBuilder");
    header.addStyleName("header-label");
    layout.addComponent(header);

    Label info = new OfflineLabel("OfflineBuilder allows to define offline UI without need of writing GWT"
            + " code. Add-on offers offline extended versions of basic Vaadin UI components and layouts. This way"
            + " your server defined UI can be used on offline mode too.");
    info.addStyleName("info-label");
    layout.addComponent(info);

    info = new OfflineLabel(
            "To test offline functionality. Turn on flight mode on your device or just disconnect"
                    + " from your network connection. Offline UI should look identical with online UI.");
    info.addStyleName("info-label");
    layout.addComponent(info);

    Image image = new OfflineImage();
    image.setWidth("300px");
    image.addStyleName("extra-stylename-image");
    image.setSource(new ThemeResource("img/offline.png"));
    image.setDescription("Example image");
    layout.addComponent(image);

    HorizontalLayout buttonLayout = new OfflineHorizontalLayout();
    buttonLayout.setSpacing(true);
    layout.addComponent(buttonLayout);

    OfflineButton pingButton = new OfflineButton("Ping server");
    pingButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            Notification.show("Server says pong!");
        }
    });
    pingButton.setDescription("Button that will be automatically disabled on offline mode");
    buttonLayout.addComponent(pingButton);

    OfflineButton writeButton = new OfflineButton("Store value (TODO)");
    writeButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            Notification.show("No need to store, in online mode.");
        }
    });
    buttonLayout.addComponent(writeButton);

    /*
    OfflineFormLayout formTest = new OfflineFormLayout();
    OfflineCheckBox checkbox = new OfflineCheckBox("Flag me");
    checkbox.setOfflineValueKey("flag");
    formTest.addComponent(checkbox);
    layout.addComponent(formTest);
    */

    Link link = new OfflineLink("Open project's GitHub page",
            new ExternalResource("https://github.com/alump/OfflineBuilder"));
    link.addStyleName("github-link");
    layout.addComponent(link);
}

From source file:org.vaadin.numberfield.NumberFieldUI.java

License:Apache License

private VerticalLayout createLayout() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*from  www .  j  av  a2  s . c om*/
    layout.setSpacing(true);
    layout.addStyleName("border");
    return layout;
}

From source file:org.vaadin.spring.samples.security.ui.login.views.LoginView.java

License:Apache License

private Component buildLoginForm() {
    final VerticalLayout loginPanel = new VerticalLayout();
    loginPanel.setSizeUndefined();//from  w ww .j  a  v  a2 s. c  om
    loginPanel.setSpacing(true);
    Responsive.makeResponsive(loginPanel);
    loginPanel.addStyleName("login-panel");

    loginPanel.addComponent(buildLabels());
    loginPanel.addComponent(buildFields());
    loginPanel.addComponent(rememberMe);
    return loginPanel;
}