Search in sources :

Example 1 with Risk

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

the class CustomRiskPropertiesEditionComponent 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 Risk riskObject = getRiskObject(obeoDSMObject);
        final RiskPropertiesEditionPart riskPart = (RiskPropertiesEditionPart) editingPart;
        // init values
        if (riskObject != null) {
            if (benefitsSettings.getSignificantObject() != null && isAccessible(GraalextensionsViewsRepository.Risk.Properties.benefits)) {
                riskPart.initBenefits(EEFUtils.choiceOfValues(benefitsSettings.getSignificantObject(), GraalExtensionsPackage.eINSTANCE.getRisk_Benefits()), (Enumerator) benefitsSettings.getValue());
            }
            if (drawbacksSettings.getSignificantObject() != null && isAccessible(GraalextensionsViewsRepository.Risk.Properties.drawbacks)) {
                riskPart.initDrawbacks(EEFUtils.choiceOfValues(drawbacksSettings.getSignificantObject(), GraalExtensionsPackage.eINSTANCE.getRisk_Drawbacks()), (Enumerator) drawbacksSettings.getValue());
            }
            if (riskSettings.getSignificantObject() != null && isAccessible(GraalextensionsViewsRepository.Risk.Properties.risk_)) {
                riskPart.initRisk(EEFUtils.choiceOfValues(riskSettings.getSignificantObject(), GraalExtensionsPackage.eINSTANCE.getRisk_Risk()), (Enumerator) riskSettings.getValue());
            }
        } else {
            riskPart.initBenefits(BenefitsLevel.values(), BenefitsLevel.UNDEFINED);
            riskPart.initDrawbacks(DrawbacksLevel.values(), DrawbacksLevel.UNDEFINED);
            riskPart.initRisk(RiskLevel.values(), RiskLevel.UNDEFINED);
        }
    // init filters
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) Risk(fr.gouv.mindef.safran.graalextensions.Risk) RiskPropertiesEditionPart(fr.gouv.mindef.safran.graalextensions.parts.RiskPropertiesEditionPart)

Example 2 with Risk

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

the class CustomRiskPropertiesEditionComponent method createRiskObject.

private Risk createRiskObject(EObject element) {
    if (element instanceof ObeoDSMObject) {
        ObeoDSMObject obeoDSMObject = (ObeoDSMObject) element;
        MetaDataContainer container = obeoDSMObject.getMetadatas();
        if (container == null) {
            container = EnvironmentFactory.eINSTANCE.createMetaDataContainer();
            obeoDSMObject.setMetadatas(container);
        }
        Risk newRisk = GraalExtensionsFactory.eINSTANCE.createRisk();
        container.getMetadatas().add(newRisk);
        return newRisk;
    }
    return null;
}
Also used : ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) Risk(fr.gouv.mindef.safran.graalextensions.Risk) MetaDataContainer(org.obeonetwork.dsl.environment.MetaDataContainer)

Example 3 with Risk

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

the class CustomEEFEditorSettings method getOrCreateSignificantObject.

public EObject getOrCreateSignificantObject() {
    EObject object = getSignificantObject();
    if (object == null) {
        if (getSource() instanceof ObeoDSMObject) {
            ObeoDSMObject source = (ObeoDSMObject) getSource();
            EditingDomain domain = context.getEditingDomain();
            if (source.getMetadatas() == null) {
                // Create MetaDataContainer
                MetaDataContainer mdContainer = EnvironmentFactory.eINSTANCE.createMetaDataContainer();
                domain.getCommandStack().execute(SetCommand.create(domain, source, EnvironmentPackage.eINSTANCE.getObeoDSMObject_Metadatas(), mdContainer));
            }
            // Create Risk
            Risk risk = GraalExtensionsFactory.eINSTANCE.createRisk();
            domain.getCommandStack().execute(AddCommand.create(domain, source.getMetadatas(), EnvironmentPackage.eINSTANCE.getMetaDataContainer_Metadatas(), risk));
            significantObject = getSignificantObject();
            return significantObject;
        }
    }
    return object;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) Risk(fr.gouv.mindef.safran.graalextensions.Risk) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) MetaDataContainer(org.obeonetwork.dsl.environment.MetaDataContainer)

Example 4 with Risk

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

the class RiskItemProvider method getText.

/**
 * This returns the label text for the adapted class.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
@Override
public String getText(Object object) {
    Risk riskObject = (Risk) object;
    BenefitsLevel benefitsValue = riskObject.getBenefits();
    String benefitsLabel = benefitsValue == null ? "" : benefitsValue.toString();
    DrawbacksLevel drawbacksValue = riskObject.getDrawbacks();
    String drawbacksLabel = drawbacksValue == null ? "" : drawbacksValue.toString();
    RiskLevel riskValue = riskObject.getRisk();
    String riskLabel = riskValue == null ? "" : riskValue.toString();
    String label = benefitsLabel + "/" + drawbacksLabel + "/" + riskLabel;
    return label == null || label.length() == 0 ? getString("_UI_Risk_type") : getString("_UI_Risk_type") + " " + label;
}
Also used : BenefitsLevel(fr.gouv.mindef.safran.graalextensions.BenefitsLevel) Risk(fr.gouv.mindef.safran.graalextensions.Risk) DrawbacksLevel(fr.gouv.mindef.safran.graalextensions.DrawbacksLevel) RiskLevel(fr.gouv.mindef.safran.graalextensions.RiskLevel)

Example 5 with Risk

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

the class CustomRiskPropertiesEditionComponent method updateSemanticModel.

/**
 * {@inheritDoc}
 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updateSemanticModel(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 */
public void updateSemanticModel(final IPropertiesEditionEvent event) {
    if (GraalextensionsViewsRepository.Risk.Properties.benefits == event.getAffectedEditor()) {
        Risk riskObject = getRiskObject(semanticObject);
        if (riskObject == null) {
            riskObject = createRiskObject(semanticObject);
        }
        benefitsSettings.setValue((BenefitsLevel) event.getNewValue());
    }
    if (GraalextensionsViewsRepository.Risk.Properties.drawbacks == event.getAffectedEditor()) {
        Risk riskObject = getRiskObject(semanticObject);
        if (riskObject == null) {
            createRiskObject(semanticObject);
        }
        drawbacksSettings.setValue((DrawbacksLevel) event.getNewValue());
    }
    if (GraalextensionsViewsRepository.Risk.Properties.risk_ == event.getAffectedEditor()) {
        Risk riskObject = getRiskObject(semanticObject);
        if (riskObject == null) {
            createRiskObject(semanticObject);
        }
        riskSettings.setValue((RiskLevel) event.getNewValue());
    }
}
Also used : Risk(fr.gouv.mindef.safran.graalextensions.Risk)

Aggregations

Risk (fr.gouv.mindef.safran.graalextensions.Risk)5 ObeoDSMObject (org.obeonetwork.dsl.environment.ObeoDSMObject)3 MetaDataContainer (org.obeonetwork.dsl.environment.MetaDataContainer)2 BenefitsLevel (fr.gouv.mindef.safran.graalextensions.BenefitsLevel)1 DrawbacksLevel (fr.gouv.mindef.safran.graalextensions.DrawbacksLevel)1 RiskLevel (fr.gouv.mindef.safran.graalextensions.RiskLevel)1 RiskPropertiesEditionPart (fr.gouv.mindef.safran.graalextensions.parts.RiskPropertiesEditionPart)1 EObject (org.eclipse.emf.ecore.EObject)1 EditingDomain (org.eclipse.emf.edit.domain.EditingDomain)1