private XmlUIElement getXmlUIElementFor(String typeArg) { if (typeToClassMappingProp == null) { setUpMappingsHM(); } String clsName = (String) typeToClassMappingProp.get(typeArg); if ((clsName != null) && !(clsName.equals("*NOTFOUND*")) && !(clsName.equals("*EXCEPTION*"))) { try { Class cls = Class.forName(clsName); return (XmlUIElement) cls.newInstance(); } catch (Throwable th) { typeToClassMappingProp.put(typeArg, "*EXCEPTION*"); showErrorMessage( MessageFormat.format( ProvClientUtils.getString( "{0} occurred when trying to get the XmlUIElement for type : {1}"), new Object[] {th.getClass().getName(), typeArg})); th.printStackTrace(); return null; } } else if (clsName == null) { typeToClassMappingProp.put(typeArg, "*NOTFOUND*"); showErrorMessage( MessageFormat.format( ProvClientUtils.getString( "The type {0} does not have the corresponding XMLUIElement specified in the TypeToUIElementMapping.txt file"), new Object[] {typeArg})); } return null; }
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; }
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; }
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); }
/** 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(); }
private void setUpMappingsHM() { typeToClassMappingProp = new Properties(); URL url = UserInputUIHandler.class.getClassLoader().getResource(mappingTxt); if (url == null) { showErrorMessage(ProvClientUtils.getString("TypeToUIElementMapping.txt file is not found")); return; } try { typeToClassMappingProp.load(url.openStream()); } catch (IOException ioe) { ioe.printStackTrace(); } }