Search in sources :

Example 1 with CheckedOperation

use of org.opennms.features.topology.api.CheckedOperation in project opennms by OpenNMS.

the class TopologyUI method init.

@Override
protected void init(final VaadinRequest request) {
    // Register a cleanup
    request.getService().addSessionDestroyListener((SessionDestroyListener) event -> m_widgetManager.removeUpdateListener(TopologyUI.this));
    try {
        m_headerHtml = getHeader(((VaadinServletRequest) request).getHttpServletRequest());
    } catch (final Exception e) {
        LOG.error("failed to get header HTML for request " + request.getPathInfo(), e.getCause());
    }
    //create VaadinApplicationContext
    m_applicationContext = m_serviceManager.createApplicationContext(new VaadinApplicationContextCreator() {

        @Override
        public VaadinApplicationContext create(OnmsServiceManager manager) {
            VaadinApplicationContextImpl context = new VaadinApplicationContextImpl();
            context.setSessionId(request.getWrappedSession().getId());
            context.setUiId(getUIId());
            context.setUsername(request.getRemoteUser());
            return context;
        }
    });
    m_verticesUpdateManager = new OsgiVerticesUpdateManager(m_serviceManager, m_applicationContext);
    m_serviceManager.getEventRegistry().addPossibleEventConsumer(this, m_applicationContext);
    // Set the algorithm last so that the criteria and SZLs are
    // in place before we run the layout algorithm.
    m_graphContainer.setApplicationContext(m_applicationContext);
    createLayouts();
    // Set up an error handler for UI-level exceptions
    setupErrorHandler();
    // Add an auto refresh handler to the GraphContainer
    setupAutoRefresher();
    loadUserSettings();
    // If no Topology Provider was selected (due to loadUserSettings(), fallback to default
    if (Strings.isNullOrEmpty(m_graphContainer.getMetaTopologyId())) {
        CheckedOperation defaultTopologySelectorOperation = getDefaultTopologySelectorOperation(m_bundlecontext);
        // no default found, abort
        Objects.requireNonNull(defaultTopologySelectorOperation, "No default GraphProvider found.");
        defaultTopologySelectorOperation.execute(Lists.newArrayList(), new DefaultOperationContext(TopologyUI.this, m_graphContainer, DisplayLocation.MENUBAR));
    }
    // Add a request handler that parses incoming focusNode and szl query parameters
    TopologyUIRequestHandler handler = new TopologyUIRequestHandler();
    getSession().addRequestHandler(handler);
    // deal with those in init case
    handler.handleRequestParameter(request);
    // Add the default criteria if we do not have already a criteria set
    if (getWrappedVertexHopCriteria(m_graphContainer).isEmpty() && noAdditionalFocusCriteria()) {
        List<Criteria> defaultCriteriaList = m_graphContainer.getTopologyServiceClient().getDefaults().getCriteria();
        if (defaultCriteriaList != null) {
            // set default
            defaultCriteriaList.forEach(eachCriteria -> m_graphContainer.addCriteria(eachCriteria));
        }
    }
    // We set the listeners at the end, to not fire them all the time when initializing the UI
    setupListeners();
    // We force a reload to trigger a fireGraphChanged()
    m_graphContainer.setDirty(true);
    m_graphContainer.redoLayout();
    // Trigger a selectionChanged
    m_selectionManager.selectionChanged(m_selectionManager);
}
Also used : HasExtraComponents(org.opennms.features.topology.api.HasExtraComponents) VerticalSplitPanel(com.vaadin.ui.VerticalSplitPanel) Alignment(com.vaadin.ui.Alignment) SelectionAwareTable(org.opennms.features.topology.api.browsers.SelectionAwareTable) SearchBox(org.opennms.features.topology.app.internal.ui.SearchBox) VertexHopGraphProvider.getWrappedVertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.getWrappedVertexHopCriteria) CategoryHopCriteria(org.opennms.features.topology.app.internal.support.CategoryHopCriteria) Map(java.util.Map) ServiceReference(org.osgi.framework.ServiceReference) RedoLayoutOperation(org.opennms.features.topology.app.internal.operations.RedoLayoutOperation) VaadinResponse(com.vaadin.server.VaadinResponse) Property(com.vaadin.data.Property) HistoryManager(org.opennms.features.topology.api.HistoryManager) Set(java.util.Set) AbsoluteLayout(com.vaadin.ui.AbsoluteLayout) IconRepositoryManager(org.opennms.features.topology.app.internal.support.IconRepositoryManager) Criteria(org.opennms.features.topology.api.topo.Criteria) VaadinApplicationContextImpl(org.opennms.osgi.VaadinApplicationContextImpl) VertexRef(org.opennms.features.topology.api.topo.VertexRef) MenuUpdateListener(org.opennms.features.topology.app.internal.menu.MenuUpdateListener) DefaultErrorHandler(com.vaadin.server.DefaultErrorHandler) UriFragmentChangedListener(com.vaadin.server.Page.UriFragmentChangedListener) Title(com.vaadin.annotations.Title) VerticalLayout(com.vaadin.ui.VerticalLayout) TreeSet(java.util.TreeSet) VertexHopGraphProvider(org.opennms.features.topology.api.support.VertexHopGraphProvider) VertexUpdateListener(org.opennms.features.topology.app.internal.TopologyComponent.VertexUpdateListener) DefaultTopologyProviderInfo(org.opennms.features.topology.api.topo.DefaultTopologyProviderInfo) Strings(com.google.common.base.Strings) HttpServletRequest(javax.servlet.http.HttpServletRequest) Lists(com.google.common.collect.Lists) VaadinApplicationContextCreator(org.opennms.osgi.VaadinApplicationContextCreator) TopologyMenuBar(org.opennms.features.topology.app.internal.menu.TopologyMenuBar) OnmsHeaderProvider(org.opennms.web.api.OnmsHeaderProvider) InfoPanelItem(org.opennms.features.topology.api.info.item.InfoPanelItem) IOException(java.io.IOException) PreserveOnRefresh(com.vaadin.annotations.PreserveOnRefresh) Refresher(com.github.wolfie.refresher.Refresher) LayoutHintComponent(org.opennms.features.topology.app.internal.ui.LayoutHintComponent) HorizontalLayout(com.vaadin.ui.HorizontalLayout) TopologyProviderInfo(org.opennms.features.topology.api.topo.TopologyProviderInfo) InfoPanelItemProvider(org.opennms.features.topology.api.info.InfoPanelItemProvider) OperationManager(org.opennms.features.topology.app.internal.menu.OperationManager) ContentType(org.opennms.features.topology.api.browsers.ContentType) EventConsumer(org.opennms.osgi.EventConsumer) GraphContainer(org.opennms.features.topology.api.GraphContainer) ConfirmationDialog(org.opennms.netmgt.vaadin.core.ConfirmationDialog) RequestHandler(com.vaadin.server.RequestHandler) ToolbarPanel(org.opennms.features.topology.app.internal.ui.ToolbarPanel) LoggerFactory(org.slf4j.LoggerFactory) UI(com.vaadin.ui.UI) CheckedOperation(org.opennms.features.topology.api.CheckedOperation) Window(com.vaadin.ui.Window) VaadinRequest(com.vaadin.server.VaadinRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) DefaultInfoPanelItem(org.opennms.features.topology.api.info.item.DefaultInfoPanelItem) SelectionListener(org.opennms.features.topology.api.SelectionListener) VaadinApplicationContext(org.opennms.osgi.VaadinApplicationContext) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) Collection(java.util.Collection) OnmsServiceManager(org.opennms.osgi.OnmsServiceManager) Collectors(java.util.stream.Collectors) BundleContext(org.osgi.framework.BundleContext) Objects(java.util.Objects) List(java.util.List) Theme(com.vaadin.annotations.Theme) HudDisplay(org.opennms.features.topology.app.internal.ui.HudDisplay) TabSheet(com.vaadin.ui.TabSheet) TransactionOperations(org.springframework.transaction.support.TransactionOperations) VertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria) TopologyContextMenu(org.opennms.features.topology.app.internal.menu.TopologyContextMenu) Optional(java.util.Optional) WidgetUpdateListener(org.opennms.features.topology.api.WidgetUpdateListener) IViewContribution(org.opennms.features.topology.api.IViewContribution) SessionDestroyListener(com.vaadin.server.SessionDestroyListener) VerticesUpdateManager(org.opennms.features.topology.api.VerticesUpdateManager) WidgetManager(org.opennms.features.topology.api.WidgetManager) LayoutManager(org.opennms.features.topology.app.internal.support.LayoutManager) TopologyLinkBuilder(org.opennms.features.topology.link.TopologyLinkBuilder) SelectionContext(org.opennms.features.topology.api.SelectionContext) Vertex(org.opennms.features.topology.api.topo.Vertex) MapViewManager(org.opennms.features.topology.api.MapViewManager) BreadcrumbComponent(org.opennms.features.topology.app.internal.ui.breadcrumbs.BreadcrumbComponent) CustomLayout(com.vaadin.ui.CustomLayout) SelectionNotifier(org.opennms.features.topology.api.SelectionNotifier) OnmsServiceManagerLocator(org.opennms.osgi.locator.OnmsServiceManagerLocator) Notification(com.vaadin.ui.Notification) Label(com.vaadin.ui.Label) WidgetContext(org.opennms.features.topology.api.WidgetContext) Logger(org.slf4j.Logger) SelectedTabChangeEvent(com.vaadin.ui.TabSheet.SelectedTabChangeEvent) DisplayLocation(org.opennms.features.topology.api.OperationContext.DisplayLocation) MapViewManagerListener(org.opennms.features.topology.api.MapViewManagerListener) InfoPanel(org.opennms.features.topology.app.internal.ui.InfoPanel) VaadinServletRequest(com.vaadin.server.VaadinServletRequest) SelectedTabChangeListener(com.vaadin.ui.TabSheet.SelectedTabChangeListener) UriFragmentChangedEvent(com.vaadin.server.Page.UriFragmentChangedEvent) VaadinSession(com.vaadin.server.VaadinSession) OperationContext(org.opennms.features.topology.api.OperationContext) ToolbarPanelController(org.opennms.features.topology.app.internal.ui.ToolbarPanelController) SelectionManager(org.opennms.features.topology.api.SelectionManager) NoSuchProviderException(org.opennms.features.topology.app.internal.service.NoSuchProviderException) NoContentAvailableWindow(org.opennms.features.topology.app.internal.ui.NoContentAvailableWindow) StyleSheet(com.vaadin.annotations.StyleSheet) Collections(java.util.Collections) InputStream(java.io.InputStream) Component(com.vaadin.ui.Component) OnmsServiceManager(org.opennms.osgi.OnmsServiceManager) VaadinApplicationContextCreator(org.opennms.osgi.VaadinApplicationContextCreator) VaadinApplicationContextImpl(org.opennms.osgi.VaadinApplicationContextImpl) CheckedOperation(org.opennms.features.topology.api.CheckedOperation) VaadinServletRequest(com.vaadin.server.VaadinServletRequest) VertexHopGraphProvider.getWrappedVertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.getWrappedVertexHopCriteria) CategoryHopCriteria(org.opennms.features.topology.app.internal.support.CategoryHopCriteria) Criteria(org.opennms.features.topology.api.topo.Criteria) VertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria) IOException(java.io.IOException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) NoSuchProviderException(org.opennms.features.topology.app.internal.service.NoSuchProviderException)

Aggregations

Refresher (com.github.wolfie.refresher.Refresher)1 Strings (com.google.common.base.Strings)1 Lists (com.google.common.collect.Lists)1 PreserveOnRefresh (com.vaadin.annotations.PreserveOnRefresh)1 StyleSheet (com.vaadin.annotations.StyleSheet)1 Theme (com.vaadin.annotations.Theme)1 Title (com.vaadin.annotations.Title)1 Property (com.vaadin.data.Property)1 DefaultErrorHandler (com.vaadin.server.DefaultErrorHandler)1 UriFragmentChangedEvent (com.vaadin.server.Page.UriFragmentChangedEvent)1 UriFragmentChangedListener (com.vaadin.server.Page.UriFragmentChangedListener)1 RequestHandler (com.vaadin.server.RequestHandler)1 SessionDestroyListener (com.vaadin.server.SessionDestroyListener)1 VaadinRequest (com.vaadin.server.VaadinRequest)1 VaadinResponse (com.vaadin.server.VaadinResponse)1 VaadinServletRequest (com.vaadin.server.VaadinServletRequest)1 VaadinSession (com.vaadin.server.VaadinSession)1 AbsoluteLayout (com.vaadin.ui.AbsoluteLayout)1 Alignment (com.vaadin.ui.Alignment)1 Component (com.vaadin.ui.Component)1