Grafoscopio/repository/Grafoscopio/GrafoscopioReplace.class.st

123 lines
2.3 KiB
Smalltalk
Raw Normal View History

"
I'm a tool for finding and replacing text ocurrences in notebook
nodes.
"
Class {
#name : #GrafoscopioReplace,
#superclass : #ComposableModel,
#instVars : [
'find',
'replace',
'ok',
'cancel'
],
#category : #'Grafoscopio-UI'
}
{ #category : #specs }
GrafoscopioReplace class >> defaultSpec [
2017-09-16 17:10:46 +00:00
^ SpecLayout composed
newColumn: [ :column |
column
add: #find;
add: #replace;
newRow: [ :row | row add: #ok; add: #cancel ] height: self toolbarHeight ];
yourself
]
2017-09-16 17:10:46 +00:00
{ #category : #accessing }
GrafoscopioReplace >> cancel [
^ cancel
]
{ #category : #accessing }
GrafoscopioReplace >> cancel: anObject [
cancel := anObject
]
{ #category : #accessing }
GrafoscopioReplace >> find [
^ find
]
{ #category : #accessing }
GrafoscopioReplace >> find: anObject [
find := anObject
]
2017-09-16 21:21:06 +00:00
{ #category : #initialization }
GrafoscopioReplace >> initializePresenter [
"Here we need to deal with changes in the OK button to send messages about the
state of the 'find' and 'replace' variables or do nothing if 'Cancel' is pressed."
ok whenStateChangedDo: [
Transcript show: 'OK Clicked!' ]
2017-09-16 21:21:06 +00:00
]
{ #category : #initialization }
GrafoscopioReplace >> initializeWidgets [
find := self newTextInput
ghostText: 'Text to find...';
autoAccept: true.
replace := self newTextInput
ghostText: 'Text to replace...';
autoAccept: true.
ok := self newButton
2017-09-16 17:10:46 +00:00
label: 'OK';
state: false;
2017-09-16 21:05:26 +00:00
action: [
ok state: true.
self window close. ] .
cancel := self newButton
label: 'Cancel';
2017-09-16 21:05:26 +00:00
action: [
cancel state: true.
self window close ].
2017-09-16 20:23:34 +00:00
self focusOrder
add: find;
2017-09-16 17:10:46 +00:00
add: replace;
add: ok;
2017-09-16 17:10:46 +00:00
add: cancel.
2017-09-16 20:23:34 +00:00
self askOkToClose: true
2017-09-16 17:10:46 +00:00
]
{ #category : #accessing }
GrafoscopioReplace >> ok [
^ ok
]
{ #category : #accessing }
GrafoscopioReplace >> ok: anObject [
ok := anObject
]
{ #category : #private }
GrafoscopioReplace >> okToChange [
^ true
]
2017-09-16 17:10:46 +00:00
{ #category : #accessing }
GrafoscopioReplace >> replace [
^ replace
]
{ #category : #accessing }
GrafoscopioReplace >> replace: anObject [
replace := anObject
]
2017-09-16 20:23:34 +00:00
{ #category : #initialization }
GrafoscopioReplace >> returnValues [
2017-09-16 21:05:26 +00:00
self ok state
ifFalse: [ ^ self ]
ifTrue: [^ Dictionary new
at: 'find' put: find getText;
at: 'replace' put: replace getText;
yourself]
2017-09-16 20:23:34 +00:00
]
{ #category : #api }
GrafoscopioReplace >> title [
^ 'Find & Replace'
]