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