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