Example usage for com.google.gwt.xml.client NamedNodeMap getNamedItem

List of usage examples for com.google.gwt.xml.client NamedNodeMap getNamedItem

Introduction

In this page you can find the example usage for com.google.gwt.xml.client NamedNodeMap getNamedItem.

Prototype

Node getNamedItem(String name);

Source Link

Document

This method gets the item having the given name.

Usage

From source file:ccc.client.gwt.core.GWTValidations.java

License:Open Source License

/** {@inheritDoc} */
@Override//from   ww  w .j a v a2s. c om
public String notValidXML(final String definition) {
    try {
        final Document d = XMLParser.parse(definition);
        final NodeList fields = d.getElementsByTagName("field");
        if (fields.getLength() > 32) {
            return UI_CONSTANTS.tooManyFields();
        }

        final NodeList l = d.getElementsByTagName("option");
        for (int n = 0; n < l.getLength(); n++) {
            final NamedNodeMap al = l.item(n).getAttributes();
            final Node value = al.getNamedItem("value");
            if (value != null && value.getNodeValue().indexOf(',') != -1) {
                return "XML option value " + UI_CONSTANTS.mustNotContainComma();
            }
        }
    } catch (final DOMParseException e) {
        return "XML " + UI_CONSTANTS.isNotValid();
    }
    return null;
}

From source file:edu.cudenver.bios.glimmpse.client.panels.guided.CategoricalPredictorsPanel.java

License:Open Source License

@Override
public void loadFromNode(Node node) {
    if (GlimmpseConstants.TAG_CATEGORICAL_PREDICTORS.equalsIgnoreCase(node.getNodeName())) {
        NodeList children = node.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node child = children.item(i);
            String childName = child.getNodeName();
            if (GlimmpseConstants.TAG_PREDICTOR.equalsIgnoreCase(childName)) {
                NamedNodeMap attrs = child.getAttributes();
                Node nameNode = attrs.getNamedItem(GlimmpseConstants.ATTR_NAME);
                if (nameNode != null && !nameNode.getNodeValue().isEmpty()) {
                    String predictor = nameNode.getNodeValue();
                    addPredictor(predictor);
                    loadCategoriesFromNode(child, predictor);
                }//from ww  w  .  ja  v  a 2  s .c o m
            }
        }
        // notify listeners and reset changed to false after initial setup
        DataTable groups = buildGroupTable();
        for (PredictorsListener listener : listeners)
            listener.onPredictors(predictorCategoryMap, groups);
        changed = false;
    }
    checkComplete();
}

From source file:edu.cudenver.bios.glimmpse.client.panels.guided.HypothesisIndependentMeasuresPanel.java

License:Open Source License

@Override
public void loadFromNode(Node node) {
    if (GlimmpseConstants.TAG_HYPOTHESIS.equalsIgnoreCase(node.getNodeName())) {
        NamedNodeMap attr = node.getAttributes();
        Node typeNode = attr.getNamedItem(GlimmpseConstants.ATTR_TYPE);
        if (typeNode != null) {
            Node valueNode = node.getFirstChild();
            if (valueNode != null) {
                try {
                    int selected = Integer.parseInt(valueNode.getNodeValue());
                    Widget w = null;/*from  w w w. java2 s  .  c  o  m*/
                    if (TYPE_INTERACTION.equals(typeNode.getNodeValue()))
                        w = interactionsTable.getWidget(selected, 0);
                    else
                        w = mainEffectsTable.getWidget(selected, 0);
                    if (w != null) {
                        ((RadioButton) w).setValue(true);
                    }
                } catch (NumberFormatException e) {
                    // catch but ignore
                }
            }
        }
    }
}

From source file:edu.cudenver.bios.glimmpse.client.panels.guided.MeanDifferencesPanel.java

License:Open Source License

@Override
public void loadFromNode(Node node) {
    if (GlimmpseConstants.TAG_FIXED_RANDOM_MATRIX.equalsIgnoreCase(node.getNodeName())) {
        NodeList children = node.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node child = children.item(i);
            String childName = child.getNodeName();
            if (GlimmpseConstants.TAG_MATRIX.equals(childName)) {
                NamedNodeMap childattrs = child.getAttributes();
                Node nameNode = childattrs.getNamedItem(GlimmpseConstants.ATTR_NAME);
                if (nameNode != null) {
                    if (GlimmpseConstants.MATRIX_FIXED.equals(nameNode.getNodeValue())) {
                        NamedNodeMap attrs = child.getAttributes();
                        Node rowNode = attrs.getNamedItem("rows");
                        Node colNode = attrs.getNamedItem("columns");
                        if (rowNode != null && colNode != null) {
                            NodeList rowNodeList = child.getChildNodes();
                            for (int r = 0; r < rowNodeList.getLength(); r++) {
                                NodeList colNodeList = rowNodeList.item(r).getChildNodes();
                                for (int c = 0; c < colNodeList.getLength(); c++) {
                                    Node colItem = colNodeList.item(c).getFirstChild();
                                    if (colItem != null) {
                                        uploadedValues.add(colItem.getNodeValue());
                                    }/*from w w w.  j  av  a2 s  .  c  o m*/
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

From source file:edu.cudenver.bios.glimmpse.client.panels.guided.RepeatedMeasuresPanel.java

License:Open Source License

@Override
public void loadFromNode(Node node) {
    if (GlimmpseConstants.TAG_REPEATED_MEASURES.equalsIgnoreCase(node.getNodeName())) {
        NamedNodeMap attrs = node.getAttributes();
        Node typeNode = attrs.getNamedItem(GlimmpseConstants.ATTR_TYPE);
        if (typeNode != null) {
            if (NON_REPEATED.equals(typeNode.getNodeValue())) {
                singleMeasureRadioButton.setValue(true);
            } else if (SINGLY_REPEATED.equals(typeNode.getNodeValue())) {
                repeatedMeasures1DRadioButton.setValue(true);
                repetitions1DTextBox.setEnabled(true);
                units1DTextBox.setEnabled(true);
                Node dimensionNode = node.getFirstChild();
                if (dimensionNode != null) {
                    NamedNodeMap dimAttrs = dimensionNode.getAttributes();
                    Node timesNode = dimAttrs.getNamedItem(GlimmpseConstants.ATTR_TIMES);
                    if (timesNode != null) {
                        repetitions1DTextBox.setText(timesNode.getNodeValue());
                    }/*from  w  w w.  j  av a 2s.  c o  m*/
                    Node unitsNode = dimensionNode.getFirstChild();
                    if (unitsNode != null) {
                        units1DTextBox.setText(unitsNode.getNodeValue());
                    }
                }
            } else if (DOUBLY_REPEATED.equals(typeNode.getNodeValue())) {
                repeatedMeasures2DRadioButton.setValue(true);
                repetitions2DOuterTextBox.setEnabled(true);
                units2DOuterTextBox.setEnabled(true);
                repetitions2DInnerTextBox.setEnabled(true);
                units2DInnerTextBox.setEnabled(true);
                NodeList children = node.getChildNodes();
                Node outerDimensionNode = children.item(0);
                if (outerDimensionNode != null) {
                    NamedNodeMap dimAttrs = outerDimensionNode.getAttributes();
                    Node timesNode = dimAttrs.getNamedItem(GlimmpseConstants.ATTR_TIMES);
                    if (timesNode != null) {
                        repetitions2DOuterTextBox.setText(timesNode.getNodeValue());
                    }
                    Node unitsNode = outerDimensionNode.getFirstChild();
                    if (unitsNode != null) {
                        units2DOuterTextBox.setText(unitsNode.getNodeValue());
                    }
                }
                Node innerDimensionNode = children.item(1);
                if (innerDimensionNode != null) {
                    NamedNodeMap dimAttrs = innerDimensionNode.getAttributes();
                    Node timesNode = dimAttrs.getNamedItem(GlimmpseConstants.ATTR_TIMES);
                    if (timesNode != null) {
                        repetitions2DInnerTextBox.setText(timesNode.getNodeValue());
                    }
                    Node unitsNode = innerDimensionNode.getFirstChild();
                    if (unitsNode != null) {
                        units2DInnerTextBox.setText(unitsNode.getNodeValue());
                    }
                }
            }
        }
    }
    checkComplete();
}

From source file:edu.cudenver.bios.glimmpse.client.panels.guided.VariabilityCovariateOutcomePanel.java

License:Open Source License

@Override
public void loadFromNode(Node node) {
    if (GlimmpseConstants.TAG_VARIABILITY_YG.equalsIgnoreCase(node.getNodeName())) {
        NodeList childList = node.getChildNodes();
        for (int i = 0; i < childList.getLength(); i++) {
            Node child = childList.item(i);
            if (GlimmpseConstants.TAG_CORRELATION.equalsIgnoreCase(child.getNodeName())) {
                NamedNodeMap attrs = child.getAttributes();
                Node labelNode = attrs.getNamedItem(GlimmpseConstants.ATTR_NAME);
                Node valueNode = attrs.getNamedItem(GlimmpseConstants.ATTR_VALUE);
                if (labelNode != null && valueNode != null) {
                    correlationTable.setWidget(i, COLUMN_LABEL, new HTML(labelNode.getNodeValue()));
                    TextBox tb = new TextBox();
                    tb.setText(valueNode.getNodeValue());
                    correlationTable.setWidget(i, COLUMN_TEXTBOX, tb);
                    tb.addChangeHandler(new ChangeHandler() {
                        @Override
                        public void onChange(ChangeEvent event) {
                            TextBox tb = (TextBox) event.getSource();
                            try {
                                TextValidation.parseDouble(tb.getText(), 0, 1, false);
                                TextValidation.displayOkay(errorHTML, "");
                            } catch (NumberFormatException e) {
                                TextValidation.displayError(errorHTML,
                                        Glimmpse.constants.errorInvalidPositiveNumber());
                                tb.setText("");
                            }//ww w . j  a  va 2 s.  c  om
                            checkComplete();
                        }
                    });
                }
            }
        }
    }
}

From source file:edu.cudenver.bios.glimmpse.client.panels.guided.VariabilityIndependentMeasuresPanel.java

License:Open Source License

private void parseStandardDeviationList(Node node) {
    NodeList childList = node.getChildNodes();
    for (int i = 0; i < childList.getLength(); i++) {
        Node child = childList.item(i);
        NamedNodeMap attrs = child.getAttributes();
        Node labelNode = attrs.getNamedItem(GlimmpseConstants.ATTR_NAME);
        Node valueNode = attrs.getNamedItem(GlimmpseConstants.ATTR_VALUE);
        if (labelNode != null && valueNode != null) {
            standardDeviationTable.setWidget(i, COLUMN_LABEL, new HTML(labelNode.getNodeValue()));
            TextBox tb = new TextBox();
            tb.setText(valueNode.getNodeValue());
            standardDeviationTable.setWidget(i, COLUMN_TEXTBOX, tb);
            tb.addChangeHandler(new ChangeHandler() {
                @Override/*from  ww  w . ja  v  a2 s .  co m*/
                public void onChange(ChangeEvent event) {
                    TextBox tb = (TextBox) event.getSource();
                    try {
                        TextValidation.parseDouble(tb.getText(), 0, true);
                        TextValidation.displayOkay(standardDeviationErrorHTML, "");
                    } catch (NumberFormatException e) {
                        TextValidation.displayError(standardDeviationErrorHTML,
                                Glimmpse.constants.errorInvalidPositiveNumber());
                        tb.setText("");
                    }
                    checkComplete();
                }
            });
        }
    }
}

From source file:edu.cudenver.bios.glimmpse.client.panels.guided.VariabilityIndependentMeasuresPanel.java

License:Open Source License

private void parseCorrelationList(Node node) {
    NodeList childList = node.getChildNodes();
    for (int i = 0; i < childList.getLength(); i++) {
        Node child = childList.item(i);
        NamedNodeMap attrs = child.getAttributes();
        Node labelNode = attrs.getNamedItem(GlimmpseConstants.ATTR_NAME);
        Node valueNode = attrs.getNamedItem(GlimmpseConstants.ATTR_VALUE);
        if (labelNode != null && valueNode != null) {
            correlationTable.setWidget(i, COLUMN_LABEL, new HTML(labelNode.getNodeValue()));
            TextBox tb = new TextBox();
            tb.setText(valueNode.getNodeValue());
            correlationTable.setWidget(i, COLUMN_TEXTBOX, tb);
            tb.addChangeHandler(new ChangeHandler() {
                @Override// ww w . j  a  v  a2  s  . c  o  m
                public void onChange(ChangeEvent event) {
                    TextBox tb = (TextBox) event.getSource();
                    try {
                        TextValidation.parseDouble(tb.getText(), 0, 1, false);
                        TextValidation.displayOkay(correlationErrorHTML, "");
                    } catch (NumberFormatException e) {
                        TextValidation.displayError(correlationErrorHTML,
                                Glimmpse.constants.errorInvalidPositiveNumber());
                        tb.setText("");
                    }
                    checkComplete();
                }
            });
        }
    }
}

From source file:edu.cudenver.bios.glimmpse.client.panels.GuidedWizardPanel.java

License:Open Source License

/**
 * Fill in the wizard from an XML description of the study matrices
 *///from w  w  w .j  a v a2  s . c  om
public void loadFromXML(Document doc) {
    Node studyNode = doc.getElementsByTagName(GlimmpseConstants.TAG_STUDY).item(0);
    if (studyNode != null) {
        NodeList children = studyNode.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node child = children.item(i);
            String childName = child.getNodeName();
            if (GlimmpseConstants.TAG_SOLVING_FOR.equalsIgnoreCase(childName))
                solvingForPanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_ALPHA_LIST.equalsIgnoreCase(childName))
                alphaPanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_TEST_LIST.equalsIgnoreCase(childName))
                optionsTestsPanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_QUANTILE_LIST.equalsIgnoreCase(childName))
                optionsPowerMethodsPanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_POWER_LIST.equalsIgnoreCase(childName))
                powerPanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_POWER_METHOD_LIST.equalsIgnoreCase(childName))
                optionsPowerMethodsPanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_SAMPLE_SIZE_LIST.equalsIgnoreCase(childName))
                perGroupSampleSizePanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_CATEGORICAL_PREDICTORS.equalsIgnoreCase(childName))
                catPredictorsPanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_RELATIVE_GROUP_SIZE_LIST.equalsIgnoreCase(childName))
                relativeGroupSizePanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_OUTCOMES_LIST.equalsIgnoreCase(childName))
                outcomesPanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_HYPOTHESIS.equalsIgnoreCase(childName))
                hypothesisIndependentPanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_REPEATED_MEASURES.equalsIgnoreCase(childName))
                repeatedMeasuresPanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_BETA_SCALE_LIST.equalsIgnoreCase(childName))
                meanDifferencesScalePanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_SIGMA_SCALE_LIST.equalsIgnoreCase(childName))
                variabilityScalePanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_FIXED_RANDOM_MATRIX.equalsIgnoreCase(childName)) {
                NamedNodeMap attrs = child.getAttributes();
                Node nameNode = attrs.getNamedItem(GlimmpseConstants.ATTR_NAME);
                if (nameNode != null) {
                    String name = nameNode.getNodeValue();
                    if (GlimmpseConstants.MATRIX_BETA.equalsIgnoreCase(name))
                        meanDifferencesPanel.loadFromNode(child);
                }
            } else if (GlimmpseConstants.TAG_VARIABILITY_Y.equalsIgnoreCase(childName))
                variabilityIndependentPanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_VARIABILITY_YG.equalsIgnoreCase(childName))
                variabilityCovariateOutcomePanel.loadFromNode(child);
            else if (GlimmpseConstants.TAG_VARIABILITY_G.equalsIgnoreCase(childName))
                variabilityCovariatePanel.loadFromNode(child);

            /*
            TODO: finish upload for these panels
            {hypothesisRepeatedPanel, hypothesisDoublyRepeatedPanel},
            {meanDifferencesIndependentPanel,   meanDifferencesRepeatedPanel, },
            {, variabilityRepeatedPanel,},
                    
            */
        }
    }
}

From source file:edu.cudenver.bios.glimmpse.client.panels.matrix.BetaPanel.java

License:Open Source License

@Override
public void loadFromNode(Node node) {
    if (GlimmpseConstants.TAG_FIXED_RANDOM_MATRIX.equalsIgnoreCase(node.getNodeName())) {
        NodeList children = node.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node child = children.item(i);
            String childName = child.getNodeName();
            if (GlimmpseConstants.TAG_MATRIX.equals(childName)) {
                NamedNodeMap attrs = child.getAttributes();
                Node nameNode = attrs.getNamedItem(GlimmpseConstants.ATTR_NAME);
                if (nameNode != null) {
                    if (GlimmpseConstants.MATRIX_FIXED.equals(nameNode.getNodeValue())) {
                        betaFixed.loadFromDomNode(child);
                    }/*from  w w w  . j  av a2 s .co  m*/
                }
            }
        }
    }
}