Search in sources :

Example 1 with State

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

the class StateStatePropertiesEditionComponent 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 State state = (State) elt;
        final StatePropertiesEditionPart statePart = (StatePropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(StatemachineViewsRepository.State.Properties.description))
            statePart.setDescription(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, state.getDescription()));
        if (isAccessible(StatemachineViewsRepository.State.Properties.keywords))
            statePart.setKeywords(state.getKeywords());
        if (isAccessible(StatemachineViewsRepository.State.Properties.incomingTransitions)) {
            incomingTransitionsSettings = new ReferencesTableSettings(state, StateMachinePackage.eINSTANCE.getAbstractState_IncomingTransitions());
            statePart.initIncomingTransitions(incomingTransitionsSettings);
        }
        if (isAccessible(StatemachineViewsRepository.State.Properties.outcomingTransitions)) {
            outcomingTransitionsSettings = new ReferencesTableSettings(state, StateMachinePackage.eINSTANCE.getAbstractState_OutcomingTransitions());
            statePart.initOutcomingTransitions(outcomingTransitionsSettings);
        }
        if (isAccessible(StatemachineViewsRepository.State.Properties.name))
            statePart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, state.getName()));
        if (isAccessible(StatemachineViewsRepository.State.Properties.incomingTransitions)) {
            statePart.addFilterToIncomingTransitions(new EObjectFilter(StateMachinePackage.Literals.TRANSITION));
        // Start of user code for additional businessfilters for incomingTransitions
        // End of user code
        }
        if (isAccessible(StatemachineViewsRepository.State.Properties.outcomingTransitions)) {
            statePart.addFilterToOutcomingTransitions(new EObjectFilter(StateMachinePackage.Literals.TRANSITION));
        // Start of user code for additional businessfilters for outcomingTransitions
        // End of user code
        }
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : EObjectFilter(org.eclipse.emf.eef.runtime.impl.filters.EObjectFilter) ReferencesTableSettings(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings) State(org.obeonetwork.dsl.statemachine.State) StatePropertiesEditionPart(org.obeonetwork.dsl.statemachine.parts.StatePropertiesEditionPart)

Example 2 with State

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

the class StateStatePropertiesEditionComponent 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) {
    State state = (State) semanticObject;
    if (StatemachineViewsRepository.State.Properties.description == event.getAffectedEditor()) {
        state.setDescription((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
    }
    if (StatemachineViewsRepository.State.Properties.keywords == event.getAffectedEditor()) {
        if (event.getKind() == PropertiesEditionEvent.SET) {
            state.getKeywords().clear();
            state.getKeywords().addAll(((EList) event.getNewValue()));
        }
    }
    if (StatemachineViewsRepository.State.Properties.incomingTransitions == event.getAffectedEditor()) {
        if (event.getKind() == PropertiesEditionEvent.ADD) {
            if (event.getNewValue() instanceof Transition) {
                incomingTransitionsSettings.addToReference((EObject) event.getNewValue());
            }
        } else if (event.getKind() == PropertiesEditionEvent.REMOVE) {
            incomingTransitionsSettings.removeFromReference((EObject) event.getNewValue());
        } else if (event.getKind() == PropertiesEditionEvent.MOVE) {
            incomingTransitionsSettings.move(event.getNewIndex(), (Transition) event.getNewValue());
        }
    }
    if (StatemachineViewsRepository.State.Properties.outcomingTransitions == event.getAffectedEditor()) {
        if (event.getKind() == PropertiesEditionEvent.ADD) {
            if (event.getNewValue() instanceof Transition) {
                outcomingTransitionsSettings.addToReference((EObject) event.getNewValue());
            }
        } else if (event.getKind() == PropertiesEditionEvent.REMOVE) {
            outcomingTransitionsSettings.removeFromReference((EObject) event.getNewValue());
        } else if (event.getKind() == PropertiesEditionEvent.MOVE) {
            outcomingTransitionsSettings.move(event.getNewIndex(), (Transition) event.getNewValue());
        }
    }
    if (StatemachineViewsRepository.State.Properties.name == event.getAffectedEditor()) {
        state.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) State(org.obeonetwork.dsl.statemachine.State) EObject(org.eclipse.emf.ecore.EObject) Transition(org.obeonetwork.dsl.statemachine.Transition)

Example 3 with State

use of org.obeonetwork.dsl.statemachine.State 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)

Aggregations

State (org.obeonetwork.dsl.statemachine.State)3 ArrayList (java.util.ArrayList)1 BasicEList (org.eclipse.emf.common.util.BasicEList)1 EList (org.eclipse.emf.common.util.EList)1 EObject (org.eclipse.emf.ecore.EObject)1 EObjectFilter (org.eclipse.emf.eef.runtime.impl.filters.EObjectFilter)1 ReferencesTableSettings (org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)1 AbstractState (org.obeonetwork.dsl.statemachine.AbstractState)1 Region (org.obeonetwork.dsl.statemachine.Region)1 StateMachine (org.obeonetwork.dsl.statemachine.StateMachine)1 Transition (org.obeonetwork.dsl.statemachine.Transition)1 StatePropertiesEditionPart (org.obeonetwork.dsl.statemachine.parts.StatePropertiesEditionPart)1