Search in sources :

Example 1 with Region

use of org.obeonetwork.dsl.statemachine.Region in project InformationSystem by ObeoNetwork.

the class StateMachineStateMachinePropertiesEditionComponent 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) {
    StateMachine stateMachine = (StateMachine) semanticObject;
    if (StatemachineViewsRepository.StateMachine_.Properties.description == event.getAffectedEditor()) {
        stateMachine.setDescription((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
    }
    if (StatemachineViewsRepository.StateMachine_.Properties.keywords == event.getAffectedEditor()) {
        if (event.getKind() == PropertiesEditionEvent.SET) {
            stateMachine.getKeywords().clear();
            stateMachine.getKeywords().addAll(((EList) event.getNewValue()));
        }
    }
    if (StatemachineViewsRepository.StateMachine_.Properties.name == event.getAffectedEditor()) {
        stateMachine.setName((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
    }
    if (StatemachineViewsRepository.StateMachine_.Properties.regions == event.getAffectedEditor()) {
        if (event.getKind() == PropertiesEditionEvent.ADD) {
            EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, regionsSettings, editingContext.getAdapterFactory());
            PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt(semanticObject, PropertiesEditingProvider.class);
            if (provider != null) {
                PropertiesEditingPolicy policy = provider.getPolicy(context);
                if (policy instanceof CreateEditingPolicy) {
                    policy.execute();
                }
            }
        } else if (event.getKind() == PropertiesEditionEvent.EDIT) {
            EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory());
            PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class);
            if (provider != null) {
                PropertiesEditingPolicy editionPolicy = provider.getPolicy(context);
                if (editionPolicy != null) {
                    editionPolicy.execute();
                }
            }
        } else if (event.getKind() == PropertiesEditionEvent.REMOVE) {
            regionsSettings.removeFromReference((EObject) event.getNewValue());
        } else if (event.getKind() == PropertiesEditionEvent.MOVE) {
            regionsSettings.move(event.getNewIndex(), (Region) event.getNewValue());
        }
    }
}
Also used : EObjectPropertiesEditionContext(org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext) BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) PropertiesEditingProvider(org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider) StateMachine(org.obeonetwork.dsl.statemachine.StateMachine) EObject(org.eclipse.emf.ecore.EObject) Region(org.obeonetwork.dsl.statemachine.Region) PropertiesEditingPolicy(org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy) CreateEditingPolicy(org.eclipse.emf.eef.runtime.policies.impl.CreateEditingPolicy) EReferencePropertiesEditionContext(org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext)

Example 2 with Region

use of org.obeonetwork.dsl.statemachine.Region in project InformationSystem by ObeoNetwork.

the class StateMachineServices method evaluateLabel.

public String evaluateLabel(EObject context) {
    // ['State_' + container.oclAsType(statemachine::StateMachine).states->filter(statemachine::State)->size()/]
    String label = "State_";
    List<AbstractState> abstractStates = null;
    if (context.eContainer() instanceof StateMachine) {
        abstractStates = ((StateMachine) context.eContainer()).getStates();
    } else if (context.eContainer() instanceof Region) {
        abstractStates = ((Region) context.eContainer()).getStates();
    }
    List<State> states = new ArrayList<State>();
    for (AbstractState absState : abstractStates) {
        if (absState instanceof State) {
            states.add((State) absState);
        }
    }
    return label + states.size();
}
Also used : StateMachine(org.obeonetwork.dsl.statemachine.StateMachine) State(org.obeonetwork.dsl.statemachine.State) AbstractState(org.obeonetwork.dsl.statemachine.AbstractState) AbstractState(org.obeonetwork.dsl.statemachine.AbstractState) ArrayList(java.util.ArrayList) Region(org.obeonetwork.dsl.statemachine.Region)

Example 3 with Region

use of org.obeonetwork.dsl.statemachine.Region in project InformationSystem by ObeoNetwork.

the class RegionRegionPropertiesEditionComponent 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) {
    Region region = (Region) semanticObject;
    if (StatemachineViewsRepository.Region.Properties.description == event.getAffectedEditor()) {
        region.setDescription((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
    }
    if (StatemachineViewsRepository.Region.Properties.keywords == event.getAffectedEditor()) {
        if (event.getKind() == PropertiesEditionEvent.SET) {
            region.getKeywords().clear();
            region.getKeywords().addAll(((EList) event.getNewValue()));
        }
    }
    if (StatemachineViewsRepository.Region.Properties.name == event.getAffectedEditor()) {
        region.setName((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
    }
}
Also used : BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) Region(org.obeonetwork.dsl.statemachine.Region)

Example 4 with Region

use of org.obeonetwork.dsl.statemachine.Region in project InformationSystem by ObeoNetwork.

the class RegionRegionPropertiesEditionComponent 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 Region region = (Region) elt;
        final RegionPropertiesEditionPart regionPart = (RegionPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(StatemachineViewsRepository.Region.Properties.description))
            regionPart.setDescription(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, region.getDescription()));
        if (isAccessible(StatemachineViewsRepository.Region.Properties.keywords))
            regionPart.setKeywords(region.getKeywords());
        if (isAccessible(StatemachineViewsRepository.Region.Properties.name))
            regionPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, region.getName()));
    // init filters
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : Region(org.obeonetwork.dsl.statemachine.Region) RegionPropertiesEditionPart(org.obeonetwork.dsl.statemachine.parts.RegionPropertiesEditionPart)

Example 5 with Region

use of org.obeonetwork.dsl.statemachine.Region in project InformationSystem by ObeoNetwork.

the class StateMachineStateMachinePropertiesEditionComponent 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 StateMachine stateMachine = (StateMachine) elt;
        final StateMachinePropertiesEditionPart stateMachinePart = (StateMachinePropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(StatemachineViewsRepository.StateMachine_.Properties.description))
            stateMachinePart.setDescription(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, stateMachine.getDescription()));
        if (isAccessible(StatemachineViewsRepository.StateMachine_.Properties.keywords))
            stateMachinePart.setKeywords(stateMachine.getKeywords());
        if (isAccessible(StatemachineViewsRepository.StateMachine_.Properties.name))
            stateMachinePart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, stateMachine.getName()));
        if (isAccessible(StatemachineViewsRepository.StateMachine_.Properties.regions)) {
            regionsSettings = new ReferencesTableSettings(stateMachine, StateMachinePackage.eINSTANCE.getStateMachine_Regions());
            stateMachinePart.initRegions(regionsSettings);
        }
        if (isAccessible(StatemachineViewsRepository.StateMachine_.Properties.regions)) {
            stateMachinePart.addFilterToRegions(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 Region);
                }
            });
        // Start of user code for additional businessfilters for regions
        // End of user code
        }
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : ReferencesTableSettings(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) StateMachine(org.obeonetwork.dsl.statemachine.StateMachine) Region(org.obeonetwork.dsl.statemachine.Region) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject) StateMachinePropertiesEditionPart(org.obeonetwork.dsl.statemachine.parts.StateMachinePropertiesEditionPart)

Aggregations

Region (org.obeonetwork.dsl.statemachine.Region)5 StateMachine (org.obeonetwork.dsl.statemachine.StateMachine)3 BasicEList (org.eclipse.emf.common.util.BasicEList)2 EList (org.eclipse.emf.common.util.EList)2 EObject (org.eclipse.emf.ecore.EObject)2 ArrayList (java.util.ArrayList)1 EObjectPropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext)1 EReferencePropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext)1 PropertiesEditingPolicy (org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy)1 CreateEditingPolicy (org.eclipse.emf.eef.runtime.policies.impl.CreateEditingPolicy)1 PropertiesEditingProvider (org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider)1 ReferencesTableSettings (org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 AbstractState (org.obeonetwork.dsl.statemachine.AbstractState)1 State (org.obeonetwork.dsl.statemachine.State)1 RegionPropertiesEditionPart (org.obeonetwork.dsl.statemachine.parts.RegionPropertiesEditionPart)1 StateMachinePropertiesEditionPart (org.obeonetwork.dsl.statemachine.parts.StateMachinePropertiesEditionPart)1