Search in sources :

Example 6 with FormLayout

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

the class BusinessServiceVertexAttributesInfoPanelItemProvider method createComponent.

private Component createComponent(VertexRef ref) {
    final FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(false);
    formLayout.setMargin(false);
    final BusinessService businessService = businessServiceManager.getBusinessServiceById(((BusinessServiceVertex) ref).getServiceId());
    for (Map.Entry<String, String> e : businessService.getAttributes().entrySet()) {
        formLayout.addComponent(createLabel(e.getKey(), e.getValue()));
    }
    return formLayout;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) Map(java.util.Map)

Example 7 with FormLayout

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

the class BusinessServiceVertexInfoPanelItemProvider method createComponent.

private Component createComponent(AbstractBusinessServiceVertex ref, GraphContainer graphContainer) {
    final FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(false);
    formLayout.setMargin(false);
    ref.accept(new BusinessServiceVertexVisitor<Void>() {

        @Override
        public Void visit(BusinessServiceVertex vertex) {
            final BusinessService businessService = businessServiceManager.getBusinessServiceById(vertex.getServiceId());
            formLayout.addComponent(createLabel("Reduce function", getReduceFunctionDescription(businessService.getReduceFunction())));
            // Apply Reduce Function specific details
            businessService.getReduceFunction().accept(new ReduceFunctionVisitor<Void>() {

                @Override
                public Void visit(HighestSeverity highestSeverity) {
                    return null;
                }

                @Override
                public Void visit(HighestSeverityAbove highestSeverityAbove) {
                    return null;
                }

                @Override
                public // Threshold is not very transparent, we add an Explain Button in these cases
                Void visit(Threshold threshold) {
                    final Button explainButton = createButton("Explain", "Explain the Threshold function", FontAwesome.TABLE, (Button.ClickListener) event -> {
                        ThresholdExplanationWindow explainWindow = new ThresholdExplanationWindow(SimulationAwareStateMachineFactory.createSimulatedStateMachine(businessServiceManager, graphContainer.getCriteria()).explain(businessService, (Threshold) businessService.getReduceFunction()));
                        UI.getCurrent().addWindow(explainWindow);
                    });
                    explainButton.setStyleName(BaseTheme.BUTTON_LINK);
                    formLayout.addComponent(explainButton);
                    return null;
                }

                @Override
                public Void visit(ExponentialPropagation exponentialPropagation) {
                    return null;
                }
            });
            return null;
        }

        @Override
        public Void visit(IpServiceVertex vertex) {
            IpService ipService = businessServiceManager.getIpServiceById(vertex.getIpServiceId());
            formLayout.addComponent(createLabel("Interface", ipService.getIpAddress()));
            formLayout.addComponent(createLabel("Service", ipService.getServiceName()));
            if (!ipService.getServiceName().equals(vertex.getLabel())) {
                formLayout.addComponent(createLabel("Friendly Name", vertex.getLabel()));
            }
            return null;
        }

        @Override
        public Void visit(ReductionKeyVertex vertex) {
            formLayout.addComponent(createLabel("Reduction Key", vertex.getReductionKey()));
            if (!vertex.getReductionKey().equals(vertex.getLabel())) {
                formLayout.addComponent(createLabel("Friendly Name", vertex.getLabel()));
            }
            return null;
        }
    });
    return formLayout;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) GraphContainer(org.opennms.features.topology.api.GraphContainer) AbstractBusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.AbstractBusinessServiceVertex) IpService(org.opennms.netmgt.bsm.service.model.IpService) BaseTheme(com.vaadin.ui.themes.BaseTheme) VerticalLayout(com.vaadin.ui.VerticalLayout) Threshold(org.opennms.netmgt.bsm.service.model.functions.reduce.Threshold) UI(com.vaadin.ui.UI) BusinessServiceManager(org.opennms.netmgt.bsm.service.BusinessServiceManager) HighestSeverityAbove(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverityAbove) Window(com.vaadin.ui.Window) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) BusinessServiceVertexVisitor(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertexVisitor) Strings(com.google.common.base.Strings) FontAwesome(com.vaadin.server.FontAwesome) GraphVertexToTopologyVertexConverter(org.opennms.features.topology.plugins.topo.bsm.GraphVertexToTopologyVertexConverter) VertexInfoPanelItemProvider(org.opennms.features.topology.api.info.VertexInfoPanelItemProvider) DefaultInfoPanelItem(org.opennms.features.topology.api.info.item.DefaultInfoPanelItem) ReductionFunction(org.opennms.netmgt.bsm.service.model.functions.reduce.ReductionFunction) Status(org.opennms.netmgt.bsm.service.model.Status) Label(com.vaadin.ui.Label) ShortcutAction(com.vaadin.event.ShortcutAction) Comparator.comparing(java.util.Comparator.comparing) UIHelper.createLabel(org.opennms.netmgt.vaadin.core.UIHelper.createLabel) BusinessServicesTopologyProvider(org.opennms.features.topology.plugins.topo.bsm.BusinessServicesTopologyProvider) ThresholdResultExplanation(org.opennms.netmgt.bsm.service.model.functions.reduce.ThresholdResultExplanation) InfoPanelItem(org.opennms.features.topology.api.info.item.InfoPanelItem) ExponentialPropagation(org.opennms.netmgt.bsm.service.model.functions.reduce.ExponentialPropagation) IpServiceVertex(org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex) Collectors(java.util.stream.Collectors) Sizeable(com.vaadin.server.Sizeable) SimulationAwareStateMachineFactory(org.opennms.features.topology.plugins.topo.bsm.simulate.SimulationAwareStateMachineFactory) TransactionAwareBeanProxyFactory(org.opennms.netmgt.vaadin.core.TransactionAwareBeanProxyFactory) BusinessServiceVertexStatusInfoPanelItemProvider.createStatusLabel(org.opennms.features.topology.plugins.topo.bsm.info.BusinessServiceVertexStatusInfoPanelItemProvider.createStatusLabel) List(java.util.List) Button(com.vaadin.ui.Button) Table(com.vaadin.ui.Table) Edge(org.opennms.netmgt.bsm.service.model.edge.Edge) FormLayout(com.vaadin.ui.FormLayout) BusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex) ReductionKeyVertex(org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex) GraphEdge(org.opennms.netmgt.bsm.service.model.graph.GraphEdge) ReduceFunctionVisitor(org.opennms.netmgt.bsm.service.model.functions.reduce.ReduceFunctionVisitor) VertexRef(org.opennms.features.topology.api.topo.VertexRef) HighestSeverity(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity) UIHelper.createButton(org.opennms.netmgt.vaadin.core.UIHelper.createButton) Component(com.vaadin.ui.Component) HighestSeverity(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity) ReductionKeyVertex(org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex) HighestSeverityAbove(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverityAbove) IpService(org.opennms.netmgt.bsm.service.model.IpService) IpServiceVertex(org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) ReduceFunctionVisitor(org.opennms.netmgt.bsm.service.model.functions.reduce.ReduceFunctionVisitor) Button(com.vaadin.ui.Button) UIHelper.createButton(org.opennms.netmgt.vaadin.core.UIHelper.createButton) ExponentialPropagation(org.opennms.netmgt.bsm.service.model.functions.reduce.ExponentialPropagation) AbstractBusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.AbstractBusinessServiceVertex) BusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex) Threshold(org.opennms.netmgt.bsm.service.model.functions.reduce.Threshold)

Example 8 with FormLayout

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

the class SimulationModeReductionKeyInfoPanelItemProvider method createComponent.

private Component createComponent(ReductionKeyVertex vertex, GraphContainer container) {
    final FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(false);
    formLayout.setMargin(false);
    NativeSelect dropdown = new NativeSelect("Severity");
    dropdown.setMultiSelect(false);
    dropdown.setNewItemsAllowed(false);
    dropdown.setNullSelectionAllowed(true);
    dropdown.setImmediate(true);
    dropdown.setRequired(true);
    dropdown.addItems(Arrays.asList(Status.values()));
    SetStatusToCriteria setStatusTo = findCriteria(container, vertex);
    if (setStatusTo != null) {
        dropdown.setValue(setStatusTo.getStatus());
    } else {
        dropdown.setValue(null);
    }
    dropdown.addValueChangeListener(event -> {
        SetStatusToCriteria currentSetStatusTo = findCriteria(container, vertex);
        Status selectedStatus = (Status) dropdown.getValue();
        if (currentSetStatusTo != null) {
            currentSetStatusTo.setStatus(selectedStatus);
        } else {
            currentSetStatusTo = new SetStatusToCriteria(vertex.getReductionKey(), selectedStatus);
            container.addCriteria(currentSetStatusTo);
        }
        container.getSelectionManager().setSelectedVertexRefs(Collections.emptyList());
        container.getSelectionManager().setSelectedEdgeRefs(Collections.emptyList());
        container.redoLayout();
    });
    formLayout.addComponent(dropdown);
    return formLayout;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Status(org.opennms.netmgt.bsm.service.model.Status) SetStatusToCriteria(org.opennms.features.topology.plugins.topo.bsm.simulate.SetStatusToCriteria) NativeSelect(com.vaadin.ui.NativeSelect)

Example 9 with FormLayout

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

the class DefaultVertexInfoPanelItemProvider method createComponent.

private Component createComponent(VertexRef ref) {
    FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(false);
    formLayout.setMargin(false);
    formLayout.addComponent(createLabel("Name", ref.getLabel()));
    formLayout.addComponent(createLabel("ID", String.format("%s:%s", ref.getNamespace(), ref.getId())));
    if (ref instanceof AbstractVertex) {
        AbstractVertex vertex = (AbstractVertex) ref;
        formLayout.addComponent(createLabel("Icon Key", vertex.getIconKey()));
        if (vertex.getIpAddress() != null) {
            formLayout.addComponent(createLabel("IP Address", vertex.getIpAddress()));
        }
    }
    return formLayout;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex)

Example 10 with FormLayout

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

the class BusinessServiceVertexStatusInfoPanelItemProvider method createComponent.

private Component createComponent(BusinessServiceVertex vertex, GraphContainer container) {
    final FormLayout rootLayout = new FormLayout();
    rootLayout.setSizeFull();
    rootLayout.setSpacing(false);
    rootLayout.setMargin(false);
    rootLayout.addStyleName("severity");
    final BusinessServiceStateMachine stateMachine = SimulationAwareStateMachineFactory.createStateMachine(businessServiceManager, container.getCriteria());
    final Status overallStatus = BusinessServicesStatusProvider.getStatus(stateMachine, vertex);
    rootLayout.addComponent(createStatusLabel("Overall", overallStatus));
    rootLayout.addComponent(new Label());
    final BusinessServiceGraph graph = stateMachine.getGraph();
    final BusinessService businessService = businessServiceManager.getBusinessServiceById(vertex.getServiceId());
    final Set<GraphVertex> impactingVertices = getImpactingVertices(stateMachine, graph, businessService);
    for (final Edge edge : businessService.getEdges()) {
        // Get the topology vertex for the child to determine the display label
        final Vertex childVertex = businessServicesTopologyProvider.getVertex(edge.accept(new EdgeVisitor<VertexRef>() {

            @Override
            public VertexRef visit(final IpServiceEdge edge) {
                return new IpServiceVertex(edge.getIpService(), 0);
            }

            @Override
            public VertexRef visit(final ReductionKeyEdge edge) {
                return new ReductionKeyVertex(edge.getReductionKey(), 0);
            }

            @Override
            public VertexRef visit(final ChildEdge edge) {
                return new BusinessServiceVertex(edge.getChild(), 0);
            }
        }));
        final Status edgeStatus = stateMachine.getOperationalStatus(edge);
        rootLayout.addComponent(createStatusLabel(childVertex.getLabel(), edgeStatus, String.format("%s &times; %d <i class=\"pull-right glyphicon %s\"></i>", edgeStatus.getLabel(), edge.getWeight(), impactingVertices.contains(graph.getVertexByEdgeId(edge.getId())) ? "glyphicon-flash" : "")));
    }
    return rootLayout;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Status(org.opennms.netmgt.bsm.service.model.Status) Vertex(org.opennms.features.topology.api.topo.Vertex) IpServiceVertex(org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) BusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex) ReductionKeyVertex(org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex) ReductionKeyVertex(org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex) ChildEdge(org.opennms.netmgt.bsm.service.model.edge.ChildEdge) Label(com.vaadin.ui.Label) UIHelper.createLabel(org.opennms.netmgt.vaadin.core.UIHelper.createLabel) IpServiceEdge(org.opennms.netmgt.bsm.service.model.edge.IpServiceEdge) BusinessServiceGraph(org.opennms.netmgt.bsm.service.model.graph.BusinessServiceGraph) EdgeVisitor(org.opennms.netmgt.bsm.service.model.edge.EdgeVisitor) IpServiceVertex(org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex) ReductionKeyEdge(org.opennms.netmgt.bsm.service.model.edge.ReductionKeyEdge) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) BusinessServiceStateMachine(org.opennms.netmgt.bsm.service.BusinessServiceStateMachine) ChildEdge(org.opennms.netmgt.bsm.service.model.edge.ChildEdge) ReductionKeyEdge(org.opennms.netmgt.bsm.service.model.edge.ReductionKeyEdge) Edge(org.opennms.netmgt.bsm.service.model.edge.Edge) IpServiceEdge(org.opennms.netmgt.bsm.service.model.edge.IpServiceEdge) BusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex)

Aggregations

FormLayout (com.vaadin.ui.FormLayout)10 Status (org.opennms.netmgt.bsm.service.model.Status)4 Button (com.vaadin.ui.Button)3 BusinessService (org.opennms.netmgt.bsm.service.model.BusinessService)3 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 Label (com.vaadin.ui.Label)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 Window (com.vaadin.ui.Window)2 AbstractBusinessServiceVertex (org.opennms.features.topology.plugins.topo.bsm.AbstractBusinessServiceVertex)2 BusinessServiceVertex (org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex)2 IpServiceVertex (org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex)2 ReductionKeyVertex (org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex)2 UIHelper.createButton (org.opennms.netmgt.vaadin.core.UIHelper.createButton)2 Strings (com.google.common.base.Strings)1 AbstractStringValidator (com.vaadin.data.validator.AbstractStringValidator)1 ShortcutAction (com.vaadin.event.ShortcutAction)1 FontAwesome (com.vaadin.server.FontAwesome)1 Sizeable (com.vaadin.server.Sizeable)1 Component (com.vaadin.ui.Component)1 NativeSelect (com.vaadin.ui.NativeSelect)1