Example usage for javafx.scene Node lookupAll

List of usage examples for javafx.scene Node lookupAll

Introduction

In this page you can find the example usage for javafx.scene Node lookupAll.

Prototype

public Set<Node> lookupAll(String selector) 

Source Link

Document

Finds all Node s, including this one and any children, which match the given CSS selector.

Usage

From source file:de.bayern.gdi.gui.Controller.java

private List<ProcessingStep> extractProcessingSteps() {

    List<ProcessingStep> steps = new ArrayList<>();
    if (!this.chkChain.isSelected()) {
        return steps;
    }/*ww w  . ja v a  2 s  . c  o  m*/

    Set<Node> parameter = this.chainContainer.lookupAll("#process_parameter");

    if (parameter.isEmpty()) {
        return steps;
    }

    String format = this.dataBean.getAttributeValue(OUTPUTFORMAT);
    if (format == null || format.isEmpty()) {
        setStatusTextUI(I18n.getMsg(GUI_PROCESS_NO_FORMAT));
        logToAppLog(I18n.getMsg(GUI_PROCESS_NO_FORMAT));
        return steps;
    }

    MIMETypes mtypes = Config.getInstance().getMimeTypes();
    MIMEType mtype = mtypes.findByName(format);
    if (mtype == null) {
        setStatusTextUI(I18n.getMsg(GUI_PROCESS_FORMAT_NOT_FOUND));
        logToAppLog(I18n.getMsg(GUI_PROCESS_FORMAT_NOT_FOUND));
        return steps;
    }

    for (Node n : parameter) {
        Set<Node> vars = n.lookupAll("#process_var");
        Node nameNode = n.lookup("#process_name");
        ComboBox namebox = (ComboBox) nameNode;
        ProcessingStepConfiguration psc = (ProcessingStepConfiguration) namebox.getValue();

        String name = psc.getName();

        if (!psc.isCompatibleWithFormat(mtype.getType())) {
            setStatusTextUI(I18n.format(GUI_PROCESS_NOT_COMPATIBLE, name));
            logToAppLog(I18n.format(GUI_PROCESS_NOT_COMPATIBLE, name));
            continue;
        }

        ProcessingStep step = new ProcessingStep();
        steps.add(step);
        step.setName(name);
        ArrayList<Parameter> parameters = new ArrayList<>();
        step.setParameters(parameters);

        for (Node v : vars) {
            String varName = null;
            String varValue = null;
            if (v instanceof TextField) {
                TextField input = (TextField) v;
                varName = input.getUserData().toString();
                varValue = input.getText();
            } else if (v instanceof ComboBox) {
                ComboBox input = (ComboBox) v;
                varName = input.getUserData().toString();
                varValue = input.getValue() != null ? ((Option) input.getValue()).getValue() : null;
            }
            if (varName != null && varValue != null) {
                Parameter p = new Parameter(varName, varValue);
                parameters.add(p);
            }
        }
    }
    return steps;
}