Skip to content

Commit 1634a13

Browse files
committed
Merge e44c822
2 parents 6ca320b + e44c822 commit 1634a13

3 files changed

Lines changed: 155 additions & 22 deletions

File tree

src/Pyramid-Bloc/PyramidPluginEditOnRunning.class.st

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,9 @@ Class {
33
#superclass : #Object,
44
#traits : 'TPyramidPlugin',
55
#classTraits : 'TPyramidPlugin classTrait',
6-
#instVars : [
7-
'editOnRunning'
8-
],
96
#classInstVars : [
107
'editOnRunning',
11-
'spaceIds',
128
'shortcut',
13-
'shortcutFork',
149
'keyCombination',
1510
'breakpoint'
1611
],
@@ -51,20 +46,12 @@ PyramidPluginEditOnRunning class >> cleanUp: anObject [
5146
PyramidPluginEditOnRunning class >> doShortcutAction: anEvent [
5247

5348
| space editor whenClosedDo |
54-
self flag:
55-
'labordep: this is a temporary processing because this fork is due to a Bloc opened issue'.
56-
(shortcutFork notNil and: [ shortcutFork isTerminated not ]) ifTrue: [
57-
^ self ].
58-
59-
shortcutFork := [
60-
self editOnRunning ifTrue: [
61-
space := anEvent source space.
62-
(self canEditSpace: space) ifTrue: [
63-
editor := space editWithPyramid.
64-
whenClosedDo := editor window whenClosedDo.
65-
editor window whenClosedDo: [ whenClosedDo value ] ] ] ]
66-
forkAt: Processor userBackgroundPriority
67-
named: 'Pyramid edit-on-running plugin shortcut'
49+
self editOnRunning ifFalse: [ ^ self ].
50+
space := anEvent source space.
51+
(self canEditSpace: space) ifFalse: [ ^ self ].
52+
editor := space editWithPyramid.
53+
whenClosedDo := editor window whenClosedDo.
54+
editor window whenClosedDo: [ whenClosedDo value ]
6855
]
6956

7057
{ #category : #'as yet unclassified' }

src/Pyramid-Bloc/PyramidSaveModelVerifier.class.st

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ PyramidSaveModelVerifier class >> classPackageIsEqual [
4747
PyramidSaveModelVerifier class >> methodIsValid [
4848

4949
^ self new
50-
verifyBlock: [ :model |
51-
OCScanner isSelector: model savingMethodName ];
50+
verifyBlock: [ :model | model savingMethodName isValidSelector ];
5251
showBlock: [ :view | view showMethodIsNotValidError ];
53-
yourself
52+
yourself.
5453
]
5554

5655
{ #category : #constructor }
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
Class {
2+
#name : #PyramidShowCodePlugin,
3+
#superclass : #Object,
4+
#traits : 'TPyramidPlugin',
5+
#classTraits : 'TPyramidPlugin classTrait',
6+
#instVars : [
7+
'codePresenterForAll',
8+
'codePresenterForSelection',
9+
'projectModel'
10+
],
11+
#category : #'Pyramid-Bloc-plugin-showcode'
12+
}
13+
14+
{ #category : #adding }
15+
PyramidShowCodePlugin >> addPanelsOn: aPyramidSimpleWindow [
16+
17+
aPyramidSimpleWindow at: #tabLeft addItem: [ :builder |
18+
builder
19+
makeTab: self codePresenterForAll
20+
label: 'Code for all'
21+
icon: (Smalltalk ui icons iconNamed: #page)
22+
order: 5 ].
23+
aPyramidSimpleWindow at: #tabRight addItem: [ :builder |
24+
builder
25+
makeTab: self codePresenterForSelection
26+
label: 'Code for selection'
27+
icon: (Smalltalk ui icons iconNamed: #page)
28+
order: 999 ]
29+
]
30+
31+
{ #category : #accessing }
32+
PyramidShowCodePlugin >> codePresenterForAll [
33+
34+
^ codePresenterForAll
35+
]
36+
37+
{ #category : #accessing }
38+
PyramidShowCodePlugin >> codePresenterForSelection [
39+
40+
^ codePresenterForSelection
41+
]
42+
43+
{ #category : #connecting }
44+
PyramidShowCodePlugin >> connectOn: aPyramidEditor [
45+
46+
projectModel := aPyramidEditor projectModel.
47+
aPyramidEditor projectModel announcer
48+
when: PyramidElementsChangedEvent
49+
do: [ :evt | self elementsChanged: evt ]
50+
for: self.
51+
aPyramidEditor projectModel announcer
52+
when: PyramidFirstLevelElementsChangedEvent
53+
do: [ :evt | self firstLevelElementsChanged: evt ]
54+
for: self.
55+
aPyramidEditor projectModel announcer
56+
when: PyramidSelectionChangedEvent
57+
do: [ :evt | self selectionChanged: evt ]
58+
for: self
59+
]
60+
61+
{ #category : #'as yet unclassified' }
62+
PyramidShowCodePlugin >> elementsChanged: aPyramidElementsChangedEvent [
63+
64+
self firstLevelElementsChanged: aPyramidElementsChangedEvent.
65+
self selectionChanged: aPyramidElementsChangedEvent
66+
]
67+
68+
{ #category : #'as yet unclassified' }
69+
PyramidShowCodePlugin >> firstLevelElementsChanged: aPyramidFirstLevelElementsChangedEvent [
70+
71+
self codePresenterForAll text: (Stash new serialize:
72+
aPyramidFirstLevelElementsChangedEvent firstLevelElements)
73+
]
74+
75+
{ #category : #initialization }
76+
PyramidShowCodePlugin >> initialize [
77+
78+
super initialize.
79+
codePresenterForAll := SpCodePresenter new
80+
beForScripting;
81+
whenSubmitDo: [ :text |
82+
self validateCodeForAll: text ];
83+
yourself.
84+
codePresenterForSelection := SpCodePresenter new
85+
beForScripting;
86+
whenSubmitDo: [ :text |
87+
self validateCodeForSelection: text ];
88+
yourself
89+
]
90+
91+
{ #category : #accessing }
92+
PyramidShowCodePlugin >> projectModel [
93+
94+
^ projectModel
95+
]
96+
97+
{ #category : #'event handling' }
98+
PyramidShowCodePlugin >> selectionChanged: aPyramidSelectionChangedEvent [
99+
100+
self codePresenterForSelection text: ''.
101+
aPyramidSelectionChangedEvent selection ifEmpty: [
102+
self codePresenterForSelection text: '"Select one element."'.
103+
^ self ].
104+
aPyramidSelectionChangedEvent selection size > 2 ifTrue: [
105+
self codePresenterForSelection text: '"Select only one element."'.
106+
^ self ].
107+
self codePresenterForSelection text: (Stash new serialize:
108+
aPyramidSelectionChangedEvent selection first)
109+
]
110+
111+
{ #category : #'as yet unclassified' }
112+
PyramidShowCodePlugin >> validateCodeForAll: aString [
113+
114+
| collection |
115+
collection := Stash new materialize: aString.
116+
collection isCollection ifFalse: [
117+
^ self inform: 'Could not serialize: The code is not a collection.' ].
118+
(collection allSatisfy: [ :each | each isKindOf: BlElement ])
119+
ifFalse: [
120+
^ self inform:
121+
'Could not serialize: Not BlElement found in the code.' ].
122+
self projectModel firstLevelElements replaceAll: collection.
123+
self projectModel updateSelection
124+
]
125+
126+
{ #category : #'as yet unclassified' }
127+
PyramidShowCodePlugin >> validateCodeForSelection: aString [
128+
129+
| newElement currentSelection |
130+
newElement := Stash new materialize: aString.
131+
(newElement isKindOf: BlElement) ifFalse: [
132+
^ self inform: 'Could not serialize: The code is not a BlElement.' ].
133+
self projectModel selection size = 1 ifFalse: [
134+
^ self inform:
135+
'Could not serialize: The selection should only contains one element.' ].
136+
currentSelection := self projectModel selection first.
137+
(self projectModel firstLevelElements includes: currentSelection)
138+
ifTrue: [
139+
self projectModel firstLevelElements replaceAll:
140+
(self projectModel firstLevelElements asArray
141+
copyReplaceAll: { currentSelection }
142+
with: { newElement }) ].
143+
currentSelection parent ifNotNil: [ :p |
144+
p replaceChild: currentSelection with: newElement ].
145+
146+
self projectModel selection replaceAll: { newElement }
147+
]

0 commit comments

Comments
 (0)