Package net.n3.nanoxml

Examples of net.n3.nanoxml.XMLElement


     * @param idata The installation data.
     * @param panelRoot The XML root element of the panels blackbox tree.
     */
    public void runAutomated(AutomatedInstallData idata, XMLElement panelRoot)
    {
        XMLElement userInput;
        XMLElement dataElement;
        String variable;
        String value;

        // ----------------------------------------------------
        // get the section containing the user entries
        // ----------------------------------------------------
        userInput = panelRoot.getFirstChildNamed(AUTO_KEY_USER_INPUT);

        if (userInput == null) { return; }
        String panelName = userInput.getAttribute( AUTO_ATTR_PANEL_NAME );
        if( panelName == null ) {
           System.out.println("Auto-installation will fail. Panel name not set in xml" );
        }

        Vector userEntries = userInput.getChildrenNamed(AUTO_KEY_ENTRY);

        if (userEntries == null) { return; }

        // ----------------------------------------------------
        // retieve each entry and substitute the associated
        // variable
        // ----------------------------------------------------
        for (int i = 0; i < userEntries.size(); i++)
        {
            dataElement = (XMLElement) userEntries.elementAt(i);
            variable = dataElement.getAttribute(AUTO_ATTRIBUTE_KEY);
            value = dataElement.getAttribute(AUTO_ATTRIBUTE_VALUE);

            Debug.trace("ValidatePackSelections: setting variable " + variable + " to " + value);
            idata.setVariable(variable, value);
        }
        GeronimoConfigProcessor gcp = new GeronimoConfigProcessor();
View Full Code Here


        // ----------------------------------------------------
        Vector fields = spec.getChildrenNamed(FIELD_NODE_ID);

        for (int i = 0; i < fields.size(); i++)
        {
            XMLElement field = (XMLElement) fields.elementAt(i);
            String attribute = field.getAttribute(TYPE);

            if (attribute != null)
            {
                if (attribute.equals(RULE_FIELD))
                {
View Full Code Here

       // entry.  It is possible to delete all but the last entry as
       // well.
       // This is all done when the last panel is exited -- although
       //    which direction is unknown/unchecked.
       if( gcp.isCheckpointPanel( getTitle() )) {
          XMLElement xml = idata.xmlData;
          XMLElement panelRoot = null;
          Debug.trace( "-ValidatePackSelections.panelDeactivate() - xml: " + xml.getName() );
          panelRoot = xml.getFirstChildNamed( PANEL_PKG + "." + PACKS_PANEL );
          if( panelRoot != null ) {
             Vector vSel = panelRoot.getChildrenNamed( SELECTED_PACKS );
             for( int i = 0; i < vSel.size(); ++i ) {
                XMLElement sel = (XMLElement)vSel.elementAt(i);
                Debug.trace( "-ValidatePackSelections.panelDeactivate() - vSel( " + i + " ) = " + sel.toString() );
             }
             int children = panelRoot.getChildrenCount();
             int curChild = 0;
             while( panelRoot.getChildrenCount() > 0 ) {
                panelRoot.removeChildAtIndex( 0 );
View Full Code Here

     */
    /*--------------------------------------------------------------------------*/
    protected void readSpec() throws Exception
    {
        InputStream input = null;
        XMLElement data;
        Vector specElements;
        String attribute;
        String instance = Integer.toString(instanceNumber);

        try
        {
            input = parentFrame.getResource(SPEC_FILE_NAME);
        }
        catch (Exception exception)
        {
            haveSpec = false;
            return;
        }
        if (input == null)
        {
            haveSpec = false;
            return;
        }

        // initialize the parser
        StdXMLParser parser = new StdXMLParser();
        parser.setBuilder(new StdXMLBuilder());
        parser.setValidator(new NonValidator());
        parser.setReader(new StdXMLReader(input));

        // get the data
        data = (XMLElement) parser.parse();

        // extract the spec to this specific panel instance
        if (data.hasChildren())
        {
            specElements = data.getChildrenNamed(NODE_ID);
            //Debug.trace( "--> Panel elements: " + specElements.size() );
            for (int i = 0; i < specElements.size(); i++)
            {
                data = (XMLElement) specElements.elementAt(i);
                attribute = data.getAttribute(INSTANCE_IDENTIFIER);
                //Debug.trace( "----> instance: '" + instance + "'  instanceNumber: '" + instanceNumber + "'");
                if (instance.equals(attribute))
                {
                    // use the current element as spec
                    spec = data;
View Full Code Here

    /*--------------------------------------------------------------------------*/
    protected void addRuleField(XMLElement spec)
    {
        Vector forPacks = spec.getChildrenNamed(SELECTEDPACKS);
        Vector forOs = spec.getChildrenNamed(OS);
        XMLElement element = spec.getFirstChildNamed(SPEC);
        String variable = spec.getAttribute(VARIABLE);
        RuleInputField field = null;
        JLabel label;
        String layout;
        String set;
        String separator;
        String format;
        String validator = null;
        String message = null;
        boolean hasParams = false;
        String paramName = null;
        String paramValue = null;
        HashMap validateParamMap = null;
        Vector validateParams = null;
        String processor = null;
        int resultFormat = RuleInputField.DISPLAY_FORMAT;

        // ----------------------------------------------------
        // extract the specification details
        // ----------------------------------------------------
        if (element != null)
        {
            label = new JLabel(getText(element));
            layout = element.getAttribute(RULE_LAYOUT);
            set = element.getAttribute(SET);

            // retrieve value of variable if not specified
            // (does not work here because of special format for set attribute)
            // if (set == null)
            // {
            // set = idata.getVariable (variable);
            // }

            separator = element.getAttribute(RULE_SEPARATOR);
            format = element.getAttribute(RULE_RESULT_FORMAT);

            if (format != null)
            {
                if (format.equals(RULE_PLAIN_STRING))
                {
                    resultFormat = RuleInputField.PLAIN_STRING;
                }
                else if (format.equals(RULE_DISPLAY_FORMAT))
                {
                    resultFormat = RuleInputField.DISPLAY_FORMAT;
                }
                else if (format.equals(RULE_SPECIAL_SEPARATOR))
                {
                    resultFormat = RuleInputField.SPECIAL_SEPARATOR;
                }
                else if (format.equals(RULE_ENCRYPTED))
                {
                    resultFormat = RuleInputField.ENCRYPTED;
                }
            }
        }
        // ----------------------------------------------------
        // if there is no specification element, return without
        // doing anything.
        // ----------------------------------------------------
        else
        {
            return;
        }

        // ----------------------------------------------------
        // get the description and add it to the list of UI
        // elements if it exists.
        // ----------------------------------------------------
        element = spec.getFirstChildNamed(DESCRIPTION);
        addDescription(element, forPacks, forOs, null);

        // ----------------------------------------------------
        // get the validator and processor if they are defined
        // ----------------------------------------------------
        element = spec.getFirstChildNamed(VALIDATOR);
        if (element != null)
        {
            validator = element.getAttribute(CLASS);
            message = getText(element);
            // ----------------------------------------------------------
            // check and see if we have any parameters for this validator.
            // If so, then add them to validateParamMap.
            // ----------------------------------------------------------
            validateParams = element.getChildrenNamed(RULE_PARAM);
            if (validateParams != null && validateParams.size() > 0 && validateParamMap == null)
            {

                validateParamMap = new HashMap();
                hasParams = true;

            }

            for (Iterator it = validateParams.iterator(); it.hasNext();)
            {
                element = (XMLElement) it.next();
                paramName = element.getAttribute(RULE_PARAM_NAME);
                paramValue = element.getAttribute(RULE_PARAM_VALUE);
                validateParamMap.put(paramName, paramValue);
            }
        }

        element = spec.getFirstChildNamed(PROCESSOR);
        if (element != null)
        {
            processor = element.getAttribute(CLASS);
        }

        // ----------------------------------------------------
        // create an instance of RuleInputField based on the
        // extracted specifications, then add it to the list
View Full Code Here

    /*--------------------------------------------------------------------------*/
    protected void addTextField(XMLElement spec)
    {
        Vector forPacks = spec.getChildrenNamed(SELECTEDPACKS);
        Vector forOs = spec.getChildrenNamed(OS);
        XMLElement element = spec.getFirstChildNamed(SPEC);
        JLabel label;
        String set;
        int size;

        String variable = spec.getAttribute(VARIABLE);
        if ((variable == null) || (variable.length() == 0)) { return; }

        // ----------------------------------------------------
        // extract the specification details
        // ----------------------------------------------------
        if (element != null)
        {
            label = new JLabel(getText(element));
            set = element.getAttribute(SET);
            if (set == null)
            {
                set = idata.getVariable(variable);
                if (set == null)
                {
                    set = "";
                }
            }else{
                if (set != null && !"".equals(set)){
                    VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
                    set = vs.substitute(set, null);
                }
            }
               
            try
            {
                size = Integer.parseInt(element.getAttribute(TEXT_SIZE));
            }
            catch (Throwable exception)
            {
                size = 1;
            }
View Full Code Here

    /*--------------------------------------------------------------------------*/
    protected void addComboBox(XMLElement spec)
    {
        Vector forPacks = spec.getChildrenNamed(SELECTEDPACKS);
        Vector forOs = spec.getChildrenNamed(OS);
        XMLElement element = spec.getFirstChildNamed(SPEC);
        String variable = spec.getAttribute(VARIABLE);
        TextValuePair listItem = null;
        JComboBox field = new JComboBox();
        JLabel label;

        // ----------------------------------------------------
        // extract the specification details
        // ----------------------------------------------------
        if (element != null)
        {
            label = new JLabel(getText(element));

            Vector choices = element.getChildrenNamed(COMBO_CHOICE);

            if (choices == null) { return; }

            for (int i = 0; i < choices.size(); i++)
            {
View Full Code Here

        Vector forPacks = spec.getChildrenNamed(SELECTEDPACKS);
        Vector forOs = spec.getChildrenNamed(OS);
        String variable = spec.getAttribute(VARIABLE);
        String value = null;

        XMLElement element = null;
        ButtonGroup group = new ButtonGroup();

        TwoColumnConstraints constraints = new TwoColumnConstraints();
        constraints.position = TwoColumnConstraints.BOTH;
        constraints.indent = true;
        constraints.stretch = true;

        // ----------------------------------------------------
        // get the description and add it to the list of UI
        // elements if it exists.
        // ----------------------------------------------------
        element = spec.getFirstChildNamed(DESCRIPTION);
        addDescription(element, forPacks, forOs, null);

        // ----------------------------------------------------
        // extract the specification details
        // ----------------------------------------------------
        element = spec.getFirstChildNamed(SPEC);

        if (element != null)
        {
            Vector choices = element.getChildrenNamed(RADIO_CHOICE);

            if (choices == null) { return; }

            // --------------------------------------------------
            // process each choice element
View Full Code Here

        Vector forOs = spec.getChildrenNamed(OS);
        String variable = spec.getAttribute(VARIABLE);
        String validator = null;
        String message = null;
        String processor = null;
        XMLElement element = null;
        PasswordGroup group = null;
        int size = 0;

        // ----------------------------------------------------
        // get the description and add it to the list of UI
        // elements if it exists.
        // ----------------------------------------------------
        element = spec.getFirstChildNamed(DESCRIPTION);
        addDescription(element, forPacks, forOs, null);

        // ----------------------------------------------------
        // get the validator and processor if they are defined
        // ----------------------------------------------------
        element = spec.getFirstChildNamed(VALIDATOR);
        if (element != null)
        {
            validator = element.getAttribute(CLASS);
            message = getText(element);
        }

        element = spec.getFirstChildNamed(PROCESSOR);
        if (element != null)
        {
            processor = element.getAttribute(CLASS);
        }

        group = new PasswordGroup(validator, processor);

        // ----------------------------------------------------
        // extract the specification details
        // ----------------------------------------------------
        element = spec.getFirstChildNamed(SPEC);

        if (element != null)
        {
            Vector inputs = element.getChildrenNamed(PWD_INPUT);

            if (inputs == null) { return; }

            // --------------------------------------------------
            // process each input field
            // --------------------------------------------------
            XMLElement fieldSpec;
            for (int i = 0; i < inputs.size(); i++)
            {
                fieldSpec = (XMLElement) inputs.elementAt(i);
                String set = fieldSpec.getAttribute(SET);
                if (set != null && !"".equals(set)){
                    VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
                    set = vs.substitute(set, null);
                }
                JLabel label = new JLabel(getText(fieldSpec));
                try
                {
                    size = Integer.parseInt(fieldSpec.getAttribute(PWD_SIZE));
                }
                catch (Throwable exception)
                {
                    size = 1;
                }
View Full Code Here

       }
       return fRet;
    }
    protected Vector getFieldSuppressionList( XMLElement spec ) { // ###ead
       Vector supps = null;
       XMLElement suppress = spec.getFirstChildNamed( SUPPRESS );
       if( suppress != null ) {
          Vector whens = suppress.getChildrenNamed( WHEN );
          for( int i = 0; i < whens.size(); ++i ) {
             if( supps == null ) supps = new Vector();
             XMLElement when = (XMLElement)whens.elementAt(i);
             String var = when.getAttribute( VARIABLE );
             String val = when.getAttribute( VALUE );
             supps.add( new TextValuePair( var, val ));
          }
       }
       return supps;
    }
View Full Code Here

TOP

Related Classes of net.n3.nanoxml.XMLElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.