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