Example #1
0
        private void setCheckbox(CheckBox cb, XmlInputConfiguration xmlConfig, string key, XmlElement[] eIncomingMetaInfo)
        {
            string setting = (string)xmlConfig[key] ?? Constants.DEFAULTINDEXGROUPS; // Get the data held in the config (Y/N)

            if (isTrueString(setting))
            {
                cb.Checked = true;
            }
            else
            {
                cb.Checked = false;
            }
        }
Example #2
0
        public Control GetConfigurationControl(
            AlteryxGuiToolkit.Document.Properties docProperties,
            XmlElement eConfig,
            XmlElement[] eIncomingMetaInfo,
            int nToolId,
            string strToolName)
        {
            // Call LoadFromConfiguration to get the xml file name and field information from eConfig.
            XmlInputConfiguration xmlConfig = XmlInputConfiguration.LoadFromConfiguration(eConfig);

            if (xmlConfig == null)
            {
                return(this);
            }

            // Populate the ComboBox with field names
            // If there is no incoming connection, use what is stored

            string selectedField = xmlConfig.SelectedField;

            if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null)
            {
                string   fieldNames    = xmlConfig.FieldNames;
                string[] arrFieldNames = fieldNames.Split(',');

                comboboxXmlSlammerField.Items.Clear();
                foreach (string fieldName in arrFieldNames)
                {
                    comboboxXmlSlammerField.Items.Add(fieldName);
                }

                // Select the saved field
                if (!string.IsNullOrWhiteSpace(selectedField))
                {
                    int selectedIndex = comboboxXmlSlammerField.FindStringExact(selectedField);
                    if (selectedIndex > 0)
                    {
                        comboboxXmlSlammerField.SelectedIndex = selectedIndex;
                    }
                }
            }
            else
            {
                comboboxXmlSlammerField.Items.Clear();

                var xmlElementMetaInfo   = eIncomingMetaInfo[0];
                var xmlElementRecordInfo = xmlElementMetaInfo.FirstChild;

                foreach (XmlElement elementChild in xmlElementRecordInfo)
                {
                    string fieldName = elementChild.GetAttribute("name");
                    string fieldType = elementChild.GetAttribute("type");

                    if (isStringType(fieldType))
                    {
                        comboboxXmlSlammerField.Items.Add(fieldName);
                    }
                }

                // If the selectedField matches a possible field in the combo box,
                // make it the selected field.
                // If the selectedField does not match, do not select anything and
                // blank the selectedField.
                if (!string.IsNullOrWhiteSpace(selectedField))
                {
                    int selectedIndex = comboboxXmlSlammerField.FindStringExact(selectedField);
                    if (selectedIndex == -1)
                    {
                        // Not Found
                        XmlElement xmlElementSelectedField = XmlHelpers.GetOrCreateChildNode(eConfig, Constants.SELECTEDFIELDKEY);
                        xmlElementSelectedField.InnerText = "";
                    }
                    else
                    {
                        // Found
                        comboboxXmlSlammerField.SelectedIndex = selectedIndex;
                    }
                }
            } // end of "if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null)"

            // Update the Delimiter textbox.
            textboxXmlSlammerPathDelim.Text = xmlConfig.PathDelimiter;

            // Update the Attribute textbox.
            textboxXmlSlammerAttrDelim.Text = xmlConfig.AttrDelimiter;


            /////////////
            // CHECKBOX
            //

            setCheckbox(checkBoxIndexGroups, xmlConfig, Constants.INDEXGROUPSKEY, eIncomingMetaInfo);


            return(this);
        }