public LocationStepModifier registerNewPseudoComp(
     MapperTcContext mapperTcContext, TreeItem anyTreeItem, BpelMapperPseudoComp newPseudo)
     throws ExtRegistrationException {
   //
   DirectedList<Object> parentCompPath =
       BpelPathConverter.singleton().constructObjectLocationList(anyTreeItem, true, true);
   //
   LocationStepModifier result = null;
   try {
     if (parentCompPath != null) {
       if (addPseudoCompImpl(parentCompPath, newPseudo)) {
         VariableDeclaration varDecl = newPseudo.getBaseBpelVariable();
         if (varDecl != null) {
           result =
               BpelMapperLsmProcessor.registerLsmToVariable(
                   mapperTcContext,
                   varDecl,
                   parentCompPath,
                   newPseudo,
                   mMapperTreeModel.isLeftMapperTree());
         }
       }
     }
   } finally {
     if (result == null) {
       // remove newly cached pseudo component if it didn't manage
       // to register it in BPEL
       removePseudoComp(newPseudo);
     }
   }
   //
   return result;
 }
 public List<TreeItemFinder> build(XPathSchemaContext schemaContext) {
   if (schemaContext == null) {
     return Collections.emptyList();
   }
   //
   ArrayList<TreeItemFinder> finderList = new ArrayList<TreeItemFinder>();
   //
   LinkedList<Object> result = new LinkedList<Object>();
   //
   DirectedList<Object> pathList =
       BpelPathConverter.singleton().constructObjectLocationList(schemaContext, false, false);
   //
   if (pathList != null && !pathList.isEmpty()) {
     Iterator itr = pathList.backwardIterator();
     while (itr.hasNext()) {
       Object obj = itr.next();
       //
       if (obj instanceof AbstractVariableDeclaration) {
         finderList.add(new VariableFinder((AbstractVariableDeclaration) obj));
       } else if (obj instanceof Part) {
         finderList.add(new PartFinder((Part) obj));
       } else if (obj instanceof BpelMapperTypeCast) {
         BpelMapperTypeCast typeCast = (BpelMapperTypeCast) obj;
         Object castedObj = typeCast.getCastedObject();
         if (castedObj instanceof SchemaComponent) {
           result.addLast(typeCast);
         } else if (castedObj instanceof AbstractVariableDeclaration) {
           finderList.add(new CastedVariableFinder(typeCast));
         } else if (castedObj instanceof Part) {
           finderList.add(new CastedPartFinder(typeCast));
         } else {
           return Collections.emptyList();
         }
       } else {
         result.addLast(obj);
       }
     }
     //
     if (!result.isEmpty()) {
       PathFinder pathFinder = new PathFinder(result);
       finderList.add(pathFinder);
     }
   }
   //
   return finderList;
 }
 public boolean addPseudoCompCmd(
     DetachedPseudoComp newDPC,
     TreePath xsdAnyTreePath,
     boolean inLeftTree,
     MapperStaticContext sContext)
     throws ExtRegistrationException {
   //
   // Preparation
   MapperTcContext tcContext = MapperTcContext.class.cast(sContext);
   BpelMapperModel bmm = tcContext.getMapperModel();
   BpelMapperSwingTreeModel treeModel =
       inLeftTree ? bmm.getLeftTreeModel() : bmm.getRightTreeModel();
   TreeItem xsdAnyTreeItem = MapperSwingTreeModel.getTreeItem(xsdAnyTreePath);
   BpelExtManagerHolder bemh = treeModel.getExtManagerHolder();
   BpelPseudoCompManager pseudoCompManager = bemh.getPseudoCompManager();
   //
   try {
     //
     XPathSchemaContext baseSContext =
         BpelPathConverter.singleton().constructContext(xsdAnyTreeItem, true);
     BpelMapperPseudoComp newPseudoComp = new BpelMapperPseudoComp(baseSContext, newDPC);
     LocationStepModifier newPseudo =
         pseudoCompManager.registerNewPseudoComp(tcContext, xsdAnyTreeItem, newPseudoComp);
     if (newPseudo == null) {
       return Boolean.FALSE;
     }
     //
     TreePath parentPath = xsdAnyTreePath.getParentPath();
     //
     // Update tree
     int childIndex =
         treeModel.getIndexOfChild(
             parentPath.getLastPathComponent(), xsdAnyTreePath.getLastPathComponent());
     treeModel.insertChild(parentPath, childIndex + 1, newPseudoComp);
     //
     // Set selection to the added pseudo component item
     Mapper mapper = tcContext.getMapper();
     if (mapper != null) {
       TreeFinderProcessor findProc = new TreeFinderProcessor(treeModel);
       TreePath newPseudoPath = findProc.findChildByDataObj(parentPath, newPseudoComp);
       //
       if (inLeftTree) {
         LeftTree leftTree = mapper.getLeftTree();
         leftTree.setSelectionPath(newPseudoPath);
       } else {
         mapper.expandGraphs(Collections.singletonList(newPseudoPath));
         mapper.setSelected(newPseudoPath);
       }
     }
   } catch (ExtRegistrationException regEx) {
     Throwable cause = regEx.getCause();
     if (cause instanceof VetoException) {
       VetoException vetoEx = (VetoException) cause;
       String errMsg = vetoEx.getMessage();
       UserNotification.showMessage(errMsg);
       return Boolean.FALSE;
     } else if (cause instanceof InvalidNamespaceException) {
       InvalidNamespaceException nsEx = (InvalidNamespaceException) cause;
       String errMsg = nsEx.getMessage();
       UserNotification.showMessage(errMsg);
       return Boolean.FALSE;
     } else {
       throw regEx;
     }
   }
   //
   return Boolean.TRUE;
 }