Ejemplo n.º 1
0
  /** Get the panel for a given form. * */
  public JPanel getPanelFor(ArrayList elements) {
    JPanel p = new JPanel(new GridBagLayout());
    int maxCols = 1;
    int elementSize = elements.size();
    for (int i = 0; i < elementSize; i++) { // count max number of cols
      // ((XmlUIElement)elements.get(i)).setEditable(true);//by jai
      int cols = ((XmlUIElement) elements.get(i)).getNumberOfColumns();
      if (cols > maxCols) {
        maxCols = cols;
      }
    }
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    if (elementSize < 5) c.insets = new Insets(8, 8, 8, 14);
    else if (elementSize < 20) c.insets = new Insets(4, 4, 4, 10);
    else if ((elementSize > 40 && maxCols == 2) || (elementSize > 80 && maxCols == 4))
      c.insets = new Insets(1, 1, 1, 8);
    else c.insets = new Insets(2, 2, 2, 8);

    int rowsAdded = 0;
    for (int i = 0; i < elementSize; i++) {
      elementsAndPanels.put(elements.get(i), p);
      rowsAdded += ((XmlUIElement) elements.get(i)).addComponents(p, c, 0, rowsAdded, maxCols);
    }
    return p;
  }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 4
0
 private JPanel getPanelWithTable(ArrayList list, Table element) throws InvalidTemplateException {
   JTable table = getTable(list, element);
   JPanel panel = new JPanel();
   panel.setLayout(new BorderLayout());
   panel.add(new JScrollPane(table));
   for (int j = 0; j < list.size(); j++) {
     elementsAndPanels.put(list.get(j), panel);
   }
   return panel;
 }
Ejemplo n.º 5
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();
 }
Ejemplo n.º 6
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;
 }