コード例 #1
0
 public XmlUIElement getXmlElement(UserInput uiArg) {
   String type = "textfield";
   Qualifier qual = uiArg.getQualifier();
   String enumNames[] = null;
   String enumValues[] = null;
   if (qual != null) {
     type = qual.getType();
     Vector enumVec = qual.getEnums();
     if (enumVec.size() > 0) {
       enumNames = new String[enumVec.size()];
       enumValues = new String[enumVec.size()];
       for (int i = 0; i < enumNames.length; i++) {
         com.adventnet.management.config.xml.Enum e =
             (com.adventnet.management.config.xml.Enum) enumVec.elementAt(i);
         enumNames[i] = e.getName();
         enumValues[i] = e.getValue();
         if (enumNames[i] == null) {
           enumNames[i] = enumValues[i];
         }
       }
     }
   }
   XmlUIElement el = getXmlUIElementFor(type);
   if (el == null) {
     return null;
   }
   el.setDescription(uiArg.getDescription());
   if (enumNames != null) {
     el.setEnumeratedValues(enumNames, enumValues);
   }
   if ((qual != null) && (qual.getRange() != null) && (!(qual.getRange().equals("")))) {
     el.setRange(qual.getRange());
   }
   if (uiArg.getDefaultValue() != null) {
     el.setValue(uiArg.getDefaultValue());
   }
   String isEditable = uiArg.getAttribute("editable");
   if (isEditable != null) {
     if (isEditable.trim().equals("false")) {
       el.setEditable(false);
     } else {
       el.setEditable(true);
     }
   }
   String required = uiArg.getAttribute("required");
   {
     if (required.trim().equals("true")) {
       el.setRequired(true);
       numberOfRequiredFields++;
     } else {
       el.setRequired(false);
     }
   }
   el.setLabelName(uiArg.getLabel());
   return el;
 }
コード例 #2
0
 public Properties getUserInputValues() {
   Properties prop = new Properties();
   for (int i = 0; i < uiList.size(); i++) {
     UserInput ui = (UserInput) uiList.get(i);
     XmlUIElement el = (XmlUIElement) uiElementsList.get(i);
     ui.setValue(el.getValue());
     prop.put("$UserInput$" + ui.getID(), el.getValue());
   }
   return prop;
 }
コード例 #3
0
 public Properties getPropertiesValue() {
   Properties props = new Properties();
   for (int i = 0; i < propKeyList.size(); i++) {
     String propName = (String) propKeyList.get(i);
     // Since $Template$Params is being appended (before replacement)in the server side latest code
     // it is removed here using substring(15).
     // If not removed, this results in $Template$Params$Template$ParamsSource as the key to be
     // replaced by the user specified value.
     // Check to be introduced in server side.
     // propName = propName.trim().substring(15);
     XmlUIElement el = (XmlUIElement) propValueList.get(i);
     props.put(propName, el.getValue());
   }
   return props;
 }
コード例 #4
0
 public JPanel getPanelForProperties(Properties propsArg) {
   // clear();
   propKeyList = new ArrayList();
   propValueList = new ArrayList();
   for (Enumeration e = propsArg.propertyNames(); e.hasMoreElements(); ) {
     String name = (String) e.nextElement();
     String value = (String) propsArg.getProperty(name);
     XmlUIElement el = getXmlUIElementFor("textfield");
     if (el != null) {
       propKeyList.add(name);
       el.setValue(value);
       if (name.endsWith("#")) {
         el.setLabelName(name.substring(0, name.length() - 1));
       } else {
         el.setLabelName(name);
       }
       propValueList.add(el);
     }
   }
   return getPanelFor(propValueList);
 }
コード例 #5
0
 public boolean areInputValuesValid() {
   for (int i = 0; i < uiList.size(); i++) {
     XmlUIElement el = (XmlUIElement) uiElementsList.get(i);
     try {
       el.checkConstraints();
     } catch (Exception e) {
       errorMessage = e.getMessage();
       incompletePanel = (JPanel) elementsAndPanels.get(el);
       return false;
     }
     if ((el.isRequired()) && (el.isValueNull())) {
       errorMessage =
           MessageFormat.format(
               ProvClientUtils.getString("{0} field cannot be empty"),
               new Object[] {el.getLabelName()});
       incompletePanel = (JPanel) elementsAndPanels.get(el);
       return false;
     }
   }
   return true;
 }
コード例 #6
0
 /** This replaces the user input variables in the XML template * */
 public String replaceVariablesInString(String xmlStringArg) {
   String modXmlString = xmlStringArg;
   Properties prop = new Properties();
   for (int i = 0; i < uiList.size(); i++) {
     UserInput ui = (UserInput) uiList.get(i);
     XmlUIElement el = (XmlUIElement) uiElementsList.get(i);
     ui.setValue(el.getValue());
     prop.put("$UserInput$" + ui.getID(), el.getValue());
     // modXmlString = StringUtil.replaceStringBySpecifiedString(modXmlString,"$UserInput$" +
     // ui.getID(),el.getValue());
   }
   Template template = null;
   try {
     template = new Template(xmlStringArg);
     //			template = PopulateTemplateParams.substituteParams(template, prop, 3);
     template = PopulateTemplateParams.substituteParams(template, prop);
   } catch (Exception exc) {
     exc.printStackTrace();
   }
   // return modXmlString;
   return template.toString();
 }