Search in sources :

Example 26 with RegExp

use of com.google.gwt.regexp.shared.RegExp in project rstudio by rstudio.

the class NewConnectionSnippetHost method parseSnippet.

private ArrayList<NewConnectionSnippetParts> parseSnippet(String input) {
    ArrayList<NewConnectionSnippetParts> parts = new ArrayList<NewConnectionSnippetParts>();
    RegExp regExp = RegExp.compile(pattern_, "g");
    for (MatchResult matcher = regExp.exec(input); matcher != null; matcher = regExp.exec(input)) {
        if (matcher.getGroupCount() >= 2) {
            int order = 0;
            try {
                order = Integer.parseInt(matcher.getGroup(1));
            } catch (NumberFormatException e) {
            }
            String key = matcher.getGroup(2);
            String value = matcher.getGroupCount() >= 4 ? matcher.getGroup(4) : null;
            String connStringField = matcher.getGroupCount() >= 6 ? matcher.getGroup(6) : null;
            if (value != null) {
                value = value.replaceAll("\\$colon\\$", ":");
                value = value.replaceAll("\\$equal\\$", "=");
            }
            parts.add(new NewConnectionSnippetParts(order, key, value, connStringField));
        }
    }
    Collections.sort(parts, new Comparator<NewConnectionSnippetParts>() {

        @Override
        public int compare(NewConnectionSnippetParts p1, NewConnectionSnippetParts p2) {
            return p1.getOrder() - p2.getOrder();
        }
    });
    return parts;
}
Also used : RegExp(com.google.gwt.regexp.shared.RegExp) ArrayList(java.util.ArrayList) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Example 27 with RegExp

use of com.google.gwt.regexp.shared.RegExp in project kie-wb-common by kiegroup.

the class AssignmentListItemWidgetTest method testInitWidget.

@Test
public void testInitWidget() {
    widget.init();
    verify(widget, times(1)).init();
    verify(dataTypeComboBox, times(1)).init(widget, false, dataType, customDataType, false, true, AssignmentListItemWidgetView.CUSTOM_PROMPT, AssignmentListItemWidgetView.ENTER_TYPE_PROMPT);
    verify(processVarComboBox, times(1)).init(widget, false, processVar, constant, true, true, AssignmentListItemWidgetView.CONSTANT_PROMPT, AssignmentListItemWidgetView.ENTER_CONSTANT_PROMPT);
    verify(name, times(1)).setRegExp(regExpCaptor.capture(), anyString(), anyString());
    RegExp regExp = RegExp.compile(regExpCaptor.getValue());
    assertEquals(false, regExp.test("a 1"));
    assertEquals(false, regExp.test("a@1"));
    assertEquals(true, regExp.test("a1"));
    verify(customDataType, times(1)).addKeyDownHandler(any(KeyDownHandler.class));
    verify(name, times(1)).addBlurHandler(any(BlurHandler.class));
}
Also used : BlurHandler(com.google.gwt.event.dom.client.BlurHandler) RegExp(com.google.gwt.regexp.shared.RegExp) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) Test(org.junit.Test)

Example 28 with RegExp

use of com.google.gwt.regexp.shared.RegExp in project kie-wb-common by kiegroup.

the class VariableListItemWidgetTest method testInitWidget.

@Test
public void testInitWidget() {
    widget.init();
    verify(widget, times(1)).init();
    verify(dataTypeComboBox, times(1)).init(widget, true, dataType, customDataType, false, true, VariableListItemWidgetView.CUSTOM_PROMPT, VariableListItemWidgetView.ENTER_TYPE_PROMPT);
    verify(name, times(1)).setRegExp(regExpCaptor.capture(), anyString(), anyString());
    RegExp regExp = RegExp.compile(regExpCaptor.getValue());
    assertEquals(false, regExp.test("a 1"));
    assertEquals(false, regExp.test("a@1"));
    assertEquals(true, regExp.test("a1"));
    verify(customDataType, times(1)).addKeyDownHandler(any(KeyDownHandler.class));
    verify(name, times(1)).addBlurHandler(any(BlurHandler.class));
}
Also used : BlurHandler(com.google.gwt.event.dom.client.BlurHandler) RegExp(com.google.gwt.regexp.shared.RegExp) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) Test(org.junit.Test)

Example 29 with RegExp

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

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

RegExp (com.google.gwt.regexp.shared.RegExp)34 MatchResult (com.google.gwt.regexp.shared.MatchResult)23 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)7 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)4 BasicOverlayType (cz.metacentrum.perun.webgui.model.BasicOverlayType)4 IsLoginAvailable (cz.metacentrum.perun.webgui.json.usersManager.IsLoginAvailable)3 SetLogin (cz.metacentrum.perun.webgui.json.usersManager.SetLogin)3 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)3 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)3 ArrayList (java.util.ArrayList)3 BlurHandler (com.google.gwt.event.dom.client.BlurHandler)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)2 GetEntityById (cz.metacentrum.perun.webgui.json.GetEntityById)2 CreatePassword (cz.metacentrum.perun.webgui.json.usersManager.CreatePassword)2 GenerateAccount (cz.metacentrum.perun.webgui.json.usersManager.GenerateAccount)2 PerunError (cz.metacentrum.perun.webgui.model.PerunError)2 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)2 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)2