01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05:
06: package com.sun.portal.search.admin;
07:
08: import java.io.IOException;
09:
10: import com.iplanet.jato.view.RequestHandlingTiledViewBase;
11: import com.iplanet.jato.view.View;
12: import com.iplanet.jato.view.ViewBean;
13: import com.iplanet.jato.view.ViewBeanBase;
14: import com.iplanet.jato.view.TiledView;
15: import com.iplanet.jato.RequestHandler;
16: import com.iplanet.jato.model.ModelControlException;
17: import com.iplanet.jato.view.event.DisplayEvent;
18: import com.iplanet.jato.view.event.RequestInvocationEvent;
19: import com.iplanet.jato.view.event.TiledViewRequestInvocationEvent;
20: import com.iplanet.jato.view.event.ChildDisplayEvent;
21: import com.iplanet.jato.view.html.StaticTextField;
22: import com.iplanet.jato.view.html.CheckBox;
23: import com.iplanet.jato.view.html.HiddenField;
24: import com.iplanet.jato.model.DatasetModel;
25: import javax.servlet.http.HttpServletRequest;
26: import javax.servlet.http.HttpServletResponse;
27:
28: import com.iplanet.am.console.components.view.html.IPlanetButton;
29:
30: import com.sun.portal.search.robot.ConverterConfig;
31:
32: public class ConverterListView extends RequestHandlingTiledViewBase
33: implements TiledView, RequestHandler {
34: public static final String DOC_LABEL = "DocLabel";
35: public static final String DOC_NAME = "HiddenName";
36: public static final String DOC_CHECKBOX = "DocCheckbox";
37: public static final String CHECKED_VALUE = "checked";
38: ConverterConfig cc = null;
39:
40: public ConverterListView(View parent, String name) {
41: super (parent, name);
42: setPrimaryModel((DatasetModel) getDefaultModel());
43: registerChildren();
44: cc = CSConfig.getRobotConfig().convertConf;
45: }
46:
47: protected void registerChildren() {
48: registerChild(DOC_LABEL, StaticTextField.class);
49: registerChild(DOC_NAME, HiddenField.class);
50: registerChild(DOC_CHECKBOX, CheckBox.class);
51: }
52:
53: protected View createChild(String name) {
54: if (name.equals(DOC_LABEL)) {
55: return new StaticTextField(this , DOC_LABEL, "");
56: }
57: if (name.equals(DOC_NAME)) {
58: return new HiddenField(this , DOC_NAME, "");
59: }
60: if (name.equals(DOC_CHECKBOX)) {
61: return new CheckBox(this , DOC_CHECKBOX, this .CHECKED_VALUE,
62: "", false);
63: }
64: throw new IllegalArgumentException("Invalid child name ["
65: + name + "]");
66: }
67:
68: public void beginDisplay(DisplayEvent event)
69: throws ModelControlException {
70: super .beginDisplay(event);
71: resetTileIndex();
72: getPrimaryModel().setSize(cc.numOfDocs());
73: }
74:
75: public boolean nextTile() throws ModelControlException {
76: boolean movedToRow = super .nextTile();
77: if (movedToRow) {
78: // Put row specific logic here
79: int index = getTileIndex();
80: setDisplayFieldValue(DOC_LABEL, cc.getDocLabel(index));
81: setDisplayFieldValue(DOC_NAME, cc.getDocLabel(index));
82: CheckBox cb = (CheckBox) this .getChild(this .DOC_CHECKBOX);
83: cb.setChecked(cc.getDocEnable(index));
84: }
85: return movedToRow;
86: }
87:
88: public void updateData() throws ModelControlException {
89: DatasetModel model = getPrimaryModel();
90: model.beforeFirst();
91: while (model.next()) {
92: String cValue = (String) model.getValue(this .DOC_CHECKBOX);
93: cc.setDocEnable(model.getLocation(), cValue
94: .compareTo(this .CHECKED_VALUE) == 0);
95: cc.updateFile();
96: }
97: }
98:
99: }
|