1 19 20 package org.netbeans.modules.xml.wsdl.model.extensions.bpel.impl; 21 22 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.BPELExtensibilityComponent; 23 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.CorrelationProperty; 24 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.Documentation; 25 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.PartnerLinkType; 26 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.PropertyAlias; 27 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.Role; 28 import org.netbeans.modules.xml.xam.Component; 29 import org.netbeans.modules.xml.xam.ComponentUpdater; 30 import org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent; 31 32 38 public class BPELComponentUpdater implements 39 BPELExtensibilityComponent.Visitor, 40 ComponentUpdater<BPELExtensibilityComponent>, 41 ComponentUpdater.Query<BPELExtensibilityComponent> 42 { 43 44 private BPELExtensibilityComponent parent; 45 46 private ComponentUpdater.Operation operation; 47 48 private int index; 49 50 private boolean canAdd; 51 52 53 public BPELComponentUpdater() { 54 } 55 56 public boolean canAdd(BPELExtensibilityComponent target, Component child) { 57 if (!(child instanceof BPELExtensibilityComponent)) { 58 return false; 59 } 60 update(target, (BPELExtensibilityComponent) child, null); 61 return canAdd; 62 } 63 64 public void update( BPELExtensibilityComponent target, 65 BPELExtensibilityComponent child, 66 ComponentUpdater.Operation operation ) 67 { 68 update(target, child, -1, operation); 69 } 70 71 public void update( BPELExtensibilityComponent target, 72 BPELExtensibilityComponent child, int index, 73 ComponentUpdater.Operation operation ) 74 { 75 parent = target; 76 this.operation = operation; 77 this.index = index; 78 child.accept(this); 79 } 80 81 public void visit( PropertyAlias c ) { 82 } 84 85 public void visit( CorrelationProperty c ) { 86 } 88 89 public void visit( Role child ) { 90 if (parent instanceof PartnerLinkTypeImpl) { 91 92 100 PartnerLinkTypeImpl target = (PartnerLinkTypeImpl) parent; 101 if (operation == ComponentUpdater.Operation.ADD) { 102 target.addRole(child); 103 } 104 else if (operation == ComponentUpdater.Operation.REMOVE) { 105 target.removeRole(child); 106 } else { 107 canAdd = true; 108 } 109 } 110 } 111 112 public void visit( PartnerLinkType c ) { 113 } 115 116 public void visit( org.netbeans.modules.xml.wsdl.model.extensions.bpel.Query c ) { 117 if ( parent instanceof PropertyAliasImpl ){ 118 PropertyAliasImpl propertyAlias = ( PropertyAliasImpl )parent; 119 if (operation == ComponentUpdater.Operation.ADD) { 120 125 propertyAlias.setQuery( c ); 126 } else if (operation == ComponentUpdater.Operation.REMOVE) { 127 propertyAlias.removeQuery( c ); 128 } else { 129 canAdd = true; 130 } 131 } 132 133 } 134 135 public void visit(Documentation c) { 136 if ( parent instanceof PartnerLinkTypeImpl ){ 137 PartnerLinkTypeImpl partnerLinkType = ( PartnerLinkTypeImpl )parent; 138 if (operation == ComponentUpdater.Operation.ADD) { 139 if (index > -1) 141 partnerLinkType.insertPartnerLinkTypeDocumentationAt( c, index); 142 else 143 partnerLinkType.addPartnerLinkTypeDocumentation(c); 144 } 145 else if (operation == ComponentUpdater.Operation.REMOVE) { 146 partnerLinkType.removePartnerLinkTypeDocumentation( c ); 147 } else { 148 canAdd = true; 149 } 150 } else if ( parent instanceof RoleImpl ){ 151 RoleImpl role = ( RoleImpl )parent; 152 if (operation == ComponentUpdater.Operation.ADD) { 153 if (index > -1) { 155 ((AbstractDocumentComponent)role).insertAtIndex(Role.ROLE_DOCUMENTATION_PROPERTY, 156 c, index); 157 } else { 158 role.addRoleDocumentation( c ); 159 } 160 } 161 else if (operation == ComponentUpdater.Operation.REMOVE) { 162 role.removeRoleDocumentation( c ); 163 } else { 164 canAdd = true; 165 } 166 } 167 168 } 169 170 } 171 | Popular Tags |