001: package com.teamkonzept.webman.field;
002:
003: import com.teamkonzept.webman.mainint.*;
004: import com.teamkonzept.webman.mainint.db.queries.TKDBContentTreeGetType;
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: import de.webman.generator.*;
017: import java.sql.*;
018: import java.util.*;
019: import org.apache.log4j.Category;
020:
021: /**
022: * The form type selector field control.
023: *
024: * @author $Author: uli $
025: * @version $Revision: 1.11 $
026: */
027: public class TKFormTypeSelectorField extends TKSelectField {
028: /**
029: * The class identifier.
030: */
031: public static final String CLASS_ID = "FORMLIST";
032:
033: /**
034: * The logging category.
035: */
036: private static Category cat = Category
037: .getInstance(TKFormTypeSelectorField.class);
038:
039: /**
040: * The <CODE>structure</CODE> form type constant.
041: */
042: public static final Integer STRUCTURE_FORM_TYPE = new Integer(1);
043:
044: /**
045: * The <CODE>fragment</CODE> form type constant.
046: */
047: public static final Integer FRAGMENT_FORM_TYPE = new Integer(2);
048:
049: /**
050: * The <CODE>content</CODE> form type constant.
051: */
052: public static final Integer CONTENT_FORM_TYPE = new Integer(3);
053:
054: /**
055: * The selected form type.
056: */
057: protected Integer formType = null;
058:
059: /**
060: * Creates an empty form type selector field control.
061: */
062: public TKFormTypeSelectorField() {
063: super ();
064: }
065:
066: public TKFormTypeSelectorField(String name, String showName,
067: Integer fType) {
068: initSelectorField(CLASS_ID, name, showName, fType);
069: }
070:
071: public void initSelectorField(String type, String name,
072: String showName, Integer fType) {
073: initSelectField(type, name, showName, new TKVector(), 1, false);
074: formType = fType;
075: }
076:
077: public void fillIntoTemplate(TKHTMLTemplate t, Object value,
078: String prefix) {
079: TKVector tmpOptionList = optionList;
080: try {
081: // Achtung hier noch den Formtype !!!!
082: TKQuery q = TKDBManager.newQuery(TKDBFormGetAll69.class);
083: // q.setQueryParams( "FORM_TYPE", fNodeType );
084: q.execute();
085: ResultSet res = q.fetchResultSet();
086: TKVector newOptionList = new TKVector();
087: newOptionList.addElement(new TKOptionFieldEntry(
088: LanguageManager.getText("form",
089: "OPTIONLIST_POSSIBILITIES"), "0"));
090: while (res.next()) {
091: String name = res.getString("FORM_NAME");
092: newOptionList.addElement(new TKOptionFieldEntry(name,
093: String.valueOf(res.getInt("FORM_ID"))));
094: }
095: res.close();
096: optionList = newOptionList;
097: } catch (SQLException e) {
098: cat.error("fillIntoTemplate", e);
099: return;
100: }
101: super .fillIntoTemplate(t, value, prefix);
102: optionList = tmpOptionList;
103: }
104:
105: /**
106: * Checks wether this object and the specified object
107: * may be treated as equal.
108: *
109: * @param object the object to checked for equality.
110: * @return <CODE>true</CODE> if this object and the
111: * specified object may be treated as equal, otherwise
112: * <CODE>false</CODE>.
113: */
114: public boolean equals(Object object) {
115: if (!super .equals(object)) {
116: return false;
117: }
118:
119: TKFormTypeSelectorField field = (TKFormTypeSelectorField) object;
120:
121: return (this .formType == null ? field.formType == null
122: : this .formType.equals(field.formType));
123: }
124:
125: /**
126: * Returns the hash code for this object.
127: *
128: * @return the hash code for this object.
129: */
130: public int hashCode() {
131: // Implementation for JTest only ;-(
132: return super.hashCode();
133: }
134:
135: }
|