private static String getReferenceParameter(EPlanElement ePlanElement, EReferenceParameter eStructuralFeature) { IItemPropertySource source = EMFUtils.adapt(ePlanElement, IItemPropertySource.class); IItemPropertyDescriptor startPD = source.getPropertyDescriptor(ePlanElement, eStructuralFeature); // First check the instance name if (startPD != null) { Object value = EMFUtils.getPropertyValue(startPD, ePlanElement); if (value != null && StringifierRegistry.hasRegisteredStringifier(eStructuralFeature.getName())) { IStringifier stringifier = StringifierRegistry.getStringifier(eStructuralFeature.getName()); return stringifier.getDisplayString(value); } if(value instanceof EcoreEList) { List<String> valueList = new ArrayList<String>(); for (Object o : ((EcoreEList) value).toArray()) { valueList.add(getChoiceText(eStructuralFeature, o)); } return EEnumStringifier.formatString(valueList.toString()); } } return ""; }
public static <T> void execute(String label, EcoreEList<T> list, T object) { if (list.getEStructuralFeature().isUnique() && list.contains(object)) { return; } IUndoableOperation op = new FeatureTransactionAddOperation<T>(label, list, object); IUndoContext context = TransactionUtils.getUndoContext(list); if (context != null) { op.addContext(context); try { IOperationHistory history = OperationHistoryFactory.getOperationHistory(); history.execute(op, null, null); } catch (Exception e) { LogUtil.error("execute", e); } } }
public FeatureTransactionRemoveAllOperation(String label, EcoreEList<T> list, List<T> objects) { super(label); this.list = list; this.objects = objects; int i = 0; List<T> matches = new ArrayList<T>(); int matchIndex = -1; for (T object : list) { if (objects.contains(object)) { matches.add(object); if (matchIndex == -1) { matchIndex = i; } } else if (matchIndex != -1) { indexObjects.put(matchIndex, matches); matches = new ArrayList<T>(); matchIndex = -1; } i++; } if (matchIndex != -1) { indexObjects.put(matchIndex, matches); matches = new ArrayList<T>(); matchIndex = -1; } }
public static <T> void execute(String label, EcoreEList<T> list, List<T> objects) { boolean containsOne = false; for (T item : list) { if (objects.contains(item)) { containsOne = true; break; } } if (!containsOne) { return; } IUndoableOperation op = new FeatureTransactionRemoveAllOperation<T>(label, list, objects); IUndoContext context = TransactionUtils.getUndoContext(list); if (context != null) { op.addContext(context); try { IOperationHistory history = OperationHistoryFactory.getOperationHistory(); history.execute(op, null, null); } catch (Exception e) { LogUtil.error("execute", e); } } }
public static <T> void execute(String label, EcoreEList<T> list, List<T> objects) { if (list.getEStructuralFeature().isUnique() && list.containsAll(objects)) { return; } IUndoableOperation op = new FeatureTransactionAddAllOperation<T>(label, list, objects); IUndoContext context = TransactionUtils.getUndoContext(list); if (context != null) { op.addContext(context); try { IOperationHistory history = OperationHistoryFactory.getOperationHistory(); history.execute(op, null, null); } catch (Exception e) { LogUtil.error("execute", e); } } }
public static <T> void execute(String label, EcoreEList<T> list, T object) { if (!list.contains(object)) { return; } IUndoableOperation op = new FeatureTransactionRemoveOperation<T>(label, list, object); IUndoContext context = TransactionUtils.getUndoContext(list); if (context != null) { op.addContext(context); try { IOperationHistory history = OperationHistoryFactory.getOperationHistory(); history.execute(op, null, null); } catch (Exception e) { LogUtil.error("execute", e); } } }
private void suggestTogglingWaiverOfRuleForElement(Set<Suggestion> suggestions, EPlanElement element) { EcoreEList<String> oldRuleNames = RuleUtils.getWaivedRuleNames(element); String name = rule.getName(); if (!oldRuleNames.contains(name)) { String label; IUndoableOperation operation; String description; if (RuleUtils.isWaived(element, rule)) { label = "waive " + rule.getPrintName(); operation = new FeatureTransactionAddOperation<String>(label, oldRuleNames, name); description = "Waive " + rule.getPrintName(); } else { label = "unwaive " + rule.getPrintName(); operation = new FeatureTransactionRemoveOperation<String>(label, oldRuleNames, name); description = "Unwaive " + rule.getPrintName(); } if (element instanceof EPlan) { description += " for this plan"; } else { description += " for " + element.getName(); } suggestions.add(new Suggestion(description, operation)); } }
private Suggestion createAddConstraintSuggestion() { IUndoableOperation operation = null; if (constraint instanceof ProfileConstraint) { EcoreEList<ProfileConstraint> currentConstraints = (EcoreEList)target.getMember(ProfileMember.class).getConstraints(); // Need to make a copy so it doesn't get removed from the template ProfileConstraint constraintCopy = (ProfileConstraint) EMFUtils.copy(constraint); operation = new FeatureTransactionAddOperation("Add Profile Constraint", currentConstraints, constraintCopy); } else if (constraint instanceof BinaryTemporalConstraint) { operation = new CreateTemporalRelationOperation((BinaryTemporalConstraint)constraint); } else if (constraint instanceof PeriodicTemporalConstraint) { operation = new CreateTemporalBoundOperation((PeriodicTemporalConstraint)constraint); } else if (constraint instanceof TemporalChain) { List<EPlanChild> linked = CommonUtils.castList(EPlanChild.class, ((TemporalChain)constraint).getElements()); operation = new ChainOperation(PlanStructureModifier.INSTANCE, linked, false); } if (operation != null) { return new Suggestion(UPDATE_ACTIVITY_ICON, "Add Constraint to Plan", operation); } return null; }
private Suggestion createRemoveConstraintSuggestion() { IUndoableOperation operation = null; if (constraint instanceof ProfileConstraint) { EcoreEList<ProfileConstraint> currentConstraints = (EcoreEList)target.getMember(ProfileMember.class).getConstraints(); operation = new FeatureTransactionRemoveOperation("Remove Profile Constraint", currentConstraints, constraint); } else if (constraint instanceof BinaryTemporalConstraint) { operation = new DeleteTemporalRelationOperation((BinaryTemporalConstraint)constraint); } else if (constraint instanceof PeriodicTemporalConstraint) { operation = new DeleteTemporalBoundOperation((PeriodicTemporalConstraint)constraint); } else if (constraint instanceof TemporalChain) { operation = new UnchainOperation(((TemporalChain)constraint).getElements()); } if (operation != null) { return new Suggestion(UPDATE_ACTIVITY_ICON, "Remove Constraint from Plan", operation); } return null; }
private Suggestion createModifyConstraintSuggestion() { CompositeOperation operation = null; if (constraint instanceof ProfileConstraint) { operation = new CompositeOperation("Update Profile Constraint"); EcoreEList<ProfileConstraint> currentConstraints = (EcoreEList)target.getMember(ProfileMember.class).getConstraints(); for (ProfileConstraint currentConstraint : currentConstraints) { if (similarProfileReferences(currentConstraint, (ProfileConstraint)constraint)) { operation.add(new FeatureTransactionRemoveOperation("Remove Profile Constraint", currentConstraints, currentConstraint)); } } // Need to make a copy so it doesn't get removed from the template ProfileConstraint constraintCopy = (ProfileConstraint) EMFUtils.copy(constraint); operation.add(new FeatureTransactionAddOperation("Add Profile Constraint", currentConstraints, constraintCopy)); } if (operation != null) { return new Suggestion(UPDATE_ACTIVITY_ICON, "Update Constraint in Plan", operation); } return null; }
/** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated NOT */ @Override public EList<Relation> getInsideLinkedRelations() { List<Relation> relations = new ArrayList<>(); for (Relation r : getLinkedRelations()) { if (getContainer().equals(r.getContainer())) { relations.add(r); } } return new EcoreEList.UnmodifiableEList(this, TriqPackage.eINSTANCE.getPort_InsideLinkedRelations(), relations.size(), relations.toArray()); }
/** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated NOT */ @Override public EList<Relation> getOutsideLinkedRelations() { List<Relation> relations = new ArrayList<>(); for (Relation r : getLinkedRelations()) { if (getContainer().getContainer().equals(r.getContainer())) { relations.add(r); } } return new EcoreEList.UnmodifiableEList(this, TriqPackage.eINSTANCE.getPort_OutsideLinkedRelations(), relations.size(), relations.toArray()); }
@Override public boolean editOnActivate(DayResourceFacet facet, IUndoContext undoContext, TreeItem item, int index) { Object element = facet.getElement(); if (element instanceof EActivity) { EActivity activity = (EActivity) element; EStructuralFeature feature = getFacetFeature(activity); if (feature == null) { return false; } String featureName = EMFUtils.getDisplayName(activity, feature); IUndoableOperation operation = null; if (feature.isMany()) { EcoreEList value = (EcoreEList) (activity.getData().eGet(feature)); if (!value.contains(object)) { operation = new FeatureTransactionAddOperation("add "+featureName, value, object); } else { operation = new FeatureTransactionRemoveOperation("remove "+featureName, value, object); } } else { operation = new FeatureTransactionChangeOperation("change "+featureName, activity, feature, object); } CommonUtils.execute(operation, undoContext); return true; } return false; }
public FeatureTransactionAddAllOperation(String label, EcoreEList<T> list, List<T> objects) { super(label); this.list = list; if (list.getEStructuralFeature().isUnique()) { this.objects = new ArrayList<T>(objects); this.objects.removeAll(list); } else { this.objects = objects; } }
@Override public String toString() { StringBuilder builder = new StringBuilder(Object.class.getSimpleName()); builder.append(":"); if (list instanceof EcoreEList) { builder.append(((EcoreEList) list).getEStructuralFeature().getName()); builder.append(" on " + ((EcoreEList) list).getEObject()); } builder.append(" remove "); builder.append(String.valueOf(object)); return builder.toString(); }
/** * Set some particular rule to be waived or enabled * @param rule * @param waived */ public static void setWaived(EPlan element, ERule rule, boolean waived) { EcoreEList<String> ruleNames = getWaivedRuleNames(element); String name = rule.getName(); if (waived) { FeatureTransactionAddOperation.execute("waive rule", ruleNames, name); } else if (!waived) { FeatureTransactionRemoveOperation.execute("unwaive rule", ruleNames, name); } }
/** * Set these rules to be waived or enabled * @param rules * @param waived */ public static void setWaivedRules(EPlan element, Set<ERule> rules, boolean waived) { EcoreEList<String> oldRuleNames = getWaivedRuleNames(element); List<String> changedRuleNames = new ArrayList<String>(); for (ERule rule : rules) { changedRuleNames.add(rule.getName()); } if (waived) { FeatureTransactionAddAllOperation.execute("waive rule(s)", oldRuleNames, changedRuleNames); } else { FeatureTransactionRemoveAllOperation.execute("unwaive rule(s)", oldRuleNames, changedRuleNames); } }
private String getProfileConstraintFormText(ProfileConstraint profileConstraint, IdentifiableRegistry<EPlanElement> identifiableRegistry) { PlanPrinter printer = new PlanPrinter(identifiableRegistry); StringBuilder builder = new StringBuilder(); switch (getDiffType()) { case MODIFY: EcoreEList<ProfileConstraint> currentConstraints = (EcoreEList)target.getMember(ProfileMember.class).getConstraints(); ProfileConstraint oldConstraint = null; for (ProfileConstraint currentConstraint : currentConstraints) { if (similarProfileReferences(currentConstraint, (ProfileConstraint)constraint)) { oldConstraint = currentConstraint; break; } } if (oldConstraint != null) { builder.append(getTargetSource()).append(": "); buildConstraintFormText(target, oldConstraint, printer, builder); builder.append("<BR/>"); } builder.append(getUpdatedSource()).append(": "); buildConstraintFormText(updated, profileConstraint, printer, builder); break; case ADD: builder.append(getUpdatedSource()).append(": "); buildConstraintFormText(updated, profileConstraint, printer, builder); break; case REMOVE: builder.append(getTargetSource()).append(": "); buildConstraintFormText(target, profileConstraint, printer, builder); break; default: } return builder.toString(); }
private String getEffectFormText(FormText text, IdentifiableRegistry<EPlanElement> identifiableRegistry) { if (text != null) { text.setColor("start", ColorConstants.darkGreen); text.setColor("end", ColorConstants.red); } PlanPrinter printer = new PlanPrinter(identifiableRegistry); StringBuilder builder = new StringBuilder(); switch (getDiffType()) { case MODIFY: EcoreEList<ProfileEffect> currentEffects = (EcoreEList)target.getMember(ProfileMember.class).getEffects(); ProfileEffect oldEffect = null; for (ProfileEffect currentEffect : currentEffects) { if (similarProfileReferences(currentEffect, effect)) { oldEffect = currentEffect; break; } } if (oldEffect != null) { builder.append(getTargetSource()).append(": "); buildEffectFormText(target, oldEffect, printer, builder); builder.append("<BR/>"); } builder.append(getUpdatedSource()).append(": "); buildEffectFormText(updated, effect, printer, builder); break; case ADD: builder.append(getUpdatedSource()).append(": "); buildEffectFormText(updated, effect, printer, builder); break; case REMOVE: builder.append(getTargetSource()).append(": "); buildEffectFormText(target, effect, printer, builder); break; default: } return builder.toString(); }
private Suggestion createAddEffectSuggestion() { EcoreEList<ProfileEffect> currentEffects = (EcoreEList)target.getMember(ProfileMember.class).getEffects(); // Need to make a copy so it doesn't get removed from the template ProfileEffect effectCopy = EMFUtils.copy(effect); IUndoableOperation operation = new FeatureTransactionAddOperation("Add Profile Effect", currentEffects, effectCopy); return new Suggestion(UPDATE_ACTIVITY_ICON, "Add Effect to Plan", operation); }
private Suggestion createModifyEffectSuggestion() { EcoreEList<ProfileEffect> currentEffects = (EcoreEList)target.getMember(ProfileMember.class).getEffects(); CompositeOperation operation = new CompositeOperation("Update Profile Effect"); for (ProfileEffect currentEffect : currentEffects) { if (similarProfileReferences(currentEffect, effect)) { operation.add(new FeatureTransactionRemoveOperation("Remove Profile Effect", currentEffects, currentEffect)); } } // Need to make a copy so it doesn't get removed from the template ProfileEffect effectCopy = EMFUtils.copy(effect); operation.add(new FeatureTransactionAddOperation("Add Profile Effect", currentEffects, effectCopy)); return new Suggestion(UPDATE_ACTIVITY_ICON, "Update Effect in Plan", operation); }
public EList<EReference> getEAllContainments() { if (eAllContainments == null) { BasicEList<EReference> result = new UniqueEList<EReference>() { private static final long serialVersionUID = 1L; @Override protected Object [] newData(int capacity) { return new EReference [capacity]; } @Override protected boolean useEquals() { return false; } }; for (EReference eReference : getEAllReferences()) { if (eReference.isContainment()) { result.add(eReference); } } result.shrink(); eAllContainments = new EcoreEList.UnmodifiableEList.FastCompare<EReference> (this, EcorePackage.eINSTANCE.getEClass_EAllContainments(), result.size(), result.data()); getESuperAdapter().setAllContainmentsCollectionModified(false); } return eAllContainments; }
@Override protected List<E> delegateBasicList() { int size = delegateSize(); if (size == 0) { return ECollections.emptyEList(); } else { Object[] data = eStore().toArray(owner, eStructuralFeature); return new EcoreEList.UnmodifiableEList<E>(owner, eStructuralFeature, data.length, data); } }
@Override protected List<FeatureMap.Entry> delegateBasicList() { int size = delegateSize(); if (size == 0) { return ECollections.emptyEList(); } else { Object[] data = eStore().toArray(owner, eStructuralFeature); return new EcoreEList.UnmodifiableEList<FeatureMap.Entry>(owner, eStructuralFeature, data.length, data); } }
public InternalSettingDelegateMany(int style, EStructuralFeature feature) { this.style = style; this.dataClass = Object.class; this.dynamicKind = EcoreEList.Generic.kind(feature); this.feature = feature; }
public InternalSettingDelegateMany(int style, EStructuralFeature feature, EReference inverseFeature) { this.style = style; this.dataClass = Object.class; this.dynamicKind = EcoreEList.Generic.kind(feature); this.feature = feature; this.inverseFeature = inverseFeature; }
@Override protected EStructuralFeature.Internal.SettingDelegate eSettingDelegate(final EStructuralFeature eFeature) { FragmentationType type = EMFFragUtil.getFragmentationType(eFeature); if (type == FragmentationType.None || type == FragmentationType.FragmentsContainment) { return ((EStructuralFeature.Internal) eFeature).getSettingDelegate(); } else { return new EStructuralFeatureImpl.InternalSettingDelegateMany(EStructuralFeatureImpl.InternalSettingDelegateMany.DATA_DYNAMIC, eFeature) { @Override protected Setting createDynamicSetting(InternalEObject owner) { int kind = EcoreEList.Generic.kind(eFeature); return new FValueSetList(kind, FInternalObjectImpl.class, FInternalObjectImpl.this, eFeature); } }; } }
/** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated NOT */ @Override public EList<VirtualConcept> getVirtualConcepts() { ArrayList<VirtualConcept> virtualConcepts = new ArrayList<>(); for (VirtualLink l : getVirtualLinks()) { if (l instanceof VirtualConcept) { virtualConcepts.add((VirtualConcept) l); } } return new EcoreEList.UnmodifiableEList<>(this, VirtualLinksPackage.eINSTANCE .getWeavingModel_VirtualConcepts(), virtualConcepts.size(), virtualConcepts.toArray()); }
/** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated NOT */ @Override public EList<VirtualProperty> getVirtualProperties() { ArrayList<VirtualProperty> virtualProperties = new ArrayList<>(); for (VirtualLink l : getVirtualLinks()) { if (l instanceof VirtualProperty) { virtualProperties.add((VirtualProperty) l); } } return new EcoreEList.UnmodifiableEList<>(this, VirtualLinksPackage.eINSTANCE .getWeavingModel_VirtualProperties(), virtualProperties.size(), virtualProperties.toArray()); }
/** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated NOT */ @Override public EList<VirtualAssociation> getVirtualAssociations() { ArrayList<VirtualAssociation> virtualAssociations = new ArrayList<>(); for (VirtualLink l : getVirtualLinks()) { if (l instanceof VirtualAssociation) { virtualAssociations.add((VirtualAssociation) l); } } return new EcoreEList.UnmodifiableEList<>(this, VirtualLinksPackage.eINSTANCE .getWeavingModel_VirtualAssociations(), virtualAssociations.size(), virtualAssociations.toArray()); }
/** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated NOT */ @Override public EList<VirtualElement> getVirtualElements() { ArrayList<VirtualElement> virtualElements = new ArrayList<>(); for (VirtualLink l : getVirtualLinks()) { if (l instanceof VirtualElement) { virtualElements.add((VirtualElement) l); } } return new EcoreEList.UnmodifiableEList<>(this, VirtualLinksPackage.eINSTANCE .getWeavingModel_VirtualElements(), virtualElements.size(), virtualElements.toArray()); }
/** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated NOT */ @Override public EList<Filter> getFilters() { ArrayList<Filter> filters = new ArrayList<>(); for (VirtualLink l : getVirtualLinks()) { if (l instanceof Filter) { filters.add((Filter) l); } } return new EcoreEList.UnmodifiableEList<>(this, VirtualLinksPackage.eINSTANCE .getWeavingModel_Filters(), filters.size(), filters.toArray()); }
@Override public EList<EStructuralFeature> getEStructuralFeatures() { // The return value must be castable to EStructuralFeature.Setting, // hence why we use an EcoreList.UnmodifiableElist List<EStructuralFeature> cs = getVisibleLocalFeatures(); return new EcoreEList.UnmodifiableEList<>( this, EcorePackage.Literals.ECLASS__ESTRUCTURAL_FEATURES, cs.size(), cs.toArray()); }
@Override public EList<EStructuralFeature> getEAllStructuralFeatures() { // The return value must be castable to EStructuralFeature.Setting, // hence why we use an EcoreList.UnmodifiableElist List<EStructuralFeature> cs = getVisibleFeatures(); return new EcoreEList.UnmodifiableEList<>( this, EcorePackage.Literals.ECLASS__ESTRUCTURAL_FEATURES, cs.size(), cs.toArray()); }
@Override public EList<EClassifier> getEClassifiers() { // The return value must be castable to EStructuralFeature.Setting, // hence why we use an EcoreList.UnmodifiableElist List<EClassifier> cs = getNonFilteredClassifiers(); return new EcoreEList.UnmodifiableEList<>( this, EcorePackage.Literals.EPACKAGE__ECLASSIFIERS, cs.size(), cs.toArray()); }