Search in sources :

Example 6 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class DiagramPartitioningUtil method openEditor.

/**
 * Opens a subdiagram for a given {@link Diagram}
 */
public static IEditorPart openEditor(Diagram diagramToOpen) {
    IFile file = WorkspaceSynchronizer.getFile(diagramToOpen.eResource());
    try {
        IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
        final IWorkbenchPage wbPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        if (diagramToOpen.getElement() instanceof Statechart) {
            return wbPage.openEditor(new FileEditorInput(file), desc.getId());
        } else if (diagramToOpen.getElement() instanceof State) {
            return wbPage.openEditor(new DiagramEditorInput(diagramToOpen), desc.getId());
        }
    } catch (PartInitException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : IDiagramEditorInput(org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramEditorInput) IFile(org.eclipse.core.resources.IFile) State(org.yakindu.sct.model.sgraph.State) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Statechart(org.yakindu.sct.model.sgraph.Statechart) PartInitException(org.eclipse.ui.PartInitException)

Example 7 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class JavaGeneratorModule method configureForExecutionStyle.

public void configureForExecutionStyle(GeneratorEntry entry, Binder binder) {
    Statechart statechart = (Statechart) entry.getElementRef();
    Annotation eventDrivenAnnotation = statechart.getAnnotationOfType(EVENT_DRIVEN_ANNOTATION);
    if (eventDrivenAnnotation != null) {
        binder.bind(Statemachine.class).to(EventDrivenStatemachine.class);
    }
}
Also used : EventDrivenStatemachine(org.yakindu.sct.generator.java.eventdriven.EventDrivenStatemachine) Statechart(org.yakindu.sct.model.sgraph.Statechart) Annotation(org.yakindu.base.types.Annotation)

Example 8 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class CppCodeGeneratorModule method bindEventDrivenClasses.

protected void bindEventDrivenClasses(GeneratorEntry entry, Binder binder) {
    Statechart statechart = (Statechart) entry.getElementRef();
    Annotation eventDrivenAnnotation = statechart.getAnnotationOfType(EVENT_DRIVEN_ANNOTATION);
    if (eventDrivenAnnotation != null) {
        binder.bind(StatemachineHeader.class).to(EventDrivenStatemachineHeader.class);
        binder.bind(StatemachineImplementation.class).to(EventDrivenStatemachineImplementation.class);
        binder.bind(CppExpressionsGenerator.class).to(EventDrivenExpressionCode.class);
        binder.bind(EventCode.class).to(EventDrivenEventCode.class);
        binder.bind(StandardCppIncludeProvider.class).to(EventDrivenCppIncludeProvider.class);
    }
}
Also used : EventDrivenStatemachineImplementation(org.yakindu.sct.generator.cpp.eventdriven.EventDrivenStatemachineImplementation) Statechart(org.yakindu.sct.model.sgraph.Statechart) EventDrivenStatemachineHeader(org.yakindu.sct.generator.cpp.eventdriven.EventDrivenStatemachineHeader) Annotation(org.yakindu.base.types.Annotation) EventDrivenEventCode(org.yakindu.sct.generator.cpp.eventdriven.EventDrivenEventCode)

Example 9 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class SCTUnitTestModels method loadAllStatecharts.

public List<Statechart> loadAllStatecharts() throws Exception {
    List<Statechart> result = new ArrayList<>();
    Field[] fields = getClass().getFields();
    for (Field field : fields) {
        String value = (String) field.get(this);
        if (value.endsWith(".sct")) {
            result.add(loadStatechartFromResource(value));
        }
    }
    return result;
}
Also used : Field(java.lang.reflect.Field) ArrayList(java.util.ArrayList) Statechart(org.yakindu.sct.model.sgraph.Statechart)

Example 10 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class CPPDefaultFeatureValueProvider method setDefaultValue.

@Override
protected void setDefaultValue(FeatureType featureType, FeatureParameterValue parameterValue, EObject contextElement) {
    GeneratorEntry entry = (GeneratorEntry) contextElement;
    Statechart statechart = (Statechart) entry.getElementRef();
    if (parameterValue.getParameter().getName().equals(ICFeatureConstants.PARAMETER_NAMING_MODULE_NAME)) {
        parameterValue.setValue(asIdentifier(statechart.getName(), "_"));
    } else if (parameterValue.getParameter().getName().equals(ICFeatureConstants.PARAMETER_NAMING_STATEMACHINE_PREFIX)) {
        parameterValue.setValue(StringExtensions.toFirstLower(asIdentifier(statechart.getName(), "_")));
    } else if (parameterValue.getParameter().getName().equals(ICFeatureConstants.PARAMETER_NAMING_MAX_IDENTIFIER_LENGTH)) {
        parameterValue.setValue("31");
    } else if (parameterValue.getParameter().getName().equals(ICFeatureConstants.PARAMETER_NAMING_SEPARATOR)) {
        parameterValue.setValue("_");
    } else if (parameterValue.getParameter().getName().equals(CPPFeatureConstants.PARAMETER_INNER_FUNCTION_VISIBILITY)) {
        parameterValue.setValue(Visibility.PRIVATE.toString().toLowerCase());
    } else if (parameterValue.getParameter().getName().equals(CPPFeatureConstants.PARAMETER_STATIC_OPC)) {
        parameterValue.setValue(false);
    } else if (parameterValue.getParameter().getName().equals(CPPFeatureConstants.PARAMETER_INCLUDES_USE_RELATIVE_PATHS)) {
        parameterValue.setValue(true);
    } else if (parameterValue.getParameter().getName().equals(CPPFeatureConstants.PARAMETER_API_CHECK_UNIMPLEMENTED_OCBS)) {
        parameterValue.setValue(true);
    }
}
Also used : GeneratorEntry(org.yakindu.sct.model.sgen.GeneratorEntry) Statechart(org.yakindu.sct.model.sgraph.Statechart)

Aggregations

Statechart (org.yakindu.sct.model.sgraph.Statechart)132 Test (org.junit.Test)89 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)65 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)63 Region (org.yakindu.sct.model.sgraph.Region)59 State (org.yakindu.sct.model.sgraph.State)59 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)57 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)57 SGraphTestFactory._createState (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState)51 VariableDefinition (org.yakindu.sct.model.stext.stext.VariableDefinition)48 StextTestFactory._createInterfaceScope (org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope)48 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)47 StextTestFactory._createVariableDefinition (org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition)47 Sequence (org.yakindu.sct.model.sexec.Sequence)40 Entry (org.yakindu.sct.model.sgraph.Entry)30 SCTTestUtil.findState (org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.findState)29 SGraphTestFactory._createEntry (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createEntry)29 Reaction (org.yakindu.sct.model.sexec.Reaction)25 Scope (org.yakindu.sct.model.sgraph.Scope)25 EnterState (org.yakindu.sct.model.sexec.EnterState)21