예제 #1
0
 @Check
 public void checkGenerators(final MobaApplication application) {
   boolean activeFound = false;
   int firstIndex = (-1);
   List<MobaGenerator> _generators = application.getGenerators();
   int _size = _generators.size();
   boolean _greaterThan = (_size > 1);
   if (_greaterThan) {
     List<MobaGenerator> _generators_1 = application.getGenerators();
     for (final MobaGenerator generator : _generators_1) {
       {
         if ((firstIndex == (-1))) {
           EList<MobaApplicationFeature> _features = application.getFeatures();
           int _indexOf = _features.indexOf(generator);
           firstIndex = _indexOf;
         }
         boolean _and = false;
         if (!activeFound) {
           _and = false;
         } else {
           boolean _isActive = generator.isActive();
           _and = _isActive;
         }
         if (_and) {
           EList<MobaApplicationFeature> _features_1 = application.getFeatures();
           final int index = _features_1.indexOf(generator);
           StringConcatenation _builder = new StringConcatenation();
           _builder.append(
               "You are using multiple generators. Please define the active attribute for ONLY one generator.");
           this.error(
               _builder.toString(),
               application,
               MobaPackage.Literals.MOBA_APPLICATION__FEATURES,
               index);
           return;
         }
         if ((!activeFound)) {
           boolean _isActive_1 = generator.isActive();
           activeFound = _isActive_1;
         }
       }
     }
     if ((!activeFound)) {
       StringConcatenation _builder = new StringConcatenation();
       _builder.append(
           "You are using multiple generators. Please define the #active attribute for one generator.");
       this.error(
           _builder.toString(),
           application,
           MobaPackage.Literals.MOBA_APPLICATION__FEATURES,
           firstIndex);
     }
   }
 }
 @Override
 public void run(
     VariantTableContent content,
     Resource resource,
     IProgressMonitor monitor,
     Map<String, VCObject> seenObjects,
     List<Option> options)
     throws Exception {
   VariantTable table = content.getTable();
   JCoFunction deletefunc = maintainEntries(content, monitor, options, true);
   executeTransaction(monitor, "DELETE " + table.getName(), deletefunc);
   JCoFunction createfunc = maintainEntries(content, monitor, options, false);
   JCoTable entries = createfunc.getTableParameterList().getTable("VAR_TAB_ENTRIES");
   EList<Row> rows = content.getRows();
   List<VariantTableArgument> arguments = table.getArguments();
   for (Row row : rows) {
     for (VariantTableArgument arg : arguments) {
       String cstic = arg.getCharacteristic().getName();
       int index = arguments.indexOf(arg);
       entries.appendRow();
       Literal literal = row.getValues().get(index);
       entries.setValue("VTCHARACT", cstic);
       entries.setValue("VTLINENO", "" + rows.indexOf(row));
       entries.setValue("VTVALUE", getValue(literal));
     }
   }
   executeTransaction(monitor, "CREATE/CHANGE " + table.getName(), createfunc);
 }
  private void addResultToList(
      org.emftext.sdk.concretesyntax.resource.cs.ICsReferenceMapping<ReferenceType> mapping,
      org.eclipse.emf.ecore.EObject proxy,
      org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> list) {
    org.eclipse.emf.ecore.EObject target = null;
    int proxyPosition = list.indexOf(proxy);

    if (mapping instanceof org.emftext.sdk.concretesyntax.resource.cs.ICsElementMapping<?>) {
      target =
          ((org.emftext.sdk.concretesyntax.resource.cs.ICsElementMapping<ReferenceType>) mapping)
              .getTargetElement();
    } else if (mapping instanceof org.emftext.sdk.concretesyntax.resource.cs.ICsURIMapping<?>) {
      target = org.eclipse.emf.ecore.util.EcoreUtil.copy(proxy);
      org.eclipse.emf.common.util.URI uri =
          ((org.emftext.sdk.concretesyntax.resource.cs.ICsURIMapping<ReferenceType>) mapping)
              .getTargetIdentifier();
      ((org.eclipse.emf.ecore.InternalEObject) target).eSetProxyURI(uri);
    } else {
      assert false;
    }
    try {
      // if target is an another proxy and list is "unique" add() will try to resolve
      // the new proxy to check for uniqueness. There seems to be no way to avoid that.
      // Until now this does not cause any problems.
      if (proxyPosition + 1 == list.size()) {
        list.add(target);
      } else {
        list.add(proxyPosition + 1, target);
      }
    } catch (Exception e1) {
      e1.printStackTrace();
    }
  }
예제 #4
0
  private void adjustPersistentOppositeReference(
      InternalCDOObject cdoObject, EObject oppositeObject, EReference oppositeReference) {
    InternalCDOObject oppositeCDOObject = (InternalCDOObject) CDOUtil.getCDOObject(oppositeObject);
    if (oppositeCDOObject != null) {
      InternalCDOView view = oppositeCDOObject.cdoView();
      if (view != null) {
        CDOStore store = viewAndState.view.getStore();
        if (store != null) {
          if (oppositeReference.isMany()) {
            EObject eObject = oppositeCDOObject.cdoInternalInstance();

            @SuppressWarnings("unchecked")
            EList<Object> list = (EList<Object>) eObject.eGet(oppositeReference);
            int index = list.indexOf(instance);

            if (index != EStore.NO_INDEX && !store.isEmpty(oppositeCDOObject, oppositeReference)) {
              store.set(oppositeCDOObject, oppositeReference, index, cdoObject);
            }
          } else {
            store.set(oppositeCDOObject, oppositeReference, 0, cdoObject);
          }
        }
      }
    }
  }
 /**
  * Deduces the index where the new attribute must be inserted.
  *
  * @param parent The container of the child model object.
  * @param child An object belonging to an EList
  * @return The index where Attribute must be inserted
  */
 private int calculateIndex(EObject parent, EObject child) {
   int index = ((Requirement) parent).getAttribute().size();
   if (parent instanceof Requirement) {
     EList<Attribute> attList = ((Requirement) parent).getAttribute();
     index = attList.indexOf(child) + 1;
   }
   return index;
 }
 public String syntheticName(final KeyAST b) {
   final EObject binding = b.eContainer();
   EStructuralFeature _eContainingFeature = b.eContainingFeature();
   String _name = _eContainingFeature.getName();
   String _plus = ("_" + _name);
   EObject _eContainer = binding.eContainer();
   EList<EObject> _eContents = _eContainer.eContents();
   int _indexOf = _eContents.indexOf(binding);
   return (_plus + Integer.valueOf(_indexOf));
 }
예제 #7
0
 public static void replaceInContainer(final EObject search, final EObject replacement) {
   EObject container = search.eContainer();
   EStructuralFeature f = search.eContainingFeature();
   if (f.isMany()) {
     @SuppressWarnings("unchecked")
     EList<? super EObject> l = (EList<? super EObject>) container.eGet(f);
     l.set(l.indexOf(search), replacement);
   } else {
     container.eSet(f, replacement);
   }
 }
 protected boolean _createEqualityHelperHelper_(final EObject left, final EObject right) {
   boolean _xblockexpression = false;
   {
     boolean _and = false;
     if (!(left instanceof Module)) {
       _and = false;
     } else {
       _and = (right instanceof Module);
     }
     if (_and) {
       EObject _eContainer = left.eContainer();
       EList<Module> _modules = ((ModularizationModel) _eContainer).getModules();
       final int leftIndex = _modules.indexOf(left);
       EObject _eContainer_1 = right.eContainer();
       EList<Module> _modules_1 = ((ModularizationModel) _eContainer_1).getModules();
       final int rightIndex = _modules_1.indexOf(right);
       return Integer.valueOf(leftIndex).equals(Integer.valueOf(rightIndex));
     }
     _xblockexpression = left.equals(right);
   }
   return _xblockexpression;
 }
 /** This method should be called with write Transaction. */
 protected void safelyChangeOrder() {
   EList<InteractionFragment> orderingFragments = getOrderingFragments();
   synchronized (orderingFragments) {
     computeNewIndexes();
     for (InteractionFragment fragment : new ArrayList<InteractionFragment>(orderingFragments)) {
       int oldPos = orderingFragments.indexOf(fragment);
       if (oldPos == -1) {
         continue;
       }
       Integer newPos = fragmentIndexes.get(fragment);
       if (newPos == null
           || oldPos == newPos.intValue()
           || newPos.intValue() < 0
           || newPos.intValue() >= orderingFragments.size()) {
         continue;
       }
       orderingFragments.move(newPos.intValue(), oldPos);
     }
   }
 }
예제 #10
0
 public void repair() {
   final EObject eObjectOwner = objectMapping.get(owner.getTarget());
   final ModelObject<?> modelObjectOwner = ModelResolver.getInstance().getModelObject(owner);
   final Object listObject = modelObjectOwner.eGet(eReference);
   if (!(listObject instanceof List<?>)) {
     // no order maintained anyway
     return;
   }
   final EList<?> eList = (EList<?>) eObjectOwner.eGet(eReference);
   final List<?> list = (List<?>) listObject;
   int currentIndex = 0;
   for (Object objectElement : list) {
     final EObject eObjectElement = objectMapping.get(objectElement);
     final int newIndex = eList.indexOf(eObjectElement);
     if (newIndex != currentIndex) {
       eList.move(currentIndex, newIndex);
     }
     currentIndex++;
   }
 }
예제 #11
0
 public int indexOf(Object o) {
   return copy.indexOf(o);
 }
 public String syntheticToInstanceName(final BindingAST binding) {
   EObject _eContainer = binding.eContainer();
   EList<EObject> _eContents = _eContainer.eContents();
   int _indexOf = _eContents.indexOf(binding);
   return ("_toInstance" + Integer.valueOf(_indexOf));
 }