Search in sources :

Example 1 with SearchBox

use of org.opennms.features.topology.app.internal.ui.SearchBox in project opennms by OpenNMS.

the class GraphMLSearchProviderTest method canSearchAllSearchProviders.

@Test
public void canSearchAllSearchProviders() throws IOException, InvalidGraphException {
    final GraphMLMetaTopologyProvider metaTopologyProvider = new GraphMLMetaTopologyProvider(new GraphMLServiceAccessor());
    metaTopologyProvider.setTopologyLocation("target/test-classes/test-graph.xml");
    metaTopologyProvider.reload();
    Assert.assertNotNull(metaTopologyProvider.getDefaultGraphProvider());
    List<SearchProvider> searchProviders = metaTopologyProvider.getGraphProviders().stream().map(eachProvider -> new GraphMLSearchProvider(metaTopologyProvider.getRawTopologyProvider(eachProvider.getNamespace()))).collect(Collectors.toList());
    Assert.assertEquals(2, searchProviders.size());
    DefaultTopologyService defaultTopologyService = new DefaultTopologyService();
    defaultTopologyService.setServiceLocator(new SimpleServiceLocator(metaTopologyProvider));
    VEProviderGraphContainer graphContainer = new VEProviderGraphContainer();
    graphContainer.setTopologyService(defaultTopologyService);
    graphContainer.setMetaTopologyId(metaTopologyProvider.getId());
    graphContainer.setSelectedNamespace(metaTopologyProvider.getDefaultGraphProvider().getNamespace());
    OperationContext operationContext = EasyMock.niceMock(OperationContext.class);
    EasyMock.expect(operationContext.getGraphContainer()).andReturn(graphContainer).anyTimes();
    OnmsServiceManager onmsServiceManager = EasyMock.niceMock(OnmsServiceManager.class);
    EasyMock.expect(onmsServiceManager.getServices(SearchProvider.class, null, new Hashtable<>())).andReturn(searchProviders).anyTimes();
    EasyMock.replay(onmsServiceManager, operationContext);
    SearchBox searchBox = new SearchBox(onmsServiceManager, operationContext);
    List<SearchSuggestion> results = searchBox.getQueryResults("North");
    Assert.assertEquals(5, results.size());
}
Also used : IOException(java.io.IOException) Test(org.junit.Test) EasyMock(org.easymock.EasyMock) DefaultTopologyService(org.opennms.features.topology.app.internal.service.DefaultTopologyService) OnmsServiceManager(org.opennms.osgi.OnmsServiceManager) Collectors(java.util.stream.Collectors) SearchBox(org.opennms.features.topology.app.internal.ui.SearchBox) List(java.util.List) OperationContext(org.opennms.features.topology.api.OperationContext) InvalidGraphException(org.opennms.features.graphml.model.InvalidGraphException) SearchSuggestion(org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion) VEProviderGraphContainer(org.opennms.features.topology.app.internal.VEProviderGraphContainer) Assert(org.junit.Assert) SimpleServiceLocator(org.opennms.features.topology.app.internal.service.SimpleServiceLocator) GraphMLGraph(org.opennms.features.graphml.model.GraphMLGraph) GraphMLServiceAccessor(org.opennms.features.topology.plugins.topo.graphml.internal.GraphMLServiceAccessor) Hashtable(java.util.Hashtable) SearchProvider(org.opennms.features.topology.api.topo.SearchProvider) OperationContext(org.opennms.features.topology.api.OperationContext) OnmsServiceManager(org.opennms.osgi.OnmsServiceManager) SearchSuggestion(org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion) DefaultTopologyService(org.opennms.features.topology.app.internal.service.DefaultTopologyService) VEProviderGraphContainer(org.opennms.features.topology.app.internal.VEProviderGraphContainer) Hashtable(java.util.Hashtable) SimpleServiceLocator(org.opennms.features.topology.app.internal.service.SimpleServiceLocator) SearchProvider(org.opennms.features.topology.api.topo.SearchProvider) SearchBox(org.opennms.features.topology.app.internal.ui.SearchBox) GraphMLServiceAccessor(org.opennms.features.topology.plugins.topo.graphml.internal.GraphMLServiceAccessor) Test(org.junit.Test)

Example 2 with SearchBox

use of org.opennms.features.topology.app.internal.ui.SearchBox in project opennms by OpenNMS.

the class TopologyUI method createMapLayout.

private Component createMapLayout() {
    // Topology (Map) Component
    m_topologyComponent = new TopologyComponent(m_graphContainer, m_iconRepositoryManager, this);
    m_topologyComponent.setSizeFull();
    m_topologyComponent.addMenuItemStateListener(this);
    m_topologyComponent.addVertexUpdateListener(this);
    // Search Box
    m_searchBox = new SearchBox(m_serviceManager, new DefaultOperationContext(this, m_graphContainer, OperationContext.DisplayLocation.SEARCH));
    // Info Panel
    m_infoPanel = new InfoPanel(m_searchBox);
    // Breadcrumb
    m_breadcrumbComponent = new BreadcrumbComponent();
    // Layout hint
    m_layoutHintComponent = new LayoutHintComponent(m_layoutManager, m_graphContainer);
    // Toolbar
    m_toolbarPanel = new ToolbarPanel(new ToolbarPanelController() {

        @Override
        public void refreshUI() {
            new TopologyUI.DynamicUpdateRefresher().refreshUI();
        }

        @Override
        public void saveHistory() {
            TopologyUI.this.saveHistory();
        }

        @Override
        public void saveLayout() {
            m_graphContainer.saveLayout();
        }

        @Override
        public void setActiveTool(ActiveTool activeTool) {
            Objects.requireNonNull(activeTool);
            m_topologyComponent.setActiveTool(activeTool.name());
        }

        @Override
        public void showAllMap() {
            m_topologyComponent.showAllMap();
        }

        @Override
        public void centerMapOnSelection() {
            m_topologyComponent.centerMapOnSelection();
        }

        @Override
        public void toggleHighlightFocus() {
            m_topologyComponent.getState().setHighlightFocus(!m_topologyComponent.getState().isHighlightFocus());
            m_topologyComponent.updateGraph();
        }

        @Override
        public void setSemanticZoomLevel(int semanticZoomLevel) {
            m_graphContainer.setSemanticZoomLevel(semanticZoomLevel);
            m_graphContainer.redoLayout();
        }

        public int getSemanticZoomLevel() {
            return m_graphContainer.getSemanticZoomLevel();
        }

        @Override
        public Property<Double> getScaleProperty() {
            return m_graphContainer.getScaleProperty();
        }

        @Override
        public LayoutManager getLayoutManager() {
            return m_layoutManager;
        }
    });
    // Map Layout (we need to wrap it in an absolute layout otherwise it shows up twice on the topology map)
    AbsoluteLayout mapLayout = new AbsoluteLayout();
    mapLayout.addComponent(m_topologyComponent, "top:0px; left: 0px; right: 0px; bottom: 0px;");
    mapLayout.addComponent(m_breadcrumbComponent, "top:10px; left: 50px");
    mapLayout.addComponent(m_layoutHintComponent, "bottom: 10px; left:20px");
    mapLayout.setSizeFull();
    HorizontalLayout layout = new HorizontalLayout();
    layout.addStyleName("map-layout");
    layout.addComponent(m_infoPanel);
    layout.addComponent(mapLayout);
    layout.addComponent(m_toolbarPanel);
    layout.setExpandRatio(mapLayout, 1);
    layout.setSizeFull();
    return layout;
}
Also used : LayoutHintComponent(org.opennms.features.topology.app.internal.ui.LayoutHintComponent) InfoPanel(org.opennms.features.topology.app.internal.ui.InfoPanel) BreadcrumbComponent(org.opennms.features.topology.app.internal.ui.breadcrumbs.BreadcrumbComponent) SearchBox(org.opennms.features.topology.app.internal.ui.SearchBox) AbsoluteLayout(com.vaadin.ui.AbsoluteLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ToolbarPanelController(org.opennms.features.topology.app.internal.ui.ToolbarPanelController) ToolbarPanel(org.opennms.features.topology.app.internal.ui.ToolbarPanel)

Aggregations

SearchBox (org.opennms.features.topology.app.internal.ui.SearchBox)2 AbsoluteLayout (com.vaadin.ui.AbsoluteLayout)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 IOException (java.io.IOException)1 Hashtable (java.util.Hashtable)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 EasyMock (org.easymock.EasyMock)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1 GraphMLGraph (org.opennms.features.graphml.model.GraphMLGraph)1 InvalidGraphException (org.opennms.features.graphml.model.InvalidGraphException)1 OperationContext (org.opennms.features.topology.api.OperationContext)1 SearchProvider (org.opennms.features.topology.api.topo.SearchProvider)1 VEProviderGraphContainer (org.opennms.features.topology.app.internal.VEProviderGraphContainer)1 SearchSuggestion (org.opennms.features.topology.app.internal.gwt.client.SearchSuggestion)1 DefaultTopologyService (org.opennms.features.topology.app.internal.service.DefaultTopologyService)1 SimpleServiceLocator (org.opennms.features.topology.app.internal.service.SimpleServiceLocator)1 InfoPanel (org.opennms.features.topology.app.internal.ui.InfoPanel)1 LayoutHintComponent (org.opennms.features.topology.app.internal.ui.LayoutHintComponent)1