001: /*
002: * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.romaframework.aspect.view.echo2.form;
018:
019: import nextapp.echo2.app.Component;
020: import nextapp.echo2.app.Extent;
021: import nextapp.echo2.extras.app.MenuBarPane;
022: import nextapp.echo2.extras.app.menu.DefaultMenuModel;
023:
024: import org.romaframework.aspect.view.ViewAspect;
025: import org.romaframework.aspect.view.echo2.component.ComponentFactory;
026: import org.romaframework.aspect.view.echo2.component.Titleable;
027: import org.romaframework.aspect.view.echo2.look.LookAndFeelManager;
028: import org.romaframework.aspect.view.feature.ViewBaseFeatures;
029: import org.romaframework.aspect.view.form.ContentComponent;
030: import org.romaframework.core.config.RomaApplicationContext;
031: import org.romaframework.core.flow.ObjectContext;
032: import org.romaframework.core.schema.SchemaObject;
033: import org.romaframework.core.validation.MultiValidationException;
034: import org.romaframework.core.validation.ValidationException;
035:
036: public class MenuForm extends EntityForm implements Titleable {
037:
038: private DefaultMenuModel menuContainer;
039: private static final Extent DEFAULT_MENU_HEIGHT = new Extent(24);
040:
041: public MenuForm(ContentComponent iParent, DefaultMenuModel iMenuNode) {
042: super (iParent);
043: menuContainer = iMenuNode;
044: }
045:
046: @Override
047: public void validateValues() throws ValidationException,
048: MultiValidationException {
049: }
050:
051: public void activate() {
052: }
053:
054: public void passivate() {
055: }
056:
057: public void render(ContentComponent iFormToRender) {
058: setHeight(DEFAULT_MENU_HEIGHT);
059:
060: RomaApplicationContext
061: .getInstance()
062: .getBean(LookAndFeelManager.class)
063: .assignStyle(
064: this ,
065: getSchemaInstance().getSchemaClass().getClazz(),
066: (String) getSchemaInstance().getFeature(
067: ViewAspect.ASPECT_NAME,
068: ViewBaseFeatures.STYLE));
069:
070: if (getContainerComponent() instanceof MenuForm) {
071: // THIS MENU IS A NODE OF AN ALREADY EXISTENT PARENT MENU
072: // menuContainer = ((MenuForm)
073: // getContainerComponent()).getMenuContainer();
074: } else {
075: // FIRST MENU IN FORM: CREATE THE CONTAINER
076: MenuBarPane menu = (MenuBarPane) ObjectContext
077: .getInstance().getComponent(ComponentFactory.class)
078: .createMenuContainerComponent(this );
079: add(menu);
080:
081: RomaApplicationContext.getInstance().getBean(
082: LookAndFeelManager.class).assignStyle(
083: menu,
084: getSchemaInstance().getSchemaClass().getClazz(),
085: (String) getSchemaInstance().getFeature(
086: ViewAspect.ASPECT_NAME,
087: ViewBaseFeatures.STYLE));
088:
089: menu.setModel(menuContainer);
090: }
091:
092: SchemaObject obj = iFormToRender.getSchemaInstance();
093:
094: renderFormFields(obj, iFormToRender);
095: renderFormActions(obj, iFormToRender);
096: }
097:
098: public DefaultMenuModel getMenuNode() {
099: return menuContainer;
100: }
101:
102: public String getTitle() {
103: return (String) schemaInstance.getFeature(
104: ViewAspect.ASPECT_NAME, ViewBaseFeatures.LABEL);
105: }
106:
107: public void setTitle(String iTitle) {
108: }
109:
110: @Override
111: public void placeComponentInForm(String area, Component component) {
112: }
113: }
|