Skip to content

Commit

Permalink
kill find replace service signleton
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-krivanek committed May 24, 2019
1 parent c48d7a7 commit dcf8ffe
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 32 deletions.
19 changes: 13 additions & 6 deletions src/Rubric/RubAbstractTextArea.class.st
Expand Up @@ -94,7 +94,8 @@ Class {
'getMenuPolicy',
'mouseDownPoint',
'completionEngine',
'maxLength'
'maxLength',
'findReplaceService'
],
#classVars : [
'BackgroundColor',
Expand Down Expand Up @@ -810,6 +811,12 @@ RubAbstractTextArea >> findRegex [
^ self editor findRegex
]

{ #category : #'event handling' }
RubAbstractTextArea >> findReplaceService [
^ findReplaceService ifNil: [
findReplaceService := RubFindReplaceService new ].
]

{ #category : #'find-replace' }
RubAbstractTextArea >> findText [
^ self editor findText
Expand Down Expand Up @@ -1022,7 +1029,7 @@ RubAbstractTextArea >> hasDecoratorNamed: aKey [

{ #category : #'find-replace' }
RubAbstractTextArea >> hasFindReplaceFocus [
^ RubFindReplaceService default dialogIsActiveFor: self
^ self findReplaceService dialogIsActiveFor: self
]

{ #category : #'accessing editing state' }
Expand Down Expand Up @@ -1440,9 +1447,9 @@ RubAbstractTextArea >> paragraphWasComposedFrom: startIndex to: stopIndex [
{ #category : #initialization }
RubAbstractTextArea >> plugFindReplace [
self announcer
when: MorphGotFocus send: #whenTextAreaGotFocus: to: RubFindReplaceService default;
when: MorphLostFocus send: #whenTextAreaLostFocus: to: RubFindReplaceService default;
when: RubSelectionChanged send: #whenTextAreaSelectionChanged: to: RubFindReplaceService default
when: MorphGotFocus send: #whenTextAreaGotFocus: to: self findReplaceService;
when: MorphLostFocus send: #whenTextAreaLostFocus: to: self findReplaceService;
when: RubSelectionChanged send: #whenTextAreaSelectionChanged: to: self findReplaceService
]

{ #category : #'accessing selection' }
Expand Down Expand Up @@ -1915,7 +1922,7 @@ RubAbstractTextArea >> unplug [

{ #category : #initialization }
RubAbstractTextArea >> unplugFindReplace [
self announcer unsubscribe: RubFindReplaceService default
self announcer unsubscribe: self findReplaceService

]

Expand Down
24 changes: 2 additions & 22 deletions src/Rubric/RubFindReplaceDialogWindow.class.st
Expand Up @@ -9,51 +9,31 @@ Class {
],
#classVars : [
'Finds',
'Replacements',
'Singleton'
'Replacements'
],
#category : #'Rubric-Editing-FindReplaceService'
}

{ #category : #cleanup }
RubFindReplaceDialogWindow class >> cleanUp [
Singleton ifNotNil: [
Singleton close.
Singleton := nil ]
]

{ #category : #accessing }
RubFindReplaceDialogWindow class >> finds [
^ Finds ifNil: [Finds := OrderedCollection new]
]

{ #category : #accessing }
RubFindReplaceDialogWindow class >> initialize [
"EditorFindReplaceDialogWindow initialize"
Singleton := nil.
]

{ #category : #accessing }
RubFindReplaceDialogWindow class >> maxPreviousListSize [
^ 15
]

{ #category : #accessing }
RubFindReplaceDialogWindow class >> on: aTextView [
^ self singleton on: aTextView
^ self new on: aTextView
]

{ #category : #accessing }
RubFindReplaceDialogWindow class >> replacements [
^ Replacements ifNil: [Replacements := OrderedCollection new]
]

{ #category : #accessing }
RubFindReplaceDialogWindow class >> singleton [
^ Singleton ifNil: [Singleton := self new].

]

{ #category : #'user-interface' }
RubFindReplaceDialogWindow >> buildWindowMenu [
"Build and answer the window menu."
Expand Down
2 changes: 1 addition & 1 deletion src/Rubric/RubFindReplaceService.class.st
Expand Up @@ -176,7 +176,7 @@ RubFindReplaceService >> findText [
RubFindReplaceService >> findText: aStringOrText [
findText := aStringOrText asText.
self findPolicyChanged.
self textArea whenFindTextChanged: RubFindTextChanged new.
"self textArea whenFindTextChanged: RubFindTextChanged new."
^ true
]

Expand Down
2 changes: 1 addition & 1 deletion src/Rubric/RubMethodEditingExample.class.st
Expand Up @@ -205,7 +205,7 @@ RubMethodEditingExample >> textModel [
]

{ #category : #accessing }
RubMethodEditingExample >> updateCodeWith: someText. [
RubMethodEditingExample >> updateCodeWith: someText [.
self textModel setText: someText.

]
5 changes: 3 additions & 2 deletions src/Rubric/RubTextEditor.class.st
Expand Up @@ -6,7 +6,8 @@ Class {
#superclass : #Object,
#instVars : [
'defaultKeymappingIndex',
'textArea'
'textArea',
'findReplaceService'
],
#category : #'Rubric-Editing-Core'
}
Expand Down Expand Up @@ -1213,7 +1214,7 @@ RubTextEditor >> findRegex [

{ #category : #'find-select' }
RubTextEditor >> findReplaceService [
^ RubFindReplaceService default
^ self textArea findReplaceService
]

{ #category : #'find-select' }
Expand Down

0 comments on commit dcf8ffe

Please sign in to comment.