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; }
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(); } }
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; }
private void showErrorMessage(String message) { JOptionPane.showMessageDialog( null, message, ProvClientUtils.getString("Error"), JOptionPane.ERROR_MESSAGE); }