From 4fa3aa9541655acc2065a15b5913894497b5849b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Blizni=C4=8Denko?= Date: Thu, 25 Jul 2024 15:13:22 +0200 Subject: [PATCH] Added roundabout persistence test --- .../OPPetriNetExamplePersistenceTest.class.st | 13 +++++ .../OPPetriNetsExamples.class.st | 47 ++++++++++++++----- 2 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 repository/OpenPonk-PetriNets/OPPetriNetExamplePersistenceTest.class.st diff --git a/repository/OpenPonk-PetriNets/OPPetriNetExamplePersistenceTest.class.st b/repository/OpenPonk-PetriNets/OPPetriNetExamplePersistenceTest.class.st new file mode 100644 index 0000000..49db54d --- /dev/null +++ b/repository/OpenPonk-PetriNets/OPPetriNetExamplePersistenceTest.class.st @@ -0,0 +1,13 @@ +Class { + #name : 'OPPetriNetExamplePersistenceTest', + #superclass : 'OPExamplePersistenceTest', + #category : 'OpenPonk-PetriNets-Tests', + #package : 'OpenPonk-PetriNets', + #tag : 'Tests' +} + +{ #category : 'hooks' } +OPPetriNetExamplePersistenceTest >> createExampleModel [ + + ^ OPPetriNetsExamples examplePetriNet +] diff --git a/repository/OpenPonk-PetriNets/OPPetriNetsExamples.class.st b/repository/OpenPonk-PetriNets/OPPetriNetsExamples.class.st index 6035356..ea5a97d 100644 --- a/repository/OpenPonk-PetriNets/OPPetriNetsExamples.class.st +++ b/repository/OpenPonk-PetriNets/OPPetriNetsExamples.class.st @@ -7,22 +7,20 @@ Class { } { #category : 'examples' } -OPPetriNetsExamples class >> exampleEmpty [ +OPPetriNetsExamples class >> emptyModel [ - | project model | - project := OPProject named: 'New Petri Net'. - model := OPPetriNet new name: 'New Petri Net'. - project addModel: model. - OPWorkbench openProject: project + + ^ OPPetriNet new + name: 'New Petri Net'; + yourself ] { #category : 'examples' } -OPPetriNetsExamples class >> examplePetriNets [ +OPPetriNetsExamples class >> examplePetriNet [ - | project model place1 arc1 arc2 arc3 arc4 arc5 place2 place3 place4 trans1 trans2 workbench | - project := OPProject named: 'Example Petri Net'. + + | model place1 arc1 arc2 arc3 arc4 arc5 place2 place3 place4 trans1 trans2 | model := OPPetriNet named: 'Petri Net'. - project addModel: model. place1 := (OPPetriNetPTPlace named: 'P1') tokens: 20; yourself. @@ -51,7 +49,7 @@ OPPetriNetsExamples class >> examplePetriNets [ add: arc3; add: arc4; add: arc5. - (OPProject openOnModel: model) showAllElementsInAllDiagrams + ^ model ] { #category : 'menu' } @@ -60,12 +58,35 @@ OPPetriNetsExamples class >> menuCommandOn: aBuilder [ (aBuilder item: #'Petri Nets') icon: OPPetriNetsIcons petriNetIcon; - action: [ self exampleEmpty ]; + action: [ self openExampleEmptyModel ]; order: 215; with: [ (aBuilder item: #'Petri Nets Example') parent: #'Petri Nets'; label: 'Petri Nets example'; icon: OPPetriNetsIcons petriNetIcon; - action: [ self examplePetriNets ] ] + action: [ self openExamplePetriNet ] ] +] + +{ #category : 'examples' } +OPPetriNetsExamples class >> openExample: aModel [ + + | project | + project := OPProject named: 'FSM Example'. + project addModel: aModel. + ^ (OPWorkbench openProject: project) showAllElementsInAllDiagrams +] + +{ #category : 'examples' } +OPPetriNetsExamples class >> openExampleEmptyModel [ + + + self openExample: self emptyModel +] + +{ #category : 'examples' } +OPPetriNetsExamples class >> openExamplePetriNet [ + + + self openExample: self examplePetriNet ]