1 10 11 12 package org.enhydra.jawe.xml.panels; 13 14 import org.enhydra.jawe.xml.*; 15 16 import java.util.*; 17 import javax.swing.*; 18 import java.awt.*; 19 20 24 public class XMLGroupPanel extends XMLPanel{ 25 26 public XMLGroupPanel (XMLElement myOwner,Object [] elements) { 27 this(myOwner,elements,""); 28 } 29 30 public XMLGroupPanel (XMLElement myOwner,Object [] elements,String title) { 31 this(myOwner,elements,title,XMLPanel.BOX_LAYOUT); 32 } 33 34 public XMLGroupPanel (XMLElement myOwner,Object [] elements,String title, 35 int layout) { 36 this(myOwner,elements,title,layout,true); 37 } 38 39 public XMLGroupPanel (XMLElement myOwner,Object [] elements,String title, 40 int layout,boolean isVertical) { 41 this(myOwner,elements,title,layout,isVertical,true); 42 } 43 44 public XMLGroupPanel (XMLElement myOwner,Object [] elements,String title, 45 int layout,boolean isVertical,boolean hasBorder) { 46 47 super(myOwner,elements.length+1,title,layout,isVertical,hasBorder); 48 49 XMLPanel dtdp=null; 50 for (int i=0; i<elements.length; i++) { 51 if (elements[i] instanceof XMLElement) { 52 dtdp=((XMLElement)elements[i]).getPanel(); 53 } else if (elements[i] instanceof XMLPanel) { 54 dtdp=(XMLPanel)elements[i]; 55 } 56 dtdp.setEnabled(!myOwner.isReadOnly()); 57 add(dtdp); 58 } 59 60 if (isVertical) { 61 add(Box.createVerticalGlue()); 62 } 63 else { 64 add(Box.createHorizontalGlue()); 65 } 66 67 } 68 69 public XMLPanel getPanel (int no) { 70 if (no>=getComponentCount()-1) { 71 return null; 72 } 73 return (XMLPanel)getComponent(no); 74 } 75 76 public boolean checkRequired () { 77 if (isEmpty() && !getOwner().isRequired()) return true; 78 boolean isOK=true; 79 for (int i=0; i<getComponentCount();i++) { 80 Component c=getComponent(i); 81 if (c instanceof XMLPanel) { 82 isOK=isOK && ((XMLPanel)c).checkRequired(); 83 } 84 } 85 return isOK; 86 } 87 88 public boolean isEmpty () { 89 boolean isEmpty=true; 90 for (int i=0; i<getComponentCount();i++) { 91 Component c=getComponent(i); 92 if (c instanceof XMLPanel) { 93 isEmpty=isEmpty && ((XMLPanel)c).isEmpty(); 94 } 95 } 96 return isEmpty; 97 } 98 99 public void setElements () { 100 boolean isOK=true; 101 for (int i=0; i<getComponentCount();i++) { 102 Component c=getComponent(i); 103 if (c instanceof XMLPanel) { 104 ((XMLPanel)c).setElements(); 106 } 107 } 108 } 109 110 } 111 112 113 | Popular Tags |