KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > webman > field > TKContentNodeTypeSelectorField


1 package com.teamkonzept.webman.field;
2
3 import com.teamkonzept.webman.mainint.*;
4 import com.teamkonzept.webman.mainint.db.queries.TKDBContentTreeGetTypeOrderByName;
5 import com.teamkonzept.webman.mainint.db.queries.*;
6 import de.webman.content.eventhandler.CEUtils;
7
8 import com.teamkonzept.lib.*;
9 import com.teamkonzept.publishing.markups.*;
10 import com.teamkonzept.web.*;
11 import com.teamkonzept.field.db.*;
12 import com.teamkonzept.field.db.queries.*;
13 import com.teamkonzept.db.*;
14 import com.teamkonzept.field.*;
15 import com.teamkonzept.international.LanguageManager;
16
17 import java.sql.*;
18 import java.util.*;
19
20 /**
21  * The content node type selector field control.
22  *
23  * @author $Author: uli $
24  * @version $Revision: 1.10 $
25  */

26 public class TKContentNodeTypeSelectorField
27     extends TKSelectField
28 {
29     // $Id: TKContentNodeTypeSelectorField.java,v 1.10 2002/02/27 11:32:19 uli Exp $
30

31     /**
32      * The class identifier.
33      */

34     public static final String JavaDoc CLASS_ID = "GROUPNODELIST";
35
36     /**
37      * The <CODE>directory</CODE> node type constant.
38      */

39     public static final Integer JavaDoc DIRECTORY_NODE_TYPE = new Integer JavaDoc(1);
40
41     /**
42      * The <CODE>group</CODE> node type constant.
43      */

44     public static final Integer JavaDoc GROUP_NODE_TYPE = new Integer JavaDoc(2);
45
46     /**
47      * The <CODE>single</CODE> node type constant.
48      */

49     public static final Integer JavaDoc SINGLE_NODE_TYPE = new Integer JavaDoc(3);
50
51     /**
52      * The selected node type.
53      */

54     protected Integer JavaDoc fNodeType = null;
55
56     /**
57      * Creates an empty field.
58      */

59     public TKContentNodeTypeSelectorField ()
60     {
61         super();
62     }
63
64     public TKContentNodeTypeSelectorField(
65         String JavaDoc name,
66         String JavaDoc showName,
67         Integer JavaDoc nodeType
68     )
69     {
70         initContentNodeTypeSelectorField( CLASS_ID, name, showName, nodeType );
71     }
72
73     public void initContentNodeTypeSelectorField(
74         String JavaDoc type,
75         String JavaDoc name,
76         String JavaDoc showName,
77         Integer JavaDoc nodeType
78     )
79     {
80         initSelectField( type, name, showName, new TKVector(), 1, false );
81         fNodeType = nodeType;
82     }
83
84     public void fillIntoTemplate( TKHTMLTemplate t, Object JavaDoc value, String JavaDoc prefix )
85     {
86         TKVector tmpOptionList = optionList;
87         try {
88             TKQuery q = TKDBManager.newQuery( TKDBContentTreeGetTypeOrderByName.class );
89             q.setQueryParams( "CONTENT_NODE_TYPE", fNodeType );
90             q.execute();
91             ResultSet res = q.fetchResultSet();
92             TKVector newOptionList = new TKVector();
93             newOptionList.addElement(new TKOptionFieldEntry(LanguageManager.getText("form", "OPTIONLIST_POSSIBILITIES"), "0"));
94             while( res.next() ) {
95                 newOptionList.addElement(
96                     new TKOptionFieldEntry(
97                         res.getString("CONTENT_NODE_NAME"),
98                         String.valueOf( res.getInt("CONTENT_NODE_ID") )
99                     )
100                 );
101             }
102             res.close();
103             optionList = newOptionList;
104         }
105         catch( SQLException e ) {
106             TKHttp.out().println("<br><b>ERROR: </b>" + e);
107             return;
108         }
109
110         super.fillIntoTemplate( t, value, prefix );
111
112         optionList = tmpOptionList;
113     }
114
115     /**
116      * Checks wether this object and the specified object
117      * may be treated as equal.
118      *
119      * @param object the object to checked for equality.
120      * @return <CODE>true</CODE> if this object and the
121      * specified object may be treated as equal, otherwise
122      * <CODE>false</CODE>.
123      */

124     public boolean equals (Object JavaDoc object)
125     {
126         if (! super.equals(object))
127         {
128             return false;
129         }
130
131         TKContentNodeTypeSelectorField field = (TKContentNodeTypeSelectorField) object;
132
133         return (this.fNodeType == null ? field.fNodeType == null : this.fNodeType.equals(field.fNodeType));
134     }
135
136     /**
137      * Returns the hash code for this object.
138      *
139      * @return the hash code for this object.
140      */

141     public int hashCode ()
142     {
143         // Implementation for JTest only ;-(
144
return super.hashCode();
145     }
146
147 }
148
Popular Tags