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);
}
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;
}
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;
}
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;
}
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());
}
}
Aggregations