Search in sources :

Example 1 with RequirementPropertiesEditionPart

use of org.obeonetwork.dsl.requirement.parts.RequirementPropertiesEditionPart in project InformationSystem by ObeoNetwork.

the class RequirementRequirementPropertiesEditionComponent method initPart.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
    setInitializing(true);
    if (editingPart != null && key == partKey) {
        editingPart.setContext(elt, allResource);
        final Requirement requirement = (Requirement) elt;
        final RequirementPropertiesEditionPart requirementPart = (RequirementPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(RequirementViewsRepository.Requirement_.id))
            requirementPart.setId(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, requirement.getId()));
        if (isAccessible(RequirementViewsRepository.Requirement_.version)) {
            requirementPart.setVersion(requirement.getVersion());
        }
        if (isAccessible(RequirementViewsRepository.Requirement_.name))
            requirementPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, requirement.getName()));
        if (isAccessible(RequirementViewsRepository.Requirement_.statement))
            requirementPart.setStatement(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, requirement.getStatement()));
        if (isAccessible(RequirementViewsRepository.Requirement_.type)) {
            requirementPart.initType(EEFUtils.choiceOfValues(requirement, RequirementPackage.eINSTANCE.getRequirement_Type()), requirement.getType());
        }
        if (isAccessible(RequirementViewsRepository.Requirement_.status))
            requirementPart.setStatus(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, requirement.getStatus()));
        if (isAccessible(RequirementViewsRepository.Requirement_.subtype))
            requirementPart.setSubtype(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, requirement.getSubtype()));
        if (isAccessible(RequirementViewsRepository.Requirement_.modifiedOn))
            requirementPart.setModifiedOn(EEFConverterUtil.convertToString(EcorePackage.Literals.EDATE, requirement.getModifiedOn()));
        if (isAccessible(RequirementViewsRepository.Requirement_.createdOn))
            requirementPart.setCreatedOn(EEFConverterUtil.convertToString(EcorePackage.Literals.EDATE, requirement.getCreatedOn()));
        // init filters
        // Start of user code  for version filter update
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (requirement.getModifiedOn() != null && isAccessible(RequirementViewsRepository.Requirement_.modifiedOn))
            requirementPart.setModifiedOn(simpleDateFormat.format(requirement.getModifiedOn()));
        if (requirement.getCreatedOn() != null && isAccessible(RequirementViewsRepository.Requirement_.createdOn))
            requirementPart.setCreatedOn(simpleDateFormat.format(requirement.getCreatedOn()));
    // End of user code
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : Requirement(org.obeonetwork.dsl.requirement.Requirement) RequirementPropertiesEditionPart(org.obeonetwork.dsl.requirement.parts.RequirementPropertiesEditionPart) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with RequirementPropertiesEditionPart

use of org.obeonetwork.dsl.requirement.parts.RequirementPropertiesEditionPart in project InformationSystem by ObeoNetwork.

the class RequirementRequirementPropertiesEditionComponent method updatePart.

/**
 * {@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()) {
        RequirementPropertiesEditionPart requirementPart = (RequirementPropertiesEditionPart) editingPart;
        if (RequirementPackage.eINSTANCE.getRequirement_Id().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && requirementPart != null && isAccessible(RequirementViewsRepository.Requirement_.id)) {
            if (msg.getNewValue() != null) {
                requirementPart.setId(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue()));
            } else {
                requirementPart.setId("");
            }
        }
        if (RequirementPackage.eINSTANCE.getRequirement_Version().equals(msg.getFeature()) && requirementPart != null && isAccessible(RequirementViewsRepository.Requirement_.version)) {
            if (msg.getNewValue() != null) {
                requirementPart.setVersion((Integer) msg.getNewValue());
            } else {
                requirementPart.setVersion(null);
            }
        }
        if (RequirementPackage.eINSTANCE.getRequirement_ModifiedOn().equals(msg.getFeature()) && requirementPart != null && isAccessible(RequirementViewsRepository.Requirement_.modifiedOn)) {
            if (msg.getNewValue() != null) {
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                requirementPart.setModifiedOn(simpleDateFormat.format(msg.getNewValue()));
            } else {
                requirementPart.setModifiedOn("");
            }
            return;
        }
        if (RequirementPackage.eINSTANCE.getRequirement_CreatedOn().equals(msg.getFeature()) && requirementPart != null && isAccessible(RequirementViewsRepository.Requirement_.createdOn)) {
            if (msg.getNewValue() != null) {
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                requirementPart.setCreatedOn(simpleDateFormat.format(msg.getNewValue()));
            } else {
                requirementPart.setCreatedOn("");
            }
            return;
        }
        if (RequirementPackage.eINSTANCE.getNamedElement_Name().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && requirementPart != null && isAccessible(RequirementViewsRepository.Requirement_.name)) {
            if (msg.getNewValue() != null) {
                requirementPart.setName(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue()));
            } else {
                requirementPart.setName("");
            }
        }
        if (RequirementPackage.eINSTANCE.getRequirement_Statement().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && requirementPart != null && isAccessible(RequirementViewsRepository.Requirement_.statement)) {
            if (msg.getNewValue() != null) {
                requirementPart.setStatement(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue()));
            } else {
                requirementPart.setStatement("");
            }
        }
        if (RequirementPackage.eINSTANCE.getRequirement_Type().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && isAccessible(RequirementViewsRepository.Requirement_.type))
            requirementPart.setType((RequirementType) msg.getNewValue());
        if (RequirementPackage.eINSTANCE.getRequirement_Status().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && requirementPart != null && isAccessible(RequirementViewsRepository.Requirement_.status)) {
            if (msg.getNewValue() != null) {
                requirementPart.setStatus(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue()));
            } else {
                requirementPart.setStatus("");
            }
        }
        if (RequirementPackage.eINSTANCE.getRequirement_Subtype().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && requirementPart != null && isAccessible(RequirementViewsRepository.Requirement_.subtype)) {
            if (msg.getNewValue() != null) {
                requirementPart.setSubtype(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue()));
            } else {
                requirementPart.setSubtype("");
            }
        }
        if (RequirementPackage.eINSTANCE.getRequirement_ModifiedOn().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && requirementPart != null && isAccessible(RequirementViewsRepository.Requirement_.modifiedOn)) {
            if (msg.getNewValue() != null) {
                requirementPart.setModifiedOn(EcoreUtil.convertToString(EcorePackage.Literals.EDATE, msg.getNewValue()));
            } else {
                requirementPart.setModifiedOn("");
            }
        }
        if (RequirementPackage.eINSTANCE.getRequirement_CreatedOn().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && requirementPart != null && isAccessible(RequirementViewsRepository.Requirement_.createdOn)) {
            if (msg.getNewValue() != null) {
                requirementPart.setCreatedOn(EcoreUtil.convertToString(EcorePackage.Literals.EDATE, msg.getNewValue()));
            } else {
                requirementPart.setCreatedOn("");
            }
        }
    }
}
Also used : RequirementPropertiesEditionPart(org.obeonetwork.dsl.requirement.parts.RequirementPropertiesEditionPart) RequirementType(org.obeonetwork.dsl.requirement.RequirementType) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

SimpleDateFormat (java.text.SimpleDateFormat)2 RequirementPropertiesEditionPart (org.obeonetwork.dsl.requirement.parts.RequirementPropertiesEditionPart)2 Requirement (org.obeonetwork.dsl.requirement.Requirement)1 RequirementType (org.obeonetwork.dsl.requirement.RequirementType)1