Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #3 from leofrere/feature/openOnSection
Browse files Browse the repository at this point in the history
search one section in help
  • Loading branch information
Ducasse authored Aug 29, 2021
2 parents 0ec6487 + 4425981 commit c25c9c9
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions src/NewTools-DocumentationReader/StHelpBrowserPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,26 @@ Class {
],
#classInstVars : [
'filesystem',
'helpCache'
'helpCache',
'lastopenHelp'
],
#category : #'NewTools-DocumentationReader'
}

{ #category : #specs }
StHelpBrowserPresenter class >> defaultSpec [

| searchInput |
searchInput := (SpTextInputFieldPresenter new
placeholder: 'Enter you search').
^ SpBoxLayout newTopToBottom
add: (SpPanedLayout newLeftToRight
add: #topicList;
add: #textOutput;
yourself);
add: searchInput height: 30 ;
add: (SpButtonPresenter new
label: 'Search';
action: [ lastopenHelp searchAndClick: searchInput text ]) height: 50;
yourself
]

Expand Down Expand Up @@ -158,19 +165,33 @@ StHelpBrowserPresenter class >> openOnHelpFolder: aFileReference [
"Implementation note: the logic is not really good because I have to copy the logic from SpPresenter class>>#newApplication:model:.
Especially how to pass a model before the initialization which is normally done via message #on: "

| inst fileReference |
inst := self basicNew.
| fileReference |
lastopenHelp := self basicNew.
fileReference := aFileReference exists
ifFalse: [ self helpCache ]
ifTrue: [ aFileReference ].
inst createRootTopicFromFolder: fileReference.
^ inst
setModelBeforeInitialization: inst rootTopic;
lastopenHelp createRootTopicFromFolder: fileReference.
^ lastopenHelp
setModelBeforeInitialization: lastopenHelp rootTopic;
initialize;
openWithSpec;
yourself
]

{ #category : #'as yet unclassified' }
StHelpBrowserPresenter class >> search: aTopicName in: topicCollection with: aCollection [
topicCollection ifNotEmpty: [
topicCollection doWithIndex: [ :topic :i |
aCollection add: i.
topic title = aTopicName
ifTrue: [ ^ aCollection ]
ifFalse: [ (self search: aTopicName in: topic subtopics with: aCollection) isCollection
ifTrue: [ ^ aCollection]].
aCollection removeLast ]
]

]

{ #category : #initialization }
StHelpBrowserPresenter >> connectPresenters [

Expand Down Expand Up @@ -345,6 +366,15 @@ StHelpBrowserPresenter >> rootTopic: aHelpTopic [
rootTopic := aHelpTopic asHelpTopic
]

{ #category : #'as yet unclassified' }
StHelpBrowserPresenter >> searchAndClick: aTopicName [
| collection |
collection := OrderedCollection new.
collection add: 1.
self class search: aTopicName in: rootTopic subtopics with: collection.
self topicList clickAtPath: collection
]

{ #category : #initialization }
StHelpBrowserPresenter >> setModelBeforeInitialization: anHelpTopic [

Expand Down

0 comments on commit c25c9c9

Please sign in to comment.