Search in sources :

Example 11 with Label

use of com.vaadin.ui.Label in project opennms by OpenNMS.

the class AlarmsDashlet method addComponents.

/**
     * Adds the alarms components to a {@link com.vaadin.ui.AbstractOrderedLayout}
     *
     * @param component the component to add alarms to
     * @param alarms    the alarms list
     */
private void addComponents(AbstractOrderedLayout component, List<OnmsAlarm> alarms) {
    if (alarms.size() == 0) {
        Label label = new Label("No alarms found!");
        label.addStyleName("alerts-noalarms-font");
        component.addComponent(label);
    } else {
        for (OnmsAlarm onmsAlarm : alarms) {
            OnmsNode onmsNode = null;
            if (onmsAlarm.getNodeId() != null) {
                CriteriaBuilder nodeCb = new CriteriaBuilder(OnmsNode.class);
                nodeCb.eq("id", onmsAlarm.getNodeId());
                List<OnmsNode> nodes = m_nodeDao.findMatching(nodeCb.toCriteria());
                if (nodes.size() == 1) {
                    onmsNode = nodes.get(0);
                }
            }
            component.addComponent(createAlarmComponent(onmsAlarm, onmsNode));
            OnmsSeverity boostSeverity = OnmsSeverity.valueOf(getDashletSpec().getParameters().get("boostSeverity"));
            if (onmsAlarm.getSeverity().isGreaterThanOrEqual(boostSeverity)) {
                boosted = true;
            }
        }
    }
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) Label(com.vaadin.ui.Label)

Example 12 with Label

use of com.vaadin.ui.Label in project opennms by OpenNMS.

the class AlarmsDashlet method createAlarmComponent.

/**
     * Returns the component for visualising the alarms data.
     *
     * @param onmsAlarm an {@link OnmsAlarm} instance
     * @param onmsNode  an {@link OnmsNode} instance
     * @return component for this alarm
     */
public Component createAlarmComponent(OnmsAlarm onmsAlarm, OnmsNode onmsNode) {
    Calendar calendar = Calendar.getInstance();
    String ago = getHumanReadableFormat((calendar.getTimeInMillis() / 1000) - (onmsAlarm.getLastEventTime().getTime() / 1000));
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setWidth("100%");
    horizontalLayout.addStyleName("alerts");
    horizontalLayout.addStyleName(onmsAlarm.getSeverity().name().toLowerCase());
    Label labelAgo = new Label();
    labelAgo.setSizeUndefined();
    labelAgo.addStyleName("alerts-font");
    labelAgo.setValue(ago);
    Label labelId = new Label();
    labelId.setSizeUndefined();
    labelId.addStyleName("alerts-font");
    if (onmsNode != null) {
        labelId.setValue(onmsNode.getLabel() + " (" + onmsNode.getNodeId() + ")");
    } else {
        labelId.setValue("-");
    }
    Label labelUei = new Label();
    labelUei.setSizeUndefined();
    labelUei.addStyleName("alerts-font");
    labelUei.setValue(onmsAlarm.getUei());
    horizontalLayout.addComponent(labelAgo);
    horizontalLayout.addComponent(labelId);
    horizontalLayout.addComponent(labelUei);
    horizontalLayout.setExpandRatio(labelAgo, 1.0f);
    horizontalLayout.setExpandRatio(labelId, 3.0f);
    horizontalLayout.setExpandRatio(labelUei, 3.0f);
    return horizontalLayout;
}
Also used : Calendar(java.util.Calendar) Label(com.vaadin.ui.Label) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 13 with Label

use of com.vaadin.ui.Label in project opennms by OpenNMS.

the class AlarmDetailsDashlet method createAlarmComponent.

/**
     * Returns the component for visualising the alarms data.
     *
     * @param onmsAlarm an {@link OnmsAlarm} instance
     * @param onmsNode  an {@link OnmsNode} instance
     * @return component for this alarm
     */
@Deprecated
public Component createAlarmComponent(OnmsAlarm onmsAlarm, OnmsNode onmsNode) {
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeFull();
    horizontalLayout.addStyleName("alert-details");
    horizontalLayout.addStyleName("alert-details-font");
    horizontalLayout.addStyleName(onmsAlarm.getSeverity().name().toLowerCase());
    VerticalLayout verticalLayout1 = new VerticalLayout();
    VerticalLayout verticalLayout2 = new VerticalLayout();
    horizontalLayout.addComponent(verticalLayout1);
    horizontalLayout.addComponent(verticalLayout2);
    Label lastEvent = new Label();
    lastEvent.setSizeUndefined();
    lastEvent.addStyleName("alert-details-font");
    lastEvent.setCaption("Last event");
    lastEvent.setValue(StringUtils.toStringEfficiently(onmsAlarm.getLastEventTime()));
    Label firstEvent = new Label();
    firstEvent.setSizeUndefined();
    firstEvent.addStyleName("alert-details-font");
    firstEvent.setCaption("First event");
    firstEvent.setValue(StringUtils.toStringEfficiently(onmsAlarm.getFirstEventTime()));
    verticalLayout1.addComponent(firstEvent);
    verticalLayout1.addComponent(lastEvent);
    Label nodeId = new Label();
    nodeId.setSizeUndefined();
    nodeId.addStyleName("alert-details-font");
    nodeId.setCaption("Node Id");
    if (onmsNode != null) {
        nodeId.setValue(onmsNode.getNodeId());
    } else {
        nodeId.setValue("-");
    }
    Label nodeLabel = new Label();
    nodeLabel.setSizeUndefined();
    nodeLabel.addStyleName("alert-details-font");
    nodeLabel.setCaption("Node Label");
    if (onmsNode != null) {
        nodeLabel.setValue(onmsNode.getLabel());
    } else {
        nodeLabel.setValue("-");
    }
    Label logMessage = new Label();
    logMessage.addStyleName("alert-details-font");
    logMessage.setSizeFull();
    logMessage.setCaption("Log message");
    logMessage.setValue(onmsAlarm.getLogMsg().replaceAll("<[^>]*>", ""));
    HorizontalLayout horizontalLayout2 = new HorizontalLayout();
    horizontalLayout2.setSizeFull();
    horizontalLayout2.setSpacing(true);
    horizontalLayout2.addComponent(nodeId);
    horizontalLayout2.addComponent(nodeLabel);
    verticalLayout2.addComponent(horizontalLayout2);
    verticalLayout2.addComponent(logMessage);
    horizontalLayout.setExpandRatio(verticalLayout1, 1.0f);
    horizontalLayout.setExpandRatio(verticalLayout2, 4.0f);
    return horizontalLayout;
}
Also used : Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 14 with Label

use of com.vaadin.ui.Label in project opennms by OpenNMS.

the class UndefinedDashlet method getWallboardComponent.

@Override
public DashletComponent getWallboardComponent() {
    DashletComponent dashletComponent = new AbstractDashletComponent() {

        @Override
        public void refresh() {
        }

        @Override
        public Component getComponent() {
            VerticalLayout verticalLayout = new VerticalLayout();
            Label label = new Label("The specified dashlet could not be found!");
            verticalLayout.addComponent(label);
            verticalLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
            return verticalLayout;
        }
    };
    return dashletComponent;
}
Also used : Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout)

Example 15 with Label

use of com.vaadin.ui.Label in project opennms by OpenNMS.

the class AbstractDashletFactory method getHelpComponent.

/**
     * Returns the help component for the {@link Dashlet}.
     *
     * @return the help component
     */
@Override
public Component getHelpComponent() {
    VerticalLayout verticalLayout = new VerticalLayout();
    Label helpContent = new Label(getHelpContentHTML(), ContentMode.HTML);
    helpContent.addStyleName("help-content");
    Label helpParameters = new Label(getParameterDescriptionsHTML(), ContentMode.HTML);
    helpParameters.addStyleName("help-content");
    verticalLayout.addComponent(helpContent);
    verticalLayout.addComponent(helpParameters);
    return verticalLayout;
}
Also used : Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout)

Aggregations

Label (com.vaadin.ui.Label)158 HorizontalLayout (com.vaadin.ui.HorizontalLayout)45 PrettyTimeLabel (org.activiti.explorer.ui.custom.PrettyTimeLabel)40 VerticalLayout (com.vaadin.ui.VerticalLayout)33 Embedded (com.vaadin.ui.Embedded)29 Button (com.vaadin.ui.Button)18 GridLayout (com.vaadin.ui.GridLayout)17 Link (com.vaadin.ui.Link)14 ClickEvent (com.vaadin.ui.Button.ClickEvent)13 Table (com.vaadin.ui.Table)13 ClickListener (com.vaadin.ui.Button.ClickListener)11 TextField (com.vaadin.ui.TextField)10 Item (com.vaadin.data.Item)9 ExternalResource (com.vaadin.server.ExternalResource)9 StreamResource (com.vaadin.terminal.StreamResource)8 PostConstruct (javax.annotation.PostConstruct)8 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)6 ExternalResource (com.vaadin.terminal.ExternalResource)6 Component (com.vaadin.ui.Component)6 Panel (com.vaadin.ui.Panel)5