001: package org.romaframework.module.designer.domain;
002:
003: import java.util.Iterator;
004: import java.util.LinkedHashSet;
005: import java.util.Set;
006: import org.romaframework.aspect.core.annotation.AnnotationConstants;
007: import org.romaframework.aspect.core.annotation.CoreClass;
008: import org.romaframework.aspect.view.annotation.ViewField;
009: import org.romaframework.core.schema.SchemaAction;
010: import org.romaframework.core.schema.SchemaClass;
011: import org.romaframework.core.schema.SchemaClassDefinition;
012: import org.romaframework.core.schema.SchemaField;
013: import org.romaframework.core.schema.SchemaObject;
014:
015: @CoreClass(orderFields="name classPackage javaClass extendsClass fields actions")
016: public class RadClass extends RadElement {
017: private String javaClass;
018: @ViewField(selectionField="selectedField")
019: private Set<RadField> fields = new LinkedHashSet<RadField>();
020: @ViewField(layout="form:fields",selectionField="selectedAction")
021: private Set<RadAction> actions = new LinkedHashSet<RadAction>();
022: private RadClass extendsClass;
023: private RadPackage classPackage = null;
024: @ViewField(visible=AnnotationConstants.FALSE)
025: private RadField selectedField;
026: @ViewField(visible=AnnotationConstants.FALSE)
027: private RadAction selectedAction;
028:
029: public RadClass(String iName) {
030: super (iName);
031: }
032:
033: public RadClass() {
034: super ("");
035: }
036:
037: public RadClass(SchemaClassDefinition classDefinition)
038: throws CloneNotSupportedException {
039: // TODO : managage exception
040: super ("");
041: if (classDefinition instanceof SchemaClass) {
042: SchemaClass schemaClass = (SchemaClass) classDefinition;
043: super .setName(schemaClass.getClazz().getSimpleName());
044: schemaFeatures = new SchemaObject(schemaClass);
045: if (schemaClass.getParent() != null) {
046: extendsClass = new RadClass(schemaClass.getParent());
047: }
048: classPackage = new RadPackage(schemaClass.getClass()
049: .getPackage().getName());
050: } else {
051: SchemaObject clazz = (SchemaObject) classDefinition;
052: super .setName(clazz.getSchemaClass().getClazz()
053: .getSimpleName());
054: schemaFeatures = clazz;
055: if (clazz.getSchemaClass().getParent() != null) {
056: extendsClass = new RadClass(clazz.getSchemaClass()
057: .getParent());
058: }
059: classPackage = new RadPackage(clazz.getSchemaClass()
060: .getClass().getPackage().getName());
061: }
062: Iterator<SchemaField> iter = ((SchemaObject) schemaFeatures)
063: .getFieldIterator();
064: while (iter.hasNext()) {
065: fields.add(new RadField(this , "", iter.next()));
066: }
067: Iterator<SchemaAction> actionIterator = ((SchemaObject) schemaFeatures)
068: .getActionIterator();
069: while (actionIterator.hasNext()) {
070: actions.add(new RadAction(this , "", actionIterator.next()));
071: }
072: }
073:
074: public Set<RadField> getFields() {
075: return fields;
076: }
077:
078: public Set<RadAction> getActions() {
079: return actions;
080: }
081:
082: public String getJavaClass() {
083: return javaClass;
084: }
085:
086: public void setJavaClass(String javaClass) {
087: this .javaClass = javaClass;
088: }
089:
090: public RadClass getExtendsClass() {
091: return extendsClass;
092: }
093:
094: public RadPackage getClassPackage() {
095: return classPackage;
096: }
097:
098: public void setSchemaObject(SchemaObject schema) {
099: schemaFeatures = schema;
100: }
101:
102: public RadField getSelectedField() {
103: return selectedField;
104: }
105:
106: public RadAction getSelectedAction() {
107: return selectedAction;
108: }
109:
110: @Override
111: @ViewField(enabled=AnnotationConstants.FALSE)
112: public String getName() {
113: return super .getName();
114: }
115:
116: public void setSelectedAction(RadAction selectedAction) {
117: this .selectedAction = selectedAction;
118: }
119:
120: @ViewField(visible=AnnotationConstants.FALSE)
121: public SchemaObject getSchemaClass() {
122: return (SchemaObject) schemaFeatures;
123: }
124: }
|