org.openxma.xmadsl.XmadslModelExtension Maven / Gradle / Ivy
package org.openxma.xmadsl;
import org.openxma.dsl.common.extensions.EObjectPropertiesAdapter;
import org.openxma.dsl.core.model.DataTypeAndTypeParameter;
import org.openxma.dsl.dom.model.Attribute;
import org.openxma.dsl.dom.model.PresentableFeature;
import org.openxma.dsl.pom.model.CustomizeableField;
import org.openxma.dsl.pom.model.IField;
public class XmadslModelExtension {
/**
* Get the label text for a CustomizeableField
* @param field
* @return
*/
public static String getLabelText(CustomizeableField field) {
if (field == null) {
throw new IllegalArgumentException();
}
//System.out.println(">>>> getLabelText for field: "+field.getObject().getName()+"."+field.getAttributeHolder().getName());
return field.getLabelText();
}
/**
* Get the label text for a CustomizeableField
* @param field
* @return
*/
public static String getTooltipText(CustomizeableField field) {
if (field == null) {
throw new IllegalArgumentException();
}
return field.getTooltipText();
}
/**
* Get the unit text for a CustomizeableField
* @param field
* @return
*/
public static String getUnitText(CustomizeableField field) {
if (field == null) {
throw new IllegalArgumentException();
}
return field.getUnitText();
}
/**
* Get the unit-attribute for a CustomizeableField
* @param field
* @return
*/
public static Attribute getUnitAttribute(CustomizeableField field) {
if (field == null) {
throw new IllegalArgumentException();
}
return field.getUnitAttribute();
}
/**
* Get the unit-object for a CustomizableField
* @param field
* @return
*/
public static Object getUnitObject(CustomizeableField field) {
if (field == null) {
throw new IllegalArgumentException();
}
return field.getUnitObject();
}
public static String getName(PresentableFeature attributeHolder) {
if (attributeHolder != null) {
return attributeHolder.getName();
}
return null;
}
public static DataTypeAndTypeParameter getType(PresentableFeature attributeHolder) {
if (attributeHolder != null) {
return attributeHolder.getAttribute().getType();
}
return null;
}
public static String getAttributeName(IField iField) {
if (iField != null && iField.getAttributeHolder() != null) {
return iField.getAttributeHolder().getName();
}
return null;
}
public static Attribute getAttribute(IField iField) {
if (iField != null && iField.getAttributeHolder() != null) {
return iField.getAttributeHolder().getAttribute();
}
return null;
}
/**
* Get the Attribute hold by an AttributeHolder
* @param attrHolder
* @return
*/
public static Attribute getAttributeOfAttributeHolder(PresentableFeature attrHolder) {
Attribute attribute = attrHolder.getAttribute();
if (attribute == null) {
throw new RuntimeException("Nested AttributeHolder is null");
}
return attribute;
}
public static String getFQNProperty(PresentableFeature attr) {
return (String)EObjectPropertiesAdapter.getProperty(attr,"fqn");
}
}