Skip to content
Snippets Groups Projects
Commit 7dd62636 authored by Sebastian Ebert's avatar Sebastian Ebert
Browse files

merge

parents 0d226642 5be5d222
Branches
No related tags found
No related merge requests found
......@@ -184,6 +184,16 @@ export function isPlace(element: GModelElement): boolean {
return element.type === PNMLModelTypes.PLACE;
}
export function isRefTransition(element: GModelElement): boolean {
return element.type === PNMLModelTypes.REF_TRANSITION;
}
export function isRefPlace(element:GModelElement): boolean {
return element.type === PNMLModelTypes.REF_PLACE;
}
export interface HasArgs {
args: any;
}
......@@ -45,6 +45,9 @@ export class DirectedEdgeView extends PolylineEdgeViewWithGapsOnIntersections {
const additionals = super.renderAdditionals(edge, segments, context);
const p1 = segments[segments.length - 2];
const p2 = segments[segments.length - 1];
// edge.parent.move(edge, edge.parent.children.length - 1);
const arrow = (
<path
class-sprotty-edge={true}
......
......@@ -37,7 +37,8 @@ export class EditInputSignalsMenuCommandContribution implements CommandContribut
visible: true
})
],
isEnabled: context => !context.isReadonly && context.selectedElements.filter(isTransition).length === 1
isEnabled: context => !context.isReadonly && context.selectedElements.filter(isTransition).length === 1,
isVisible: context => !context.isReadonly && context.selectedElements.filter(isTransition).length === 1
})
);
}
......
......@@ -31,7 +31,8 @@ export class ResetMarkingsCommandContribution implements CommandContribution {
{ id: ResetMarkingsCommand.RESET_MARKINGS, label: 'Reset Markings' },
new GLSPCommandHandler(this.shell, {
actions: context => [ResetMarkingsOperation.create()],
isEnabled: context => !context.isReadonly && context.selectedElements.filter(isPlace).length === 1
isEnabled: context => !context.isReadonly && context.selectedElements.filter(isPlace).length === 1,
isVisible: context => !context.isReadonly && context.selectedElements.filter(isPlace).length === 1
})
);
}
......
......@@ -54,6 +54,34 @@ public class CreateNodePageNodeHandler extends CreatePageHandler
return Optional.of(pageCommand);
}
@Override
protected EObject getParentElement(final GModelElement container)
{
// prevent node page as root page (should be normal page, not a node)
if(container.getType().equals(PNMLModelTypes.GRAPH))
throw new IllegalCallerException("Node Page must be placed inside a Page.");
//only basic page my be container for node page
if(!container.getType().equals(PNMLModelTypes.PAGE_NODE))
throw new IllegalCallerException("Node Page should only be contained inside a (basic) Page.");
// check if the new node page would be nested inside an existing node page (forbidden)
GModelElement temp = container;
while (temp != null)
{
String type = temp.getType();
if(type.equals(PNMLModelTypes.GRAPH))
break;
if(type.equals(PNMLModelTypes.NODE_PAGE_NODE))
throw new IllegalCallerException("Node Pages may not in any way contain a Node Page.");
temp = temp.getParent();
}
return modelState.getIndex().getEObject(container.getId()).orElseThrow();
}
protected ToolInfoPage createNodePageToolInfo (Page newPage)
{
ToolInfoPage toolSpecifics = PtnetFactory.eINSTANCE.createToolInfoPage();
......
......@@ -63,26 +63,36 @@ public class CreatePageHandler extends AbstractCreateNodeHandler<CreateNodeOpera
return Optional.of(pageCommand);
}
protected EObject getParentElement(final GModelElement container) {
if(container.getType().equals(PNMLModelTypes.PAGE_NODE)){ //page is subpage of other page
protected EObject getParentElement(final GModelElement container)
{
String type = container.getType();
//page is subpage of other page or node page
if(type.equals(PNMLModelTypes.PAGE_NODE) || type.equals(PNMLModelTypes.NODE_PAGE_NODE))
return modelState.getIndex().getEObject(container.getId()).orElseThrow();
} else if(container.getType().equals(PNMLModelTypes.GRAPH)){ //page is top level page
//page is top level page
if(type.equals(PNMLModelTypes.GRAPH))
return modelState.getSemanticModel(pnml.class).orElseThrow()
.getNet().stream().findFirst().orElseThrow();
} else {
throw new IllegalArgumentException("Page must be placed in graph or other page.");
}
}
protected EReference getRelationshipLiteral(final GModelElement container) {
if(container.getType().equals(PNMLModelTypes.PAGE_NODE)){ //page is subpage of other page
protected EReference getRelationshipLiteral(final GModelElement container)
{
String type = container.getType();
//page is subpage of other page or node page
if(type.equals(PNMLModelTypes.PAGE_NODE) || type.equals(PNMLModelTypes.NODE_PAGE_NODE))
return PtnetPackage.Literals.PAGE__PAGE;
} else if(container.getType().equals(PNMLModelTypes.GRAPH)){ //page is top level page
//page is top level page
if(type.equals(PNMLModelTypes.GRAPH))
return PtnetPackage.Literals.PETRI_NET__PAGE;
} else {
throw new IllegalArgumentException("Page must be placed in graph or other page.");
}
}
protected void denySecondRootPage(final GModelElement container)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment