Skip to content

Commit

Permalink
Fix all the demos.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducasse committed Sep 3, 2023
1 parent c8a3bc4 commit 9548003
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 178 deletions.
13 changes: 7 additions & 6 deletions src/Spec2-Code/SpCodePresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -320,18 +320,19 @@ SpCodePresenter >> doBrowseImplementors [
{ #category : #commands }
SpCodePresenter >> doBrowseMethodReferences [
"Browse references to Variables (Cmd-shift-n)"
| variableOrClassName variable usingMethods |

| variableOrClassName variable usingMethods |
variableOrClassName := self selectedSelector ifNil: [ ^ nil ].

variable := self lookupEnvironment lookupVar: variableOrClassName.
variable ifNil: [
^ self doBrowseSenders ].
usingMethods := variable usingMethods ifEmpty: [ ^ application inform: 'No users found.'].
variable ifNil: [ ^ self doBrowseSenders ].
usingMethods := variable usingMethods ifEmpty: [
^ self inform: 'No users found.' ].

"the dialog sadly hard-codes 'senders'"
^ self systemNavigation openBrowserFor: variable name withMethods: usingMethods

^ self systemNavigation
openBrowserFor: variable name
withMethods: usingMethods
]

{ #category : #commands }
Expand Down
47 changes: 26 additions & 21 deletions src/Spec2-Dialogs/SpConfirmDialog.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,36 @@ SpConfirmDialog class >> documentFactoryMethodSelector [
{ #category : #examples }
SpConfirmDialog class >> example [

^ self new
title: 'Confirm example';
label: 'Are you sure?';
acceptLabel: 'Sure!';
cancelLabel: 'No, forget it';
label: 'Are you sure?';
onAccept: [ self inform: 'Yes!' ];
onCancel: [ self inform: 'No!' ];
openDialog
| dialog |
dialog := self new.
^ dialog
title: 'Confirm example';
label: 'Are you sure?';
acceptLabel: 'Sure!';
cancelLabel: 'No, forget it';
label: 'Are you sure?';
onAccept: [
dialog inform: 'Yes!' ];
onCancel: [
dialog inform: 'No!' ];
openDialog
]

{ #category : #examples }
SpConfirmDialog class >> exampleModal [
| ok |

ok := self new
title: 'Confirm modal example';
label: 'Are you sure?';
acceptLabel: 'Sure!';
cancelLabel: 'No, forget it';
openModal.

self inform: (ok
ifTrue: [ 'Yes!' ]
ifFalse: [ 'No!' ])

| ok dialog |
dialog := self new.
ok := dialog
title: 'Confirm modal example';
label: 'Are you sure?';
acceptLabel: 'Sure!';
cancelLabel: 'No, forget it';
openModal.

dialog inform: (ok
ifTrue: [ 'Yes!' ]
ifFalse: [ 'No!' ])
]

{ #category : #api }
Expand Down
28 changes: 15 additions & 13 deletions src/Spec2-Dialogs/SpRequestDialog.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,32 @@ SpRequestDialog class >> documentFactoryMethodSelector [
{ #category : #examples }
SpRequestDialog class >> example [

self new
| presenter |
presenter := self new.
presenter
title: 'Request example';
label: 'The meaning of life?';
text: 'I am tempted to say 42...';
acceptLabel: 'I know!';
cancelLabel: 'Cancel';
onAccept: [ :dialog | self inform: dialog presenter text ];
onAccept: [ :dialog | dialog presenter inform: dialog presenter text ];
openDialog
]

{ #category : #examples }
SpRequestDialog class >> exampleModal [
| string |

string := self new
title: 'Request modal example';
label: 'The meaning of life?';
text: 'I am tempted to say 42...';
acceptLabel: 'I know!';
cancelLabel: 'Cancel';
openModal.

string ifNotNil: [
self inform: string ]
| string presenter |
presenter := self new.
string := presenter
title: 'Request modal example';
label: 'The meaning of life?';
text: 'I am tempted to say 42...';
acceptLabel: 'I know!';
cancelLabel: 'Cancel';
openModal.

string ifNotNil: [ presenter inform: string ]
]

{ #category : #visiting }
Expand Down
30 changes: 17 additions & 13 deletions src/Spec2-Dialogs/SpSelectDialog.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,34 @@ SpSelectDialog class >> documentFactoryMethodSelector [
{ #category : #examples }
SpSelectDialog class >> example [

self new
| presenter |
presenter := self new.
presenter
title: 'Select example';
label: 'Select a class';
items: Smalltalk allClassesAndTraits;
display: [ :each | each name ];
displayIcon: [ :each | self iconNamed: each systemIconName ];
onAccept: [ :dialog | self inform: dialog presenter selectedItem asString ];
onAccept: [ :dialog |
dialog presenter inform: dialog presenter selectedItem asString ];
openDialog
]

{ #category : #examples }
SpSelectDialog class >> exampleModal [
| selection |

selection := self new
title: 'Select modal example';
label: 'Select a class';
items: Smalltalk allClassesAndTraits;
display: [ :each | each name ];
displayIcon: [ :each | self iconNamed: each systemIconName ];
openModal.

selection ifNotNil: [
self inform: selection asString ]
| dialog selection |
dialog := self new.
selection := dialog
title: 'Select modal example';
label: 'Select a class';
items: Smalltalk allClassesAndTraits;
display: [ :each | each name ];
displayIcon: [ :each |
self iconNamed: each systemIconName ];
openModal.

selection ifNotNil: [ dialog inform: selection asString ]
]

{ #category : #api }
Expand Down
93 changes: 43 additions & 50 deletions src/Spec2-Examples/SpBoxLayout.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -105,106 +105,99 @@ SpBoxLayout class >> exampleExpand [

{ #category : #'*Spec2-Examples' }
SpBoxLayout class >> exampleHAlignCenter [
| presenter |

| presenter |
presenter := SpPresenter new.
presenter layout: (self newTopToBottom
hAlignCenter;
add: (presenter newButton
icon: (presenter application iconNamed: #smallOk);
label: 'Press me!';
action: [ presenter application inform: 'Pressed!' ])
yourself).
hAlignCenter;
add: (presenter newButton
icon: (presenter application iconNamed: #smallOk);
label: 'Press me!';
action: [ presenter inform: 'Pressed!' ]) yourself).
presenter open
]

{ #category : #'*Spec2-Examples' }
SpBoxLayout class >> exampleHAlignEnd [
| presenter |

| presenter |
presenter := SpPresenter new.
presenter layout: (self newTopToBottom
hAlignEnd;
add: (presenter newButton
icon: (presenter application iconNamed: #smallOk);
label: 'Press me!';
action: [ presenter application inform: 'Pressed!' ])
yourself).
hAlignEnd;
add: (presenter newButton
icon: (presenter application iconNamed: #smallOk);
label: 'Press me!';
action: [ presenter inform: 'Pressed!' ]) yourself).
presenter open
]

{ #category : #'*Spec2-Examples' }
SpBoxLayout class >> exampleHAlignStart [
| presenter |

| presenter |
presenter := SpPresenter new.
presenter layout: (self newTopToBottom
hAlignStart;
add: (presenter newButton
icon: (presenter application iconNamed: #smallOk);
label: 'Press me!';
action: [ presenter application inform: 'Pressed!' ])
yourself).
hAlignStart;
add: (presenter newButton
icon: (presenter application iconNamed: #smallOk);
label: 'Press me!';
action: [ presenter inform: 'Pressed!' ]) yourself).
presenter open
]

{ #category : #'*Spec2-Examples' }
SpBoxLayout class >> exampleVAlignAndHAlign [
| presenter |

| presenter |
presenter := SpPresenter new.
presenter layout: (self newTopToBottom
vAlignCenter;
hAlignCenter;
add: (presenter newButton
icon: (presenter application iconNamed: #smallOk);
label: 'Press me!';
action: [ presenter application inform: 'Pressed!' ])
yourself).
vAlignCenter;
hAlignCenter;
add: (presenter newButton
icon: (presenter application iconNamed: #smallOk);
label: 'Press me!';
action: [ presenter inform: 'Pressed!' ]) yourself).
presenter open
]

{ #category : #'*Spec2-Examples' }
SpBoxLayout class >> exampleVAlignCenter [
| presenter |

| presenter |
presenter := SpPresenter new.
presenter layout: (self newTopToBottom
vAlignCenter;
add: (presenter newButton
icon: (presenter application iconNamed: #smallOk);
label: 'Press me!';
action: [ presenter application inform: 'Pressed!' ])
yourself).
vAlignCenter;
add: (presenter newButton
icon: (presenter application iconNamed: #smallOk);
label: 'Press me!';
action: [ presenter inform: 'Pressed!' ]) yourself).
presenter open
]

{ #category : #'*Spec2-Examples' }
SpBoxLayout class >> exampleVAlignEnd [
| presenter |

| presenter |
presenter := SpPresenter new.
presenter layout: (self newTopToBottom
vAlignEnd;
add: (presenter newButton
icon: (presenter application iconNamed: #smallOk);
label: 'Press me!';
action: [ presenter application inform: 'Pressed!' ])
yourself).
vAlignEnd;
add: (presenter newButton
icon: (presenter application iconNamed: #smallOk);
label: 'Press me!';
action: [ presenter inform: 'Pressed!' ]) yourself).
presenter open
]

{ #category : #'*Spec2-Examples' }
SpBoxLayout class >> exampleVAlignStart [
| presenter |

| presenter |
presenter := SpPresenter new.
presenter layout: (self newTopToBottom
vAlignStart;
add: (presenter newButton
icon: (presenter application iconNamed: #smallOk);
label: 'Press me!';
action: [ presenter application inform: 'Pressed!' ])
yourself).
vAlignStart;
add: (presenter newButton
icon: (presenter application iconNamed: #smallOk);
label: 'Press me!';
action: [ presenter inform: 'Pressed!' ]) yourself).
presenter open
]
41 changes: 22 additions & 19 deletions src/Spec2-Examples/SpDemoActionBarPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,29 @@ SpDemoActionBarPresenter >> defaultLayout [

{ #category : #initialization }
SpDemoActionBarPresenter >> initializePresenters [

actionBar := self newActionBar
add: (self newButton
label: 'Add';
icon: (self iconNamed: #smallOk);
help: 'Add.';
action: [ UIManager default defer: [ self inform: 'Add' ] ];
yourself);
add: (self newButton
label: 'Remove';
icon: (self iconNamed: #smallCancel);
help: 'Remove.';
action: [ UIManager default defer: [ self inform: 'Remove' ] ];
yourself);
addLast: (self newButton
label: 'Other';
help: 'Other.';
action: [ UIManager default defer: [ self inform: 'Other' ] ];
yourself);
yourself.
add: (self newButton
label: 'Add';
icon: (self iconNamed: #smallOk);
help: 'Add.';
action: [
actionBar defer: [ self inform: 'Add' ] ];
yourself);
add: (self newButton
label: 'Remove';
icon: (self iconNamed: #smallCancel);
help: 'Remove.';
action: [
actionBar defer: [ self inform: 'Remove' ] ];
yourself);
addLast: (self newButton
label: 'Other';
help: 'Other.';
action: [
actionBar defer: [ self inform: 'Other' ] ];
yourself);
yourself.

text := self newText
]
1 change: 1 addition & 0 deletions src/Spec2-Examples/SpDemoModal1Presenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SpDemoModal1Presenter >> content [

{ #category : #initialization }
SpDemoModal1Presenter >> initializeDialogWindow: aDialog [

super initializeDialogWindow: aDialog.
aDialog
closeOnBackdropClick: true;
Expand Down
Loading

0 comments on commit 9548003

Please sign in to comment.