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 org.romaframework.aspect.core.annotation.AnnotationConstants;
18: import org.romaframework.aspect.view.ViewAspect;
19: import org.romaframework.aspect.view.annotation.ViewAction;
20: import org.romaframework.aspect.view.annotation.ViewField;
21: import org.romaframework.aspect.view.echo2.area.AreaInstance;
22: import org.romaframework.aspect.view.feature.ViewClassFeatures;
23: import org.romaframework.core.schema.SchemaClassDefinition;
24: import org.romaframework.core.schema.SchemaFeatures;
25: import org.romaframework.core.schema.SchemaHelper;
26: import org.romaframework.core.serializer.RomaSerializerComponent;
27: import org.romaframework.module.designer.view.domain.DesignerContainerPage;
28: import org.romaframework.xml.config.XmlConfigAreaType;
29:
30: public class ViewAspectPage extends DesignerContainerPage implements
31: ChildPage {
32: private ViewFeatureAspectPage viewPage;
33: private FormAreaEditingPage formPage;
34:
35: public ViewAspectPage(SchemaFeatures iActualFeature) {
36:
37: viewPage = new ViewFeatureAspectPage(iActualFeature);
38: addPage(viewPage);
39: XmlConfigAreaType form = null;
40: try {
41: form = (XmlConfigAreaType) iActualFeature.getFeature(
42: ViewAspect.ASPECT_NAME, ViewClassFeatures.FORM);
43: } catch (Exception e) {
44: // page must be created
45: }
46: if (iActualFeature instanceof SchemaClassDefinition
47: && form == null) {
48: form = SchemaHelper
49: .getDesktopConfiguration(((SchemaClassDefinition) iActualFeature)
50: .getSchemaClass().getClazz());
51: }
52: if (form != null) {
53: formPage = new FormAreaEditingPage(new AreaInstance(null,
54: null, null, form));
55: addPage(formPage);
56: }
57: }
58:
59: @ViewAction(visible=AnnotationConstants.FALSE)
60: public void apply() throws Exception {
61: viewPage.apply();
62: try {
63: if (formPage != null) {
64: XmlConfigAreaType areaType = (XmlConfigAreaType) RomaSerializerComponent
65: .getInstance()
66: .serialize(formPage.getRootArea());
67: viewPage.getActualFeature().setAttribute(
68: ViewClassFeatures.FORM, areaType);
69: }
70: } catch (Exception e) {
71: e.printStackTrace();
72: }
73: }
74:
75: @ViewField(visible=AnnotationConstants.FALSE)
76: public AreaInstance getRootArea() {
77: if (formPage != null) {
78: return formPage.getRootArea();
79: } else {
80: return null;
81: }
82: }
83:
84: @Override
85: public String toString() {
86: return ViewAspect.ASPECT_NAME;
87: }
88: }
|