SmallSense__Navigator.st
changeset 377 c686ea588575
parent 370 b02030d796d8
child 378 359fd8380abd
--- a/SmallSense__Navigator.st	Fri Jan 23 19:19:02 2015 +0100
+++ b/SmallSense__Navigator.st	Sat Jan 24 01:58:51 2015 +0000
@@ -21,7 +21,7 @@
 "{ NameSpace: SmallSense }"
 
 AbstractSearchDialog subclass:#Navigator
-	instanceVariableNames:''
+	instanceVariableNames:'steps'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'SmallSense-Core-Interface-Search'
@@ -50,14 +50,104 @@
 "
 ! !
 
+!Navigator methodsFor:'change & update'!
+
+update:something with:aParameter from:changedObject
+    "Invoked when an object that I depend upon sends a change notification."
+
+    changedObject == matchingObjectsSelectionHolder ifTrue:[
+        self updateMextSearchStepVisibility.
+    ].
+    ^ super update:something with:aParameter from:changedObject
+
+    "Created: / 23-01-2015 / 22:21:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+updateMatchingIgnorePattern
+    steps size == 1 ifTrue:[
+        ^ super updateMatchingIgnorePattern 
+    ].
+    self updateMatchingObjectPOs: (self matchingObjectPOsForPattern: nil)
+
+    "Created: / 24-01-2015 / 00:50:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+updateMextSearchStepVisibility
+    "raise an error: this method should be implemented (TODO)"
+
+    | selection |
+
+    selection := self matchingObjectsSelection.
+    matchingObjectsMultiselect ifTrue:[ 
+        selection := selection size == 1 ifTrue:[ selection anElement ] ifFalse:[ nil ]
+    ].
+    selection notNil ifTrue:[ 
+        self nextSearchStepVisibleHolder value: (processor canDoNextStepFor: selection)
+    ] ifFalse:[ 
+        self nextSearchStepVisibleHolder value: false.
+    ].
+
+    "Created: / 23-01-2015 / 22:21:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Navigator methodsFor:'event processing'!
+
+keyPressCursorRightInMatchingObjectsView
+   self nextSearchStepVisibleHolder value ifTrue:[ 
+       self step.
+       ^ true.
+   ].
+   ^ super keyPressCursorRightInMatchingObjectsView
+
+    "Created: / 23-01-2015 / 22:45:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !Navigator methodsFor:'initialization'!
 
 initialize
     super initialize.
-    processor := CompositeProcessor 
+    steps := OrderedCollection new: 3.
+    self push: 
+        (NavigatorStep for: 
+            (CompositeProcessor 
                     with: ClassSearchProcessor new 
-                    with: ImplementorSearchProcessor new.
+                    with: ImplementorSearchProcessor new))
+        update: false.
 
     "Created: / 10-01-2015 / 07:03:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 24-01-2015 / 00:25:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!Navigator methodsFor:'private-steps'!
+
+push: aNavigatorStep
+    self push: aNavigatorStep update: true
+
+    "Created: / 23-01-2015 / 21:01:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 24-01-2015 / 00:24:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+push: aNavigatorStep update: update
+    steps addLast: aNavigatorStep.
+    processor := aNavigatorStep processor.
+    update ifTrue:[ 
+        self matchPatternHolder value: nil.
+        self updateMatching
+    ].
+
+    "Created: / 24-01-2015 / 00:24:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+step
+    | selection step |
+
+    selection := self matchingObjectsSelection.
+    matchingObjectsMultiselect ifTrue:[ 
+        selection := selection size == 1 ifTrue:[ selection anElement ] ifFalse:[ nil ]
+    ].
+    step := NavigatorStep for: (processor processorForNextStepFor: selection).
+    self push: step.
+
+    "Created: / 23-01-2015 / 22:48:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+