Ejemplo n.º 1
0
 public boolean deletePseudoCompCmd(
     MapperPseudoComp oldPseudoComp,
     TreeItem treeItem,
     TreePath subjectTPath,
     boolean inLeftTree,
     MapperStaticContext stContext) {
   //
   MapperTcContext tcContext = MapperTcContext.class.cast(stContext);
   BpelMapperPseudoComp oldBpelPseudoComp = BpelMapperPseudoComp.class.cast(oldPseudoComp);
   //
   BpelMapperLsmProcessor lsmProcessor = new BpelMapperLsmProcessor(tcContext);
   lsmProcessor.deleteLsm(tcContext, treeItem, oldBpelPseudoComp, inLeftTree);
   //
   BpelMapperModel mModel = tcContext.getMapperModel();
   MapperSwingTreeModel treeModel = null;
   if (inLeftTree) {
     treeModel = mModel.getLeftTreeModel();
   } else {
     treeModel = mModel.getRightTreeModel();
   }
   //
   // Update BPEL model
   if (inLeftTree) {
     treeModel = mModel.getLeftTreeModel();
     List<TreePath> dependentGraphs = mModel.getLeftChangeAffectedGraphs(oldBpelPseudoComp);
     for (TreePath graphPath : dependentGraphs) {
       mModel.removeIngoingLinks(graphPath, subjectTPath);
     }
     //
     // Modify BPEL model for all changed graphs in one transaction.
     mModel.fireGraphsChanged(dependentGraphs);
   } else {
     treeModel = mModel.getRightTreeModel();
     mModel.removeNestedGraphs(subjectTPath);
   }
   //
   // Remove node from the tree
   treeModel.remove(subjectTPath);
   //
   return true;
 }
Ejemplo n.º 2
0
 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;
 }