Search in sources :

Example 36 with MatchResult

use of com.google.gwt.regexp.shared.MatchResult 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 37 with MatchResult

use of com.google.gwt.regexp.shared.MatchResult in project webprotege by protegeproject.

the class TextFieldEditor method validateInput.

private void validateInput() {
    GWT.log("[TextFieldEditor] Validating input.");
    GWT.log("[TextFieldEditor] Pattern: " + pattern);
    if (pattern.isPresent()) {
        RegExp regExp = RegExp.compile(pattern.get());
        String value = editor.getText().trim();
        GWT.log("[TextFieldEditor] Value: " + value);
        MatchResult mr = regExp.exec(value);
        GWT.log("[TextFieldEditor] Match: " + mr);
        if (mr == null) {
            GWT.log("[TextFieldEditor] Input is not valid");
            if (patternViolationErrorMessage.isPresent()) {
                editor.setTitle(patternViolationErrorMessage.get());
            }
            displayErrorBorder();
        } else {
            GWT.log("[TextFieldEditor] Input is valid");
            clearErrorBorder();
        }
    }
}
Also used : RegExp(com.google.gwt.regexp.shared.RegExp) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Example 38 with MatchResult

use of com.google.gwt.regexp.shared.MatchResult in project webprotege by protegeproject.

the class ProjectTagsPlaceTokenizer method getPlace.

@Override
public ProjectTagsPlace getPlace(String token) {
    MatchResult matchResult = regExp.exec(token);
    if (matchResult == null) {
        return null;
    }
    String projectIdString = matchResult.getGroup(1);
    if (ProjectId.isWelFormedProjectId(projectIdString)) {
        ProjectId projectId = ProjectId.get(projectIdString);
        return new ProjectTagsPlace(projectId, Optional.empty());
    } else {
        return null;
    }
}
Also used : ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Example 39 with MatchResult

use of com.google.gwt.regexp.shared.MatchResult in project webprotege by protegeproject.

the class ProjectViewPlaceTokenizer method getPlace.

public ProjectViewPlace getPlace(String token) {
    GWT.log("[ProjectViewPlaceTokenizer] Parsing: " + token);
    token = URL.decode(token);
    GWT.log("[ProjectViewPlaceTokenizer] Decoded: " + token);
    MatchResult result = regExp.exec(token);
    GWT.log("[ProjectViewPlaceTokenizer] MatchResult: " + result);
    String projectId = result.getGroup(1);
    String perspectiveId = result.getGroup(2);
    String selectionString = result.getGroup(4);
    GWT.log("[ProjectViewPlaceTokenizer] Parsed: ProjectId: " + projectId);
    GWT.log("[ProjectViewPlaceTokenizer] Parsed: PerspectiveId: " + perspectiveId);
    GWT.log("[ProjectViewPlaceTokenizer] Parsed: Selection: " + selectionString);
    ProjectViewPlace.Builder builder = new ProjectViewPlace.Builder(ProjectId.get(projectId), new PerspectiveId(perspectiveId));
    if (selectionString != null) {
        ItemTokenizer tokenizer = new ItemTokenizer();
        List<ItemToken> tokenList = tokenizer.parseTokens(selectionString);
        for (ItemToken t : tokenList) {
            OWLDataFactoryImpl dataFactory = new OWLDataFactoryImpl();
            ItemTokenParser parser = new ItemTokenParser();
            DefaultPrefixManager prefixManager = new DefaultPrefixManager();
            prefixManager.setPrefix("owl:", Namespaces.OWL.getPrefixIRI());
            List<Item<?>> entity = parser.parse(t, new DefaultItemTypeMapper(dataFactory, prefixManager));
            for (Item<?> item : entity) {
                builder.withSelectedItem(item);
            }
        }
    }
    return builder.build();
}
Also used : DefaultPrefixManager(org.semanticweb.owlapi.util.DefaultPrefixManager) PerspectiveId(edu.stanford.bmir.protege.web.shared.perspective.PerspectiveId) MatchResult(com.google.gwt.regexp.shared.MatchResult) OWLDataFactoryImpl(uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl)

Example 40 with MatchResult

use of com.google.gwt.regexp.shared.MatchResult in project webprotege by protegeproject.

the class ItemTokenizer method parseTokens.

public List<ItemToken> parseTokens(String buffer) {
    List<ItemToken> result = Lists.newArrayList();
    RegExp regExp = RegExp.compile(REGEX);
    List<String> tokens = getSeparatedTokens(buffer);
    for (String token : tokens) {
        MatchResult matchResult = regExp.exec(token);
        if (matchResult != null) {
            String type = matchResult.getGroup(TYPE_GROUP);
            String content = matchResult.getGroup(CONTENT_GROUP);
            result.add(new ItemToken(type, content));
        }
    }
    return result;
}
Also used : RegExp(com.google.gwt.regexp.shared.RegExp) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Aggregations

MatchResult (com.google.gwt.regexp.shared.MatchResult)47 RegExp (com.google.gwt.regexp.shared.RegExp)23 ArrayList (java.util.ArrayList)7 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)3 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)3 JsArrayString (com.google.gwt.core.client.JsArrayString)1 Node (com.google.gwt.dom.client.Node)1 PreElement (com.google.gwt.dom.client.PreElement)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 BasicOverlayType (cz.metacentrum.perun.webgui.model.BasicOverlayType)1 ItemTexts (cz.metacentrum.perun.webgui.model.ItemTexts)1 AutoCompletionChoice (edu.stanford.bmir.gwtcodemirror.client.AutoCompletionChoice)1 AutoCompletionResult (edu.stanford.bmir.gwtcodemirror.client.AutoCompletionResult)1 EditorPosition (edu.stanford.bmir.gwtcodemirror.client.EditorPosition)1 CollectionId (edu.stanford.bmir.protege.web.shared.collection.CollectionId)1 CollectionItem (edu.stanford.bmir.protege.web.shared.collection.CollectionItem)1 FormId (edu.stanford.bmir.protege.web.shared.form.FormId)1 GetUserIdCompletionsAction (edu.stanford.bmir.protege.web.shared.itemlist.GetUserIdCompletionsAction)1