Skip to content

Commit 3e70858

Browse files
Plugin registry fixes
1 parent e99d1ab commit 3e70858

8 files changed

Lines changed: 44 additions & 34 deletions

repository/OpenPonk-Core/OPPlugin.class.st

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ Class {
2020
#tag : 'Plugin'
2121
}
2222

23+
{ #category : 'testing' }
24+
OPPlugin class >> isTestingOnly [
25+
26+
^ false
27+
]
28+
2329
{ #category : 'accessing' }
2430
OPPlugin >> diagramClass [
2531
self
@@ -55,7 +61,7 @@ OPPlugin >> layouterClass [
5561
^ self subclassResponsibility
5662
]
5763

58-
{ #category : 'as yet unclassified' }
64+
{ #category : 'model updates' }
5965
OPPlugin >> mergeModels: aModelsCollection [
6066

6167
self notYetImplemented

repository/OpenPonk-Core/OPPluginRegistry.class.st

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,26 @@ OPPluginRegistry class >> default [
2626

2727
{ #category : 'singleton' }
2828
OPPluginRegistry class >> resetDefault [
29+
2930
<script>
30-
^ Default := nil
31+
^ self setDefault: nil
3132
]
3233

3334
{ #category : 'singleton' }
3435
OPPluginRegistry class >> setDefault: aDefault [
35-
<script>
36+
3637
^ Default := aDefault
3738
]
3839

40+
{ #category : 'singleton' }
41+
OPPluginRegistry class >> setDefaultForTesting [
42+
43+
<script>
44+
^ self setDefault: (self new
45+
add: OPTestPlugin new;
46+
yourself)
47+
]
48+
3949
{ #category : 'instance creation' }
4050
OPPluginRegistry class >> withAll [
4151
^ self new
@@ -50,12 +60,11 @@ OPPluginRegistry >> add: aPlugin [
5060

5161
{ #category : 'adding' }
5262
OPPluginRegistry >> addAll [
53-
plugins := OrderedCollection new.
54-
OPPlugin
55-
allSubclassesWithLevelDo: [ :each :level |
56-
level > 0
57-
ifTrue: [ plugins add: each new ] ]
58-
startingLevel: 0
63+
64+
plugins := OPPlugin allSubclasses
65+
reject: [ :each |
66+
each isAbstract or: [ each isTestingOnly ] ]
67+
thenCollect: [ :each | each new ]
5968
]
6069

6170
{ #category : 'accessing' }

repository/OpenPonk-Core/OPProjectControllerTest.class.st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ Class {
1212

1313
{ #category : 'running' }
1414
OPProjectControllerTest >> setUp [
15+
1516
controller := OPProjectController new.
1617
project := OPProject new.
1718
controller project: project.
18-
OPPluginRegistry setDefault: (OPPluginRegistry new add: OPTestPlugin new)
19+
OPPluginRegistry setDefaultForTesting
1920
]
2021

2122
{ #category : 'running' }

repository/OpenPonk-Core/OPProjectDirectoryMaterializerTest.class.st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ Class {
1414

1515
{ #category : 'running' }
1616
OPProjectDirectoryMaterializerTest >> setUp [
17+
1718
super setUp.
18-
OPPluginRegistry setDefault: (OPPluginRegistry new add: OPTestPlugin new).
19+
OPPluginRegistry setDefaultForTesting.
1920
reader := OPProjectDirectoryMaterializer new.
2021
self setUpBasicProject
2122
]

repository/OpenPonk-Core/OPProjectDirectorySerializerTest.class.st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ Class {
1111

1212
{ #category : 'running' }
1313
OPProjectDirectorySerializerTest >> setUp [
14+
1415
super setUp.
1516
persistence := OPProjectDirectorySerializer new.
16-
OPPluginRegistry setDefault: (OPPluginRegistry new add: OPTestPlugin new)
17+
OPPluginRegistry setDefaultForTesting
1718
]
1819

1920
{ #category : 'running' }

repository/OpenPonk-Core/OPTestPlugin.class.st

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ Instead set & reset the default of DCPluginRegistry.
66
"
77
Class {
88
#name : 'OPTestPlugin',
9-
#superclass : 'Object',
9+
#superclass : 'OPPlugin',
1010
#category : 'OpenPonk-Core-Tests',
1111
#package : 'OpenPonk-Core',
1212
#tag : 'Tests'
1313
}
1414

15+
{ #category : 'testing' }
16+
OPTestPlugin class >> isTestingOnly [
17+
18+
^ true
19+
]
20+
1521
{ #category : 'accessing' }
1622
OPTestPlugin >> diagramControllerClass [
1723
^ OPTestDiagramController
@@ -27,6 +33,13 @@ OPTestPlugin >> isPluginFor: aModel [
2733
^ self modelClass = aModel class
2834
]
2935

36+
{ #category : 'accessing' }
37+
OPTestPlugin >> layouterClass [
38+
"Create your own subclass of OPLayouter or use OPNoLayouter which does nothing"
39+
40+
^ OPNoLayouter
41+
]
42+
3043
{ #category : 'accessing' }
3144
OPTestPlugin >> modelClass [
3245
^ OPTestContainerModel

repository/OpenPonk-Spec/OPModelTreeWidget.class.st

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ OPModelTreeWidget >> doubleClick [
6464
OPPluginRegistry default plugins
6565
detect: [ :each | each modelClass = element class ]
6666
ifFound: [ self openCommand: element ]
67-
ifNone: [ ]
6867
]
6968

7069
{ #category : 'menu commands' }

repository/OpenPonk-Spec/OPRoassalShapeCommand.class.st

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,6 @@ OPRoassalShapeCommand class >> contextMenuActivation [
2626
^ CmdContextMenuActivation byRootGroupItemFor: OPCanvasPresenter
2727
]
2828

29-
{ #category : 'example' }
30-
OPRoassalShapeCommand class >> example [
31-
| proj model |
32-
proj := OPProject new.
33-
model := OPTestContainerModel new.
34-
model entities add: OPTestEntityModel new.
35-
proj addModel: model.
36-
proj open
37-
]
38-
39-
{ #category : 'example' }
40-
OPRoassalShapeCommand class >> example2 [
41-
| c a |
42-
c := OPCanvasPresenter new.
43-
a := CmdContextMenuActivation
44-
buildContextMenuFor: c
45-
inContext: (OPRoassalShapeContext for: c).
46-
a openInWindow
47-
]
48-
4929
{ #category : 'testing' }
5030
OPRoassalShapeCommand class >> isAbstract [
5131
^ self = OPRoassalShapeCommand

0 commit comments

Comments
 (0)