Search in sources :

Example 1 with AlarmSeverity

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;
}
Also used : AlarmSeverity(org.opennms.features.vaadin.nodemaps.internal.gwt.client.AlarmSeverity) ArrayList(java.util.ArrayList) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Example 2 with AlarmSeverity

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();
}
Also used : AlarmSeverity(org.opennms.features.vaadin.nodemaps.internal.gwt.client.AlarmSeverity) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Label(com.google.gwt.user.client.ui.Label) AlarmSeverityUpdatedEvent(org.opennms.features.vaadin.nodemaps.internal.gwt.client.event.AlarmSeverityUpdatedEvent) ListBox(com.google.gwt.user.client.ui.ListBox)

Aggregations

AlarmSeverity (org.opennms.features.vaadin.nodemaps.internal.gwt.client.AlarmSeverity)2 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 MatchResult (com.google.gwt.regexp.shared.MatchResult)1 Label (com.google.gwt.user.client.ui.Label)1 ListBox (com.google.gwt.user.client.ui.ListBox)1 ArrayList (java.util.ArrayList)1 AlarmSeverityUpdatedEvent (org.opennms.features.vaadin.nodemaps.internal.gwt.client.event.AlarmSeverityUpdatedEvent)1