Search in sources :

Example 1 with HTMLInputElement

use of org.w3c.dom.html.HTMLInputElement in project intellij-plugins by StepicOrg.

the class StudyBrowserWindow method loadContent.

void loadContent(@NotNull String template, @NotNull Map<String, Object> params) {
    String content = getContent(template, params);
    Platform.runLater(() -> {
        Document document = engine.getDocument();
        if (document != null) {
            HTMLFormElement form = (HTMLFormElement) document.getElementById("answer_form");
            if (form != null) {
                HTMLInputElement action = (HTMLInputElement) form.getElements().namedItem("action");
                action.setValue("save_reply");
                FormListener.handle(project, this, form);
            }
        }
        engine.loadContent(content);
    });
}
Also used : HTMLFormElement(org.w3c.dom.html.HTMLFormElement) HTMLInputElement(org.w3c.dom.html.HTMLInputElement) Document(org.w3c.dom.Document)

Example 2 with HTMLInputElement

use of org.w3c.dom.html.HTMLInputElement in project intellij-plugins by StepicOrg.

the class Elements method getInputValue.

@NotNull
String getInputValue(@NotNull String name) {
    Node item = elements.namedItem(name);
    String value = null;
    if (item instanceof HTMLInputElement) {
        value = ((HTMLInputElement) item).getValue();
    } else if (item instanceof HTMLTextAreaElement) {
        value = ((HTMLTextAreaElement) item).getValue();
    }
    return value != null ? value : "";
}
Also used : Node(org.w3c.dom.Node) HTMLInputElement(org.w3c.dom.html.HTMLInputElement) HTMLTextAreaElement(org.w3c.dom.html.HTMLTextAreaElement) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with HTMLInputElement

use of org.w3c.dom.html.HTMLInputElement in project intellij-plugins by StepicOrg.

the class StepDescriptionUtils method disableAllInputs.

private static void disableAllInputs(@NotNull Elements elements) {
    for (Node node : elements) {
        if (node instanceof HTMLInputElement) {
            HTMLInputElement element = (HTMLInputElement) node;
            element.setDisabled(true);
        } else if (node instanceof HTMLTextAreaElement) {
            HTMLTextAreaElement element = (HTMLTextAreaElement) node;
            element.setDisabled(true);
        }
    }
}
Also used : StepNode(org.stepik.core.courseFormat.StepNode) Node(org.w3c.dom.Node) HTMLInputElement(org.w3c.dom.html.HTMLInputElement) HTMLTextAreaElement(org.w3c.dom.html.HTMLTextAreaElement)

Example 4 with HTMLInputElement

use of org.w3c.dom.html.HTMLInputElement in project intellij-plugins by StepicOrg.

the class StepDescriptionUtils method forEachInputElement.

private static void forEachInputElement(@NotNull Elements elements, Consumer<HTMLInputElement> consumer) {
    for (Node node : elements) {
        if (node instanceof HTMLInputElement) {
            HTMLInputElement element = (HTMLInputElement) node;
            consumer.accept(element);
            element.setDisabled(true);
        }
    }
}
Also used : StepNode(org.stepik.core.courseFormat.StepNode) Node(org.w3c.dom.Node) HTMLInputElement(org.w3c.dom.html.HTMLInputElement)

Example 5 with HTMLInputElement

use of org.w3c.dom.html.HTMLInputElement in project intellij-plugins by StepicOrg.

the class StepDescriptionUtils method getBlanks.

private static List<String> getBlanks(@NotNull Elements elements) {
    List<String> blanks = new ArrayList<>();
    for (Node node : elements) {
        if (node instanceof HTMLInputElement) {
            HTMLInputElement element = (HTMLInputElement) node;
            String type = element.getType();
            if ("text".equals(type)) {
                blanks.add(element.getValue());
            }
            element.setDisabled(true);
        } else if (node instanceof HTMLSelectElement) {
            HTMLSelectElement element = (HTMLSelectElement) node;
            blanks.add(element.getValue());
            element.setDisabled(true);
        }
    }
    return blanks;
}
Also used : StepNode(org.stepik.core.courseFormat.StepNode) Node(org.w3c.dom.Node) HTMLInputElement(org.w3c.dom.html.HTMLInputElement) ArrayList(java.util.ArrayList) HTMLSelectElement(org.w3c.dom.html.HTMLSelectElement)

Aggregations

HTMLInputElement (org.w3c.dom.html.HTMLInputElement)5 Node (org.w3c.dom.Node)4 StepNode (org.stepik.core.courseFormat.StepNode)3 HTMLTextAreaElement (org.w3c.dom.html.HTMLTextAreaElement)2 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1 Document (org.w3c.dom.Document)1 HTMLFormElement (org.w3c.dom.html.HTMLFormElement)1 HTMLSelectElement (org.w3c.dom.html.HTMLSelectElement)1