001: /*
002: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005:
006: package com.sun.portal.subscriptions.admin;
007:
008: import java.util.Set;
009: import java.util.List;
010: import java.util.Iterator;
011:
012: import javax.servlet.http.HttpServletRequest;
013:
014: import com.iplanet.jato.RequestContext;
015:
016: import com.iplanet.jato.view.event.DisplayEvent;
017: import com.iplanet.jato.view.event.RequestInvocationEvent;
018:
019: import com.iplanet.jato.view.html.StaticTextField;
020: import com.iplanet.jato.view.html.TextField;
021: import com.iplanet.jato.view.html.CheckBox;
022: import com.iplanet.jato.view.html.Button;
023: import com.iplanet.jato.view.html.ComboBox;
024: import com.iplanet.jato.view.html.Option;
025: import com.iplanet.jato.view.html.OptionList;
026:
027: import com.iplanet.jato.view.View;
028: import com.iplanet.jato.view.ContainerView;
029: import com.iplanet.jato.RequestHandler;
030: import com.iplanet.jato.view.RequestHandlingViewBase;
031: import com.iplanet.jato.view.ViewBean;
032: import com.iplanet.jato.view.ViewBeanBase;
033:
034: import com.iplanet.jato.ViewBeanManager;
035:
036: import com.iplanet.jato.model.*;
037:
038: import com.iplanet.am.console.service.model.SMDataModel;
039: import com.iplanet.am.console.components.view.html.IPlanetButton;
040:
041: import com.sun.portal.subscriptions.admin.model.ScheduleModel;
042: import com.sun.portal.subscriptions.admin.model.SubscriptionsAdminServiceModelImpl;
043:
044: /**
045: * iPS admin console view bean: TODO
046: */
047: public class ScheduleView extends RequestHandlingViewBase implements
048: ContainerView, RequestHandler {
049: public static final String PAGE_NAME = "Schedule";
050: public static final String LBL_START_PROF = "prof.label.start.profiler";
051: public static final String LBL_STOP_PROF = "prof.label.stop.profiler";
052: public static final String COMMAND = ScheduleModel.FIELD_COMMAND;
053: public static final String DIR = ScheduleModel.FIELD_DIR;
054: public static final String HOUR_LIST = "HourList";
055: public static final String MIN_LIST = "MinList";
056: public static final String SUN_CHECKBOX = "SUN";
057: public static final String MON_CHECKBOX = "MON";
058: public static final String TUE_CHECKBOX = "TUE";
059: public static final String WED_CHECKBOX = "WED";
060: public static final String THU_CHECKBOX = "THU";
061: public static final String FRI_CHECKBOX = "FRI";
062: public static final String SAT_CHECKBOX = "SAT";
063: public static final String CHILD_TIME_TEXT = "time.text";
064: public static final String CHILD_HHMM_SEPARATOR = "hhmm.separator";
065: public static final String CHILD_DAYS_TEXT = "days.text";
066: public static final String CHILD_WEEKDAY_SUN = "weekday.sun";
067: public static final String CHILD_WEEKDAY_MON = "weekday.mon";
068: public static final String CHILD_WEEKDAY_TUE = "weekday.tue";
069: public static final String CHILD_WEEKDAY_WED = "weekday.wed";
070: public static final String CHILD_WEEKDAY_THU = "weekday.thu";
071: public static final String CHILD_WEEKDAY_FRI = "weekday.fri";
072: public static final String CHILD_WEEKDAY_SAT = "weekday.sat";
073:
074: private static OptionList hourOptions = new OptionList(
075: ScheduleModel.hourLabel, ScheduleModel.hourValues);
076: private static OptionList minOptions = new OptionList(
077: ScheduleModel.minValues, ScheduleModel.minValues);
078:
079: private ScheduleModel model = null;
080:
081: /**
082: * constructor
083: *
084: * @param PageName of this view bean
085: * @param displayURL default display URL
086: */
087: public ScheduleView(View parent, String name) {
088: super (parent, name);
089: registerChildren();
090: }
091:
092: /**
093: * register child component
094: */
095: protected void registerChildren() {
096: registerChild(COMMAND, TextField.class);
097: registerChild(DIR, TextField.class);
098: registerChild(LBL_START_PROF, StaticTextField.class);
099: registerChild(LBL_STOP_PROF, StaticTextField.class);
100: registerChild(HOUR_LIST, ComboBox.class);
101: registerChild(MIN_LIST, ComboBox.class);
102: registerChild(SUN_CHECKBOX, CheckBox.class);
103: registerChild(MON_CHECKBOX, CheckBox.class);
104: registerChild(TUE_CHECKBOX, CheckBox.class);
105: registerChild(WED_CHECKBOX, CheckBox.class);
106: registerChild(THU_CHECKBOX, CheckBox.class);
107: registerChild(FRI_CHECKBOX, CheckBox.class);
108: registerChild(SAT_CHECKBOX, CheckBox.class);
109: registerChild(CHILD_TIME_TEXT, StaticTextField.class);
110: registerChild(CHILD_HHMM_SEPARATOR, StaticTextField.class);
111: registerChild(CHILD_DAYS_TEXT, StaticTextField.class);
112: registerChild(CHILD_WEEKDAY_SUN, StaticTextField.class);
113: registerChild(CHILD_WEEKDAY_MON, StaticTextField.class);
114: registerChild(CHILD_WEEKDAY_TUE, StaticTextField.class);
115: registerChild(CHILD_WEEKDAY_WED, StaticTextField.class);
116: registerChild(CHILD_WEEKDAY_THU, StaticTextField.class);
117: registerChild(CHILD_WEEKDAY_FRI, StaticTextField.class);
118: registerChild(CHILD_WEEKDAY_SAT, StaticTextField.class);
119: }
120:
121: /**
122: * create child component
123: *
124: * @param name of component
125: * @return child component
126: */
127: protected View createChild(String name) {
128: SubscriptionsAdminServiceViewBean pvb = (SubscriptionsAdminServiceViewBean) getParentViewBean();
129: if (name.equals(this .LBL_START_PROF)) {
130: return new StaticTextField(this , LBL_START_PROF, pvb
131: .getLocalizedString(LBL_START_PROF));
132: }
133: if (name.equals(this .LBL_STOP_PROF)) {
134: return new StaticTextField(this , LBL_STOP_PROF, pvb
135: .getLocalizedString(LBL_STOP_PROF));
136: }
137: if (name.equals(COMMAND)) {
138: return new TextField(this , getModel(), COMMAND, COMMAND,
139: "", null);
140: }
141: if (name.equals(DIR)) {
142: return new TextField(this , getModel(), DIR, DIR, "", null);
143: }
144: if (name.equals(this .HOUR_LIST)) {
145: ComboBox child = new ComboBox(this , this .getModel(),
146: this .HOUR_LIST, ScheduleModel.FIELD_HOUR, "", null);
147: child.setOptions(this .hourOptions);
148: return child;
149:
150: }
151: if (name.equals(MIN_LIST)) {
152: ComboBox child = new ComboBox(this , getModel(), MIN_LIST,
153: ScheduleModel.FIELD_MIN, "", null);
154: child.setOptions(this .minOptions);
155: return child;
156: }
157: if (name.equals(SUN_CHECKBOX)) {
158: return new CheckBox(this , getModel(), SUN_CHECKBOX,
159: ScheduleModel.FIELD_SUN, "true", "false", false,
160: null);
161: }
162: if (name.equals(MON_CHECKBOX)) {
163: return new CheckBox(this , getModel(), MON_CHECKBOX,
164: ScheduleModel.FIELD_MON, "true", "false", false,
165: null);
166: }
167: if (name.equals(TUE_CHECKBOX)) {
168: return new CheckBox(this , getModel(), TUE_CHECKBOX,
169: ScheduleModel.FIELD_TUE, "true", "false", false,
170: null);
171: }
172: if (name.equals(WED_CHECKBOX)) {
173: return new CheckBox(this , getModel(), WED_CHECKBOX,
174: ScheduleModel.FIELD_WED, "true", "false", false,
175: null);
176: }
177: if (name.equals(THU_CHECKBOX)) {
178: return new CheckBox(this , getModel(), THU_CHECKBOX,
179: ScheduleModel.FIELD_THU, "true", "false", false,
180: null);
181: }
182: if (name.equals(FRI_CHECKBOX)) {
183: return new CheckBox(this , getModel(), FRI_CHECKBOX,
184: ScheduleModel.FIELD_FRI, "true", "false", false,
185: null);
186: }
187: if (name.equals(SAT_CHECKBOX)) {
188: return new CheckBox(this , getModel(), SAT_CHECKBOX,
189: ScheduleModel.FIELD_SAT, "true", "false", false,
190: null);
191: } else if (name.equals(CHILD_TIME_TEXT)) {
192: return new StaticTextField(this , CHILD_TIME_TEXT, pvb
193: .getLocalizedString(CHILD_TIME_TEXT));
194: } else if (name.equals(CHILD_HHMM_SEPARATOR)) {
195: return new StaticTextField(this , CHILD_HHMM_SEPARATOR, pvb
196: .getLocalizedString(CHILD_HHMM_SEPARATOR));
197: } else if (name.equals(CHILD_DAYS_TEXT)) {
198: return new StaticTextField(this , CHILD_DAYS_TEXT, pvb
199: .getLocalizedString(CHILD_DAYS_TEXT));
200: } else if (name.equals(CHILD_WEEKDAY_SUN)) {
201: return new StaticTextField(this , CHILD_WEEKDAY_SUN, pvb
202: .getLocalizedString(CHILD_WEEKDAY_SUN));
203: } else if (name.equals(CHILD_WEEKDAY_MON)) {
204: return new StaticTextField(this , CHILD_WEEKDAY_MON, pvb
205: .getLocalizedString(CHILD_WEEKDAY_MON));
206: } else if (name.equals(CHILD_WEEKDAY_TUE)) {
207: return new StaticTextField(this , CHILD_WEEKDAY_TUE, pvb
208: .getLocalizedString(CHILD_WEEKDAY_TUE));
209: } else if (name.equals(CHILD_WEEKDAY_WED)) {
210: return new StaticTextField(this , CHILD_WEEKDAY_WED, pvb
211: .getLocalizedString(CHILD_WEEKDAY_WED));
212: } else if (name.equals(CHILD_WEEKDAY_THU)) {
213: return new StaticTextField(this , CHILD_WEEKDAY_THU, pvb
214: .getLocalizedString(CHILD_WEEKDAY_THU));
215: } else if (name.equals(CHILD_WEEKDAY_FRI)) {
216: return new StaticTextField(this , CHILD_WEEKDAY_FRI, pvb
217: .getLocalizedString(CHILD_WEEKDAY_FRI));
218: } else if (name.equals(CHILD_WEEKDAY_SAT)) {
219: return new StaticTextField(this , CHILD_WEEKDAY_SAT, pvb
220: .getLocalizedString(CHILD_WEEKDAY_SAT));
221: }
222: throw new IllegalArgumentException("Invalid child name ["
223: + name + "]");
224: }
225:
226: /**
227: * Creates the model instance.
228: *
229: * @returns Instance of model
230: */
231: public ScheduleModel getModel() {
232: SubscriptionsAdminServiceViewBean pvb = (SubscriptionsAdminServiceViewBean) getParentViewBean();
233: if (model == null) {
234: model = new ScheduleModel(getName(),
235: ((SubscriptionsAdminServiceModelImpl) pvb
236: .getModel()).organization, (String) pvb
237: .getRequestContext().getServletContext()
238: .getInitParameter("server.root"));
239: try {
240: model.retrieve(null);
241: } catch (ModelControlException e) {
242: //TODO-log
243: }
244: }
245: return model;
246: }
247:
248: public void store() {
249: ScheduleModel model = getModel();
250: try {
251: model.update(null);
252: } catch (Exception e) {
253: //TODO-log
254: }
255: }
256:
257: public void reset() {
258: ScheduleModel model = getModel();
259: try {
260: model.retrieve(null);
261: } catch (Exception e) {
262: //TODO-log
263: }
264: }
265:
266: public void delete() {
267: ScheduleModel model = getModel();
268: try {
269: model.delete(null);
270: } catch (Exception e) {
271: //TODO-log
272: }
273: }
274: }
|