use of org.opennms.osgi.EventProxy in project opennms by OpenNMS.
the class BlueprintIViewContribution method getView.
@Override
public Component getView(final VaadinApplicationContext vaadinApplicationContext, final WidgetContext widgetContext) {
// Get the component by asking the blueprint container to instantiate a prototype bean
final Component component = (Component) m_container.getComponentInstance(m_beanId);
final BundleContext bundleContext = (BundleContext) m_container.getComponentInstance("blueprintBundleContext");
final EventProxy eventProxy = vaadinApplicationContext.getEventProxy(bundleContext);
eventProxy.addPossibleEventConsumer(component);
injectEventProxy(component, eventProxy);
injectVaadinApplicationContext(component, vaadinApplicationContext);
return component;
}
use of org.opennms.osgi.EventProxy 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();
}
}
use of org.opennms.osgi.EventProxy in project opennms by OpenNMS.
the class AlarmDetailsDashlet method getDashboardComponent.
@Override
public DashletComponent getDashboardComponent() {
if (m_dashboardComponent == null) {
m_dashboardComponent = new AbstractDashletComponent() {
private AlarmTable m_alarmTable;
{
m_alarmTable = new AlarmTable("Alarms", new AlarmDaoContainer(m_alarmDao, m_transactionTemplate), m_alarmRepository);
m_alarmTable.setSizeFull();
m_alarmTable.setSortEnabled(false);
m_alarmTable.addHeaderClickListener(new Table.HeaderClickListener() {
@Override
public void headerClick(Table.HeaderClickEvent headerClickEvent) {
m_alarmTable.setSortContainerPropertyId(headerClickEvent.getPropertyId());
m_alarmTable.setSortEnabled(true);
}
});
final VaadinApplicationContextImpl context = new VaadinApplicationContextImpl();
final UI currentUI = UI.getCurrent();
context.setSessionId(currentUI.getSession().getSession().getId());
context.setUiId(currentUI.getUIId());
m_alarmTable.setVaadinApplicationContext(context);
final EventProxy eventProxy = new EventProxy() {
@Override
public <T> void fireEvent(final T eventObject) {
System.out.println("got event: {}" + eventObject);
}
@Override
public <T> void addPossibleEventConsumer(final T possibleEventConsumer) {
System.out.println("(ignoring) add consumer: {}" + possibleEventConsumer);
}
};
m_alarmTable.setEventProxy(eventProxy);
m_alarmTable.setColumnReorderingAllowed(true);
m_alarmTable.setColumnCollapsingAllowed(true);
m_alarmTable.setSortContainerPropertyId("id");
m_alarmTable.setSortAscending(false);
m_alarmTable.setCellStyleGenerator(new AlarmTableCellStyleGenerator());
m_alarmTable.addGeneratedColumn("severity", new SeverityGenerator());
m_alarmTable.addGeneratedColumn("id", new AlarmIdColumnLinkGenerator(m_alarmDao, "id"));
m_alarmTable.setVisibleColumns("id", "severity", "nodeLabel", "counter", "lastEventTime", "logMsg");
m_alarmTable.setColumnHeaders("ID", "Severity", "Node", "Count", "Last Event Time", "Log Message");
refresh();
}
@Override
public void refresh() {
List<OnmsAlarm> alarms = getAlarms();
List<Integer> alarmIds = new LinkedList<>();
if (alarms.size() > 0) {
for (OnmsAlarm onmsAlarm : alarms) {
alarmIds.add(onmsAlarm.getId());
}
} else {
alarmIds.add(0);
}
List<Restriction> restrictions = new LinkedList<>();
restrictions.add(new InRestriction("id", alarmIds));
((OnmsVaadinContainer<?, ?>) m_alarmTable.getContainerDataSource()).setRestrictions(restrictions);
setBoosted(checkBoosted(alarms));
m_alarmTable.markAsDirtyRecursive();
}
@Override
public Component getComponent() {
return m_alarmTable;
}
};
}
return m_dashboardComponent;
}
Aggregations