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.screen;
16:
17: import java.io.File;
18: import java.io.IOException;
19: import java.util.List;
20:
21: import org.apache.xmlbeans.XmlException;
22: import org.romaframework.aspect.core.annotation.AnnotationConstants;
23: import org.romaframework.aspect.view.ViewException;
24: import org.romaframework.aspect.view.annotation.ViewField;
25: import org.romaframework.core.domain.page.ContainerPage;
26: import org.romaframework.core.flow.ObjectContext;
27: import org.romaframework.core.serializer.RomaSerializationException;
28: import org.romaframework.core.validation.ValidationException;
29: import org.romaframework.module.designer.DesignerHelper;
30: import org.romaframework.module.designer.view.domain.radpage.aspect.FormAreaEditingPage;
31:
32: /**
33: * The page for the editing of a new Screen
34: * @author Giordano Maestro(giordano.maestro@assetdata.it) 09/nov/07
35: *
36: */
37: public class ScreenEditingPage extends ContainerPage {
38: protected String name;
39: private FormAreaEditingPage formPage;
40: private Object backObject;
41: protected ApplicationScreen appScreen;
42: protected List<ApplicationScreen> screens;
43:
44: public ScreenEditingPage(ApplicationScreen root,
45: Object iBackObject, List<ApplicationScreen> iScreens) {
46: super ();
47: screens = iScreens;
48: appScreen = root;
49: formPage = new FormAreaEditingPage(root.getRootArea());
50: this .getInnerPages().put("Layout", formPage);
51: backObject = iBackObject;
52: }
53:
54: public void ok() throws IOException, RomaSerializationException,
55: ValidationException {
56: File fileToSave = new File(DesignerHelper.getScreenDir()
57: .getAbsolutePath()
58: + "/" + name + ".xml");
59: appScreen.setName(name.trim() + ".xml");
60: appScreen.setRootArea(formPage.getRootArea());
61: DesignerHelper.saveScreen(fileToSave, formPage.getRootArea());
62: ObjectContext.getInstance().show(backObject);
63: }
64:
65: public void cancel() throws ViewException, XmlException,
66: IOException {
67: ObjectContext.getInstance().show(backObject);
68: }
69:
70: @ViewField(enabled=AnnotationConstants.FALSE)
71: public String getName() {
72: return name;
73: }
74:
75: public void setName(String name) {
76: this.name = name;
77: }
78: }
|