Пример #1
0
 @Override
 protected void addReferenceCell(final SReferenceLink referenceLink) {
   SReference reference = getNode().getReference(referenceLink);
   if (reference == null) {
     addLabel("<no target>");
     return;
   }
   final SNode referentNode = reference.getTargetNode();
   if (referentNode == null) {
     String resolveInfo = ((jetbrains.mps.smodel.SReference) reference).getResolveInfo();
     String myErrorText = resolveInfo != null ? resolveInfo : "?" + referenceLink.getName() + "?";
     EditorCell_Error errorCell = new EditorCell_Error(getEditorContext(), getNode(), myErrorText);
     errorCell.setCellId("error_" + referenceLink.getName());
     addCell(errorCell);
     return;
   }
   if (referentNode.getModel() == null) {
     LOG.error("Reference to node which is not inside model. Node: " + referentNode, referentNode);
   }
   EditorCell cell =
       getUpdateSession()
           .updateReferencedNodeCell(
               new Computable<EditorCell>() {
                 @Override
                 public EditorCell compute() {
                   return createReferentEditorCell(
                       getEditorContext(), referenceLink, referentNode);
                 }
               },
               referentNode,
               referenceLink.getName());
   setSemanticNodeToCells(cell, getNode());
   cell.setCellId("reference_" + referenceLink.getName());
   addCell(cell);
 }
Пример #2
0
 public static void setLink(SNode attribute, SReferenceLink link) {
   attribute.setProperty(
       MetaAdapterFactory.getProperty(
           0xceab519525ea4f22L,
           0x9b92103b95ca8c0cL,
           0x2eb1ad060897da51L,
           0x129f3f612792fc5cL,
           "linkId"),
       MetaIdHelper.getAssociation(link).serialize());
   attribute.setProperty(
       MetaAdapterFactory.getProperty(
           0xceab519525ea4f22L,
           0x9b92103b95ca8c0cL,
           0x2eb1ad060897da51L,
           0x18649a5c82123514L,
           "linkRole"),
       link.getName());
 }
 private List<SubstituteAction> createActions(SNode targetNode) {
   final SAbstractConcept referentConcept = myLink.getTargetConcept();
   if (referentConcept == null) {
     return Collections.emptyList();
   }
   // todo use myLink.getScope
   // Iterable<SNode> nodes = myLink.getScope(mySourceNode).getAvailableElements(null);
   Iterable<SNode> nodes =
       ModelConstraints.getReferenceDescriptor(mySourceNode, myLink)
           .getScope()
           .getAvailableElements(null);
   List<SubstituteAction> actions = new ArrayList<SubstituteAction>();
   for (SNode node : nodes) {
     if (node == null) {
       continue;
     }
     assert node.getConcept().isSubConceptOf(referentConcept);
     actions.add(new DefaultSReferenceSubstituteAction(node, mySourceNode, targetNode, myLink));
   }
   return actions;
 }