Search in sources :

Example 1 with VerticesUpdateEvent

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

the class NodeMapsApplication method init.

@Override
protected void init(final VaadinRequest vaadinRequest) {
    m_request = vaadinRequest;
    LOG.debug("initializing");
    final VaadinApplicationContextImpl context = new VaadinApplicationContextImpl();
    final UI currentUI = UI.getCurrent();
    context.setSessionId(currentUI.getSession().getSession().getId());
    context.setUiId(currentUI.getUIId());
    context.setUsername(vaadinRequest.getRemoteUser());
    Assert.notNull(m_alarmTable);
    Assert.notNull(m_nodeTable);
    final String searchString = vaadinRequest.getParameter("search");
    final Integer maxClusterRadius = Integer.getInteger("gwt.maxClusterRadius", 350);
    LOG.info("Starting search string: {}, max cluster radius: {}", searchString, maxClusterRadius);
    m_alarmTable.setVaadinApplicationContext(context);
    final EventProxy eventProxy = new EventProxy() {

        @Override
        public <T> void fireEvent(final T eventObject) {
            LOG.debug("got event: {}", eventObject);
            if (eventObject instanceof VerticesUpdateEvent) {
                final VerticesUpdateEvent event = (VerticesUpdateEvent) eventObject;
                final List<Integer> nodeIds = new ArrayList<>();
                for (final VertexRef ref : event.getVertexRefs()) {
                    if ("nodes".equals(ref.getNamespace()) && ref.getId() != null) {
                        nodeIds.add(Integer.valueOf(ref.getId()));
                    }
                }
                m_nodeMapComponent.setSelectedNodes(nodeIds);
                return;
            }
            LOG.warn("Unsure how to deal with event: {}", eventObject);
        }

        @Override
        public <T> void addPossibleEventConsumer(final T possibleEventConsumer) {
            LOG.debug("(ignoring) add consumer: {}", possibleEventConsumer);
        /* throw new UnsupportedOperationException("Not yet implemented!"); */
        }
    };
    m_alarmTable.setEventProxy(eventProxy);
    m_nodeTable.setEventProxy(eventProxy);
    createMapPanel(searchString, maxClusterRadius);
    createRootLayout();
    addRefresher();
    // Notify the user if no tileserver url or options are set
    if (!configuration.isValid()) {
        new InvalidConfigurationWindow(configuration).open();
    }
}
Also used : VerticesUpdateEvent(org.opennms.features.topology.api.VerticesUpdateManager.VerticesUpdateEvent) VaadinApplicationContextImpl(org.opennms.osgi.VaadinApplicationContextImpl) UI(com.vaadin.ui.UI) ArrayList(java.util.ArrayList) VertexRef(org.opennms.features.topology.api.topo.VertexRef) EventProxy(org.opennms.osgi.EventProxy)

Aggregations

UI (com.vaadin.ui.UI)1 ArrayList (java.util.ArrayList)1 VerticesUpdateEvent (org.opennms.features.topology.api.VerticesUpdateManager.VerticesUpdateEvent)1 VertexRef (org.opennms.features.topology.api.topo.VertexRef)1 EventProxy (org.opennms.osgi.EventProxy)1 VaadinApplicationContextImpl (org.opennms.osgi.VaadinApplicationContextImpl)1