-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPyramidPluginEditOnRunning.class.st
More file actions
127 lines (97 loc) · 3.18 KB
/
PyramidPluginEditOnRunning.class.st
File metadata and controls
127 lines (97 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
Class {
#name : #PyramidPluginEditOnRunning,
#superclass : #Object,
#traits : 'TPyramidPlugin',
#classTraits : 'TPyramidPlugin classTrait',
#classInstVars : [
'editOnRunning',
'shortcut',
'keyCombination',
'breakpoint'
],
#category : #'Pyramid-Bloc-plugin-edit-on-running'
}
{ #category : #private }
PyramidPluginEditOnRunning class >> addShortcutInSpace: aSpace [
(self canEditSpace: aSpace) ifFalse: [ ^ self ].
aSpace root addShortcut: self shortcut
]
{ #category : #initialization }
PyramidPluginEditOnRunning class >> breakpoint [
^ breakpoint
]
{ #category : #'as yet unclassified' }
PyramidPluginEditOnRunning class >> canEditSpace: aSpace [
aSpace ifNil:[ ^ false ].
"Not edit the editor space or already edited to prevent cycling"
aSpace userData at: #pyramid_isEditor ifPresent:[ ^ false ].
aSpace userData at: #pyramid_isOnEdition ifPresent:[ ^ false ].
^ true
]
{ #category : #initialization }
PyramidPluginEditOnRunning class >> cleanUp: anObject [
"do nothing"
]
{ #category : #private }
PyramidPluginEditOnRunning class >> doShortcutAction: anEvent [
| space editor whenClosedDo |
self editOnRunning ifFalse: [ ^ self ].
space := anEvent source space.
(self canEditSpace: space) ifFalse: [ ^ self ].
editor := space editWithPyramid.
whenClosedDo := editor window whenClosedDo.
editor window whenClosedDo: [ whenClosedDo value ]
]
{ #category : #'as yet unclassified' }
PyramidPluginEditOnRunning class >> editOnRunning [
^ editOnRunning ifNil: [ editOnRunning := true ]
]
{ #category : #'as yet unclassified' }
PyramidPluginEditOnRunning class >> editOnRunning: aBoolean [
editOnRunning := aBoolean
]
{ #category : #initialization }
PyramidPluginEditOnRunning class >> install [
self isBreakpointInstall ifTrue: [ ^ self ].
self installBreakpoint.
]
{ #category : #'universe management' }
PyramidPluginEditOnRunning class >> installBreakpoint [
| node |
PyramidBreakpoint removeAllPyramidBreakpoint.
node := (BlParallelUniverse methodNamed: #openSpace:) ast.
breakpoint := PyramidBreakpoint new.
breakpoint node: node.
breakpoint whenHitDo: [ :context |
self addShortcutInSpace: context arguments first ].
breakpoint install
]
{ #category : #initialization }
PyramidPluginEditOnRunning class >> isBreakpointInstall [
self breakpoint ifNil: [ ^ false ].
^ self breakpoint isInstalled
]
{ #category : #accessing }
PyramidPluginEditOnRunning class >> keyCombination [
^ keyCombination ifNil: [
keyCombination := (BlKeyCombination builder key: KeyboardKey F12) build ]
]
{ #category : #private }
PyramidPluginEditOnRunning class >> removeShortcutInSpace: aSpace [
aSpace ifNil: [ ^ self ].
aSpace root removeShortcut: self shortcut.
]
{ #category : #accessing }
PyramidPluginEditOnRunning class >> shortcut [
^ shortcut ifNil: [
shortcut := BlShortcutWithAction new
name: 'Pyramid edition shortcut';
combination: self keyCombination;
action: [ :event | self doShortcutAction: event ] ]
]
{ #category : #initialization }
PyramidPluginEditOnRunning class >> uninstall [
"Undo some stuff here when the plugin used class oriented behavior"
PyramidBreakpoint removeAllPyramidBreakpoint.
breakpoint := nil.
]