KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > designer > model > GroupBase


1 /*
2  * (c) Rob Gordon 2005
3  */

4 package org.oddjob.designer.model;
5
6 import java.util.ArrayList JavaDoc;
7 import java.util.Iterator JavaDoc;
8 import java.util.List JavaDoc;
9
10
11 /**
12  * Base class for DesignDefinitions that group other DesignDefinitions.
13  *
14  * @author Rob Gordon.
15  */

16 public class GroupBase {
17
18     private final String JavaDoc heading;
19     private final List JavaDoc elements = new ArrayList JavaDoc();
20     
21     public GroupBase(String JavaDoc heading) {
22         this.heading = heading;
23     }
24     
25     public String JavaDoc getTitle() {
26         return this.heading;
27     }
28     
29     protected void addElement(DesignDefinition elementField) {
30         elements.add(elementField);
31     }
32             
33     public DesignDefinition get(int index) {
34         return (DesignDefinition) elements.get(index);
35     }
36         
37     public int size() {
38         return elements.size();
39     }
40     
41     public boolean isPopulated() {
42         boolean populated = false;
43         for (Iterator JavaDoc it = elements.iterator(); it.hasNext(); ) {
44             if (((DesignDefinition) it.next()).isPopulated()) {
45                 populated = true;
46             }
47         }
48         return populated;
49     }
50 }
51
Popular Tags