Search in sources :

Example 1 with Statechart

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

the class SGenTestScopeProvider method createDummyModel.

private Statechart createDummyModel() {
    Statechart chart = SGraphFactory.eINSTANCE.createStatechart();
    chart.setName("Example");
    resource.getContents().add(chart);
    return chart;
}
Also used : Statechart(org.yakindu.sct.model.sgraph.Statechart)

Example 2 with Statechart

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

the class SCTHotModelReplacementManager method handleHotModelReplacement.

private void handleHotModelReplacement() {
    // first implementation: If the underlying model does not change
    // semantically, no notification is required...
    List<IDebugTarget> targets = getAffectedTargets();
    List<IDebugTarget> modelReplacementFailedTargets = new ArrayList<IDebugTarget>();
    for (IDebugTarget sctDebugTarget : targets) {
        // Reload the Statechart form the changes resource
        Statechart newStatechart = ResourceUtil.loadStatechart(((SCTDebugElement) sctDebugTarget).getResourceString());
        if (!EcoreUtil.equals(newStatechart, (EObject) sctDebugTarget.getAdapter(EObject.class))) {
            // The model semantically changed, we have to create a
            // notificiation for that....
            modelReplacementFailedTargets.add(sctDebugTarget);
        }
    }
    if (modelReplacementFailedTargets.size() > 0) {
        notifyHotModelReplacementFailed(targets);
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) IDebugTarget(org.eclipse.debug.core.model.IDebugTarget) Statechart(org.yakindu.sct.model.sgraph.Statechart)

Example 3 with Statechart

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

the class StatechartDefinitionSection method createSpecificationEditor.

protected EmbeddedEditor createSpecificationEditor() {
    EmbeddedEditor embeddedEditor = createEmbeddedEditor();
    EmbeddedEditorModelAccess modelAccess = embeddedEditor.createPartialEditor();
    String specification = ((Statechart) getContextObject()).getSpecification();
    modelAccess.updateModel(specification != null ? specification : "");
    GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(embeddedEditor.getViewer().getControl());
    initializeEmbeddedEditorWidget(embeddedEditor);
    return embeddedEditor;
}
Also used : EmbeddedEditor(org.eclipse.xtext.ui.editor.embedded.EmbeddedEditor) Statechart(org.yakindu.sct.model.sgraph.Statechart) EmbeddedEditorModelAccess(org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorModelAccess)

Example 4 with Statechart

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

the class StatechartDefinitionSection method createNameLabel.

protected void createNameLabel(Composite labelComposite) {
    Text nameLabel = new Text(labelComposite, SWT.SINGLE | SWT.NORMAL);
    GridDataFactory.fillDefaults().indent(5, 1).grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(nameLabel);
    nameLabel.setText(getStatechartName());
    nameLabel.setEditable(isStatechart());
    nameLabel.setBackground(ColorConstants.white);
    nameModificationListener = new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            if (getContextObject() instanceof Statechart) {
                getSash().setRedraw(false);
                TransactionalEditingDomain domain = getTransactionalEditingDomain();
                SetCommand command = new SetCommand(domain, getContextObject(), BasePackage.Literals.NAMED_ELEMENT__NAME, nameLabel.getText());
                domain.getCommandStack().execute(command);
                refresh(nameLabel.getParent());
                getSash().setRedraw(true);
            }
        }
    };
    nameLabel.addModifyListener(nameModificationListener);
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) ModifyListener(org.eclipse.swt.events.ModifyListener) Statechart(org.yakindu.sct.model.sgraph.Statechart) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) SetCommand(org.eclipse.emf.edit.command.SetCommand)

Example 5 with Statechart

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

the class DiagramPartitioningEditor method closeSubdiagramEditors.

protected void closeSubdiagramEditors() {
    if (getDiagram() != null && getDiagram().getElement() instanceof Statechart) {
        List<IEditorReference> refsToClose = new ArrayList<IEditorReference>();
        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (workbenchWindow == null)
            return;
        IWorkbenchPage activePage = workbenchWindow.getActivePage();
        if (activePage == null)
            return;
        IEditorReference[] refs = activePage.getEditorReferences();
        for (IEditorReference ref : refs) {
            try {
                if (ref.getEditorInput() instanceof IDiagramEditorInput) {
                    IDiagramEditorInput diagramInput = (IDiagramEditorInput) ref.getEditorInput();
                    if (diagramInput.getDiagram().eResource() == getDiagram().eResource()) {
                        refsToClose.add(ref);
                    }
                }
            } catch (PartInitException e) {
                e.printStackTrace();
            }
        }
        if (refsToClose.size() > 0) {
            boolean close = MessageDialog.openQuestion(activePage.getActivePart().getSite().getShell(), "Close subdiagram editors?", "There are still subdiagram editors open. Do you want to close them?");
            if (close) {
                for (IEditorReference ref : refsToClose) {
                    activePage.closeEditor(ref.getEditor(false), false);
                }
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference) ArrayList(java.util.ArrayList) Statechart(org.yakindu.sct.model.sgraph.Statechart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) IDiagramEditorInput(org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramEditorInput)

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