Search in sources :

Example 6 with State

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

the class CreateSubdiagramCommand method isEnabled.

@Override
public boolean isEnabled() {
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (activeWorkbenchWindow == null)
        return false;
    ISelection selection = activeWorkbenchWindow.getActivePage().getSelection();
    if (selection == null)
        return false;
    Node unwrap = unwrap(selection);
    if (unwrap == null) {
        return false;
    }
    State state = (State) unwrap.getElement();
    if (state == null || state.isComposite())
        return false;
    BooleanValueStyle inlineStyle = DiagramPartitioningUtil.getInlineStyle(unwrap);
    if (inlineStyle != null && !inlineStyle.isBooleanValue())
        return false;
    return super.isEnabled();
}
Also used : BooleanValueStyle(org.eclipse.gmf.runtime.notation.BooleanValueStyle) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) State(org.yakindu.sct.model.sgraph.State) Node(org.eclipse.gmf.runtime.notation.Node) ISelection(org.eclipse.jface.viewers.ISelection)

Example 7 with State

use of org.yakindu.sct.model.sgraph.State 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 8 with State

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

the class STextScopeProvider method scope_ActiveStateReferenceExpression_value.

public IScope scope_ActiveStateReferenceExpression_value(EObject context, EReference reference) {
    Statechart statechart = getStatechart(context);
    if (statechart == null)
        return IScope.NULLSCOPE;
    List<State> allStates = EcoreUtil2.getAllContentsOfType(statechart, State.class);
    IScope scope = Scopes.scopeFor(allStates, nameProvider, IScope.NULLSCOPE);
    return new ImportScope(getActiveStateNormalizer(context), scope, new EObjectDescriptionLookUp(Lists.newArrayList(scope.getAllElements())), reference.getEReferenceType(), false);
}
Also used : EObjectDescriptionLookUp(org.eclipse.xtext.resource.impl.EObjectDescriptionLookUp) State(org.yakindu.sct.model.sgraph.State) ImportScope(org.eclipse.xtext.scoping.impl.ImportScope) Statechart(org.yakindu.sct.model.sgraph.Statechart) IScope(org.eclipse.xtext.scoping.IScope)

Example 9 with State

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

the class GroupStatesIntoCompositeRefactoring method doSemanticalRefactoring.

protected void doSemanticalRefactoring() {
    compositeState = createCompositeState();
    innerRegion = SGraphFactory.eINSTANCE.createRegion();
    // TODO check for uniqueness?
    innerRegion.setName("inner region");
    compositeState.getRegions().add(innerRegion);
    for (State state : contextStates) {
        innerRegion.getVertices().add(state);
    }
}
Also used : State(org.yakindu.sct.model.sgraph.State)

Example 10 with State

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

the class GroupStatesIntoCompositeRefactoring method createCompositeState.

protected State createCompositeState() {
    State compositeState = SGraphFactory.eINSTANCE.createState();
    compositeState.setName(getNameForCompositeState());
    getParentRegion().getVertices().add(compositeState);
    return compositeState;
}
Also used : State(org.yakindu.sct.model.sgraph.State)

Aggregations

State (org.yakindu.sct.model.sgraph.State)106 Test (org.junit.Test)77 Region (org.yakindu.sct.model.sgraph.Region)63 Statechart (org.yakindu.sct.model.sgraph.Statechart)59 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)51 SGraphTestFactory._createState (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState)51 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)51 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)50 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)46 VariableDefinition (org.yakindu.sct.model.stext.stext.VariableDefinition)46 StextTestFactory._createInterfaceScope (org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope)46 StextTestFactory._createVariableDefinition (org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition)46 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)39 Sequence (org.yakindu.sct.model.sexec.Sequence)36 FinalState (org.yakindu.sct.model.sgraph.FinalState)35 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)28 Transition (org.yakindu.sct.model.sgraph.Transition)23 EnterState (org.yakindu.sct.model.sexec.EnterState)21