Skip to content

Commit

Permalink
Fix and test for #343 category/variable selection
Browse files Browse the repository at this point in the history
some method renames make the code changes look more numerous than they actually are.
  • Loading branch information
Eric Winger authored and Eric Winger committed Dec 5, 2018
1 parent 1ffca27 commit 6f709ab
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 123 deletions.
41 changes: 20 additions & 21 deletions sources/JadeAutoSystemBrowserPresenter.cls
Original file line number Diff line number Diff line change
Expand Up @@ -168,31 +168,30 @@ removeClass
list do: [:each | self registry unregister: each]!

restoreFrom: aJadeHistoryEntry

aJadeHistoryEntry isPackageSelected
ifTrue: [self isPackageListTabSelected ifFalse: [packageDictionaryTabs previousCard].
packageListPresenter selections: aJadeHistoryEntry packageOrDictionary ifAbsent: []]
ifFalse: [self isPackageListTabSelected ifTrue: [packageDictionaryTabs nextCard].
aJadeHistoryEntry isPackageSelected
ifTrue:
[self isPackageListTabSelected ifFalse: [packageDictionaryTabs previousCard].
packageListPresenter selections: aJadeHistoryEntry packageOrDictionary ifAbsent: []]
ifFalse:
[self isPackageListTabSelected ifTrue: [packageDictionaryTabs nextCard].
dictionaryListPresenter selections: aJadeHistoryEntry packageOrDictionary ifAbsent: []].

classCategoryPresenter selection: aJadeHistoryEntry classCategory ifAbsent: [].

aJadeHistoryEntry isHierarchySelected
ifTrue: [self isClassListTabSelected ifTrue: [classHierarchyTabs nextCard].
classHierarchyPresenter selection: aJadeHistoryEntry className ifAbsent: []]
ifFalse: [self isClassListTabSelected ifFalse: [classHierarchyTabs previousCard].
aJadeHistoryEntry isHierarchySelected
ifTrue:
[self isClassListTabSelected ifTrue: [classHierarchyTabs nextCard].
classHierarchyPresenter selection: aJadeHistoryEntry className ifAbsent: []]
ifFalse:
[self isClassListTabSelected ifFalse: [classHierarchyTabs previousCard].
classListPresenter selection: aJadeHistoryEntry className ifAbsent: []].

aJadeHistoryEntry isCategoriesSelected
ifTrue: [self isCategoriesTabSelected ifFalse: [methodFilterTabs previousCard].
categoryListPresenter selection: aJadeHistoryEntry categoriesOrVariables ifAbsent: [].]
ifFalse: [self isCategoriesTabSelected ifTrue: [methodFilterTabs nextCard].
variableListPresenter selection: aJadeHistoryEntry categoriesOrVariables ifAbsent: [].].

aJadeHistoryEntry isCategoriesSelected
ifTrue:
[self isCategoryTabSelected ifFalse: [methodFilterTabs previousCard].
categoryListPresenter selection: aJadeHistoryEntry categoriesOrVariables ifAbsent: []]
ifFalse:
[self isCategoryTabSelected ifTrue: [methodFilterTabs nextCard].
variableListPresenter selection: aJadeHistoryEntry categoriesOrVariables ifAbsent: []].
methodListPresenter selection: aJadeHistoryEntry methodName ifAbsent: [].

self resetCursor.
!
self resetCursor!

updateAndSelect: aView

Expand Down
60 changes: 31 additions & 29 deletions sources/JadeSystemBrowserPresenter.cls
Original file line number Diff line number Diff line change
Expand Up @@ -743,33 +743,37 @@ editSaveClassComment

editSaveMethod
| stream caretPosition firstVisibleLine |

caretPosition := methodSourcePresenter view caretPosition.
firstVisibleLine := methodSourcePresenter view lineScroll.
(self isCategoriesTabSelected and: [categoryListPresenter hasSelection]) ifTrue: [
methodCategory := categoryListPresenter selection trimBlanks.
].

(self isCategoryTabSelected and: [categoryListPresenter hasSelection])
ifTrue: [methodCategory := categoryListPresenter selection trimBlanks].
stream := (WriteStream on: String new)
nextPutAll: 'method'; tab;
nextPutAll: self selectedClassNameWithoutVersion; tab;
nextPutAll: selectedClassOop printString; tab;
nextPutAll: instanceClassTabs currentCard name; tab;
nextPutAll: methodCategory; tab;
lf;
nextPutAll: self currentMethodSource; lf;
nextPut: $%; lf;
yourself.
[
self
updateCommand: stream contents , self requestString
onSuccessDo: [methodSourcePresenter view isModified: false; ensureVisible].
] on: GsCompileError do: [:ex |
self reportCompileError: ex list.
].
nextPutAll: 'method';
tab;
nextPutAll: self selectedClassNameWithoutVersion;
tab;
nextPutAll: selectedClassOop printString;
tab;
nextPutAll: instanceClassTabs currentCard name;
tab;
nextPutAll: methodCategory;
tab;
lf;
nextPutAll: self currentMethodSource;
lf;
nextPut: $%;
lf;
yourself.

[self updateCommand: stream contents , self requestString
onSuccessDo:
[methodSourcePresenter view
isModified: false;
ensureVisible]]
on: GsCompileError
do: [:ex | self reportCompileError: ex list].
methodSourcePresenter view firstVisibleLine: firstVisibleLine.
methodSourcePresenter view goto: caretPosition.
!
methodSourcePresenter view goto: caretPosition!

editSelectAll

Expand Down Expand Up @@ -1108,10 +1112,8 @@ inspectGlobal
(Smalltalk at: #'JadeInspector' ifAbsent: [^self]) showOn: oopType session: self gciSession.
!
isCategoriesTabSelected
^methodFilterTabs currentCard name = 'categoryList'.
!
isCategoryTabSelected
^methodFilterTabs currentCard name = 'categoryList'!
isClassListTabSelected
Expand Down Expand Up @@ -2463,7 +2465,7 @@ updateDictionaryList
updateMenuBar
| shellView menuBar dictionaryMenu methodFilterMenu textAreaMenu |
dictionaryMenu := Menu fromStrings: self dictsMenuStrings.
methodFilterMenu := Menu fromStrings: (self isCategoriesTabSelected
methodFilterMenu := Menu fromStrings: (self isCategoryTabSelected
ifTrue: [self categoriesMenuStrings]
ifFalse: [self variablesMenuStrings]).
textAreaMenu := Menu fromStrings: (self isGlobalsTabSelected
Expand Down Expand Up @@ -2815,7 +2817,7 @@ viewActivated
!JadeSystemBrowserPresenter categoriesFor: #initialize!history!public! !
!JadeSystemBrowserPresenter categoriesFor: #insertDictionary!public! !
!JadeSystemBrowserPresenter categoriesFor: #inspectGlobal!menu handlers!public! !
!JadeSystemBrowserPresenter categoriesFor: #isCategoriesTabSelected!public!testing! !
!JadeSystemBrowserPresenter categoriesFor: #isCategoryTabSelected!public!testing! !
!JadeSystemBrowserPresenter categoriesFor: #isClassListTabSelected!public!request string! !
!JadeSystemBrowserPresenter categoriesFor: #isClassSelectedInEditor!public! !
!JadeSystemBrowserPresenter categoriesFor: #isClassSideSelected!accessing!public!request string! !
Expand Down
6 changes: 5 additions & 1 deletion sources/JadeiteAbstractTestCase.cls
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,10 @@ transcriptTab
unloadSampleProject
self isSampleProjectLoaded
ifTrue: [self projectsPresenter basicUnloadProjects: (Array with: self sampleProjectName)].
! !
!

variableListPresenter
^self projectsPresenter variableListPresenter.! !
!JadeiteAbstractTestCase categoriesFor: #abortTransaction!private!setup teardown! !
!JadeiteAbstractTestCase categoriesFor: #anotherNumberMethodSource!constants!private! !
!JadeiteAbstractTestCase categoriesFor: #categoryListPresenter!private!project browser support! !
Expand Down Expand Up @@ -340,6 +343,7 @@ unloadSampleProject
!JadeiteAbstractTestCase categoriesFor: #transcriptProjectNamed:!public!transcript support! !
!JadeiteAbstractTestCase categoriesFor: #transcriptTab!public!transcript support! !
!JadeiteAbstractTestCase categoriesFor: #unloadSampleProject!private!project support! !
!JadeiteAbstractTestCase categoriesFor: #variableListPresenter!private!project browser support! !

!JadeiteAbstractTestCase class methodsFor!

Expand Down
28 changes: 27 additions & 1 deletion sources/JadeiteProjectBrowserTestCase.cls
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,31 @@ test_extensionColoringInHierarchy
self selectClassInHierarchyNamed: 'RwGemStoneSpecification'.
self assert: self projectsPresenter classHierarchyPresenter selection shouldColorAsExtension!

test_filtersUpdatedInHierarchyView
| selectedClass browserServiceCategories |
self testsIssue: #issue343 withTitle: 'Category/Variables tab not updating correctly'.
self selectServiceNamed: 'Rowan' in: self projectListPresenter.
self selectServiceNamed: 'Rowan-Services-Core' in: self packageListPresenter.
self selectServiceNamed: 'RowanBrowserService' in: self classListPresenter.
self selectHierarchyTab.
self assert: self projectsPresenter isCategoryTabSelected.
self assert: self categoryListPresenter list notEmpty.
browserServiceCategories := self categoryListPresenter list.
self projectsPresenter selectVariableTab.
self assert: self variableListPresenter list notEmpty.
selectedClass := self projectsPresenter selectedClass.
self assert: selectedClass name equals: 'RowanBrowserService'.
selectedClass instVarNames
do: [:instVar | self assert: (self variableListPresenter list includes: instVar asString)].
self selectClassInHierarchyNamed: 'RowanService'.
self assert: self variableListPresenter list notEmpty.
selectedClass := self projectsPresenter selectedClass.
self assert: selectedClass name equals: 'RowanService'.
selectedClass instVarNames
do: [:instVar | self assert: (self variableListPresenter list includes: instVar asString)].
self projectsPresenter selectCategoryTab.
self deny: browserServiceCategories size equals: self categoryListPresenter list size. "At least test that something changed since the categories will change" !

test_findClass
self projectsPresenter updateAfterFindClass: (RowanClassService new name: 'RwGsPlatform').
self assert: self classListPresenter selection name equals: 'RwGsPlatform'.
Expand Down Expand Up @@ -1879,7 +1904,7 @@ test_variablesTab
self selectServiceNamed: 'Rowan' in: self projectListPresenter.
self selectServiceNamed: 'Rowan-Services-Core' in: self packageListPresenter.
self selectServiceNamed: 'RowanClassService' in: self classListPresenter.
self projectsPresenter selectVariablesTab.
self projectsPresenter selectVariableTab.
self projectsPresenter variableListPresenter selection: 'variables'.
methodListSize := self methodListPresenter list size.
self denyIsNil: (selectedMethod := self methodListPresenter list
Expand Down Expand Up @@ -1963,6 +1988,7 @@ waitForPresenter: presenter
!JadeiteProjectBrowserTestCase categoriesFor: #test_exitJadeiteValidSession!public!test! !
!JadeiteProjectBrowserTestCase categoriesFor: #test_expansion!public!test class hierarchy! !
!JadeiteProjectBrowserTestCase categoriesFor: #test_extensionColoringInHierarchy!public!test class hierarchy! !
!JadeiteProjectBrowserTestCase categoriesFor: #test_filtersUpdatedInHierarchyView!public!test class hierarchy! !
!JadeiteProjectBrowserTestCase categoriesFor: #test_findClass!public!test!test class list! !
!JadeiteProjectBrowserTestCase categoriesFor: #test_goToDefinedClassFromClassList!public!test defined package! !
!JadeiteProjectBrowserTestCase categoriesFor: #test_goToDefinedClassFromHierarchy!public!test class hierarchy!test defined package! !
Expand Down
62 changes: 33 additions & 29 deletions sources/JadeiteProjectsBrowserPresenter.cls
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ filterTabChanged
[self clearFilterLists.
^self].
self populateFilterList.
self isCategoriesTabSelected
self isCategoryTabSelected
ifTrue:
[^methodListPresenter selectionOrNil
ifNil: [self selectMethodSourceTab]
Expand Down Expand Up @@ -713,9 +713,7 @@ initialize
stonCritical := Semaphore forMutualExclusion.!

isClassSelected

^classListPresenter selectionOrNil isNil not
!
^self selectedClass notNil!

isDictionariesTabSelected

Expand Down Expand Up @@ -917,9 +915,9 @@ pkgsMenuStrings
'&Unload Package...//unloadPackage')!
populateFilterList
self isCategoriesTabSelected
ifTrue: [categoryListPresenter list: self selectedClass categories]
ifFalse: [variableListPresenter list: self selectedClass variables]!
self isCategoryTabSelected
ifTrue: [categoryListPresenter list: (ListModel withAll: self selectedClass categories)]
ifFalse: [variableListPresenter list: (ListModel withAll: self selectedClass variables)]!
postOkToChangeEvent
| service |
Expand Down Expand Up @@ -1283,13 +1281,13 @@ refreshMethodsOn: presenter
ifTrue: [classListPresenter]
ifFalse: [classHierarchyPresenter].
classService := classPresenter selectionOrNil ifNil: [^self].
self isCategoriesTabSelected
self isCategoryTabSelected
ifTrue: [classService filters: categoryListPresenter selections]
ifFalse: [classService filters: variableListPresenter selections].
classService filters isEmpty
ifTrue: [classService filterType: nil]
ifFalse:
[self isCategoriesTabSelected
[self isCategoryTabSelected
ifTrue: [classService filterType: 'categories']
ifFalse: [classService filterType: 'variables']].
classService methods isNil
Expand Down Expand Up @@ -1414,6 +1412,9 @@ selectCategoryFrom: methodService
selectCategoryNamed: category
^self selectCategoriesNamed: (Array with: category)!
selectCategoryTab
(self view viewNamed: 'categoryList') ensureVisible!
selectClass: classSelection
| selection |
selection := classListPresenter list detect: [:svc | svc name = classSelection name] ifNone: [].
Expand Down Expand Up @@ -1482,7 +1483,7 @@ selectMethodSourceTab
| methodSourceTab selection |
methodSourceTab := self view viewNamed: 'methodSource'.
methodListPresenter selectionOrNil ifNotNil: [^methodSourceTab ensureVisible].
selection := self isCategoriesTabSelected
selection := self isCategoryTabSelected
ifTrue: [categoryListPresenter selectionOrNil]
ifFalse: [variableListPresenter selectionOrNil].
selection
Expand All @@ -1506,7 +1507,7 @@ selectSourceTabNamed: tabName
selectSUnitTab
self selectSourceTabNamed: 'sunit'!
selectVariablesTab
selectVariableTab
(self view viewNamed: 'variableList') ensureVisible!
setDefaultProjectTablLabel
Expand All @@ -1516,13 +1517,13 @@ setDefaultProjectTablLabel: listModel
projectLabel ifNil: [projectLabel := listModel detect: [:each | each text = 'Project']]!
setFilterType: selection
self isCategoriesTabSelected
self isCategoryTabSelected
ifTrue: [selection filterType: 'categories']
ifFalse: [selection filterType: 'variables']!
setMethodFilterFor: presenter
| filters |
self isCategoriesTabSelected
self isCategoryTabSelected
ifTrue: [filters := categoryListPresenter selections]
ifFalse: [filters := variableListPresenter selections].
presenter model do: [:service | service filters: filters]!
Expand Down Expand Up @@ -1715,25 +1716,27 @@ updateHierarchy
classHierarchyPresenter selection: selection]]]!
updateMenuBar
| shellView menuBar methodFilterMenu textAreaMenu methodMenu |
methodFilterMenu := Menu fromStrings: (self isCategoriesTabSelected ifTrue: [self categoriesMenuStrings] ifFalse: [self variablesMenuStrings]).
textAreaMenu := Menu fromStrings: (self isGlobalsTabSelected ifTrue: [self globalsMenuStrings] ifFalse: [self editMenuStrings]).
methodFilterMenu := Menu fromStrings: (self isCategoryTabSelected
ifTrue: [self categoriesMenuStrings]
ifFalse: [self variablesMenuStrings]).
textAreaMenu := Menu fromStrings: (self isGlobalsTabSelected
ifTrue: [self globalsMenuStrings]
ifFalse: [self editMenuStrings]).
shellView := self parentPresenter parentPresenter view.
menuBar := shellView menuBar
clear;
addItem: (Menu fromStrings: self jadeMenuStrings);
addItem: self projectMenu;
addItem: (Menu fromStrings: self pkgsMenuStrings);
addItem: (Menu fromStrings: self classesMenuStrings);
addItem: methodFilterMenu;
addItem: (methodMenu := Menu fromStrings: self methodsMenuStrings);
addItem: textAreaMenu;
addItem: (Menu fromStrings: self preferencesMenuStrings);
yourself.
clear;
addItem: (Menu fromStrings: self jadeMenuStrings);
addItem: self projectMenu;
addItem: (Menu fromStrings: self pkgsMenuStrings);
addItem: (Menu fromStrings: self classesMenuStrings);
addItem: methodFilterMenu;
addItem: (methodMenu := Menu fromStrings: self methodsMenuStrings);
addItem: textAreaMenu;
addItem: (Menu fromStrings: self preferencesMenuStrings);
yourself.
shellView menuBar: menuBar.
self updateMethodMenu: methodMenu
!
self updateMethodMenu: methodMenu!
updateMethodMenu: menu
| item |
Expand Down Expand Up @@ -2026,6 +2029,7 @@ writeProject
!JadeiteProjectsBrowserPresenter categoriesFor: #selectCategoriesNamed:!public!selection! !
!JadeiteProjectsBrowserPresenter categoriesFor: #selectCategoryFrom:!public!selection! !
!JadeiteProjectsBrowserPresenter categoriesFor: #selectCategoryNamed:!public!selection! !
!JadeiteProjectsBrowserPresenter categoriesFor: #selectCategoryTab!public!selection! !
!JadeiteProjectsBrowserPresenter categoriesFor: #selectClass:!private!selection! !
!JadeiteProjectsBrowserPresenter categoriesFor: #selectClassInClassHierarchyNamed:!private!selection! !
!JadeiteProjectsBrowserPresenter categoriesFor: #selectClassInClassListNamed:!private!selection! !
Expand All @@ -2041,7 +2045,7 @@ writeProject
!JadeiteProjectsBrowserPresenter categoriesFor: #selectPackage:!private!selection! !
!JadeiteProjectsBrowserPresenter categoriesFor: #selectSourceTabNamed:!private!selection! !
!JadeiteProjectsBrowserPresenter categoriesFor: #selectSUnitTab!public!selection! !
!JadeiteProjectsBrowserPresenter categoriesFor: #selectVariablesTab!public!selection! !
!JadeiteProjectsBrowserPresenter categoriesFor: #selectVariableTab!public!selection! !
!JadeiteProjectsBrowserPresenter categoriesFor: #setDefaultProjectTablLabel!event handlers!public! !
!JadeiteProjectsBrowserPresenter categoriesFor: #setDefaultProjectTablLabel:!event handlers!public! !
!JadeiteProjectsBrowserPresenter categoriesFor: #setFilterType:!event handlers support!private!services! !
Expand Down
4 changes: 2 additions & 2 deletions sources/Rowan UI Base.pax
Original file line number Diff line number Diff line change
Expand Up @@ -3062,7 +3062,7 @@ updateMethod
backcolor: nil;
isReadOnly: true;
yourself].
((methodCategory := gsMethod category) notEmpty and: [self isCategoriesTabSelected])
((methodCategory := gsMethod category) notEmpty and: [self isCategoryTabSelected])
ifTrue:
[| fullList selections index newName |
fullList := categoryListPresenter list.
Expand Down Expand Up @@ -3118,7 +3118,7 @@ updateSelector
backcolor: nil;
isReadOnly: true;
yourself].
((methodCategory := gsMethod category) notEmpty and: [self isCategoriesTabSelected])
((methodCategory := gsMethod category) notEmpty and: [self isCategoryTabSelected])
ifTrue:
[| fullList selections index newName |
fullList := categoryListPresenter list.
Expand Down
Loading

0 comments on commit 6f709ab

Please sign in to comment.