Java 类org.eclipse.emf.common.util.BasicEList 实例源码

项目:n4js    文件:N4JSResource.java   
/**
 * This is aware of warnings from the {@link N4JSStringValueConverter}.
 *
 * Issues from the parser are commonly treated as errors but here we want to create a warning.
 */
@Override
protected void addSyntaxErrors() {
    if (isValidationDisabled())
        return;
    // EList.add unnecessarily checks for uniqueness by default
    // so we use #addUnique below to save some CPU cycles for heavily broken
    // models
    BasicEList<Diagnostic> errorList = (BasicEList<Diagnostic>) getErrors();
    BasicEList<Diagnostic> warningList = (BasicEList<Diagnostic>) getWarnings();

    for (INode error : getParseResult().getSyntaxErrors()) {
        XtextSyntaxDiagnostic diagnostic = createSyntaxDiagnostic(error);
        String code = diagnostic.getCode();
        if (AbstractN4JSStringValueConverter.WARN_ISSUE_CODE.equals(code)
                || RegExLiteralConverter.ISSUE_CODE.equals(code)
                || LegacyOctalIntValueConverter.ISSUE_CODE.equals(code)) {
            warningList.addUnique(diagnostic);
        } else if (!InternalSemicolonInjectingParser.SEMICOLON_INSERTED.equals(code)) {
            errorList.addUnique(diagnostic);
        }
    }
}
项目:n4js    文件:ConcreteSyntaxAwareReferenceFinder.java   
@Override
public void findReferences(Predicate<URI> targetURIs, Resource resource, Acceptor acceptor,
        IProgressMonitor monitor) {
    // make sure data is present
    keys.getData((TargetURIs) targetURIs, new SimpleResourceAccess(resource.getResourceSet()));
    EList<EObject> astContents;
    if (resource instanceof N4JSResource) {
        // In case of N4JSResource, we search only in the AST but NOT in TModule tree!
        Script script = (Script) ((N4JSResource) resource).getContents().get(0);
        astContents = new BasicEList<>();
        astContents.add(script);
    } else {
        astContents = resource.getContents();
    }
    for (EObject content : astContents) {
        findReferences(targetURIs, content, acceptor, monitor);
    }
}
项目:n4js    文件:ComposedMemberInfo.java   
private void handleFParameters(TMember member, RuleEnvironment G) {
    EList<TFormalParameter> fpars = null;
    if (member instanceof TMethod) {
        TMethod method = (TMethod) member;
        fpars = method.getFpars();
    }
    if (member instanceof TSetter) {
        TSetter setter = (TSetter) member;
        fpars = new BasicEList<>();
        fpars.add(setter.getFpar());
    }
    if (fpars != null) {
        for (int i = 0; i < fpars.size(); i++) {
            TFormalParameter fpar = fpars.get(i);
            if (fParameters.size() <= i) {
                fParameters.add(new ComposedFParInfo());
            }
            ComposedFParInfo fpAggr = fParameters.get(i);
            Pair<TFormalParameter, RuleEnvironment> fpPair = new Pair<>(fpar, G);
            fpAggr.fpSiblings.add(fpPair);
        }
    }
}
项目:time4sys    文件:HardwareDriveTimingPropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updatePart(org.eclipse.emf.common.notify.Notification)
 */
public void updatePart(Notification msg) {
    super.updatePart(msg);
    if (editingPart.isVisible()) {
        TimingPropertiesEditionPart timingPart = (TimingPropertiesEditionPart)editingPart;
        if (HrmPackage.eINSTANCE.getHardwareResource_Clock().equals(msg.getFeature()) && timingPart != null && isAccessible(HrmViewsRepository.Timing.TimingProperties.clock))
            timingPart.setClock((EObject)msg.getNewValue());
        if (HrmPackage.eINSTANCE.getHardwareMemory_Timings().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && timingPart != null && isAccessible(HrmViewsRepository.Timing.TimingProperties.timings)) {
            if (msg.getNewValue() instanceof EList<?>) {
                timingPart.setTimings((EList<?>)msg.getNewValue());
            } else if (msg.getNewValue() == null) {
                timingPart.setTimings(new BasicEList<Object>());
            } else {
                BasicEList<Object> newValueAsList = new BasicEList<Object>();
                newValueAsList.add(msg.getNewValue());
                timingPart.setTimings(newValueAsList);
            }
        }


    }
}
项目:time4sys    文件:HardwareRomTimingPropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updatePart(org.eclipse.emf.common.notify.Notification)
 */
public void updatePart(Notification msg) {
    super.updatePart(msg);
    if (editingPart.isVisible()) {
        TimingPropertiesEditionPart timingPart = (TimingPropertiesEditionPart)editingPart;
        if (HrmPackage.eINSTANCE.getHardwareResource_Clock().equals(msg.getFeature()) && timingPart != null && isAccessible(HrmViewsRepository.Timing.TimingProperties.clock))
            timingPart.setClock((EObject)msg.getNewValue());
        if (HrmPackage.eINSTANCE.getHardwareMemory_Timings().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && timingPart != null && isAccessible(HrmViewsRepository.Timing.TimingProperties.timings)) {
            if (msg.getNewValue() instanceof EList<?>) {
                timingPart.setTimings((EList<?>)msg.getNewValue());
            } else if (msg.getNewValue() == null) {
                timingPart.setTimings(new BasicEList<Object>());
            } else {
                BasicEList<Object> newValueAsList = new BasicEList<Object>();
                newValueAsList.add(msg.getNewValue());
                timingPart.setTimings(newValueAsList);
            }
        }


    }
}
项目:time4sys    文件:HardwareMemoryTimingPropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updatePart(org.eclipse.emf.common.notify.Notification)
 */
public void updatePart(Notification msg) {
    super.updatePart(msg);
    if (editingPart.isVisible()) {
        TimingPropertiesEditionPart timingPart = (TimingPropertiesEditionPart)editingPart;
        if (HrmPackage.eINSTANCE.getHardwareResource_Clock().equals(msg.getFeature()) && timingPart != null && isAccessible(HrmViewsRepository.Timing.TimingProperties.clock))
            timingPart.setClock((EObject)msg.getNewValue());
        if (HrmPackage.eINSTANCE.getHardwareMemory_Timings().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && timingPart != null && isAccessible(HrmViewsRepository.Timing.TimingProperties.timings)) {
            if (msg.getNewValue() instanceof EList<?>) {
                timingPart.setTimings((EList<?>)msg.getNewValue());
            } else if (msg.getNewValue() == null) {
                timingPart.setTimings(new BasicEList<Object>());
            } else {
                BasicEList<Object> newValueAsList = new BasicEList<Object>();
                newValueAsList.add(msg.getNewValue());
                timingPart.setTimings(newValueAsList);
            }
        }


    }
}
项目:time4sys    文件:MarteServices.java   
public List<EObject> getPrecedenceRelations(EObject view, ConnectorKind kind) {
    List<EObject> precedenceRelations = new BasicEList<EObject>();
    if (view instanceof ExecutionStep) {
        ExecutionStep execStep = (ExecutionStep) view;
        PrecedenceRelation inputRelation = execStep.getInputRel();
        if (inputRelation != null) {
            if (inputRelation.getConnectorKind().equals(kind)) {
                precedenceRelations.add(inputRelation);
            }
        }
        PrecedenceRelation outputRelation = execStep.getOutputRel();
        if (outputRelation != null) {
            if (outputRelation.getConnectorKind().equals(kind)) {
                precedenceRelations.add(outputRelation);
            }
        }
    }
    return precedenceRelations;
}
项目:time4sys    文件:MarteServices.java   
public List<SoftwareSchedulableResource> getSwSchedulableResourcesOrderedByPriority(EObject context) {
    List<SoftwareSchedulableResource> sortedSwSchedRes = new BasicEList<SoftwareSchedulableResource>();
    if (context instanceof HardwareComputingResource) {
        HardwareComputingResource hcr = (HardwareComputingResource) context;
        for (Resource resource : hcr.getOwnedResource()) {
            if (resource instanceof SoftwareSchedulableResource) {
                SoftwareSchedulableResource swSchedRes = (SoftwareSchedulableResource) resource;
                int insertionIndex = 0;
                // WARNING First SchedulingParameter value considered as
                // priority
                int priority = Integer.parseInt(swSchedRes.getSchedParams().get(0).getValue());
                for (SoftwareSchedulableResource sortedSwSched : sortedSwSchedRes) {
                    int sortedSwSchedPriority = Integer.parseInt(sortedSwSched.getSchedParams().get(0).getValue());
                    if (sortedSwSchedPriority < priority) {
                        insertionIndex++;
                    } else {
                        break;
                    }
                }
                sortedSwSchedRes.add(insertionIndex, swSchedRes);
            }
        }
    }
    return sortedSwSchedRes;
}
项目:time4sys    文件:AnalysisOpenJavaService.java   
public List<Task> getTasksOrderedByPriority(EObject context_p) {
    List<Task> sortedTasks = new BasicEList<Task>();
    if (context_p instanceof ComputingResource) {
        ComputingResource cr = (ComputingResource) context_p;
        for (Task task : cr.getTasksAffectedOn()) {
            int insertionIndex = 0;
            // WARNING First SchedulingParameter value considered as
            // priority
            if ((task.getSchedulingParameters() != null) && (task.getSchedulingParameters().size() != 0)) {
                int priority = Integer.parseInt(task.getSchedulingParameters().get(0).getValue());
                for (Task sortedTask : sortedTasks) {
                    int sortedTaskPriority = Integer
                            .parseInt(sortedTask.getSchedulingParameters().get(0).getValue());
                    if (sortedTaskPriority < priority) {
                        insertionIndex++;
                    } else {
                        break;
                    }
                }
                sortedTasks.add(insertionIndex, task);
            }
        }
    }
    return sortedTasks;
}
项目:xtext-extras    文件:JvmAnnotationReferenceImplCustom.java   
@Override
public EList<JvmAnnotationValue> getValues() {
    EList<JvmAnnotationValue> explicitValues = getExplicitValues();
    List<JvmOperation> operations = Lists.newArrayList(getAnnotation().getDeclaredOperations());
    if (operations.size() <= explicitValues.size()) {
        return ECollections.unmodifiableEList(explicitValues);
    }
    Set<JvmOperation> seenOperations = Sets.newHashSetWithExpectedSize(operations.size());
    BasicEList<JvmAnnotationValue> result = new BasicEList<JvmAnnotationValue>(operations.size());
    for(JvmAnnotationValue value: explicitValues) {
        seenOperations.add(value.getOperation());
        result.add(value);
    }
    for(JvmOperation operation: operations) {
        if (seenOperations.add(operation)) {
            JvmAnnotationValue defaultValue = operation.getDefaultValue();
            if (defaultValue != null) {
                result.add(defaultValue);
            }
        }
    }
    return ECollections.unmodifiableEList(result);
}
项目:DarwinSPL    文件:HyTimedImplementationEnumLinkLocalReferenceResolver.java   
public void resolve(String identifier, eu.hyvar.mspl.manifest.HyTimedImplementationEnumLink container, EReference reference, int position, boolean resolveFuzzy, final eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestReferenceResolveResult<eu.hyvar.dataValues.HyEnum> result) {
    //System.out.println("UNITO DEBUG EnumLinkLocal: identifier= "+identifier);

    HyEnum elementEnum = HyExpressionResolverUtil.resolveEnum(identifier, container);
    if(elementEnum!=null) {

        EList<eu.hyvar.evolution.HyTemporalElement> elements = new BasicEList<eu.hyvar.evolution.HyTemporalElement>();
        elements.add(container);
        elements.add((eu.hyvar.evolution.HyTemporalElement)container.eContainer());
        HyInterval interval = HyEvolutionUtil.computeTemporalIntersection(elements);

        if(HyEvolutionUtil.isWithinValidityOf(interval, elementEnum)) {
            //System.out.println("UNITO DEBUG EnumLinkLocal: enum= "+elementEnum);

            result.addMapping(identifier, elementEnum);
        }
    }

    //delegate.resolve(identifier, container, reference, position, resolveFuzzy, result);
}
项目:DarwinSPL    文件:DwAttributeRenameAction.java   
@Override
public void run(){
    Shell shell = this.getWorkbenchPart().getSite().getShell();

    StructuredSelection selection = (StructuredSelection)this.getSelection();
    DwAttributeEditPart part = (DwAttributeEditPart)selection.getFirstElement();
    HyFeatureAttribute attribute = (HyFeatureAttribute)part.getModel();

    EList<HyName> names = attribute.getNames();
    EList<EObject> items = new BasicEList<EObject>();

    for(int i=0; i<names.size(); i++){
        HyName name = names.get(i);
        items.add(name);
    }

    DwNameDialog dialog = new DwNameDialog(shell);
    dialog.setElement(attribute);
    dialog.setItems(items);
    dialog.open();
}
项目:DarwinSPL    文件:RemoveFromGroupComposition.java   
@Override
public void execute() {

    //get the group and the containing features of the group composition 
    this.group = oldGroupComposition.getCompositionOf();

    EList<HyFeature> features = new BasicEList<HyFeature>();
    features.addAll(oldGroupComposition.getFeatures());
    features.remove(feature);

    DeleteGroupComposition deleteOldComposition = new DeleteGroupComposition(oldGroupComposition, timestamp);
    AddGroupComposition addNewComposition = new AddGroupComposition(group, features , timestamp);

    //the order of the append is important for the execute, so first delete then add
    addToComposition(deleteOldComposition);
    addToComposition(addNewComposition);

    for (EvolutionOperation operation : evoOps) {
        operation.execute();
    }

    newGroupComposition = addNewComposition.getGroupComposition();

}
项目:DarwinSPL    文件:AddToGroupComposition.java   
@Override
public void execute() {

    //get the group and the containing features of the group composition 
    this.group = oldGroupComposition.getCompositionOf();

    //create a new List and add all necessary elements
    EList<HyFeature> features = new BasicEList<HyFeature>();
    features.addAll(oldGroupComposition.getFeatures());
    features.add(feature);

    DeleteGroupComposition deleteOldComposition = new DeleteGroupComposition(oldGroupComposition, timestamp);
    AddGroupComposition addNewComposition = new AddGroupComposition(group, features , timestamp);

    //the order of the append is important for the execute, so first delete then add
    addToComposition(deleteOldComposition);
    addToComposition(addNewComposition);

    for (EvolutionOperation operation : evoOps) {
        operation.execute();
    }

    newGroupComposition = addNewComposition.getGroupComposition();
}
项目:DarwinSPL    文件:MoveFeatureDeleteAndAddGroup.java   
@Override
public void execute() {

    DeleteGroupWithTypeChildAndComposition deleteGroup = new DeleteGroupWithTypeChildAndComposition(oldGroup, timestamp);

    EList<HyFeature> features = new BasicEList<HyFeature>();
    features.add(feature);
    //add a new group for the feature und the parent. The group type must be AND because at this point the group will only have one feature in his composition
    AddGroupWithTypeChildAndComposition addGroup = new AddGroupWithTypeChildAndComposition(HyGroupTypeEnum.AND, parent, features, timestamp, tfm);

    addToComposition(deleteGroup);
    addToComposition(addGroup);

    for (EvolutionOperation operation : evoOps) {
        operation.execute();
    }

    this.newGroup = addGroup.getGroup();

}
项目:dsl-devkit    文件:EObjectContentProviderTest.java   
/**
 * Mocks XtextEditor and XtextElementSelectionListener to return an element selection that has:
 * - given EAttribute with a specific value (AttributeValuePair)
 * - given EStructuralFeature
 * - given EOperation.
 *
 * @param attributeValuePair
 *          EAttribute with a specific value
 * @param feature
 *          the EStructuralFeature
 * @param operation
 *          the EOperation
 * @return the EClass of the "selected" element
 */
@SuppressWarnings("unchecked")
private EClass mockSelectedElement(final AttributeValuePair attributeValuePair, final EStructuralFeature feature, final EOperation operation) {
  EClass mockSelectionEClass = mock(EClass.class);
  when(mockSelectionListener.getSelectedElementType()).thenReturn(mockSelectionEClass);
  // Mockups for returning AttributeValuePair
  URI elementUri = URI.createURI("");
  when(mockSelectionListener.getSelectedElementUri()).thenReturn(elementUri);
  XtextEditor mockEditor = mock(XtextEditor.class);
  when(mockSelectionListener.getEditor()).thenReturn(mockEditor);
  IXtextDocument mockDocument = mock(IXtextDocument.class);
  when(mockEditor.getDocument()).thenReturn(mockDocument);
  when(mockDocument.<ArrayList<AttributeValuePair>> readOnly(any(IUnitOfWork.class))).thenReturn(newArrayList(attributeValuePair));
  // Mockups for returning EOperation
  BasicEList<EOperation> mockEOperationsList = new BasicEList<EOperation>();
  mockEOperationsList.add(operation);
  when(mockSelectionEClass.getEAllOperations()).thenReturn(mockEOperationsList);
  // Mockups for returning EStructuralFeature
  BasicEList<EStructuralFeature> mockEStructuralFeatureList = new BasicEList<EStructuralFeature>();
  mockEStructuralFeatureList.add(feature);
  mockEStructuralFeatureList.add(attributeValuePair.getAttribute());
  when(mockSelectionEClass.getEAllStructuralFeatures()).thenReturn(mockEStructuralFeatureList);
  return mockSelectionEClass;
}
项目:dsl-devkit    文件:ELists.java   
/**
 * Filters an {@link EList} of type T to contain only elements matching the provided predicate.
 *
 * @param <T>
 *          list element type
 * @param unfiltered
 *          unfiltered list
 * @param predicate
 *          to apply
 * @return filtered list
 */
public static <T> EList<T> filter(final EList<T> unfiltered, final Predicate<? super T> predicate) {
  if (unfiltered == null) {
    return ECollections.emptyEList();
  }
  if (predicate == null) {
    throw new IllegalArgumentException("predicate must not be null"); //$NON-NLS-1$
  }
  EList<T> filtered = new BasicEList<T>(unfiltered.size() / 2); // Initial guess: half the original size
  for (T t : unfiltered) {
    if (predicate.apply(t)) {
      filtered.add(t);
    }
  }
  return filtered;
}
项目:bts    文件:BTSTranslationsImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generatedNOT
 */
public EList<String> getLanguages() {
    EList<String> langs = new BasicEList<String>();
    if (translations == null) {
        return langs;
    }
    for (BTSTranslation t : translations) {
        if (t.getLang() != null && !"".equals(t.getLang())
                && t.getValue() != null && !"".equals(t.getValue()))
        {
            langs.add(t.getLang());
        }

    }
    return langs;
}
项目:statecharts    文件:TypesUtil.java   
private static void prependContainingFeatureName(StringBuilder id, EObject container) {
    EStructuralFeature feature = container.eContainingFeature();
    if (feature != null) {
        String name;
        if (feature.isMany()) {
            Object elements = container.eContainer().eGet(feature);
            int index = 0;
            if (elements instanceof BasicEList) {
                BasicEList elementList = (BasicEList) elements;
                index = elementList.indexOf(container);
            }
            name = feature.getName() + index;
        } else {
            name = feature.getName();
        }
        id.insert(0, ID_SEPARATOR);
        id.insert(0, name);
    }
}
项目:mondo-demo-wt    文件:WTModularCrossReferences.java   
public EList<?> getChoicesOfValuesProject(Resource res, EClass anEClass){

    EList<EObject> result = new BasicEList<EObject>();
    try {
        res.load(null);
        TreeIterator<EObject> tree = EcoreUtil.getAllContents(res, true);
        while (tree.hasNext()) {
            EObject anEObject = tree.next();
            if(anEClass.isInstance(anEObject))
                result.add(anEObject);          
        }           
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }       
    res.unload();
    return result;
}
项目:openhab-hdl    文件:ItemUIRegistryImpl.java   
/** 
 * This method creates a list of children for a group dynamically.
 * If there are no explicit children defined in a sitemap, the children
 * can thus be created on the fly by iterating over the members of the group item.
 * 
 * @param group The group widget to get children for
 * @return a list of default widgets provided for the member items
 */
private EList<Widget> getDynamicGroupChildren(Group group) {
    EList<Widget> children = new BasicEList<Widget>();
    String itemName = group.getItem();
    try {
        Item item = getItem(itemName);
        if(item instanceof GroupItem) {
            GroupItem groupItem = (GroupItem) item;
            for(Item member : groupItem.getMembers()) {
                Widget widget = getDefaultWidget(member.getClass(), member.getName());
                if(widget!=null) {
                    widget.setItem(member.getName());
                    children.add(widget);
                }                   
            }
        } else {
            logger.warn("Item '{}' is not a group.", item.getName());
        }
    } catch (ItemNotFoundException e) {
        logger.warn("Group '{}' could not be found.", group.getLabel(), e);
    }
    return children;

}
项目:mondo-hawk    文件:LazyResolver.java   
public Object get(EObject object, EReference feature, Map<EReference, LazyEListWrapper> pending, boolean greedyReferences, boolean mustFetchAttributes) {
    if (isPending) {
        try {
            resolvePendingReference(object, feature, pending, backingEList, greedyReferences, mustFetchAttributes);
        } catch (Exception e) {
            LOGGER.error("Error while resolving reference: " + e.getMessage(), e);
            return new BasicEList<>();
        }
    }
    if (feature.isMany()) {
        return backingEList;
    } else if (!backingEList.isEmpty()) {
        return backingEList.get(0);
    } else {
        return null;
    }
}
项目:mondo-hawk    文件:AttributeUtils.java   
private static Object setListAttribute(final EFactory eFactory, final EObject eObject, final Object value,
        final EStructuralFeature feature) {
    final EList<Object> manyValue = normalizeIntoList(value);
    if (manyValue == null) {
        eObject.eUnset(feature);
        return null;
    }

    final EClassifier eType = feature.getEType();
    if (eType instanceof EEnum) {
        final EEnum enumType = (EEnum)eType;
        final EList<Object> literals = new BasicEList<>();
        for (final Object o : manyValue) {
            literals.add(eFactory.createFromString(enumType, o.toString()));
        }
        eObject.eSet(feature, literals);
        return literals;
    } else {
        eObject.eSet(feature, manyValue);
        return manyValue;
    }
}
项目:mondo-hawk    文件:LocalHawkResourceImpl.java   
@Override
public EList<EObject> fetchNodes(final EClass eClass, boolean fetchAttributes) throws Exception {
    try (IGraphTransaction tx = indexer.getGraph().beginTransaction()) {
        final GraphWrapper gw = new GraphWrapper(indexer.getGraph());
        final MetamodelNode mn = gw.getMetamodelNodeByNsURI(eClass.getEPackage().getNsURI());
        for (TypeNode tn : mn.getTypes()) {
            if (eClass.getName().equals(tn.getTypeName())) {
                Iterable<ModelElementNode> instances = tn.getAll();
                return createOrUpdateEObjects(instances);
            }
        }
        tx.success();
    }

    LOGGER.warn("Could not find a type node for EClass {}:{}", eClass.getEPackage().getNsURI(), eClass.getName());
    return new BasicEList<EObject>();
}
项目:OpenSPIFe    文件:CompressChainOperation.java   
/**
 * Given a list representing a selection, return a list
 * with the following properties:
 * 
 * 1. the list is in temporal order (all elements will have a start time)
 * 2. each element in the returned list was in the source list
 * 3. each element in the returned list is in some chain
 * 4. no two elements in the returned list are from the same chain
 * 
 * @param list
 * @return
 */
public static List<? extends EPlanElement> getRepresentativePlanElements(Collection<? extends EPlanElement> list) {
    Map<TemporalChain, EPlanElement> chainToRepresentativeMap = createChainToRepresentiveMap(list);
    EList<EPlanElement> representatives = new BasicEList<EPlanElement>(chainToRepresentativeMap.values());
    ECollections.sort(representatives, new Comparator<EPlanElement>() {
        @Override
        public int compare(EPlanElement o1, EPlanElement o2) {
            Date start1 = o1.getMember(TemporalMember.class).getStartTime();
            Date start2 = o2.getMember(TemporalMember.class).getStartTime();
            Amount<Duration> duration = DateUtils.subtract(start1, start2);
            int comparison = duration.compareTo(DateUtils.ZERO_DURATION);
            if (comparison != 0) {
                return comparison;
            }
            return PlanUtils.INHERENT_ORDER.compare(o1, o2);
        }
    });
    return representatives;
}
项目:OpenSPIFe    文件:ChainOperation.java   
private void reorderElements(List<EPlanChild> allPlanElements, EPlanElement firstElement, int insertionIndex) {
    this.newOrder = allPlanElements;
    ISelection selection = new StructuredSelection(allPlanElements);
    this.transferable = modifier.getTransferable(selection);
    EList<EPlanChild> oldOrder = new BasicEList<EPlanChild>(allPlanElements);
    ECollections.sort(oldOrder, PlanStructureComparator.INSTANCE);
    this.oldOrder = oldOrder;
    this.origin = modifier.getLocation(transferable);
    TemporalChainTransferExtension.setTransferableChains(transferable, Collections.<TemporalChain>emptySet());
    EPlanElement parent = (EPlanElement)firstElement.eContainer();
    if (insertionIndex == 0) {
        this.destination = new PlanInsertionLocation(parent, InsertionSemantics.ON, allPlanElements);
    } else {
        EPlanElement element = EPlanUtils.getChildren(parent).get(insertionIndex - 1);
        this.destination = new PlanInsertionLocation(element, InsertionSemantics.AFTER, allPlanElements);
    }
}
项目:OpenSPIFe    文件:PatchFeatureChangeImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
@Override
public void applyAndReverse(EObject target) {
    EStructuralFeature feature = getFeature();
    if (!feature.isMany()) {
        Object valueToSet = getValue();
        Object currentValue = target.eGet(feature);
        target.eSet(feature, valueToSet);
        setOldValue(valueToSet);
        setValue(currentValue);
    } else {
        EList<PatchListChange> reversedListChange = new BasicEList();
        for (PatchListChange listChange : getListChanges()) {
            PatchListChange reversed = listChange.applyAndReverse(target, feature);
            if (reversed != null) {
                reversedListChange.add(0, reversed);
            }
        }
        getListChanges().clear();
        getListChanges().addAll(reversedListChange);
    }
}
项目:eclipse-avro    文件:BasicFeatureMap.java   
public boolean retainAll(EStructuralFeature feature, Collection<?> collection)
{
  boolean isFeatureMap = FeatureMapUtil.isFeatureMap(feature);
  FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature);
  List<Entry> entryCollection = new BasicEList<Entry>(collection.size());
  Entry [] entries = (Entry[])data;
  for (int i = size; --i >= 0; )
  {
    Entry entry = entries[i];
    if (validator.isValid(entry.getEStructuralFeature()))
    {
      if (!collection.contains(isFeatureMap ? entry : entry.getValue()))
      {
        entryCollection.add(entry);
      }
    }
  }

  return removeAll(entryCollection);
}
项目:eclipse-avro    文件:URIMappingRegistryImpl.java   
/**
 * Checks for folder mappings to populate the {@link #prefixMaps prefix maps}.
 */
@Override
protected void didAdd(Entry<URI, URI> entry)
{
  if (((MappingEntryImpl)entry).isPrefixMapEntry)
  {
    int length = entry.getKey().segmentCount();
    if (prefixMaps == null)
    {
      prefixMaps = new BasicEList<List<Entry<URI, URI>>>();
    }

    for (int i = prefixMaps.size() - 1; i <= length; ++i)
    {
      prefixMaps.add(new BasicEList<Entry<URI, URI>>());
    }

    prefixMaps.get(length).add(entry);
  }
}
项目:spinefm    文件:TestMultiSoftwareProductLine.java   
@Test
public void testGetDomainElementByName() throws DomainElementNotFoundException {
    MultipleSoftwareProductLine mspl = MSPLModelFactory.eINSTANCE.createMultipleSoftwareProductLine();

    DomainElement de1 = MSPLModelFactory.eINSTANCE.createDomainElement();
    DomainElement de2 = MSPLModelFactory.eINSTANCE.createDomainElement();
    DomainElement de3 = MSPLModelFactory.eINSTANCE.createDomainElement();

    de1.setId("foo");
    de2.setId("toto");
    de3.setId("bar");

    EList<DomainElement> des = new BasicEList<DomainElement>();
    des.add(de1);
    des.add(de2);
    des.add(de3);
    ((MultipleSoftwareProductLineImpl)mspl).eSet(MSPLModelPackage.MULTIPLE_SOFTWARE_PRODUCT_LINE__DOMAIN_ELEMENTS, des);

    DomainElement deToto = mspl.getDomainElementByName("toto");
    assertEquals(de2, deToto);
}
项目:eclipse-avro    文件:BasicFeatureMap.java   
public boolean removeAll(EStructuralFeature feature, Collection<?> collection)
{
  if (FeatureMapUtil.isFeatureMap(feature))
  {
    return removeAll(collection);
  }
  else
  {
    FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature);
    List<Entry> entryCollection = new BasicEList<Entry>(collection.size());
    Entry [] entries = (Entry[])data;
    for (int i = size; --i >= 0; )
    {
      Entry entry = entries[i];
      if (validator.isValid(entry.getEStructuralFeature()))
      {
        if (collection.contains(entry.getValue()))
        {
          entryCollection.add(entry);
        }
      }
    }

    return removeAll(entryCollection);
  }
}
项目:EMFtoCSP    文件:EResourceUMLAdapter.java   
@Override
public EList<EObject> getContents() {
    EList<EObject> result = new BasicEList<EObject>();
    //EObject tokenEObject =null;
    EPackage pac = null;
    for (EObject eObject : origResource.getContents()){
        if ( eObject instanceof Package){
            EPackage pck = new EPackageUMLAdapter((Package)eObject,this);
            result.add(pck);    
            EPackage.Registry registry =  origResource.getResourceSet().getPackageRegistry();
            if (!registry.containsKey(pck.getNsURI())){
                registry.put(pck.getNsURI(),pck);   
                pck = registry.getEPackage(pck.getNsURI());
                }
            for (Object next : registry.values()){
                if (next instanceof EPackage)
                     pac = (EPackage) next;
                System.out.print("");
                }
            }

    }
    return result;
}
项目:NeoEMF    文件:EMFProtectedMethod.java   
private static EList<MethodDeclaration> getProtectedMethodDeclarations(Resource resource) {
    EList<MethodDeclaration> methodDeclarations = new BasicEList<>();
    List<? extends EObject> allClasses = getAllInstances(resource, JavaPackage.eINSTANCE.getClassDeclaration());
    for (EObject cls : allClasses) {
        for (BodyDeclaration method : ((ClassDeclaration) cls).getBodyDeclarations()) {
            if (!(method instanceof MethodDeclaration)) {
                continue;
            }
            if (method.getModifier() == null) {
                continue;
            }
            if (method.getModifier().getVisibility() == VisibilityKind.PROTECTED) {
                methodDeclarations.add((MethodDeclaration) method);
            }
        }
    }
    return methodDeclarations;
}
项目:NeoEMF    文件:QueryFactoryASE2015.java   
public static Query<Integer> querySpecificInvisibleMethodDeclarations(Resource resource) {
    return () -> {
        List<MethodDeclaration> methodDeclarations = new BasicEList<>();

        Model model = (Model) resource.getContents().get(0);
        if (model.getName().equals("org.eclipse.gmt.modisco.java.neoemf") || model.getName().equals("org.eclipse.jdt.core")) {
            try {
                for (org.eclipse.gmt.modisco.java.Package pack : model.getOwnedElements()) {
                    appendInvisibleMethods(pack, methodDeclarations);
                }
            }
            catch (NullPointerException e) {
                log.error(e);
            }
        }
        return methodDeclarations.size();
    };
}
项目:NeoEMF    文件:QueryFactoryASE2015.java   
@SuppressWarnings("unused")
public static Query<Integer> queryBranchStatements(Resource resource) {
    return () -> {
        List<Statement> result = new BasicEList<>();

        Model model = (Model) resource.getContents().get(0);
        if (model.getName().equals("org.eclipse.gmt.modisco.java.neoemf") || model.getName().equals("org.eclipse.jdt.core")) {
            try {
                for (org.eclipse.gmt.modisco.java.Package pack : model.getOwnedElements()) {
                    appendAccessedTypes(pack, result);
                }
            }
            catch (NullPointerException e) {
                log.error(e);
            }
        }

        return result.size();
    };
}
项目:eclipse-avro    文件:BasicFeatureMap.java   
@Override
protected boolean scanPrevious()
{
  Entry [] entries = (Entry [])((BasicEList<?>)featureMap).data();
  while (--entryCursor >= 0)
  {
    Entry entry = entries[entryCursor];
    if (validator.isValid(entry.getEStructuralFeature()))
    {
      preparedResult = extractValue(entry);
      prepared = -2;
      return true;
    }
  }

  prepared = -1;
  lastCursor = -1;
  return false;
}
项目:NeoEMF    文件:QueryFactory.java   
public static Query<Integer> queryInvisibleMethodDeclarations(Resource resource) {
    return () -> {
        List<MethodDeclaration> methodDeclarations = new BasicEList<>();

        Iterable<ClassDeclaration> classDeclarations = getAllInstances(resource, JavaPackage.eINSTANCE.getClassDeclaration());
        for (ClassDeclaration clazz : classDeclarations) {
            for (BodyDeclaration method : clazz.getBodyDeclarations()) {
                if (method instanceof MethodDeclaration && nonNull(method.getModifier())) {
                    if (method.getModifier().getVisibility() == VisibilityKind.PRIVATE) {
                        methodDeclarations.add((MethodDeclaration) method);
                    }
                    else if (method.getModifier().getVisibility() == VisibilityKind.PROTECTED) {
                        if (hasNoChildTypes(classDeclarations, clazz)) {
                            methodDeclarations.add((MethodDeclaration) method);
                        }
                    }
                }
            }
        }

        return methodDeclarations.size();
    };
}
项目:NeoEMF    文件:QueryFactory.java   
public static Query<Integer> queryUnusedMethodsWithLoop(Resource resource) {
    return () -> {
        List<MethodDeclaration> unusedMethods = new BasicEList<>();

        Iterable<MethodInvocation> methodInvocations = getAllInstances(resource, JavaPackage.eINSTANCE.getMethodInvocation());

        Iterable<MethodDeclaration> methodDeclarations = getAllInstances(resource, JavaPackage.eINSTANCE.getMethodDeclaration());
        for (MethodDeclaration method : methodDeclarations) {
            if (nonNull(method.getModifier())) {
                if (method.getModifier().getVisibility() == VisibilityKind.PRIVATE) {
                    if (!hasBeenInvoked(methodInvocations, method)) {
                        unusedMethods.add(method);
                    }
                }
            }
        }

        return unusedMethods.size();
    };
}
项目:NeoEMF    文件:QueryFactory.java   
private static Iterable<NamedElement> separateFields(Iterable<BodyDeclaration> bodyDeclarations) {
    List<NamedElement> fields = new BasicEList<>();

    for (BodyDeclaration declaration : bodyDeclarations) {
        if (nonNull(declaration) && declaration instanceof FieldDeclaration) {
            FieldDeclaration field = (FieldDeclaration) declaration;
            if (field.getFragments().isEmpty()) {
                fields.add(declaration);
            }
            else {
                fields.addAll(field.getFragments());
            }
        }
    }

    return fields;
}
项目:NeoEMF    文件:BackendHelper.java   
private static void copy(Map<EObject, EObject> correspondencesMap, EObject sourceEObject, EObject targetEObject) {
    for (EStructuralFeature sourceFeature : sourceEObject.eClass().getEAllStructuralFeatures()) {
        if (sourceEObject.eIsSet(sourceFeature)) {
            EStructuralFeature targetFeature = targetEObject.eClass().getEStructuralFeature(sourceFeature.getName());
            if (sourceFeature instanceof EAttribute) {
                targetEObject.eSet(targetFeature, sourceEObject.eGet(sourceFeature));
            }
            else { // EReference
                if (!sourceFeature.isMany()) {
                    targetEObject.eSet(targetFeature, getCorrespondingEObject(correspondencesMap, (EObject) sourceEObject.eGet(targetFeature), targetEObject.eClass().getEPackage()));
                }
                else {
                    List<EObject> targetList = new BasicEList<>();

                    @SuppressWarnings({"unchecked"})
                    Iterable<EObject> sourceList = (Iterable<EObject>) sourceEObject.eGet(sourceFeature);
                    for (EObject aSourceList : sourceList) {
                        targetList.add(getCorrespondingEObject(correspondencesMap, aSourceList, targetEObject.eClass().getEPackage()));
                    }
                    targetEObject.eSet(targetFeature, targetList);
                }
            }
        }
    }
}