1 package com.calipso.xmleditor; 2 3 import javax.swing.*; 4 import java.util.Enumeration ; 5 6 13 14 public class XmlEditorSubPanelValidator { 15 16 22 public static String validateFrom(XmlEditorSubPanel subPanel, XmlEditorTreeDefinitionNode definition) { 23 String elementWrong = null; 24 Enumeration enumeration = definition.getItemsKeys().elements(); 25 for(int i = 0 ; i < subPanel.getInputComponents().size() ; i++) { 26 XmlEditorTreeNodeItemDefinition item = (XmlEditorTreeNodeItemDefinition) definition.getItems().get(enumeration.nextElement().toString()); 27 if(!item.isOptional()) { 28 if(!isValid(subPanel.getInputComponents().elementAt(i))) { 29 elementWrong = item.getName(); 30 break; 31 } 32 } 33 } 34 return elementWrong; 35 } 36 37 public static boolean isValid(Object object) { 38 if(object instanceof JTextField) { 39 if(((JTextField)object).getText().equals("")) { 40 return false; 41 } 42 } 43 return true; 44 } 45 } 46 | Popular Tags |