use of org.opennms.features.vaadin.nodemaps.internal.gwt.client.AlarmSeverity in project opennms by OpenNMS.
the class MarkerFilterImpl method matches.
@Override
public boolean matches(final NodeMarker marker) {
if (marker == null)
return false;
final AlarmSeverity severity;
if (marker.getSeverity() == null) {
severity = AlarmSeverity.NORMAL;
} else {
severity = AlarmSeverity.get(marker.getSeverity());
}
if (severity.isLessThan(m_minimumSeverity))
return false;
if (m_searchString == null || "".equals(m_searchString))
return true;
final String searchProperty;
final MatchType matchType;
final List<String> searchFor = new ArrayList<>();
final MatchResult m = m_searchPattern.exec(m_searchString);
if (m != null) {
searchProperty = m.getGroup(1);
matchType = MatchType.fromToken(m.getGroup(2));
final String searchCriteria = m.getGroup(3);
if (matchType == MatchType.IN) {
final String ignoreParens = searchCriteria.replaceAll("^\\s*\\(\\s*(.*)\\s*\\)\\s*$", "$1");
for (final String s : ignoreParens.split("\\s*,\\s*")) {
searchFor.add(s);
}
} else {
searchFor.add(searchCriteria);
}
} else {
searchProperty = null;
matchType = MatchType.SUBSTRING;
searchFor.add(m_searchString);
}
final Map<String, String> markerProperties = marker.getProperties();
if (searchProperty != null) {
return matchProperty(matchType, searchProperty, searchFor, markerProperties);
} else {
for (final String key : markerProperties.keySet()) {
if (matchProperty(matchType, key, searchFor, markerProperties)) {
return true;
}
}
}
return false;
}
use of org.opennms.features.vaadin.nodemaps.internal.gwt.client.AlarmSeverity in project opennms by OpenNMS.
the class AlarmControl method doOnAdd.
public Element doOnAdd() {
LOG.info("AlarmControl.doOnAdd()");
final AlarmControlCss css = AlarmControlBundle.INSTANCE.css();
css.ensureInjected();
m_eventManager.addHandler(AlarmSeverityUpdatedEvent.TYPE, this);
this.setStylePrimaryName("leaflet-control-alarm");
this.addStyleName("leaflet-bar");
this.addStyleName("leaflet-control");
final Label label = new Label("Show Severity >=");
label.getElement().setAttribute("for", "alarmControl");
label.addStyleName(css.label());
m_severityBox = new ListBox(false);
m_severityBox.getElement().setId("alarmControl");
for (final AlarmSeverity sev : AlarmSeverity.values()) {
m_severityBox.addItem(sev.getLabel());
}
m_severityBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(final ChangeEvent event) {
final int selected = m_severityBox.getSelectedIndex();
LOG.info("new selection index = " + selected);
final String value = m_severityBox.getValue(selected);
LOG.info("new severity = " + value);
m_eventManager.fireEvent(new AlarmSeverityUpdatedEvent(AlarmSeverity.get(value)));
event.stopPropagation();
}
});
m_severityBox.addStyleName(css.label());
this.add(label);
this.add(m_severityBox);
LOG.info("AlarmControl.doOnAdd(): finished, returning: " + this.getElement());
m_componentTracker.ready(getClass());
return this.getElement();
}
Aggregations