Example usage for com.vaadin.ui Alignment TOP_CENTER

List of usage examples for com.vaadin.ui Alignment TOP_CENTER

Introduction

In this page you can find the example usage for com.vaadin.ui Alignment TOP_CENTER.

Prototype

Alignment TOP_CENTER

To view the source code for com.vaadin.ui Alignment TOP_CENTER.

Click Source Link

Usage

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}//from  w  ww . ja v  a2  s .  c o  m
 */
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}//from  www . j a  va  2  s. co 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.opennms.features.vaadin.dashboard.dashlets.SummaryDashlet.java

License:Open Source License

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

            {//from  www . ja va2s .  c o  m
                m_horizontalLayout.setCaption(getName());
                m_horizontalLayout.setSizeFull();
            }

            /**
             * Injects CSS styles in the current page
             */
            private void injectWallboardStyles() {
                Page.getCurrent().getStyles()
                        .add(".summary.cleared { background: #000000; border-left: 15px solid #858585; }");
                Page.getCurrent().getStyles()
                        .add(".summary.normal { background: #000000; border-left: 15px solid #336600; }");
                Page.getCurrent().getStyles()
                        .add(".summary.indeterminate {  background: #000000; border-left: 15px solid #999; }");
                Page.getCurrent().getStyles()
                        .add(".summary.warning { background: #000000; border-left: 15px solid #FFCC00; }");
                Page.getCurrent().getStyles()
                        .add(".summary.minor { background: #000000;  border-left: 15px solid #FF9900; }");
                Page.getCurrent().getStyles()
                        .add(".summary.major { background: #000000; border-left: 15px solid #FF3300; }");
                Page.getCurrent().getStyles()
                        .add(".summary.critical { background: #000000; border-left: 15px solid #CC0000; }");
                Page.getCurrent().getStyles()
                        .add(".summary.global { background: #000000; border-left: 15px solid #000000; }");
                Page.getCurrent().getStyles().add(".summary { padding: 5px 5px; margin: 1px; }");
                Page.getCurrent().getStyles().add(
                        ".summary-font { font-size: 24px; line-height: normal; text-align: right; color: #3ba300; }");
                Page.getCurrent().getStyles().add(
                        ".summary-font-legend { font-size: 16px; line-height: normal; text-align: right; color: #3ba300; }");
            }

            @Override
            public void refresh() {
                m_timeslot = 3600;

                try {
                    m_timeslot = Math.max(1,
                            Integer.parseInt(getDashletSpec().getParameters().get("timeslot")));
                } catch (NumberFormatException numberFormatException) {
                    /**
                     * Just ignore
                     */
                }

                m_horizontalLayout.removeAllComponents();

                injectWallboardStyles();

                Component severity = getComponentSeverity(32);
                Component uei = getComponentUei(32);

                m_horizontalLayout.addComponent(severity);
                m_horizontalLayout.addComponent(uei);

                m_horizontalLayout.setSizeFull();
                m_horizontalLayout.setComponentAlignment(severity, Alignment.TOP_CENTER);
                m_horizontalLayout.setComponentAlignment(uei, Alignment.TOP_CENTER);
            }

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

            @Override
            public boolean isBoosted() {
                return SummaryDashlet.this.m_boosted;
            }
        };
    }

    return m_wallboardComponent;
}

From source file:org.ow2.sirocco.cloudmanager.AddressAllocationWizard.java

License:Open Source License

public AddressAllocationWizard() {
    super("Address Allocation");
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);//from ww  w .  jav  a  2s . com
    this.wizard = new Wizard();
    this.wizard.addListener(this);
    this.wizard.addStep(this.placementStep = new Util.PlacementStep(this.wizard), "placement");
    this.wizard.setHeight("300px");
    this.wizard.setWidth("560px");

    content.addComponent(this.wizard);
    content.setComponentAlignment(this.wizard, Alignment.TOP_CENTER);
    this.setContent(content);
}

From source file:org.ow2.sirocco.cloudmanager.MachineCreationWizard.java

License:Open Source License

public MachineCreationWizard() {
    super("Machine Creation");
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);//  w w  w . j a  v  a2  s .  c o m
    this.wizard = new Wizard();
    this.wizard.addListener(this);
    this.wizard.addStep(this.placementStep = new Util.PlacementStep(this.wizard), "placement");
    this.placementStep.setListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(final ValueChangeEvent event) {
            MachineCreationWizard.this.updateProviderSpecificResources();
        }
    });
    this.wizard.addStep(this.metadataStep = new Util.MetadataStep(this.wizard), "metadata");
    this.wizard.addStep(this.imageStep = new ImageStep(), "Image");
    this.wizard.addStep(this.configStep = new ConfigStep(), "Hardware");
    this.wizard.addStep(this.networkStep = new NetworkStep(), "Network");
    this.wizard.addStep(this.keyPairStep = new KeyPairStep(), "Key pair");
    this.wizard.addStep(this.userDataStep = new UserDataStep(), "User data");
    this.wizard.addStep(this.hostPlacementStep = new HostPlacementStep(), "Placement Constraints");
    this.wizard.setHeight("300px");
    this.wizard.setWidth("700px");

    content.addComponent(this.wizard);
    content.setComponentAlignment(this.wizard, Alignment.TOP_CENTER);
    this.setContent(content);
}

From source file:org.ow2.sirocco.cloudmanager.MachineImageRegisterWizard.java

License:Open Source License

public MachineImageRegisterWizard() {
    super("Register Image");
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);/*  ww w  .ja va 2 s  .  com*/
    this.wizard = new Wizard();
    this.wizard.addListener(this);
    this.wizard.addStep(this.placementStep = new Util.PlacementStep(this.wizard), "placement");
    this.wizard.addStep(this.imageStep = new ImageStep(), "Image attributes");
    this.wizard.setHeight("300px");
    this.wizard.setWidth("560px");

    content.addComponent(this.wizard);
    content.setComponentAlignment(this.wizard, Alignment.TOP_CENTER);
    this.setContent(content);
}

From source file:org.ow2.sirocco.cloudmanager.NetworkCreationWizard.java

License:Open Source License

public NetworkCreationWizard() {
    super("Network Creation");
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);/* w ww . j  a va 2  s .c  o m*/
    this.wizard = new Wizard();
    this.wizard.addListener(this);
    this.wizard.addStep(this.placementStep = new Util.PlacementStep(this.wizard), "placement");
    this.wizard.addStep(this.metadataStep = new Util.MetadataStep(this.wizard), "metadata");
    this.wizard.addStep(this.subnetStep = new SubnetStep(), "subnet");
    this.wizard.setHeight("300px");
    this.wizard.setWidth("560px");

    content.addComponent(this.wizard);
    content.setComponentAlignment(this.wizard, Alignment.TOP_CENTER);
    this.setContent(content);
}

From source file:org.ow2.sirocco.cloudmanager.ProviderAccountCreationWizard.java

License:Open Source License

public ProviderAccountCreationWizard() {
    super("New Cloud Provider Account");
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);//from w  w  w . jav a2 s .c  o m
    this.wizard = new Wizard();
    this.wizard.addListener(this);

    this.wizard.addStep(this.providerTypeStep = new ProviderTypeStep(), "type");
    this.wizard.addStep(this.accountParametersStep = new AccountParametersStep(), "params");
    this.wizard.addStep(this.importOptionsStep = new ImportOptionsStep(), "import");
    this.wizard.setHeight("400px");
    this.wizard.setWidth("560px");

    content.addComponent(this.wizard);
    content.setComponentAlignment(this.wizard, Alignment.TOP_CENTER);
    this.setContent(content);
}

From source file:org.ow2.sirocco.cloudmanager.SecurityGroupCreationWizard.java

License:Open Source License

public SecurityGroupCreationWizard() {
    super("SecurityGroup Creation");
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);/*from w w w . j a  va2s.  com*/
    this.wizard = new Wizard();
    this.wizard.addListener(this);
    this.wizard.addStep(this.placementStep = new Util.PlacementStep(this.wizard), "placement");
    this.wizard.addStep(this.metadataStep = new Util.MetadataStep(this.wizard), "metadata");
    this.wizard.setHeight("300px");
    this.wizard.setWidth("560px");

    content.addComponent(this.wizard);
    content.setComponentAlignment(this.wizard, Alignment.TOP_CENTER);
    this.setContent(content);
}

From source file:org.ow2.sirocco.cloudmanager.VolumeCreationWizard.java

License:Open Source License

public VolumeCreationWizard() {
    super("Volume Creation");
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);//from  ww w  . jav  a 2s .co  m
    this.wizard = new Wizard();
    this.wizard.addListener(this);
    this.wizard.addStep(this.placementStep = new Util.PlacementStep(this.wizard), "placement");
    this.wizard.addStep(this.metadataStep = new Util.MetadataStep(this.wizard), "metadata");
    this.wizard.addStep(this.configStep = new ConfigStep(), "config");
    this.wizard.setHeight("300px");
    this.wizard.setWidth("560px");

    content.addComponent(this.wizard);
    content.setComponentAlignment(this.wizard, Alignment.TOP_CENTER);
    this.setContent(content);
}