01: /*
02: * Copyright 2007 Giordano Maestro (giordano.maestro@assetdata.it)
03: *
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
06: * use this file except in compliance with the License.
07: *
08: * You may obtain a copy of the License at
09: * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
10: * or agreed to in writing, software distributed under the License is
11: * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12: * KIND, either express or implied. See the License for the specific language
13: * governing permissions and limitations under the License.
14: */
15: package org.romaframework.module.designer.view.domain.radpage.aspect;
16:
17: import java.util.ArrayList;
18: import java.util.List;
19: import java.util.Map;
20:
21: import org.romaframework.aspect.core.annotation.AnnotationConstants;
22: import org.romaframework.aspect.view.ViewConstants;
23: import org.romaframework.aspect.view.annotation.ViewAction;
24: import org.romaframework.aspect.view.annotation.ViewClass;
25: import org.romaframework.aspect.view.annotation.ViewField;
26: import org.romaframework.core.serializer.DefaultValues;
27: import org.romaframework.core.util.DynaBean;
28: import org.romaframework.module.designer.view.domain.FeatureListable;
29: import org.romaframework.module.designer.view.domain.radannotation.RadAnnotationListable;
30:
31: /**
32: * The page for the configuration of an element features.
33: * @author Giordano Maestro(giordano.maestro@assetdata.it) 09/nov/07
34: *
35: */
36: @ViewClass(label="")
37: public abstract class FeatureAspectPage implements ChildPage {
38: protected String aspectName;
39: @ViewField(render=ViewConstants.RENDER_TABLE,layout=ViewConstants.LAYOUT_BLOCK)
40: protected List<RadAnnotationListable> annotations = new ArrayList<RadAnnotationListable>();
41: @ViewField(visible=AnnotationConstants.FALSE)
42: protected DynaBean actualFeature;
43: @ViewField(label="")
44: protected List<FeatureListable> configurable = new ArrayList<FeatureListable>();
45:
46: public FeatureAspectPage() {
47: }
48:
49: protected FeatureAspectPage(String iName, DynaBean iActualFeature) {
50: aspectName = iName;
51: if (iActualFeature != null) {
52: actualFeature = iActualFeature;
53: } else {
54: actualFeature = new DynaBean();
55: }
56: configurable = fillConfigurable();
57: DefaultValues.getInstance().setDefaultValues(aspectName,
58: getDefaultValues());
59: }
60:
61: @Override
62: public String toString() {
63: return aspectName;
64: }
65:
66: @ViewField(enabled=AnnotationConstants.FALSE,render=ViewConstants.RENDER_TABLEEDIT)
67: public List<FeatureListable> getConfigurable() {
68: return configurable;
69: }
70:
71: /**
72: * Fill the list of configurable properties
73: * @return
74: * @throws ClassNotFoundException
75: */
76: protected abstract List<FeatureListable> fillConfigurable();
77:
78: @ViewAction(visible=AnnotationConstants.FALSE)
79: public void apply() throws Exception {
80: for (FeatureListable elementToSet : configurable) {
81: actualFeature.setAttribute(elementToSet.getFeature(),
82: elementToSet.getValue().getFinalValue());
83: }
84: }
85:
86: public DynaBean getActualFeature() {
87: return actualFeature;
88: }
89:
90: @ViewField(visible=AnnotationConstants.FALSE)
91: public abstract Map<String, Object> getDefaultValues();
92: }
|