KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > data > containers > ContainerEditView


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12
//
13
//
14
//
15
//
16
//
17
// 28.07.2002 NK
18

19
20 package org.jahia.data.containers;
21
22 import java.util.HashMap JavaDoc;
23 import java.util.Vector JavaDoc;
24
25 import org.jahia.utils.JahiaConsole;
26 import java.io.Serializable JavaDoc;
27
28
29 /**
30  * Holds information used to build the Container Edition Popup.
31  *
32  * @author Khue Nguyen <a HREF="mailto:khue@jahia.org">khue@jahia.org</a>
33  */

34
35 public class ContainerEditView implements Serializable JavaDoc {
36
37     private static final String JavaDoc CLASS_NAME = ContainerEditView.class.getName();
38
39     private HashMap JavaDoc views = new HashMap JavaDoc();
40
41     /** The list of all fields ordered as they are added **/
42     private Vector JavaDoc fields = new Vector JavaDoc();
43
44     //--------------------------------------------------------------------------
45
/**
46      * Constructor
47      *
48      * @param String groupName
49      *
50      */

51     public ContainerEditView(){}
52
53     //--------------------------------------------------------------------------
54
/**
55      * Add a Field
56      *
57      * @param String groupName, the group name
58      * @param String groupTitle, the group title
59      * @param String groupDescr, the group descr
60      * @param String fielName, the field name
61      * @param String descr, the field descr
62      */

63     public void addField(String JavaDoc groupName, String JavaDoc groupTitle, String JavaDoc groupDescr, String JavaDoc fieldName,String JavaDoc fieldDescr){
64         if ( groupName == null || groupName.trim().equals("") ){
65             return;
66         }
67         if ( fieldName == null || fieldName.trim().equals("") ){
68             return;
69         }
70
71         ContainerEditViewFieldGroup fieldGroup = new ContainerEditViewFieldGroup(groupName,groupTitle,groupDescr);
72         fieldGroup.addField(fieldName,fieldDescr);
73         addFieldGroup(fieldGroup);
74     }
75
76
77     //--------------------------------------------------------------------------
78
/**
79      * Add a group of fields
80      *
81      * @param ContainerEditViewFieldGroup , a group of fields
82      */

83     public void addFieldGroup(ContainerEditViewFieldGroup fieldGroup){
84
85         JahiaConsole.println("ContainerEditView.addFieldGroup",
86                             "Added Group [" + fieldGroup.getName() + "]");
87
88         if ( fieldGroup == null || fieldGroup.getName()==null || fieldGroup.getName().trim().equals("") ){
89             return;
90         }
91         fieldGroup.setPos(views.size());
92         views.put(fieldGroup.getName(),fieldGroup);
93
94         fields.addAll(fieldGroup.getFieldNames());
95
96     }
97
98     //--------------------------------------------------------------------------
99
/**
100      * Return the Field Group containing a given field name
101      *
102      * @param String fieldName, the field name
103      */

104     public ContainerEditViewFieldGroup getFieldGroupByFieldName(String JavaDoc fieldName){
105         if ( fieldName == null ){
106             return null;
107         }
108         Vector JavaDoc v = new Vector JavaDoc(views.values());
109         int size = v.size();
110         ContainerEditViewFieldGroup fieldGroup = null;
111         for ( int i=0 ; i<size ; i++ ){
112             fieldGroup = (ContainerEditViewFieldGroup)v.get(i);
113             if ( fieldGroup.fieldExists(fieldName) ){
114                 return fieldGroup;
115             }
116         }
117         return null;
118     }
119
120     //--------------------------------------------------------------------------
121
/**
122      * Returns the HashMap of views
123      *
124      */

125     public HashMap JavaDoc getViews(){
126         return views;
127     }
128
129     //--------------------------------------------------------------------------
130
/**
131      * Returns the vector of field names
132      *
133      */

134     public Vector JavaDoc getFields(){
135         return this.fields;
136     }
137
138 }
139
Popular Tags