Search in sources :

Example 1 with VersionPropertiesEditionPart

use of fr.gouv.mindef.safran.graalextensions.parts.VersionPropertiesEditionPart in project InformationSystem by ObeoNetwork.

the class VersionPropertiesEditionComponent 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 ObeoDSMObject obeoDSMObject = (ObeoDSMObject) elt;
        final VersionPropertiesEditionPart versionPart = (VersionPropertiesEditionPart) editingPart;
        if (isAccessible(GraalextensionsViewsRepository.Version.Properties.version_)) {
            versionPart.setVersion(obeoDSMObject.getVersion());
        }
        if (isAccessible(GraalextensionsViewsRepository.Version.Properties.createdOn))
            versionPart.setCreatedOn(EEFConverterUtil.convertToString(EcorePackage.Literals.EDATE, obeoDSMObject.getCreatedOn()));
        if (isAccessible(GraalextensionsViewsRepository.Version.Properties.modifiedOn))
            versionPart.setModifiedOn(EEFConverterUtil.convertToString(EcorePackage.Literals.EDATE, obeoDSMObject.getModifiedOn()));
        // init filters
        // Start of user code  for version filter update
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (obeoDSMObject.getModifiedOn() != null && isAccessible(GraalextensionsViewsRepository.Version.Properties.modifiedOn))
            versionPart.setModifiedOn(simpleDateFormat.format(obeoDSMObject.getModifiedOn()));
        if (obeoDSMObject.getCreatedOn() != null && isAccessible(GraalextensionsViewsRepository.Version.Properties.createdOn))
            versionPart.setCreatedOn(simpleDateFormat.format(obeoDSMObject.getCreatedOn()));
    // End of user code
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : VersionPropertiesEditionPart(fr.gouv.mindef.safran.graalextensions.parts.VersionPropertiesEditionPart) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with VersionPropertiesEditionPart

use of fr.gouv.mindef.safran.graalextensions.parts.VersionPropertiesEditionPart in project InformationSystem by ObeoNetwork.

the class VersionPropertiesEditionComponent 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()) {
        VersionPropertiesEditionPart versionPart = (VersionPropertiesEditionPart) editingPart;
        if (EnvironmentPackage.eINSTANCE.getObeoDSMObject_Version().equals(msg.getFeature()) && versionPart != null && isAccessible(GraalextensionsViewsRepository.Version.Properties.version_)) {
            if (msg.getNewValue() != null) {
                versionPart.setVersion((Integer) msg.getNewValue());
            } else {
                versionPart.setVersion(null);
            }
        }
        if (EnvironmentPackage.eINSTANCE.getObeoDSMObject_ModifiedOn().equals(msg.getFeature()) && versionPart != null && isAccessible(GraalextensionsViewsRepository.Version.Properties.modifiedOn)) {
            if (msg.getNewValue() != null) {
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                versionPart.setModifiedOn(simpleDateFormat.format(msg.getNewValue()));
            } else {
                versionPart.setModifiedOn("");
            }
            return;
        }
        if (EnvironmentPackage.eINSTANCE.getObeoDSMObject_CreatedOn().equals(msg.getFeature()) && versionPart != null && isAccessible(GraalextensionsViewsRepository.Version.Properties.createdOn)) {
            if (msg.getNewValue() != null) {
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                versionPart.setCreatedOn(simpleDateFormat.format(msg.getNewValue()));
            } else {
                versionPart.setCreatedOn("");
            }
            return;
        }
        if (EnvironmentPackage.eINSTANCE.getObeoDSMObject_CreatedOn().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && versionPart != null && isAccessible(GraalextensionsViewsRepository.Version.Properties.createdOn)) {
            if (msg.getNewValue() != null) {
                versionPart.setCreatedOn(EcoreUtil.convertToString(EcorePackage.Literals.EDATE, msg.getNewValue()));
            } else {
                versionPart.setCreatedOn("");
            }
        }
        if (EnvironmentPackage.eINSTANCE.getObeoDSMObject_ModifiedOn().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && versionPart != null && isAccessible(GraalextensionsViewsRepository.Version.Properties.modifiedOn)) {
            if (msg.getNewValue() != null) {
                versionPart.setModifiedOn(EcoreUtil.convertToString(EcorePackage.Literals.EDATE, msg.getNewValue()));
            } else {
                versionPart.setModifiedOn("");
            }
        }
    }
}
Also used : VersionPropertiesEditionPart(fr.gouv.mindef.safran.graalextensions.parts.VersionPropertiesEditionPart) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

VersionPropertiesEditionPart (fr.gouv.mindef.safran.graalextensions.parts.VersionPropertiesEditionPart)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ObeoDSMObject (org.obeonetwork.dsl.environment.ObeoDSMObject)1