001: package com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.custom;
002:
003: import com.bostechcorp.cbesb.common.util.custcomponent.IBooleanProperty;
004: import com.bostechcorp.cbesb.common.util.custcomponent.ICustComponent;
005: import com.bostechcorp.cbesb.common.util.custcomponent.IEndpointProperty;
006: import com.bostechcorp.cbesb.common.util.custcomponent.IEnumProperty;
007: import com.bostechcorp.cbesb.common.util.custcomponent.IFileProperty;
008: import com.bostechcorp.cbesb.common.util.custcomponent.IProperty;
009: import com.bostechcorp.cbesb.common.util.custcomponent.ITextProperty;
010: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.Custom;
011: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.DefaultMepType;
012: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.PropertyObject;
013: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.RoleType;
014: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.componentflowFactory;
015:
016: public class ModelInfoPass {
017:
018: public static void modeltoFlow(
019: Custom custom,
020: com.bostechcorp.cbesb.common.util.custcomponent.ICustComponent curr) {
021:
022: //custom = (Custom)getWizard().getModels();
023: if (custom == null)
024: return;
025:
026: if (curr == null)
027: return;
028:
029: custom.setType(curr.getName());
030: custom.setDescription(curr.getDescription());
031:
032: custom.setUseCCSL(curr.getUseCCSL());
033:
034: custom.setRole(CustRoleToModelRole(curr.getRole()));
035:
036: custom
037: .getCustomConsumer()
038: .setDefaultMep(
039: CustDefMEPToModelDefMEP(curr
040: .getDefaultMep(com.bostechcorp.cbesb.common.util.custcomponent.ICustComponent.Role.CONSUMER)));
041:
042: custom.clearConsumerProperties();
043:
044: custom.clearProviderProperties();
045: com.bostechcorp.cbesb.common.util.custcomponent.IWizardPage[] pagesConsumer = curr
046: .getWizardPages(ICustComponent.Role.CONSUMER);
047: for (int i = 0; i < pagesConsumer.length; i++) {
048: IProperty[] properties = pagesConsumer[i].getProperties();
049:
050: for (int j = 0; j < properties.length; j++) {
051: PropertyObject propertyObject = componentflowFactory.eINSTANCE
052: .createPropertyObject();
053: inforMove(properties[j], propertyObject);
054:
055: custom.addConsumerProperty(propertyObject);
056: }
057: }
058:
059: com.bostechcorp.cbesb.common.util.custcomponent.IWizardPage[] pagesProvider = curr
060: .getWizardPages(ICustComponent.Role.PROVIDER);
061:
062: for (int i = 0; i < pagesProvider.length; i++) {
063: IProperty[] properties = pagesProvider[i].getProperties();
064:
065: for (int j = 0; j < properties.length; j++) {
066: PropertyObject propertyObject = componentflowFactory.eINSTANCE
067: .createPropertyObject();
068: inforMove(properties[j], propertyObject);
069:
070: custom.addProviderProperty(propertyObject);
071: }
072: }
073:
074: }
075:
076: public static void inforMove(IProperty property,
077: PropertyObject propertyObject) {
078:
079: propertyObject.setName(property.getName());
080: if (property instanceof ITextProperty) {
081: propertyObject.setValue(((ITextProperty) property)
082: .getDefaultValue());
083: } else if (property instanceof IBooleanProperty) {
084: if (((IBooleanProperty) property).getDefaultValue())
085: propertyObject.setValue("true");
086: else
087: propertyObject.setValue("false");
088: } else if (property instanceof IEnumProperty) {
089: propertyObject.setValue(((IEnumProperty) property)
090: .getDefaultValue());
091: } else if (property instanceof IFileProperty) {
092: propertyObject.setValue(((IFileProperty) property)
093: .getFileName());
094: }
095:
096: else if (property instanceof IEndpointProperty) {
097: propertyObject.setValue("<None>");
098: }
099: }
100:
101: static public RoleType CustRoleToModelRole(
102: com.bostechcorp.cbesb.common.util.custcomponent.ICustComponent.Role role) {
103: if (role
104: .equals(com.bostechcorp.cbesb.common.util.custcomponent.ICustComponent.Role.CONSUMER))
105: return RoleType.get(RoleType.CONSUMER);
106: else if (role
107: .equals(com.bostechcorp.cbesb.common.util.custcomponent.ICustComponent.Role.PROVIDER))
108: return RoleType.get(RoleType.PROVIDER);
109: else
110: return RoleType.get(RoleType.BOTH);
111: }
112:
113: public static DefaultMepType CustDefMEPToModelDefMEP(
114: com.bostechcorp.cbesb.common.util.custcomponent.ICustComponent.DefaultMEP defaultMep) {
115: if (defaultMep
116: .equals(com.bostechcorp.cbesb.common.util.custcomponent.ICustComponent.DefaultMEP.IN_ONLY))
117: return DefaultMepType.get(DefaultMepType.INONLY);
118: else if (defaultMep
119: .equals(com.bostechcorp.cbesb.common.util.custcomponent.ICustComponent.DefaultMEP.IN_OUT))
120: return DefaultMepType.get(DefaultMepType.INOUT);
121: else
122: return DefaultMepType.get(DefaultMepType.RELIABLEIN);
123: }
124: }
|