Search in sources :

Example 6 with ObeoDSMObject

use of org.obeonetwork.dsl.environment.ObeoDSMObject 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 7 with ObeoDSMObject

use of org.obeonetwork.dsl.environment.ObeoDSMObject 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 8 with ObeoDSMObject

use of org.obeonetwork.dsl.environment.ObeoDSMObject 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 9 with ObeoDSMObject

use of org.obeonetwork.dsl.environment.ObeoDSMObject in project InformationSystem by ObeoNetwork.

the class ParticipantParticipantPropertiesEditionComponent 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 Participant participant = (Participant) elt;
        final ParticipantPropertiesEditionPart participantPart = (ParticipantPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(InteractionViewsRepository.Participant.Properties.name))
            participantPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, participant.getName()));
        if (isAccessible(InteractionViewsRepository.Participant.Properties.type)) {
            // init part
            typeSettings = new EObjectFlatComboSettings(participant, InteractionPackage.eINSTANCE.getParticipant_Type());
            participantPart.initType(typeSettings);
            // set the button mode
            participantPart.setTypeButtonMode(ButtonsModeEnum.BROWSE);
        }
        if (isAccessible(InteractionViewsRepository.Participant.Properties.description))
            participantPart.setDescription(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, participant.getDescription()));
        if (isAccessible(InteractionViewsRepository.Participant.Properties.type)) {
            participantPart.addFilterToType(new ViewerFilter() {

                /**
                 * {@inheritDoc}
                 *
                 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
                 */
                public boolean select(Viewer viewer, Object parentElement, Object element) {
                    // $NON-NLS-1$
                    return (element instanceof String && element.equals("")) || (element instanceof ObeoDSMObject);
                }
            });
        // Start of user code for additional businessfilters for type
        // End of user code
        }
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : Participant(org.obeonetwork.dsl.interaction.Participant) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) ParticipantPropertiesEditionPart(org.obeonetwork.dsl.interaction.parts.ParticipantPropertiesEditionPart) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) EObjectFlatComboSettings(org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings)

Example 10 with ObeoDSMObject

use of org.obeonetwork.dsl.environment.ObeoDSMObject in project InformationSystem by ObeoNetwork.

the class StateMachineParentSelectionContentProvider method getElements.

@Override
public Object[] getElements(Object object) {
    if (object instanceof Object[]) {
        List<Object> elements = new ArrayList<Object>();
        for (Object input : (Object[]) object) {
            elements.addAll(Arrays.asList(getElements(input)));
        }
        return elements.toArray();
    } else {
        List<Object> result = new ArrayList<Object>();
        Object[] elements = super.getElements(object);
        for (Object element : elements) {
            if (element instanceof ObeoDSMObject && !(element instanceof Behaviour)) {
                result.add(element);
            }
        }
        return result.toArray();
    }
}
Also used : Behaviour(org.obeonetwork.dsl.environment.Behaviour) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) ArrayList(java.util.ArrayList) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject)

Aggregations

ObeoDSMObject (org.obeonetwork.dsl.environment.ObeoDSMObject)20 EObject (org.eclipse.emf.ecore.EObject)10 ArrayList (java.util.ArrayList)7 Behaviour (org.obeonetwork.dsl.environment.Behaviour)4 Risk (fr.gouv.mindef.safran.graalextensions.Risk)3 Date (java.util.Date)3 EClass (org.eclipse.emf.ecore.EClass)3 MetaData (org.obeonetwork.dsl.environment.MetaData)3 MetaDataContainer (org.obeonetwork.dsl.environment.MetaDataContainer)3 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 AdapterFactory (org.eclipse.emf.common.notify.AdapterFactory)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 ComposedAdapterFactory (org.eclipse.emf.edit.provider.ComposedAdapterFactory)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 Session (org.eclipse.sirius.business.api.session.Session)2 IPermissionAuthority (org.eclipse.sirius.ecore.extender.business.api.permission.IPermissionAuthority)2 LockStatus (org.eclipse.sirius.ecore.extender.business.api.permission.LockStatus)2 Shell (org.eclipse.swt.widgets.Shell)2