From 5be5d222e261f70dc08fdef290a917ef02749d9d Mon Sep 17 00:00:00 2001
From: tj <tim6542@aol.com>
Date: Tue, 28 Jan 2025 00:04:40 +0100
Subject: [PATCH] issue #8, #9 seem fixed; visibility of 'input signal'/'reset
 markings' constrained to transitions/places - their reference versions do not
 show this option either; updated TaskAndTimeTimJahn.txt; remaining tasks:
 fixing order of elements in the diagram view - arcs and references should
 never be hidden by other elemnts, renaming files and related references from
 'tasklist' to 'pnml'

---
 TaskAndTimeTimJahn.txt                        | 17 +++++++++-
 .../edit-input-signals-context-menu.ts        | 12 ++-----
 .../diagram/reset-markings-context-menu.ts    | 12 ++-----
 .../CreateNodePageNodeHandler.java            | 28 +++++++++++++++
 .../NodeCreation/CreatePageHandler.java       | 34 ++++++++++++-------
 5 files changed, 72 insertions(+), 31 deletions(-)

diff --git a/TaskAndTimeTimJahn.txt b/TaskAndTimeTimJahn.txt
index aea00be..2830252 100644
--- a/TaskAndTimeTimJahn.txt
+++ b/TaskAndTimeTimJahn.txt
@@ -56,6 +56,7 @@ hours:
 12.01.25 12h -
 19.01.25  4h
 26.01.25  8h
+27.01.25  2h
 //------------------------------------------------------------------------------------------------------
 
 see https://github.com/eclipse-theia/theia/blob/master/doc/Developing.md#prerequisite_native_keymap
@@ -174,7 +175,21 @@ some unclear aspects regarding the issues:
 
 prio 1,3,4,6
 
-push to devel, merge with sebastioan as assignee in gitlab website
+#8, #9 pages > node-pages > pages, server-pages
+ - node pages should be able to contain pages and server pages, just not node pages
+ - pages inside nodepages may also not contain further node pages
+
+further things:
+ - order arcs + references:
+	- see views.tsx line 40 -> needs to be at another position probably to always work
+	- https://github.com/eclipse-sprotty/sprotty/issues/94
+
+
+next meeting: 3.2.25
+
+--------------------------------------------------------------------------------------------
+
+push to devel, merge with sebastian as assignee in gitlab website
 
 30.11.24 8h
 01.12.24 8h
diff --git a/glsp-client/tasklist-theia/src/browser/diagram/edit-input-signals-context-menu.ts b/glsp-client/tasklist-theia/src/browser/diagram/edit-input-signals-context-menu.ts
index 232ae88..8139326 100644
--- a/glsp-client/tasklist-theia/src/browser/diagram/edit-input-signals-context-menu.ts
+++ b/glsp-client/tasklist-theia/src/browser/diagram/edit-input-signals-context-menu.ts
@@ -18,7 +18,7 @@ import { GLSPCommandHandler, GLSPContextMenu } from '@eclipse-glsp/theia-integra
 import { CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry } from '@theia/core';
 import { ApplicationShell } from '@theia/core/lib/browser';
 import { inject, injectable } from 'inversify';
-import { isTransition, EditInputSignalMenu, isRefTransition } from 'tasklist-glsp';
+import { isTransition, EditInputSignalMenu} from 'tasklist-glsp';
 
 export namespace EditInputSignalsMenuCommand {
     export const EDIT_INPUT_SIGNALS_MENU = 'edit-input-signals-menu-command';
@@ -37,14 +37,8 @@ export class EditInputSignalsMenuCommandContribution implements CommandContribut
                         visible: true
                     })
                 ],
-                isEnabled: context => !context.isReadonly && (
-                    context.selectedElements.filter(isTransition).length === 1 ||
-                    context.selectedElements.filter(isRefTransition).length === 1
-                ),
-                isVisible: context => !context.isReadonly && (
-                    context.selectedElements.filter(isTransition).length === 1 ||
-                    context.selectedElements.filter(isRefTransition).length === 1
-                )
+                isEnabled: context => !context.isReadonly && context.selectedElements.filter(isTransition).length === 1,
+                isVisible: context => !context.isReadonly && context.selectedElements.filter(isTransition).length === 1
             })
         );
     }
diff --git a/glsp-client/tasklist-theia/src/browser/diagram/reset-markings-context-menu.ts b/glsp-client/tasklist-theia/src/browser/diagram/reset-markings-context-menu.ts
index a64f27a..c00b62a 100644
--- a/glsp-client/tasklist-theia/src/browser/diagram/reset-markings-context-menu.ts
+++ b/glsp-client/tasklist-theia/src/browser/diagram/reset-markings-context-menu.ts
@@ -17,7 +17,7 @@ import { GLSPCommandHandler, GLSPContextMenu } from '@eclipse-glsp/theia-integra
 import { CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry } from '@theia/core';
 import { ApplicationShell } from '@theia/core/lib/browser';
 import { inject, injectable } from 'inversify';
-import { isPlace, ResetMarkingsOperation, isRefPlace } from 'tasklist-glsp';
+import { isPlace, ResetMarkingsOperation} from 'tasklist-glsp';
 
 export namespace ResetMarkingsCommand {
     export const RESET_MARKINGS = 'reset-markings-command';
@@ -31,14 +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 || 
-                    context.selectedElements.filter(isRefPlace).length == 1
-                ),
-                isVisible: context => !context.isReadonly && (
-                    context.selectedElements.filter(isPlace).length === 1 || 
-                    context.selectedElements.filter(isRefPlace).length == 1
-                )
+                isEnabled: context => !context.isReadonly && context.selectedElements.filter(isPlace).length === 1,
+                isVisible: context => !context.isReadonly && context.selectedElements.filter(isPlace).length === 1
             })
         );
     }
diff --git a/glsp-server/src/main/java/org/eclipse/glsp/example/javaemf/handler/DiNeROS/ElementCreation/CreateNodePageNodeHandler.java b/glsp-server/src/main/java/org/eclipse/glsp/example/javaemf/handler/DiNeROS/ElementCreation/CreateNodePageNodeHandler.java
index d176291..ace8722 100644
--- a/glsp-server/src/main/java/org/eclipse/glsp/example/javaemf/handler/DiNeROS/ElementCreation/CreateNodePageNodeHandler.java
+++ b/glsp-server/src/main/java/org/eclipse/glsp/example/javaemf/handler/DiNeROS/ElementCreation/CreateNodePageNodeHandler.java
@@ -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();
diff --git a/glsp-server/src/main/java/org/eclipse/glsp/example/javaemf/handler/NodeCreation/CreatePageHandler.java b/glsp-server/src/main/java/org/eclipse/glsp/example/javaemf/handler/NodeCreation/CreatePageHandler.java
index 87514af..81750db 100644
--- a/glsp-server/src/main/java/org/eclipse/glsp/example/javaemf/handler/NodeCreation/CreatePageHandler.java
+++ b/glsp-server/src/main/java/org/eclipse/glsp/example/javaemf/handler/NodeCreation/CreatePageHandler.java
@@ -63,25 +63,35 @@ 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.");
-        }
+                    
+        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.");
-        }
+
+        throw new IllegalArgumentException("Page must be placed in graph or other page.");
     }
 
     protected void denySecondRootPage(final GModelElement container)
-- 
GitLab