Backed out changeset 32a6602d3f8e (Bug fix 131639)
authorpslechta@netbeans.org
Wed, 30 Apr 2008 14:29:59 +0200
changeset 4271d72962f88f84
parent 4270 9bb0ec357821
child 4272 ca81481fce74
Backed out changeset 32a6602d3f8e (Bug fix 131639)
bpel.editors/src/org/netbeans/modules/bpel/properties/editors/DefineCorrelationWizard.java
bpel.mapper/src/org/netbeans/modules/bpel/mapper/cast/CastManager.java
bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/AbstractBpelModelUpdater.java
bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/BpelMapperModelFactory.java
bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/BpelModelUpdater.java
bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/EditorExtensionProcessor.java
bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/GraphBuilderVisitor.java
bpel.mapper/src/org/netbeans/modules/bpel/mapper/predicates/PredicateManager.java
bpel.mapper/src/org/netbeans/modules/bpel/mapper/predicates/SpecialStepManager.java
bpel.mapper/src/org/netbeans/modules/bpel/mapper/predicates/editor/PathConverter.java
bpel.mapper/src/org/netbeans/modules/bpel/mapper/tree/actions/AddCastAction.java
     1.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/properties/editors/DefineCorrelationWizard.java	Tue Apr 29 16:15:16 2008 +0200
     1.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/properties/editors/DefineCorrelationWizard.java	Wed Apr 30 14:29:59 2008 +0200
     1.3 @@ -52,6 +52,7 @@
     1.4  import java.awt.event.ItemListener;
     1.5  import java.awt.event.KeyEvent;
     1.6  import java.net.URI;
     1.7 +import java.net.URISyntaxException;
     1.8  import java.text.MessageFormat;
     1.9  import java.util.*;
    1.10  import java.util.ArrayList;
    1.11 @@ -84,6 +85,7 @@
    1.12  import javax.swing.tree.TreePath;
    1.13  import javax.xml.XMLConstants;
    1.14  import javax.xml.namespace.NamespaceContext;
    1.15 +import javax.xml.namespace.QName;
    1.16  import org.netbeans.modules.bpel.model.api.BPELElementsBuilder;
    1.17  import org.netbeans.modules.bpel.model.api.BaseCorrelation;
    1.18  import org.netbeans.modules.bpel.model.api.BaseScope;
    1.19 @@ -163,7 +165,6 @@
    1.20  import org.netbeans.modules.xml.wsdl.model.extensions.bpel.validation.ValidationUtil;
    1.21  import org.netbeans.modules.xml.wsdl.ui.netbeans.module.Utility;
    1.22  import org.netbeans.modules.xml.wsdl.ui.wsdl.util.RelativePath;
    1.23 -import org.netbeans.modules.xml.xam.Model;
    1.24  import org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent;
    1.25  import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
    1.26  import org.netbeans.modules.xml.xpath.ext.XPathLocationPath;
    1.27 @@ -172,9 +173,8 @@
    1.28  import org.netbeans.modules.xml.xpath.ext.XPathModel;
    1.29  import org.netbeans.modules.xml.xpath.ext.XPathModelFactory;
    1.30  import org.netbeans.modules.xml.xpath.ext.XPathModelHelper;
    1.31 +import org.netbeans.modules.xml.xpath.ext.XPathUtils;
    1.32  import org.netbeans.modules.xml.xpath.ext.schema.FindAllChildrenSchemaVisitor;
    1.33 -import org.netbeans.modules.xml.xpath.ext.schema.SchemaModelsStack;
    1.34 -import org.netbeans.modules.xml.xpath.ext.schema.XmlExNamespaceContext;
    1.35  import org.netbeans.modules.xml.xpath.ext.spi.ExternalModelResolver;
    1.36  import org.openide.DialogDisplayer;
    1.37  import org.openide.ErrorManager;
    1.38 @@ -852,42 +852,25 @@
    1.39              CorrelationMapperTreeModel 
    1.40                  leftTreeModel = (CorrelationMapperTreeModel) mapperModel.getLeftTreeModel(), 
    1.41                  rightTreeModel = (CorrelationMapperTreeModel) mapperModel.getRightTreeModel();
    1.42 -            final List<CorrelationLinker> correlationLinkers = 
    1.43 -                    getCorrelationLinkers(mapperModel, leftTreeModel, rightTreeModel);
    1.44 -            if (correlationLinkers.isEmpty()) {
    1.45 -                return;
    1.46 -            }
    1.47 -            //
    1.48 +            List<CorrelationLinker> correlationLinkers = getCorrelationLinkers(mapperModel, leftTreeModel, rightTreeModel);
    1.49              // group linkers by equivalence of [activity-message-part]
    1.50              // to combine appropriate properties in one correlation set
    1.51 -            CorrelationWizardWSDLWrapper wizardWsdlWrapper = 
    1.52 -                CorrelationWizardWSDLWrapper.getInstance(correlatedActivity.getBpelModel());
    1.53 -            final WSDLModel wizardWsdlModel = wizardWsdlWrapper.getWsdlModel();
    1.54 -            if (wizardWsdlModel != null) {
    1.55 -                WizardUtils.doInTransaction(wizardWsdlModel, new Runnable() {
    1.56 -                    public void run() {
    1.57 -                        try {
    1.58 -                            while (!correlationLinkers.isEmpty()) {
    1.59 -                                List<CorrelationLinker> equalLinkerSublist = 
    1.60 -                                        getSublistEqualCorrelationLinkers(correlationLinkers);
    1.61 -                                if (equalLinkerSublist.isEmpty()) break;
    1.62 -                                correlationLinkers.removeAll(equalLinkerSublist);
    1.63 -
    1.64 -                                createCorrelationPropertiesAndPropertyAliases(
    1.65 -                                        equalLinkerSublist, wizardWsdlModel);
    1.66 -                                CorrelationSet correlationSet = 
    1.67 -                                        createCorrelationSet(equalLinkerSublist);
    1.68 -                                equalLinkerSublist.get(0).
    1.69 -                                        createActivityCorrelation(correlationSet);
    1.70 -                            }
    1.71 -                        } catch (WizardValidationException ex) {
    1.72 -                            ErrorManager.getDefault().notify(ex);
    1.73 -                        }
    1.74 -                    }
    1.75 -                });
    1.76 +            WSDLModel wizardWsdlModel = null;
    1.77 +            while (! correlationLinkers.isEmpty()) {
    1.78 +                if (wizardWsdlModel == null) {
    1.79 +                    CorrelationWizardWSDLWrapper wizardWsdlWrapper = 
    1.80 +                        CorrelationWizardWSDLWrapper.getInstance(correlatedActivity.getBpelModel());
    1.81 +                    wizardWsdlModel = wizardWsdlWrapper.getWsdlModel();
    1.82 +                    wizardWsdlWrapper.importIntoBpelModel();
    1.83 +                }
    1.84 +                List<CorrelationLinker> equalLinkerSublist = getSublistEqualCorrelationLinkers(correlationLinkers);
    1.85 +                if (equalLinkerSublist.isEmpty()) break;
    1.86 +                correlationLinkers.removeAll(equalLinkerSublist);
    1.87 +                
    1.88 +                createCorrelationPropertiesAndPropertyAliases(equalLinkerSublist, wizardWsdlModel);
    1.89 +                CorrelationSet correlationSet = createCorrelationSet(equalLinkerSublist);
    1.90 +                equalLinkerSublist.get(0).createActivityCorrelation(correlationSet);
    1.91              }
    1.92 -            //
    1.93 -            wizardWsdlWrapper.importIntoBpelModel();
    1.94          }
    1.95  
    1.96          private CorrelationSet createCorrelationSet(List<CorrelationLinker> linkerList) {
    1.97 @@ -1059,7 +1042,7 @@
    1.98                  target.createPropertyAlias(wizardWsdlModel, correlationProperty);
    1.99              }
   1.100  
   1.101 -            public void createCorrelationProperty(final WSDLModel wizardWsdlModel) throws WizardValidationException {
   1.102 +            public void createCorrelationProperty(WSDLModel wizardWsdlModel) throws WizardValidationException {
   1.103                  String propertyName = getBasePropertyName();
   1.104                  
   1.105                  correlationProperty = (CorrelationProperty) wizardWsdlModel.getFactory().create(
   1.106 @@ -1077,13 +1060,13 @@
   1.107                  WizardUtils.importWsdlIntoWsdl(wizardWsdlModel, source.getWSDLModel());
   1.108                  WizardUtils.importWsdlIntoWsdl(wizardWsdlModel, target.getWSDLModel());
   1.109                  if (Util.isUniquePropertyName(wizardWsdlModel, propertyName)) {
   1.110 -                    WizardUtils.doInTransaction(wizardWsdlModel, new Runnable() {
   1.111 -                        public void run() {
   1.112 -                            wizardWsdlModel.addChildComponent(
   1.113 -                                    wizardWsdlModel.getRootComponent(), 
   1.114 -                                    correlationProperty, 0);
   1.115 -                        }
   1.116 -                    });
   1.117 +                    try {
   1.118 +                        wizardWsdlModel.startTransaction();
   1.119 +                        wizardWsdlModel.addChildComponent(wizardWsdlModel.getRootComponent(), 
   1.120 +                            correlationProperty, 0);
   1.121 +                    } finally {
   1.122 +                        wizardWsdlModel.endTransaction();
   1.123 +                    }
   1.124                  }
   1.125              }
   1.126              
   1.127 @@ -1248,34 +1231,32 @@
   1.128                  return null;
   1.129              }
   1.130              
   1.131 -            public void createPropertyAlias(final WSDLModel wizardWsdlModel, 
   1.132 -                    final CorrelationProperty correlationProperty) {
   1.133 +            public void createPropertyAlias(WSDLModel wizardWsdlModel, CorrelationProperty correlationProperty) {
   1.134                  if (! WizardUtils.wsdlContainsPropertyAlias(wizardWsdlModel, correlationProperty, message, part)) {
   1.135 -                    WizardUtils.doInTransaction(wizardWsdlModel, new Runnable() {
   1.136 -                        public void run() {
   1.137 -                            final PropertyAlias propertyAlias = 
   1.138 -                                    (PropertyAlias) wizardWsdlModel.getFactory().create(
   1.139 -                                wizardWsdlModel.getDefinitions(), BPELQName.PROPERTY_ALIAS.getQName());
   1.140 -                            //
   1.141 -                            wizardWsdlModel.addChildComponent(
   1.142 -                                    wizardWsdlModel.getRootComponent(), 
   1.143 -                                    propertyAlias, 0);
   1.144 -                            //
   1.145 -                            NamedComponentReference<CorrelationProperty> correlationPropertyRef =
   1.146 -                                propertyAlias.createReferenceTo(correlationProperty, CorrelationProperty.class);
   1.147 -                            propertyAlias.setPropertyName(correlationPropertyRef);
   1.148 -                            //
   1.149 -                            NamedComponentReference<Message> messageTypeRef =
   1.150 -                                propertyAlias.createReferenceTo(message, Message.class);
   1.151 -                            propertyAlias.setMessageType(messageTypeRef);
   1.152 -                            //
   1.153 -                            propertyAlias.setPart(part.getName());
   1.154 -                            //
   1.155 -                            Query query = getPropertyAliasQuery(wizardWsdlModel,
   1.156 -                                propertyAlias);
   1.157 -                            if (query != null) propertyAlias.setQuery(query);
   1.158 -                        }
   1.159 -                    });
   1.160 +                    PropertyAlias propertyAlias = (PropertyAlias) wizardWsdlModel.getFactory().create(
   1.161 +                        wizardWsdlModel.getDefinitions(), BPELQName.PROPERTY_ALIAS.getQName());
   1.162 +
   1.163 +                    NamedComponentReference<CorrelationProperty> correlationPropertyRef =
   1.164 +                        propertyAlias.createReferenceTo(correlationProperty, CorrelationProperty.class);
   1.165 +                    propertyAlias.setPropertyName(correlationPropertyRef);
   1.166 +
   1.167 +                    NamedComponentReference<Message> messageTypeRef =
   1.168 +                        propertyAlias.createReferenceTo(message, Message.class);
   1.169 +                    propertyAlias.setMessageType(messageTypeRef);
   1.170 +
   1.171 +                    propertyAlias.setPart(part.getName());
   1.172 +                    
   1.173 +                    Query query = getPropertyAliasQuery(wizardWsdlModel,
   1.174 +                        propertyAlias);
   1.175 +                    if (query != null) propertyAlias.setQuery(query);
   1.176 +                    
   1.177 +                    try {
   1.178 +                        wizardWsdlModel.startTransaction();
   1.179 +                        wizardWsdlModel.addChildComponent(wizardWsdlModel.getRootComponent(), 
   1.180 +                            propertyAlias, 0);
   1.181 +                    } finally {
   1.182 +                        wizardWsdlModel.endTransaction();
   1.183 +                    }
   1.184                  }
   1.185              }
   1.186              
   1.187 @@ -1847,23 +1828,24 @@
   1.188      }
   1.189      
   1.190      private FileObject createWSDLPropertiesFile() {
   1.191 -        FileObject folderBpelProcess = ResolverUtility.getBpelProcessFolder(bpelModel);
   1.192 -        WsdlWrapper wsdlWrapper = new WsdlWrapper(folderBpelProcess, 
   1.193 -            WIZARD_PROPERTIES_WSDL_FILE_NAME, true);
   1.194 -        wsdlModel = wsdlWrapper.getModel();
   1.195 -        final Definitions definitions = wsdlModel.getDefinitions();
   1.196 +        try {
   1.197 +            FileObject folderBpelProcess = ResolverUtility.getBpelProcessFolder(bpelModel);
   1.198 +            WsdlWrapper wsdlWrapper = new WsdlWrapper(folderBpelProcess, 
   1.199 +                WIZARD_PROPERTIES_WSDL_FILE_NAME, true);
   1.200 +            wsdlModel = wsdlWrapper.getModel();
   1.201 +            Definitions definitions = wsdlModel.getDefinitions();
   1.202  
   1.203 -        WizardUtils.doInTransaction(wsdlModel, new Runnable() {
   1.204 -            public void run() {
   1.205 -                try {
   1.206 -                    definitions.setName(getShortWsdlFileName());
   1.207 -                    definitions.setTargetNamespace(HOST + WIZARD_PROPERTIES_WSDL_FILE_NAME);
   1.208 -                } catch (Exception e) {
   1.209 -                    ErrorManager.getDefault().notify(e);
   1.210 -                }
   1.211 -            }
   1.212 -        });
   1.213 -        return wsdlWrapper.getFile();
   1.214 +            wsdlModel.startTransaction();
   1.215 +            definitions.setName(getShortWsdlFileName());
   1.216 +            definitions.setTargetNamespace(HOST + WIZARD_PROPERTIES_WSDL_FILE_NAME);
   1.217 +            
   1.218 +            return wsdlWrapper.getFile();
   1.219 +        } catch (Exception e) {
   1.220 +            ErrorManager.getDefault().notify(e);
   1.221 +        } finally {
   1.222 +            wsdlModel.endTransaction();
   1.223 +        }
   1.224 +        return null;
   1.225      }
   1.226      
   1.227      public String getShortWsdlFileName() {
   1.228 @@ -1991,46 +1973,42 @@
   1.229          return null;
   1.230      }
   1.231      
   1.232 -    public static void importRequiredSchemas(final WSDLModel wsdlModel, 
   1.233 -        final List<SchemaComponent> schemaComponents) {
   1.234 -        WizardUtils.doInTransaction(wsdlModel, new Runnable() {
   1.235 -            public void run() {
   1.236 -                try {
   1.237 -                    for (SchemaComponent schemaComponent : schemaComponents) {
   1.238 -                        Utility.addSchemaImport(schemaComponent, wsdlModel);
   1.239 -                    }
   1.240 -                } catch(Exception e) {
   1.241 -                    ErrorManager.getDefault().notify(e);
   1.242 -                }
   1.243 +    public static void importRequiredSchemas(WSDLModel wsdlModel, 
   1.244 +        List<SchemaComponent> schemaComponents) {
   1.245 +        try {
   1.246 +            wsdlModel.startTransaction();
   1.247 +            for (SchemaComponent schemaComponent : schemaComponents) {
   1.248 +                Utility.addSchemaImport(schemaComponent, wsdlModel);
   1.249              }
   1.250 -        });
   1.251 +        } catch(Exception e) {
   1.252 +            ErrorManager.getDefault().notify(e);
   1.253 +        } finally {
   1.254 +            wsdlModel.endTransaction();
   1.255 +        }
   1.256      }
   1.257      
   1.258 -    public static void importWsdlIntoWsdl(final WSDLModel baseWsdlModel, 
   1.259 -            final WSDLModel importedWsdlModel) {
   1.260 +    public static void importWsdlIntoWsdl(WSDLModel baseWsdlModel, WSDLModel importedWsdlModel) {
   1.261 +        try {
   1.262 +            org.netbeans.modules.xml.wsdl.model.Import objImport = 
   1.263 +                baseWsdlModel.getFactory().createImport();
   1.264  
   1.265 -        WizardUtils.doInTransaction(baseWsdlModel, new Runnable() {
   1.266 -            public void run() {
   1.267 -                try {
   1.268 -                    org.netbeans.modules.xml.wsdl.model.Import objImport = 
   1.269 -                        baseWsdlModel.getFactory().createImport();
   1.270 +            FileObject 
   1.271 +                baseFileObj = baseWsdlModel.getModelSource().getLookup().lookup(FileObject.class),
   1.272 +                importedFileObj = importedWsdlModel.getModelSource().getLookup().lookup(FileObject.class);
   1.273 +            String importRelativePath = getRelativePath(baseFileObj, importedFileObj);
   1.274 +            
   1.275 +            objImport.setNamespace(importedWsdlModel.getDefinitions().getTargetNamespace());
   1.276 +            objImport.setLocation(importRelativePath);
   1.277  
   1.278 -                    FileObject 
   1.279 -                        baseFileObj = baseWsdlModel.getModelSource().getLookup().lookup(FileObject.class),
   1.280 -                        importedFileObj = importedWsdlModel.getModelSource().getLookup().lookup(FileObject.class);
   1.281 -                    String importRelativePath = getRelativePath(baseFileObj, importedFileObj);
   1.282 -
   1.283 -                    objImport.setNamespace(importedWsdlModel.getDefinitions().getTargetNamespace());
   1.284 -                    objImport.setLocation(importRelativePath);
   1.285 -
   1.286 -                    if (! wsdlContainsImport(baseWsdlModel, objImport)) {
   1.287 -                        baseWsdlModel.getDefinitions().addImport(objImport);
   1.288 -                    }
   1.289 -                } catch(Exception e) {
   1.290 -                    ErrorManager.getDefault().notify(e);
   1.291 -                }
   1.292 +            if (! wsdlContainsImport(baseWsdlModel, objImport)) {
   1.293 +                baseWsdlModel.startTransaction();
   1.294 +                baseWsdlModel.getDefinitions().addImport(objImport);
   1.295              }
   1.296 -        });
   1.297 +        } catch (Exception e) {
   1.298 +            ErrorManager.getDefault().notify(e);
   1.299 +        } finally {
   1.300 +            baseWsdlModel.endTransaction();
   1.301 +        }
   1.302      }
   1.303      
   1.304      public static String getRelativePath(FileObject baseFileObj, 
   1.305 @@ -2101,10 +2079,8 @@
   1.306          XPathModelHelper xpathHelper = XPathModelHelper.getInstance();
   1.307          XPathModel xpathModel = xpathHelper.newXPathModel();
   1.308  
   1.309 -        NamespaceContext namespaceContext = new XmlExNamespaceContext(
   1.310 -            (AbstractDocumentComponent)wsdlModel.getDefinitions());
   1.311 -//        NamespaceContext namespaceContext = new WsdlNamespaceContext(
   1.312 -//            wsdlModel.getDefinitions());
   1.313 +        NamespaceContext namespaceContext = new WsdlNamespaceContext(
   1.314 +            wsdlModel.getDefinitions());
   1.315          xpathModel.setNamespaceContext(namespaceContext);
   1.316          
   1.317          xpathModel.setExternalModelResolver(new ExternalModelResolver() {
   1.318 @@ -2131,25 +2107,20 @@
   1.319          XPathModelFactory xpathModelFactory = xpathModel.getFactory();
   1.320          List<LocationStep> locationSteps = new ArrayList<LocationStep>(
   1.321              schemaComponents.size());
   1.322 -        SchemaModelsStack sms = new SchemaModelsStack();
   1.323          for (SchemaComponent schemaComponent : schemaComponents) {
   1.324 -//            String nsUri = sms.getEffectiveNamespace(schemaComponent, sms);
   1.325 -//            String namespacePrefix = getNamespacePrefix(wsdlModel, nsUri);
   1.326 -            StepNodeNameTest stepNodeNameTest = 
   1.327 -                    new StepNodeNameTest(xpathModel, schemaComponent, sms);
   1.328 -//            if (namespacePrefix != null) {
   1.329 -//                namespacePrefix = XPathUtils.isPrefixRequired(schemaComponent) ? 
   1.330 -//                    namespacePrefix : "";
   1.331 -//                stepNodeNameTest = new StepNodeNameTest(xpathModel, schemaComponent, sms);
   1.332 -////                stepNodeNameTest = new StepNodeNameTest(new QName(null, 
   1.333 -////                        getSchemaComponentName(schemaComponent), namespacePrefix));
   1.334 -//            } else {
   1.335 -//                stepNodeNameTest = new StepNodeNameTest(xpathModel, schemaComponent, sms);
   1.336 -//            }
   1.337 +            String namespacePrefix = getNamespacePrefix(wsdlModel, schemaComponent);
   1.338 +            StepNodeNameTest stepNodeNameTest = null;
   1.339 +            if (namespacePrefix != null) {
   1.340 +                namespacePrefix = XPathUtils.isPrefixRequired(schemaComponent) ? 
   1.341 +                    namespacePrefix : "";
   1.342 +                stepNodeNameTest = new StepNodeNameTest(new QName(null, 
   1.343 +                getSchemaComponentName(schemaComponent), namespacePrefix));
   1.344 +            } else {
   1.345 +                new StepNodeNameTest(xpathModel, schemaComponent);
   1.346 +            }
   1.347              LocationStep locationStep = xpathModelFactory.newLocationStep(null, 
   1.348                  stepNodeNameTest, null);
   1.349              locationSteps.add(locationStep);
   1.350 -            sms.appendSchemaComponent(schemaComponent);
   1.351          }
   1.352          XPathLocationPath locationPath = xpathModelFactory.newXPathLocationPath(
   1.353              locationSteps.toArray(new LocationStep[locationSteps.size()]));
   1.354 @@ -2158,28 +2129,41 @@
   1.355          return locationPath.getExpressionString();
   1.356      }
   1.357      
   1.358 -    public static String getNamespacePrefix(final WSDLModel wsdlModel, final String nsUri) {
   1.359 -        String prefix = getNamespacePrefixImpl(wsdlModel, nsUri);
   1.360 -        if (prefix != null) {
   1.361 +    public static String getNamespacePrefix(WSDLModel wsdlModel, SchemaComponent schemaComponent) {
   1.362 +        assert ((wsdlModel != null) && (schemaComponent != null));
   1.363 +        String uri = schemaComponent.getModel().getSchema().getTargetNamespace();
   1.364 +        if (uri != null) {
   1.365 +            try {
   1.366 +                new URI(uri);
   1.367 +            }
   1.368 +            catch (URISyntaxException e) {
   1.369 +                ErrorManager.getDefault().notify(e);
   1.370 +                return null;
   1.371 +            }
   1.372 +        }
   1.373 +        try {
   1.374 +            String prefix = getNamespacePrefix(wsdlModel, uri);
   1.375 +            if (prefix != null) {
   1.376 +                return prefix;
   1.377 +            }
   1.378 +            prefix = DEFAULT_NS_PREFIX;
   1.379 +
   1.380 +            int i = getMaxSuffixNumber(wsdlModel, prefix);
   1.381 +            prefix += (++i);
   1.382 +            
   1.383 +            wsdlModel.startTransaction();
   1.384 +            if (i == 0) { 
   1.385 +                ((AbstractDocumentComponent) wsdlModel.getDefinitions()).addPrefix(
   1.386 +                    prefix, uri);
   1.387 +            }
   1.388              return prefix;
   1.389          }
   1.390 -        prefix = DEFAULT_NS_PREFIX;
   1.391 -
   1.392 -        final int i = getMaxSuffixNumber(wsdlModel, prefix) + 1;
   1.393 -        final String resultPrefix = prefix + i;
   1.394 -        
   1.395 -        WizardUtils.doInTransaction(wsdlModel, new Runnable() {
   1.396 -            public void run() {
   1.397 -                if (i == 0) { 
   1.398 -                    ((AbstractDocumentComponent) wsdlModel.getDefinitions()).
   1.399 -                            addPrefix(resultPrefix, nsUri);
   1.400 -                }
   1.401 -            }
   1.402 -        });
   1.403 -        return resultPrefix;
   1.404 +        finally {
   1.405 +            wsdlModel.endTransaction();
   1.406 +        }
   1.407      }
   1.408      
   1.409 -    private static String getNamespacePrefixImpl(WSDLModel wsdlModel, String uri) {
   1.410 +    private static String getNamespacePrefix(WSDLModel wsdlModel, String uri) {
   1.411          String prefix = wsdlModel.getDefinitions().getPeer().lookupPrefix(uri);
   1.412          if ((prefix != null) && (prefix.length() == 0)) {
   1.413              return null;
   1.414 @@ -2206,20 +2190,6 @@
   1.415          }
   1.416          return maxSuffixNumber;
   1.417      }
   1.418 -    
   1.419 -    public static void doInTransaction(Model model, Runnable runnable) {
   1.420 -        boolean wasInTransaction = model.isIntransaction();
   1.421 -        if (!wasInTransaction) {
   1.422 -            model.startTransaction();
   1.423 -        }
   1.424 -        try {
   1.425 -            runnable.run();
   1.426 -        } finally {
   1.427 -            if (!wasInTransaction) {
   1.428 -                model.endTransaction();
   1.429 -            }
   1.430 -        }
   1.431 -    } 
   1.432  }
   1.433  //============================================================================//
   1.434  interface TypesCompatibilityValidator {
   1.435 @@ -2492,7 +2462,7 @@
   1.436          String single = getPrefix(namespaceURI);
   1.437          return Collections.singletonList(single).iterator();
   1.438      }
   1.439 -    }
   1.440 +}
   1.441  //============================================================================//
   1.442  class CommonUtils {
   1.443      private static final String
     2.1 --- a/bpel.mapper/src/org/netbeans/modules/bpel/mapper/cast/CastManager.java	Tue Apr 29 16:15:16 2008 +0200
     2.2 +++ b/bpel.mapper/src/org/netbeans/modules/bpel/mapper/cast/CastManager.java	Wed Apr 30 14:29:59 2008 +0200
     2.3 @@ -168,20 +168,17 @@
     2.4          }
     2.5      }
     2.6  
     2.7 -    public boolean addTypeCast(RestartableIterator<Object> castedCompItr, 
     2.8 +    public void addTypeCast(RestartableIterator<Object> castedCompItr, 
     2.9              SyntheticTypeCast cast) {
    2.10          //
    2.11          List<Object> castedCompPath = 
    2.12 -                PathConverter.constructObjectLocationtList(castedCompItr, true);
    2.13 +                PathConverter.constructObjectLocationtList(castedCompItr);
    2.14          //
    2.15          if (castedCompPath != null) {
    2.16              if (addTypeCastImpl(castedCompPath, cast)) {
    2.17                  registerVariableTypeCast(cast);
    2.18 -                return true;
    2.19              }
    2.20          }
    2.21 -        //
    2.22 -        return false;
    2.23      }
    2.24      
    2.25      //-------------------------------------------------------
    2.26 @@ -437,10 +434,6 @@
    2.27          int initialSize = children.size();
    2.28          int deletedChildCount = 0;
    2.29          for (BpelEntity child : children) {
    2.30 -            if (child instanceof Cast) {
    2.31 -                // it's strange, but the Cast extends the BpelContainer
    2.32 -                continue;
    2.33 -            }
    2.34              if (child instanceof BpelContainer) {
    2.35                  if (clearEmptyContainer((BpelContainer)child)) {
    2.36                      container.remove(child);
    2.37 @@ -457,22 +450,17 @@
    2.38       * @param castToDelete
    2.39       */
    2.40      public void removeTypeCast(AbstractTypeCast castToDelete) {
    2.41 -        ListIterator<CashedVariableCast> varItr = mCashedCastedVarList.listIterator();
    2.42 -        while (varItr.hasNext()) {
    2.43 -            CashedVariableCast cVarCast = varItr.next();
    2.44 +        for (CashedVariableCast cVarCast : mCashedCastedVarList) {
    2.45              AbstractTypeCast cast = cVarCast.getTypeCast();
    2.46              if (cast.equals(castToDelete)) {
    2.47 -                varItr.remove();
    2.48 +                mCashedCastList.remove(cast);
    2.49                  return;
    2.50              }
    2.51          }
    2.52 -        //
    2.53 -        ListIterator<CachedCast> typeItr = mCashedCastList.listIterator();
    2.54 -        while (typeItr.hasNext()) {
    2.55 -            CachedCast cCast = typeItr.next();
    2.56 +        for (CachedCast cCast : mCashedCastList) {
    2.57              AbstractTypeCast cast = cCast.getTypeCast();
    2.58              if (cast.equals(castToDelete)) {
    2.59 -                typeItr.remove();
    2.60 +                mCashedCastList.remove(cast);
    2.61                  return;
    2.62              }
    2.63          }
     3.1 --- a/bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/AbstractBpelModelUpdater.java	Tue Apr 29 16:15:16 2008 +0200
     3.2 +++ b/bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/AbstractBpelModelUpdater.java	Wed Apr 30 14:29:59 2008 +0200
     3.3 @@ -55,7 +55,6 @@
     3.4  import org.netbeans.modules.soa.mappercore.model.Vertex;
     3.5  import org.netbeans.modules.soa.mappercore.model.VertexItem;
     3.6  import org.netbeans.modules.xml.schema.model.Attribute;
     3.7 -import org.netbeans.modules.xml.schema.model.ReferenceableSchemaComponent;
     3.8  import org.netbeans.modules.xml.xpath.ext.CoreFunctionType;
     3.9  import org.netbeans.modules.xml.xpath.ext.CoreOperationType;
    3.10  import org.netbeans.modules.xml.xpath.ext.LocationStep;
    3.11 @@ -74,10 +73,8 @@
    3.12  import org.netbeans.modules.xml.xam.Named;
    3.13  import org.netbeans.modules.xml.xpath.ext.XPathAxis;
    3.14  import org.netbeans.modules.xml.xpath.ext.XPathPredicateExpression;
    3.15 -import org.netbeans.modules.xml.xpath.ext.XPathSchemaContext;
    3.16  import org.netbeans.modules.xml.xpath.ext.metadata.ArgumentDescriptor;
    3.17  import org.netbeans.modules.xml.xpath.ext.metadata.XPathType;
    3.18 -import org.netbeans.modules.xml.xpath.ext.schema.SchemaModelsStack;
    3.19  import org.openide.ErrorManager;
    3.20  
    3.21  /**
    3.22 @@ -185,12 +182,6 @@
    3.23          //
    3.24          XPathBpelVariable xPathVar = 
    3.25                  new XPathBpelVariable(tpInfo.varDecl, tpInfo.part);
    3.26 -        //
    3.27 -        ReferenceableSchemaComponent sComp = xPathVar.getType();
    3.28 -        assert sComp != null;
    3.29 -        SchemaModelsStack sms = new SchemaModelsStack();
    3.30 -        sms.appendSchemaComponent(sComp);
    3.31 -        //
    3.32          QName varQName = xPathVar.constructXPathName();
    3.33          XPathVariableReference xPathVarRef = 
    3.34                  xPathModel.getFactory().newXPathVariableReference(varQName);
    3.35 @@ -199,7 +190,7 @@
    3.36              return xPathVarRef;
    3.37          } else {
    3.38              List<LocationStep> stepList = constructLSteps(
    3.39 -                    xPathModel, tpInfo.schemaCompList, typeCastCollector, sms);
    3.40 +                    xPathModel, tpInfo.schemaCompList, typeCastCollector);
    3.41              if (stepList != null && !(stepList.isEmpty())) {
    3.42                  XPathExpressionPath exprPath = xPathModel.getFactory().
    3.43                          newXPathExpressionPath(xPathVarRef, 
    3.44 @@ -214,29 +205,27 @@
    3.45      //==========================================================================
    3.46  
    3.47      protected List<LocationStep> constructLSteps(XPathModel xPathModel, 
    3.48 -            List<Object> sCompList, Set<AbstractTypeCast> typeCastCollector, 
    3.49 -            SchemaModelsStack sms) {
    3.50 +            List<Object> sCompList, Set<AbstractTypeCast> typeCastCollector) {
    3.51          if (sCompList == null || sCompList.isEmpty()) {
    3.52              return null;
    3.53          } 
    3.54          //
    3.55          ArrayList<LocationStep> result = new ArrayList<LocationStep>();
    3.56 -        SchemaComponent sComp = null;
    3.57          //
    3.58          for (Object stepObj : sCompList) {
    3.59              LocationStep newLocationStep = null;
    3.60              if (stepObj instanceof SchemaComponent) {
    3.61 -                sComp = (SchemaComponent)stepObj;
    3.62 -                newLocationStep = constructLStep(xPathModel, sComp, null, sms);
    3.63 +                newLocationStep = constructLStep(xPathModel, 
    3.64 +                        (SchemaComponent)stepObj, null);
    3.65              } else if (stepObj instanceof AbstractPredicate) {
    3.66                  AbstractPredicate pred = (AbstractPredicate)stepObj;
    3.67                  XPathPredicateExpression[] predArr = pred.getPredicates();
    3.68 -                sComp = pred.getSComponent();
    3.69 -                newLocationStep = constructLStep(xPathModel, sComp, predArr, sms);
    3.70 +                SchemaComponent sComp = pred.getSComponent();
    3.71 +                newLocationStep = constructLStep(xPathModel, sComp, predArr);
    3.72              } else if (stepObj instanceof AbstractTypeCast) {
    3.73                  AbstractTypeCast typeCast = (AbstractTypeCast)stepObj;
    3.74 -                sComp = typeCast.getSComponent();
    3.75 -                newLocationStep = constructLStep(xPathModel, sComp, null, sms);
    3.76 +                SchemaComponent sComp = typeCast.getSComponent();
    3.77 +                newLocationStep = constructLStep(xPathModel, sComp, null);
    3.78                  //
    3.79                  if (typeCastCollector != null) {
    3.80                      typeCastCollector.add(typeCast);
    3.81 @@ -247,21 +236,9 @@
    3.82                  // TODO: It would be more correct to do a copy of the stepObj
    3.83                  // because of it is owned by another XPathModel. 
    3.84                  newLocationStep = (LocationStep)stepObj;
    3.85 -                if (newLocationStep != null) {
    3.86 -                    XPathSchemaContext sContext = newLocationStep.getSchemaContext();
    3.87 -                    if (sContext != null) {
    3.88 -                        sComp = XPathSchemaContext.Utilities.getSchemaComp(sContext);
    3.89 -                    }
    3.90 -                }
    3.91              } else if (stepObj instanceof AbstractTypeCast) {
    3.92 -                sComp = ((AbstractTypeCast)stepObj).getSComponent();
    3.93 -                newLocationStep = constructLStep(xPathModel, sComp, null, sms);
    3.94 -            }
    3.95 -            //
    3.96 -            if (sComp != null) {
    3.97 -                sms.appendSchemaComponent(sComp);
    3.98 -            } else {
    3.99 -                sms.discard();
   3.100 +                SchemaComponent sComp = ((AbstractTypeCast)stepObj).getSComponent();
   3.101 +                newLocationStep = constructLStep(xPathModel, sComp, null);
   3.102              }
   3.103              //
   3.104              if (newLocationStep != null) {
   3.105 @@ -279,8 +256,7 @@
   3.106       * @return
   3.107       */
   3.108      protected LocationStep constructLStep(XPathModel xPathModel, 
   3.109 -            SchemaComponent sComp, XPathPredicateExpression[] predArr, 
   3.110 -            SchemaModelsStack sms) {
   3.111 +            SchemaComponent sComp, XPathPredicateExpression[] predArr) {
   3.112          //
   3.113          if (!(sComp instanceof Named)) {
   3.114              return null;
   3.115 @@ -293,7 +269,7 @@
   3.116              axis = XPathAxis.CHILD;
   3.117          }
   3.118          //
   3.119 -        StepNodeNameTest nameTest = new StepNodeNameTest(xPathModel, sComp, sms);
   3.120 +        StepNodeNameTest nameTest = new StepNodeNameTest(xPathModel, sComp);
   3.121          LocationStep newLocationStep = xPathModel.getFactory().
   3.122                  newLocationStep(axis, nameTest, predArr);
   3.123          //
     4.1 --- a/bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/BpelMapperModelFactory.java	Tue Apr 29 16:15:16 2008 +0200
     4.2 +++ b/bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/BpelMapperModelFactory.java	Wed Apr 30 14:29:59 2008 +0200
     4.3 @@ -181,7 +181,6 @@
     4.4              editorExtProcessor.processVariables();
     4.5              for (Copy copy : assign.getChildren(Copy.class)) {
     4.6                  BpelEntityCasts castList = editorExtProcessor.getCastList(copy);
     4.7 -                editorExtProcessor.registerCasts(castList);
     4.8                  addCopyGraph(copy, newMapperModel, castList);
     4.9              }
    4.10              //
    4.11 @@ -212,14 +211,12 @@
    4.12                  if (timeEvent instanceof For) {
    4.13                      For expr = (For)timeEvent;
    4.14                      BpelEntityCasts castList = editorExtProcessor.getCastList(expr);
    4.15 -                    editorExtProcessor.registerCasts(castList);
    4.16                      addExpressionGraph(expr, newMapperModel, 
    4.17                              DateValueTreeModel.DURATION_CONDITION, 
    4.18                              timeEH, castList);
    4.19                  } else if (timeEvent instanceof DeadlineExpression) {
    4.20                      DeadlineExpression expr = (DeadlineExpression)timeEvent;
    4.21                      BpelEntityCasts castList = editorExtProcessor.getCastList(expr);
    4.22 -                    editorExtProcessor.registerCasts(castList);
    4.23                      addExpressionGraph(expr, newMapperModel, 
    4.24                              DateValueTreeModel.DEADLINE_CONDITION, 
    4.25                              timeEH, castList);
    4.26 @@ -252,7 +249,6 @@
    4.27              Expression expr = ((ConditionHolder)bpelEntity).getCondition();
    4.28              if (expr != null) {
    4.29                  BpelEntityCasts castList = editorExtProcessor.getCastList(expr);
    4.30 -                editorExtProcessor.registerCasts(castList);
    4.31                  addExpressionGraph(expr, newMapperModel, 
    4.32                          ConditionValueTreeModel.BOOLEAN_CONDITION, 
    4.33                          bpelEntity, castList);
    4.34 @@ -281,7 +277,6 @@
    4.35              Expression expr = forEach.getStartCounterValue();
    4.36              if (expr != null) {
    4.37                  BpelEntityCasts castList = editorExtProcessor.getCastList(expr);
    4.38 -                editorExtProcessor.registerCasts(castList);
    4.39                  addExpressionGraph(expr, newMapperModel, 
    4.40                          ForEachConditionsTreeModel.START_VALUE, 
    4.41                          forEach, castList);
     5.1 --- a/bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/BpelModelUpdater.java	Tue Apr 29 16:15:16 2008 +0200
     5.2 +++ b/bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/BpelModelUpdater.java	Wed Apr 30 14:29:59 2008 +0200
     5.3 @@ -23,7 +23,6 @@
     5.4  import java.util.List;
     5.5  import java.util.Set;
     5.6  import javax.swing.tree.TreePath;
     5.7 -import org.netbeans.modules.bpel.editors.api.EditorUtil;
     5.8  import org.netbeans.modules.bpel.mapper.cast.AbstractTypeCast;
     5.9  import org.netbeans.modules.bpel.mapper.model.FromProcessor.FromForm;
    5.10  import org.netbeans.modules.bpel.mapper.tree.MapperSwingTreeModel;
    5.11 @@ -70,14 +69,12 @@
    5.12  import org.netbeans.modules.soa.mappercore.model.TreeSourcePin;
    5.13  import org.netbeans.modules.soa.mappercore.model.Vertex;
    5.14  import org.netbeans.modules.soa.mappercore.model.VertexItem;
    5.15 -import org.netbeans.modules.xml.schema.model.SchemaComponent;
    5.16  import org.netbeans.modules.xml.xpath.ext.LocationStep;
    5.17  import org.netbeans.modules.xml.xpath.ext.XPathExpression;
    5.18  import org.netbeans.modules.xml.xpath.ext.XPathLocationPath;
    5.19  import org.netbeans.modules.xml.xpath.ext.XPathModel;
    5.20  import org.netbeans.modules.xml.wsdl.model.Part;
    5.21  import org.netbeans.modules.xml.xpath.ext.XPathStringLiteral;
    5.22 -import org.netbeans.modules.xml.xpath.ext.schema.SchemaModelsStack;
    5.23  
    5.24  /**
    5.25   * Looks on the current state of the BPEL Mapper and modifies 
    5.26 @@ -439,12 +436,7 @@
    5.27                      createReference(tpInfo.varDecl, VariableDeclaration.class);
    5.28              from.setVariable(varRef);
    5.29              //
    5.30 -            SchemaComponent sComp = EditorUtil.getVariableSchemaType(tpInfo.varDecl);
    5.31 -            assert sComp != null;
    5.32 -            SchemaModelsStack sms = new SchemaModelsStack();
    5.33 -            sms.appendSchemaComponent(sComp);
    5.34 -            //
    5.35 -            populateFromQuery(from, xPathModel, tpInfo, typeCastCollector, sms);
    5.36 +            populateFromQuery(from, xPathModel, tpInfo, typeCastCollector);
    5.37              //
    5.38              // from.removeVariable();
    5.39              from.removePart();
    5.40 @@ -468,12 +460,7 @@
    5.41                      createWSDLReference(tpInfo.part, Part.class);
    5.42              from.setPart(partRef);
    5.43              //
    5.44 -            SchemaComponent sComp = EditorUtil.getPartType(tpInfo.part);
    5.45 -            assert sComp != null;
    5.46 -            SchemaModelsStack sms = new SchemaModelsStack();
    5.47 -            sms.appendSchemaComponent(sComp);
    5.48 -            //
    5.49 -            populateFromQuery(from, xPathModel, tpInfo, typeCastCollector, sms);
    5.50 +            populateFromQuery(from, xPathModel, tpInfo, typeCastCollector);
    5.51              //
    5.52              // from.removeVariable();
    5.53              // from.removePart();
    5.54 @@ -536,10 +523,9 @@
    5.55      }
    5.56  
    5.57      private void populateFromQuery(From from, XPathModel xPathModel, 
    5.58 -            TreePathInfo tpInfo, Set<AbstractTypeCast> typeCastCollector, 
    5.59 -            SchemaModelsStack sms) {
    5.60 +            TreePathInfo tpInfo, Set<AbstractTypeCast> typeCastCollector) {
    5.61          List<LocationStep> stepList = constructLSteps(
    5.62 -                xPathModel, tpInfo.schemaCompList, typeCastCollector, sms);
    5.63 +                xPathModel, tpInfo.schemaCompList, typeCastCollector);
    5.64          if (stepList != null && !(stepList.isEmpty())) {
    5.65              XPathLocationPath locationPath = xPathModel.getFactory().
    5.66                      newXPathLocationPath(
    5.67 @@ -614,12 +600,7 @@
    5.68                      createReference(tpInfo.varDecl, VariableDeclaration.class);
    5.69              to.setVariable(varRef);
    5.70              //
    5.71 -            SchemaComponent sComp = EditorUtil.getVariableSchemaType(tpInfo.varDecl);
    5.72 -            assert sComp != null;
    5.73 -            SchemaModelsStack sms = new SchemaModelsStack();
    5.74 -            sms.appendSchemaComponent(sComp);
    5.75 -            //
    5.76 -            populateToQuery(to, xPathModel, tpInfo, typeCastCollector, sms);
    5.77 +            populateToQuery(to, xPathModel, tpInfo, typeCastCollector);
    5.78              //
    5.79              // to.removeVariable();
    5.80              to.removePart();
    5.81 @@ -642,12 +623,7 @@
    5.82                      createWSDLReference(tpInfo.part, Part.class);
    5.83              to.setPart(partRef);
    5.84              //
    5.85 -            SchemaComponent sComp = EditorUtil.getPartType(tpInfo.part);
    5.86 -            assert sComp != null;
    5.87 -            SchemaModelsStack sms = new SchemaModelsStack();
    5.88 -            sms.appendSchemaComponent(sComp);
    5.89 -            //
    5.90 -            populateToQuery(to, xPathModel, tpInfo, typeCastCollector, sms);
    5.91 +            populateToQuery(to, xPathModel, tpInfo, typeCastCollector);
    5.92              //
    5.93              // to.removeVariable();
    5.94              // to.removePart();
    5.95 @@ -703,10 +679,9 @@
    5.96      }
    5.97  
    5.98      private void populateToQuery(To to, XPathModel xPathModel, 
    5.99 -            TreePathInfo tpInfo, Set<AbstractTypeCast> typeCastCollector, 
   5.100 -            SchemaModelsStack sms) {
   5.101 +            TreePathInfo tpInfo, Set<AbstractTypeCast> typeCastCollector) {
   5.102          List<LocationStep> stepList = constructLSteps(
   5.103 -                xPathModel, tpInfo.schemaCompList, typeCastCollector, sms);
   5.104 +                xPathModel, tpInfo.schemaCompList, typeCastCollector);
   5.105          if (stepList != null && !(stepList.isEmpty())) {
   5.106              XPathLocationPath locationPath = xPathModel.getFactory().
   5.107                      newXPathLocationPath(
     6.1 --- a/bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/EditorExtensionProcessor.java	Tue Apr 29 16:15:16 2008 +0200
     6.2 +++ b/bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/EditorExtensionProcessor.java	Wed Apr 30 14:29:59 2008 +0200
     6.3 @@ -87,11 +87,6 @@
     6.4          }
     6.5      }
     6.6      
     6.7 -    public void registerCasts(BpelEntityCasts castList) {
     6.8 -        registerCasts(castList.getFromCasts());
     6.9 -        registerCasts(castList.getToCasts());
    6.10 -    }
    6.11 -    
    6.12      public boolean registerCasts(List<Cast> castList) {
    6.13          boolean anyRegistered = false;
    6.14          //
     7.1 --- a/bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/GraphBuilderVisitor.java	Tue Apr 29 16:15:16 2008 +0200
     7.2 +++ b/bpel.mapper/src/org/netbeans/modules/bpel/mapper/model/GraphBuilderVisitor.java	Wed Apr 30 14:29:59 2008 +0200
     7.3 @@ -187,7 +187,7 @@
     7.4       * 
     7.5       * @param newVertex
     7.6       */
     7.7 -    protected void linkToParent(SourcePin sourcePin) {
     7.8 +    protected void linkToParent(SourcePin newVertex) {
     7.9          TargetPin targetPin = null;
    7.10          if (mVertexStack.isEmpty()) {
    7.11              if (!mConnectToTargetTree) {
    7.12 @@ -208,7 +208,7 @@
    7.13              targetPin = targetVertexItem;
    7.14          }
    7.15          if (targetPin != null) {
    7.16 -            Link newLink = new Link(sourcePin, targetPin);
    7.17 +            Link newLink = new Link(newVertex, targetPin);
    7.18              mGraph.addLink(newLink);
    7.19          }
    7.20      }
     8.1 --- a/bpel.mapper/src/org/netbeans/modules/bpel/mapper/predicates/PredicateManager.java	Tue Apr 29 16:15:16 2008 +0200
     8.2 +++ b/bpel.mapper/src/org/netbeans/modules/bpel/mapper/predicates/PredicateManager.java	Wed Apr 30 14:29:59 2008 +0200
     8.3 @@ -96,7 +96,7 @@
     8.4              AbstractPredicate pred) {
     8.5          //
     8.6          List<Object> parentPath = 
     8.7 -                PathConverter.constructObjectLocationtList(parentItr, true);
     8.8 +                PathConverter.constructObjectLocationtList(parentItr);
     8.9          //
    8.10          if (parentPath != null) {
    8.11              return addPredicate(parentPath, pred);
     9.1 --- a/bpel.mapper/src/org/netbeans/modules/bpel/mapper/predicates/SpecialStepManager.java	Tue Apr 29 16:15:16 2008 +0200
     9.2 +++ b/bpel.mapper/src/org/netbeans/modules/bpel/mapper/predicates/SpecialStepManager.java	Wed Apr 30 14:29:59 2008 +0200
     9.3 @@ -81,7 +81,7 @@
     9.4              LocationStep step) {
     9.5          //
     9.6          List<Object> parentPath = 
     9.7 -                PathConverter.constructObjectLocationtList(parentItr, true);
     9.8 +                PathConverter.constructObjectLocationtList(parentItr);
     9.9          //
    9.10          if (parentPath != null) {
    9.11              return addStep(parentPath, step);
    9.12 @@ -93,7 +93,7 @@
    9.13      public void removeStep(RestartableIterator<Object> parentItr, 
    9.14              LocationStep stepToDelete) {
    9.15          List<Object> parentPath = 
    9.16 -                PathConverter.constructObjectLocationtList(parentItr, true);
    9.17 +                PathConverter.constructObjectLocationtList(parentItr);
    9.18          //
    9.19          if (parentPath != null) {
    9.20              for (CachedStep cStep : mSteps) {
    10.1 --- a/bpel.mapper/src/org/netbeans/modules/bpel/mapper/predicates/editor/PathConverter.java	Tue Apr 29 16:15:16 2008 +0200
    10.2 +++ b/bpel.mapper/src/org/netbeans/modules/bpel/mapper/predicates/editor/PathConverter.java	Wed Apr 30 14:29:59 2008 +0200
    10.3 @@ -42,7 +42,6 @@
    10.4  import org.netbeans.modules.xml.xpath.ext.XPathModelFactory;
    10.5  import org.netbeans.modules.xml.xpath.ext.XPathSchemaContext;
    10.6  import org.netbeans.modules.xml.xpath.ext.XPathVariableReference;
    10.7 -import org.netbeans.modules.xml.xpath.ext.schema.SchemaModelsStack;
    10.8  import org.netbeans.modules.xml.xpath.ext.spi.SimpleSchemaContext;
    10.9  import org.netbeans.modules.xml.xpath.ext.spi.VariableSchemaContext;
   10.10  import org.netbeans.modules.xml.xpath.ext.spi.XPathVariable;
   10.11 @@ -146,44 +145,41 @@
   10.12      /**
   10.13       * Constructs a new list, which contains the schema elements, predicates, 
   10.14       * special steps, cast objects, part and variable from the specified iterator pathItr. 
   10.15 -     * The first object taken from iterator will be at the beginning of the list 
   10.16 -     * if the parameter sameOrder is true. The order will be oposite otherwise.
   10.17 +     * The first object taken from iterator will be at the beginning of the list. 
   10.18       * If the iterator has incompatible content then the null is returned. 
   10.19       * 
   10.20       * @param pathItr
   10.21       * @return
   10.22       */
   10.23      public static List<Object> constructObjectLocationtList(
   10.24 -            RestartableIterator<Object> pathItr, boolean sameOrder) {
   10.25 +            RestartableIterator<Object> pathItr) {
   10.26          //
   10.27          pathItr.restart();
   10.28          //
   10.29 -        LinkedList<Object> treeItemList = new LinkedList<Object>();
   10.30 +        ArrayList<Object> treeItemList = new ArrayList<Object>();
   10.31          //
   10.32          // Process the path
   10.33          ParsingStage stage = null;
   10.34 -        boolean needBreak = false;
   10.35          while (pathItr.hasNext()) {
   10.36              Object obj = pathItr.next();
   10.37 -            Object toAdd = null;
   10.38              if (obj instanceof SchemaComponent) {
   10.39                  if (!(stage == null || stage == ParsingStage.SCHEMA)) {
   10.40                      return null;
   10.41                  }
   10.42                  stage = ParsingStage.SCHEMA;
   10.43 -                toAdd = obj;
   10.44 +                treeItemList.add(obj);
   10.45              } else if (stage != null && obj instanceof AbstractPredicate) {
   10.46                  if (!(stage == null || stage == ParsingStage.SCHEMA)) {
   10.47                      return null;
   10.48                  }
   10.49                  stage = ParsingStage.SCHEMA;
   10.50 -                toAdd = obj;
   10.51 +                treeItemList.add(obj);
   10.52              } else if (obj instanceof Part) {
   10.53                  if (!(stage == null || stage == ParsingStage.SCHEMA)) {
   10.54                      return null;
   10.55                  }
   10.56                  stage = ParsingStage.PART;
   10.57 -                toAdd = obj;
   10.58 +                treeItemList.add(obj);
   10.59              } else if (obj instanceof AbstractVariableDeclaration) {
   10.60                  if (!(stage == null || 
   10.61                          stage == ParsingStage.SCHEMA || 
   10.62 @@ -205,28 +201,14 @@
   10.63                  }
   10.64                  //
   10.65                  stage = ParsingStage.VARIABLE;
   10.66 -                toAdd = varDecl;
   10.67 +                treeItemList.add(varDecl);
   10.68                  //
   10.69                  // Everything found!
   10.70 -                needBreak = true;
   10.71 +                break;
   10.72              } else {
   10.73                  if (stage == null) {
   10.74                      return null;
   10.75                  }
   10.76 -                needBreak = true;
   10.77 -            }
   10.78 -            //
   10.79 -            if (toAdd == null) {
   10.80 -                needBreak = true;
   10.81 -            } else {
   10.82 -                if (sameOrder) {
   10.83 -                    treeItemList.addFirst(toAdd); 
   10.84 -                } else {
   10.85 -                    treeItemList.addLast(toAdd);
   10.86 -                }
   10.87 -            }
   10.88 -            //
   10.89 -            if (needBreak) {
   10.90                  break;
   10.91              }
   10.92          }
   10.93 @@ -326,44 +308,53 @@
   10.94      public static XPathExpression constructXPath(BpelEntity base, 
   10.95              RestartableIterator<Object> pathItr) {
   10.96          //
   10.97 -        // It's necessary to have the order, oposite to the iterator. 
   10.98 -        // It's required for correct buildeing the XPath expression
   10.99 -        List<Object> objList = constructObjectLocationtList(pathItr, false);
  10.100 -        //
  10.101 -        if (objList == null || objList.isEmpty()) {
  10.102 -            return null;
  10.103 -        }
  10.104 -        //
  10.105          XPathModel xPathModel = BpelXPathModelFactory.create(base);
  10.106          XPathModelFactory factory = xPathModel.getFactory();
  10.107 +        pathItr.restart();
  10.108          //
  10.109          VariableDeclaration varDecl = null;
  10.110          Part part = null;
  10.111          LinkedList<LocationStep> stepList = new LinkedList<LocationStep>();
  10.112 -        SchemaModelsStack sms = new SchemaModelsStack();
  10.113          //
  10.114          // Process the path
  10.115 -        for (Object obj : objList) {
  10.116 -            SchemaComponent sComp = null;
  10.117 +        ParsingStage stage = null;
  10.118 +        while (pathItr.hasNext()) {
  10.119 +            Object obj = pathItr.next();
  10.120              if (obj instanceof SchemaComponent) {
  10.121 -                sComp = (SchemaComponent)obj;
  10.122 +                if (!(stage == null || stage == ParsingStage.SCHEMA)) {
  10.123 +                    return null;
  10.124 +                }
  10.125 +                stage = ParsingStage.SCHEMA;
  10.126                  StepNodeNameTest nodeTest = 
  10.127 -                        new StepNodeNameTest(xPathModel, sComp, sms);
  10.128 +                        new StepNodeNameTest(xPathModel, (SchemaComponent)obj);
  10.129                  LocationStep ls = factory.newLocationStep(null, nodeTest, null);
  10.130                  stepList.add(0, ls);
  10.131              } else if (obj instanceof AbstractPredicate) {
  10.132 +                if (!(stage == null || stage == ParsingStage.SCHEMA)) {
  10.133 +                    return null;
  10.134 +                }
  10.135 +                stage = ParsingStage.SCHEMA;
  10.136                  AbstractPredicate pred = (AbstractPredicate)obj;
  10.137 -                sComp = pred.getSComponent();
  10.138                  StepNodeNameTest nodeTest = 
  10.139 -                        new StepNodeNameTest(xPathModel, sComp, sms);
  10.140 +                        new StepNodeNameTest(xPathModel, pred.getSComponent());
  10.141                  LocationStep ls = factory.newLocationStep(
  10.142                          null, nodeTest, pred.getPredicates());
  10.143                  stepList.add(0, ls);
  10.144              } else if (obj instanceof LocationStep) {
  10.145                  stepList.add(0, (LocationStep)obj);
  10.146              } else if (obj instanceof Part) {
  10.147 +                if (!(stage == null || stage == ParsingStage.SCHEMA)) {
  10.148 +                    return null;
  10.149 +                }
  10.150 +                stage = ParsingStage.PART;
  10.151                  part = (Part)obj;
  10.152              } else if (obj instanceof AbstractVariableDeclaration) {
  10.153 +                if (!(stage == null || 
  10.154 +                        stage == ParsingStage.SCHEMA || 
  10.155 +                        stage == ParsingStage.PART)) {
  10.156 +                    return null;
  10.157 +                }
  10.158 +                //
  10.159                  AbstractVariableDeclaration var = (AbstractVariableDeclaration)obj;
  10.160                  //
  10.161                  if (var instanceof VariableDeclaration) {
  10.162 @@ -375,15 +366,17 @@
  10.163                  if (varDecl == null) {
  10.164                      return null;
  10.165                  }
  10.166 +                //
  10.167 +                stage = ParsingStage.VARIABLE;
  10.168 +                //
  10.169 +                // Everything found!
  10.170 +                break;
  10.171              } else {
  10.172 +                if (stage == null) {
  10.173 +                    return null;
  10.174 +                }
  10.175                  break;
  10.176              }
  10.177 -            //
  10.178 -            if (sComp != null) {
  10.179 -                sms.appendSchemaComponent(sComp);
  10.180 -            } else {
  10.181 -                sms.discard();
  10.182 -            }
  10.183          }
  10.184          //
  10.185          XPathBpelVariable xPathVar = new XPathBpelVariable(varDecl, part);
    11.1 --- a/bpel.mapper/src/org/netbeans/modules/bpel/mapper/tree/actions/AddCastAction.java	Tue Apr 29 16:15:16 2008 +0200
    11.2 +++ b/bpel.mapper/src/org/netbeans/modules/bpel/mapper/tree/actions/AddCastAction.java	Wed Apr 30 14:29:59 2008 +0200
    11.3 @@ -99,17 +99,14 @@
    11.4          // The  iterator points to the casted component
    11.5          RestartableIterator<Object> itr = getActionSubject();
    11.6          SyntheticTypeCast newTypeCast = new SyntheticTypeCast(itr, subtype);
    11.7 -        boolean castAdded = castManager.addTypeCast(itr, newTypeCast);
    11.8 +        castManager.addTypeCast(itr, newTypeCast);
    11.9          //
   11.10 +        // Update tree
   11.11          TreePath parentPath = mTreePath.getParentPath();
   11.12 -        if (castAdded) {
   11.13 -            //
   11.14 -            // Update tree
   11.15 -            int childIndex = treeModel.getIndexOfChild(
   11.16 -                    parentPath.getLastPathComponent(), 
   11.17 -                    mTreePath.getLastPathComponent());
   11.18 -            treeModel.insertChild(parentPath, childIndex + 1, newTypeCast);
   11.19 -        }
   11.20 +        int childIndex = treeModel.getIndexOfChild(
   11.21 +                parentPath.getLastPathComponent(), 
   11.22 +                mTreePath.getLastPathComponent());
   11.23 +        treeModel.insertChild(parentPath, childIndex + 1, newTypeCast);
   11.24          //
   11.25          // Set selection to the added predicate item
   11.26          TreeFinderProcessor findProc = new TreeFinderProcessor(treeModel);