diff --git a/src/NewTools-Scopes-Browser/ScopeNode.class.st b/src/NewTools-Scopes-Browser/ScopeNode.class.st index 3757bbec7..637e37959 100644 --- a/src/NewTools-Scopes-Browser/ScopeNode.class.st +++ b/src/NewTools-Scopes-Browser/ScopeNode.class.st @@ -14,13 +14,13 @@ Class { } { #category : 'instance creation' } -ScopeNode class >> on: aPackageOrClass [ +ScopeNode class >> on: aRBEnvironment [ self class == ScopeNode ifTrue: [ - self error: 'I am ab abstract class' ]. + self error: 'I am an abstract class' ]. ^ self new - value: aPackageOrClass; + value: aRBEnvironment; yourself ] @@ -36,6 +36,12 @@ ScopeNode >> = anotherNode [ and: [ self label = anotherNode label ] ] +{ #category : 'accessing' } +ScopeNode >> == anotherNode [ + + ^ self = anotherNode +] + { #category : 'accessing' } ScopeNode >> basicEqualsTo: aNode [ @@ -62,6 +68,11 @@ ScopeNode >> isPackageNode [ ^ false ] +{ #category : 'testing' } +ScopeNode >> isScopeNode [ + ^ false +] + { #category : 'accessing' } ScopeNode >> label [ ^ self value name diff --git a/src/NewTools-Scopes-Browser/ScopePackageNode.class.st b/src/NewTools-Scopes-Browser/ScopePackageNode.class.st index 8d8650d0a..8977f28a1 100644 --- a/src/NewTools-Scopes-Browser/ScopePackageNode.class.st +++ b/src/NewTools-Scopes-Browser/ScopePackageNode.class.st @@ -27,6 +27,11 @@ ScopePackageNode >> isPackageNode [ ^ true ] +{ #category : 'testing' } +ScopePackageNode >> isScopeNode [ + ^ false +] + { #category : 'accessing' } ScopePackageNode >> scopesIconName [ ^ #package diff --git a/src/NewTools-Scopes-Browser/ScopeScopeNode.class.st b/src/NewTools-Scopes-Browser/ScopeScopeNode.class.st index b884fa612..706bfdf45 100644 --- a/src/NewTools-Scopes-Browser/ScopeScopeNode.class.st +++ b/src/NewTools-Scopes-Browser/ScopeScopeNode.class.st @@ -12,8 +12,21 @@ Class { { #category : 'accessing' } ScopeScopeNode >> children [ - ^ self value basisObjects collect: [ :package | - ScopePackageNode on: package ] + | className class package | + ^ self value basisObjects collect: [ :stringOrPackage | + stringOrPackage isString + ifTrue: [ + className := stringOrPackage. + class := self systemDictionary at: className ifAbsent: [ nil ]. + ScopeClassNode on: class ] + ifFalse: [ + package := stringOrPackage. + ScopePackageNode on: package ] ] +] + +{ #category : 'testing' } +ScopeScopeNode >> isScopeNode [ + ^ true ] { #category : 'accessing' } @@ -25,3 +38,8 @@ ScopeScopeNode >> label [ ScopeScopeNode >> scopesIconName [ ^ #references ] + +{ #category : 'accessing' } +ScopeScopeNode >> systemDictionary [ + ^ Smalltalk globals +] diff --git a/src/NewTools-Scopes-Browser/ScopesPresenter.class.st b/src/NewTools-Scopes-Browser/ScopesPresenter.class.st index d55fbb600..60e22d91c 100644 --- a/src/NewTools-Scopes-Browser/ScopesPresenter.class.st +++ b/src/NewTools-Scopes-Browser/ScopesPresenter.class.st @@ -53,6 +53,17 @@ ScopesPresenter class >> title [ ScopesPresenter >> addScopeToTree: aRBEnvironment [ model addScope: aRBEnvironment. + scopesTree updateRootsKeepingSelection: + (model scopes collect: [ :scope |self halt. ScopeScopeNode on: scope ]) + asOrderedCollection +] + +{ #category : 'deletion' } +ScopesPresenter >> deleteSelectedScope [ + + scopesTree selectedItems + select: [ :item | item isScopeNode ] + thenDo: [ :item | model removeScope: item ]. scopesTree updateRootsKeepingSelection: (model scopes collect: [ :scope | ScopeScopeNode on: scope ]) asOrderedCollection @@ -83,6 +94,7 @@ ScopesPresenter >> initializeScopesTree [ beMultipleSelection; roots: (model scopes collect: [ :package | + self halt. ScopeScopeNode on: package ]) asOrderedCollection sorted; beResizable; activateOnDoubleClick; diff --git a/src/NewTools-Scopes/ScopesManager.class.st b/src/NewTools-Scopes/ScopesManager.class.st index 8ceb99ea3..da825b854 100644 --- a/src/NewTools-Scopes/ScopesManager.class.st +++ b/src/NewTools-Scopes/ScopesManager.class.st @@ -105,12 +105,20 @@ ScopesManager >> newScopeFrom: aSetOfNodes [ ] +{ #category : 'removing' } +ScopesManager >> removeScope: aRBEnvironment [ + | removed | + removed := scopes select: [ :scope | scope label = aRBEnvironment label ]. + removed do: [ :scope | scopes remove: scope ] +] + { #category : 'initialization' } ScopesManager >> reset [ environment := nil. scopes := nil. - self announcer subscriptions reset + self announcer subscriptions reset. + self resetNewScope ] { #category : 'accessing' }