001: package com.teamkonzept.webman.field;
002:
003: import com.teamkonzept.webman.mainint.*;
004: import com.teamkonzept.webman.mainint.db.queries.TKDBContentTreeGetTypeOrderByName;
005: import com.teamkonzept.webman.mainint.db.queries.*;
006: import de.webman.content.eventhandler.CEUtils;
007:
008: import com.teamkonzept.lib.*;
009: import com.teamkonzept.publishing.markups.*;
010: import com.teamkonzept.web.*;
011: import com.teamkonzept.field.db.*;
012: import com.teamkonzept.field.db.queries.*;
013: import com.teamkonzept.db.*;
014: import com.teamkonzept.field.*;
015: import com.teamkonzept.international.LanguageManager;
016:
017: import java.sql.*;
018: import java.util.*;
019:
020: /**
021: * The content node type selector field control.
022: *
023: * @author $Author: uli $
024: * @version $Revision: 1.10 $
025: */
026: public class TKContentNodeTypeSelectorField extends TKSelectField {
027: // $Id: TKContentNodeTypeSelectorField.java,v 1.10 2002/02/27 11:32:19 uli Exp $
028:
029: /**
030: * The class identifier.
031: */
032: public static final String CLASS_ID = "GROUPNODELIST";
033:
034: /**
035: * The <CODE>directory</CODE> node type constant.
036: */
037: public static final Integer DIRECTORY_NODE_TYPE = new Integer(1);
038:
039: /**
040: * The <CODE>group</CODE> node type constant.
041: */
042: public static final Integer GROUP_NODE_TYPE = new Integer(2);
043:
044: /**
045: * The <CODE>single</CODE> node type constant.
046: */
047: public static final Integer SINGLE_NODE_TYPE = new Integer(3);
048:
049: /**
050: * The selected node type.
051: */
052: protected Integer fNodeType = null;
053:
054: /**
055: * Creates an empty field.
056: */
057: public TKContentNodeTypeSelectorField() {
058: super ();
059: }
060:
061: public TKContentNodeTypeSelectorField(String name, String showName,
062: Integer nodeType) {
063: initContentNodeTypeSelectorField(CLASS_ID, name, showName,
064: nodeType);
065: }
066:
067: public void initContentNodeTypeSelectorField(String type,
068: String name, String showName, Integer nodeType) {
069: initSelectField(type, name, showName, new TKVector(), 1, false);
070: fNodeType = nodeType;
071: }
072:
073: public void fillIntoTemplate(TKHTMLTemplate t, Object value,
074: String prefix) {
075: TKVector tmpOptionList = optionList;
076: try {
077: TKQuery q = TKDBManager
078: .newQuery(TKDBContentTreeGetTypeOrderByName.class);
079: q.setQueryParams("CONTENT_NODE_TYPE", fNodeType);
080: q.execute();
081: ResultSet res = q.fetchResultSet();
082: TKVector newOptionList = new TKVector();
083: newOptionList.addElement(new TKOptionFieldEntry(
084: LanguageManager.getText("form",
085: "OPTIONLIST_POSSIBILITIES"), "0"));
086: while (res.next()) {
087: newOptionList.addElement(new TKOptionFieldEntry(res
088: .getString("CONTENT_NODE_NAME"), String
089: .valueOf(res.getInt("CONTENT_NODE_ID"))));
090: }
091: res.close();
092: optionList = newOptionList;
093: } catch (SQLException e) {
094: TKHttp.out().println("<br><b>ERROR: </b>" + e);
095: return;
096: }
097:
098: super .fillIntoTemplate(t, value, prefix);
099:
100: optionList = tmpOptionList;
101: }
102:
103: /**
104: * Checks wether this object and the specified object
105: * may be treated as equal.
106: *
107: * @param object the object to checked for equality.
108: * @return <CODE>true</CODE> if this object and the
109: * specified object may be treated as equal, otherwise
110: * <CODE>false</CODE>.
111: */
112: public boolean equals(Object object) {
113: if (!super .equals(object)) {
114: return false;
115: }
116:
117: TKContentNodeTypeSelectorField field = (TKContentNodeTypeSelectorField) object;
118:
119: return (this .fNodeType == null ? field.fNodeType == null
120: : this .fNodeType.equals(field.fNodeType));
121: }
122:
123: /**
124: * Returns the hash code for this object.
125: *
126: * @return the hash code for this object.
127: */
128: public int hashCode() {
129: // Implementation for JTest only ;-(
130: return super.hashCode();
131: }
132:
133: }
|