Search in sources :

Example 41 with HorizontalLayout

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

the class SurveillanceViewDetailTable method getImageSeverityLayout.

/**
 * Returns the image severity layout for the given content.
 *
 * @param content the content
 * @return the label with the applied style
 */
protected HorizontalLayout getImageSeverityLayout(String content) {
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    Label placeholder = new Label();
    placeholder.addStyleName("placeholder");
    horizontalLayout.addComponent(placeholder);
    Label contentLabel = new Label(content);
    contentLabel.addStyleName("content");
    horizontalLayout.addComponent(contentLabel);
    return horizontalLayout;
}
Also used : Label(com.vaadin.ui.Label) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 42 with HorizontalLayout

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

the class WallboardConfigView method addNewTabComponent.

/**
 * This method is used to add a new {@link TabSheet.Tab} component. It creates a new window querying the user for the name of the new {@link Wallboard}.
 */
protected void addNewTabComponent() {
    final Window window = new Window("New Ops Board");
    window.setModal(true);
    window.setClosable(false);
    window.setResizable(false);
    window.addCloseListener(new Window.CloseListener() {

        @Override
        public void windowClose(Window.CloseEvent e) {
            m_dashboardOverview.refreshTable();
        }
    });
    getUI().addWindow(window);
    window.setContent(new VerticalLayout() {

        TextField name = new TextField("Ops Board Name");

        {
            addComponent(new FormLayout() {

                {
                    setSizeUndefined();
                    setMargin(true);
                    String newName = "Untitled";
                    int i = 1;
                    if (WallboardProvider.getInstance().containsWallboard(newName)) {
                        do {
                            i++;
                            newName = "Untitled #" + i;
                        } while (WallboardProvider.getInstance().containsWallboard(newName));
                    }
                    name.setValue(newName);
                    addComponent(name);
                    name.focus();
                    name.selectAll();
                    name.addValidator(new AbstractStringValidator("Title must be unique") {

                        @Override
                        protected boolean isValidValue(String s) {
                            return (!WallboardProvider.getInstance().containsWallboard(s) && !"".equals(s));
                        }
                    });
                }
            });
            addComponent(new HorizontalLayout() {

                {
                    setMargin(true);
                    setSpacing(true);
                    setWidth("100%");
                    Button cancel = new Button("Cancel");
                    cancel.setDescription("Cancel editing");
                    cancel.addClickListener(new Button.ClickListener() {

                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            // NMS-7560: Toggle the tab in order to allow us to click it again
                            m_tabSheet.togglePlusTab();
                            window.close();
                        }
                    });
                    cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
                    addComponent(cancel);
                    setExpandRatio(cancel, 1);
                    setComponentAlignment(cancel, Alignment.TOP_RIGHT);
                    Button ok = new Button("Save");
                    ok.setDescription("Save configuration");
                    ok.addClickListener(new Button.ClickListener() {

                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            if (name.isValid()) {
                                Wallboard wallboard = new Wallboard();
                                wallboard.setTitle(name.getValue());
                                WallboardProvider.getInstance().addWallboard(wallboard);
                                WallboardProvider.getInstance().save();
                                WallboardEditor wallboardEditor = new WallboardEditor(m_dashletSelector, wallboard);
                                TabSheet.Tab tab = m_tabSheet.addTab(wallboardEditor, wallboard.getTitle());
                                wallboardEditor.setTab(tab);
                                m_wallboardEditorMap.put(wallboard, tab);
                                tab.setClosable(true);
                                m_tabSheet.setSelectedTab(tab);
                                window.close();
                            }
                        }
                    });
                    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
                    addComponent(ok);
                }
            });
        }
    });
}
Also used : Window(com.vaadin.ui.Window) FormLayout(com.vaadin.ui.FormLayout) AbstractStringValidator(com.vaadin.data.validator.AbstractStringValidator) Wallboard(org.opennms.features.vaadin.dashboard.model.Wallboard) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Tab(com.vaadin.ui.TabSheet.Tab) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField)

Example 43 with HorizontalLayout

use of com.vaadin.ui.HorizontalLayout 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 44 with HorizontalLayout

use of com.vaadin.ui.HorizontalLayout 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 45 with HorizontalLayout

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

the class NodeMapsApplication method getTabSheet.

/**
 * Gets a {@link TabSheet} view for all widgets in this manager.
 *
 * @return TabSheet
 */
private Component getTabSheet() {
    // Use an absolute layout for the bottom panel
    AbsoluteLayout bottomLayout = new AbsoluteLayout();
    bottomLayout.setSizeFull();
    final TabSheet tabSheet = new TabSheet();
    tabSheet.setSizeFull();
    for (final SelectionAwareTable view : new SelectionAwareTable[] { m_alarmTable, m_nodeTable }) {
        // Icon can be null
        tabSheet.addTab(view, (view == m_alarmTable ? "Alarms" : "Nodes"), null);
        // components to the tab bar
        try {
            final Component[] extras = ((HasExtraComponents) view).getExtraComponents();
            if (extras != null && extras.length > 0) {
                // For any extra controls, add a horizontal layout that will float
                // on top of the right side of the tab panel
                final HorizontalLayout extraControls = new HorizontalLayout();
                extraControls.setHeight(32, Unit.PIXELS);
                extraControls.setSpacing(true);
                // Add the extra controls to the layout
                for (final Component component : extras) {
                    extraControls.addComponent(component);
                    extraControls.setComponentAlignment(component, Alignment.MIDDLE_RIGHT);
                }
                // Add a TabSheet.SelectedTabChangeListener to show or hide the extra controls
                tabSheet.addSelectedTabChangeListener(new SelectedTabChangeListener() {

                    @Override
                    public void selectedTabChange(final SelectedTabChangeEvent event) {
                        final TabSheet source = (TabSheet) event.getSource();
                        if (source == tabSheet) {
                            // If the first tab was selected...
                            if (source.getSelectedTab() == view) {
                                extraControls.setVisible(true);
                            } else {
                                extraControls.setVisible(false);
                            }
                        }
                    }
                });
                // Place the extra controls on the absolute layout
                bottomLayout.addComponent(extraControls, "top:0px;right:5px;z-index:100");
            }
        } catch (ClassCastException e) {
        }
        view.setSizeFull();
    }
    // Add the tabsheet to the layout
    bottomLayout.addComponent(tabSheet, "top: 0; left: 0; bottom: 0; right: 0;");
    return bottomLayout;
}
Also used : HasExtraComponents(org.opennms.features.topology.api.HasExtraComponents) SelectedTabChangeEvent(com.vaadin.ui.TabSheet.SelectedTabChangeEvent) SelectionAwareTable(org.opennms.features.topology.api.browsers.SelectionAwareTable) TabSheet(com.vaadin.ui.TabSheet) SelectedTabChangeListener(com.vaadin.ui.TabSheet.SelectedTabChangeListener) Component(com.vaadin.ui.Component) AbsoluteLayout(com.vaadin.ui.AbsoluteLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

HorizontalLayout (com.vaadin.ui.HorizontalLayout)85 Label (com.vaadin.ui.Label)45 Button (com.vaadin.ui.Button)26 VerticalLayout (com.vaadin.ui.VerticalLayout)20 Embedded (com.vaadin.ui.Embedded)19 ClickEvent (com.vaadin.ui.Button.ClickEvent)17 ClickListener (com.vaadin.ui.Button.ClickListener)15 ExternalResource (com.vaadin.terminal.ExternalResource)7 GridLayout (com.vaadin.ui.GridLayout)7 TextField (com.vaadin.ui.TextField)6 PrettyTimeLabel (org.activiti.explorer.ui.custom.PrettyTimeLabel)6 StreamResource (com.vaadin.terminal.StreamResource)5 Link (com.vaadin.ui.Link)5 Panel (com.vaadin.ui.Panel)5 InputStream (java.io.InputStream)4 URL (java.net.URL)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)3 ExternalResource (com.vaadin.server.ExternalResource)3