01: /*
02: * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.romaframework.aspect.view.echo2.component;
18:
19: import java.util.Calendar;
20:
21: import nextapp.echo2.app.Button;
22: import nextapp.echo2.app.Row;
23: import nextapp.echo2.app.event.ActionEvent;
24: import nextapp.echo2.app.event.ActionListener;
25:
26: import org.romaframework.aspect.view.echo2.GUIEventHandler;
27: import org.romaframework.aspect.view.echo2.form.FormUtil;
28: import org.romaframework.aspect.view.echo2.look.LookAndFeelManager;
29: import org.romaframework.aspect.view.form.ContentComponent;
30: import org.romaframework.core.config.RomaApplicationContext;
31: import org.romaframework.core.schema.SchemaField;
32:
33: import echopointng.DateField;
34:
35: public class DynaDate extends Row implements ActionListener {
36:
37: protected DateField component;
38:
39: public DynaDate(ContentComponent iForm, SchemaField iField) {
40: component = new DateField();
41: component.setPopUpAlwaysOnTop(true);
42: component.setUpdateFromTextField(true);
43:
44: DynaCalendarSelectionModel model = new DynaCalendarSelectionModel(
45: Calendar.getInstance());
46: model.setComponent(component);
47: component.setModel(model);
48: component.getModel().addListener(GUIEventHandler.getInstance());
49: component.setProperty(FormUtil.METADATA_COMPONENT_OWNER, this );
50: add(component);
51:
52: Button resetButton = new Button();
53: resetButton.addActionListener(this );
54: resetButton
55: .setProperty(FormUtil.METADATA_COMPONENT_OWNER, this );
56:
57: RomaApplicationContext.getInstance().getBean(
58: LookAndFeelManager.class).assignStyle(resetButton,
59: null, "DynaDate.reset");
60:
61: add(resetButton);
62:
63: component.getDateChooser().setSelectedDate(null);
64: }
65:
66: @Override
67: public void setProperty(String propertyName, Object newValue) {
68: if (component.getDateChooser() != null)
69: component.getDateChooser().setProperty(propertyName,
70: newValue);
71:
72: component.setProperty(propertyName, newValue);
73:
74: super .setProperty(propertyName, newValue);
75: }
76:
77: public DateField getComponent() {
78: return component;
79: }
80:
81: public void setComponent(DateField component) {
82: this .component = component;
83: }
84:
85: public void actionPerformed(ActionEvent e) {
86: component.getDateChooser().setSelectedDate(null);
87: }
88: }
|