diff --git a/sources/JadeiteBrowserPresenter.cls b/sources/JadeiteBrowserPresenter.cls index 607bf4ba..3fb237b6 100644 --- a/sources/JadeiteBrowserPresenter.cls +++ b/sources/JadeiteBrowserPresenter.cls @@ -89,9 +89,7 @@ basicRemoveClass: theClassService | service parentNode | self isHierarchyTabSelected ifTrue: [parentNode := classHierarchyPresenter model parentNodeOf: theClassService]. - service := self isNoneProjectSelected - ifTrue: [dictionaryPresenter selection] - ifFalse: [packageListPresenter selection]. + service := self selectedDictionaryOrPackage. service command: #removeClass:; commandArgs: (Array with: theClassService). @@ -1483,6 +1481,26 @@ removeAppropriateTab removeLoadSpecTab] ifFalse: [self removeGlobalsTab]! +removeClass + | classService answeringService classReferenceBrowser queryService | + classService := self selectedClass ifNil: [^self]. + answeringService := RowanAnsweringService new. + answeringService + command: #classHasSubclasses:; + commandArgs: (Array with: classService oop). + self issueCommand: answeringService. + answeringService answer ifTrue: [^MessageBox notify: 'Cannot remove class with subclasses']. + (self selectedDictionaryOrPackage confirmClassRemoval: classService) ifFalse: [^self]. + queryService := JadePresenter basicBrowseClassReferences: classService name session: self gciSession. + queryService hasResults + ifTrue: [classReferenceBrowser := self browseClassReferences: classService name]. + self basicRemoveClass: classService. + queryService hasResults + ifTrue: + [MessageBox notify: classService name + , ' was removed. You will need to remove references to the class or your code may not load in the future.']. + ^classReferenceBrowser! + removeDictionaries | dictionaryNames | dictionaryPresenter selections isEmpty ifTrue: [^self]. @@ -1559,6 +1577,11 @@ selectDictionaryNamed: dictionaryName selectedDictionaryNames ^dictionaryPresenter selections collect: [:dictionaryService | dictionaryService name]! +selectedDictionaryOrPackage + ^self isNoneProjectSelected + ifTrue: [dictionaryPresenter selection] + ifFalse: [packageListPresenter selection]! + selectedGlobalName: selection | string rs | rs := ReadStream on: (selection at: 1). @@ -2110,6 +2133,7 @@ writeProject !JadeiteBrowserPresenter categoriesFor: #registerPresentersForUpdates!public!register presenters! ! !JadeiteBrowserPresenter categoriesFor: #reloadV2Project!menu handlers!public! ! !JadeiteBrowserPresenter categoriesFor: #removeAppropriateTab!private!tabs! ! +!JadeiteBrowserPresenter categoriesFor: #removeClass!menu handlers!public! ! !JadeiteBrowserPresenter categoriesFor: #removeDictionaries!menu handlers!public! ! !JadeiteBrowserPresenter categoriesFor: #removeGlobal!menu handlers!public! ! !JadeiteBrowserPresenter categoriesFor: #removeGlobalsTab!private!tabs! ! @@ -2122,6 +2146,7 @@ writeProject !JadeiteBrowserPresenter categoriesFor: #search!accessing!public! ! !JadeiteBrowserPresenter categoriesFor: #selectDictionaryNamed:!public!selection! ! !JadeiteBrowserPresenter categoriesFor: #selectedDictionaryNames!public!selection! ! +!JadeiteBrowserPresenter categoriesFor: #selectedDictionaryOrPackage!private!selection! ! !JadeiteBrowserPresenter categoriesFor: #selectedGlobalName:!menu handlers support!private! ! !JadeiteBrowserPresenter categoriesFor: #selectedPackageNames!public!selection! ! !JadeiteBrowserPresenter categoriesFor: #selectedPackageServices!public!selection! ! diff --git a/sources/JadeiteProjectsBrowserPresenter.cls b/sources/JadeiteProjectsBrowserPresenter.cls index e00d2f46..66ca25b1 100644 --- a/sources/JadeiteProjectsBrowserPresenter.cls +++ b/sources/JadeiteProjectsBrowserPresenter.cls @@ -135,27 +135,6 @@ basicProjectTabLabel label := packageListPresenter selection name. ^self selectedClass ifNil: [label] ifNotNil: [self selectedClass name]! -basicRemoveClass: selection - | packageService parentNode | - self isHierarchyTabSelected - ifTrue: [parentNode := classHierarchyPresenter model parentNodeOf: selection]. - packageService := packageListPresenter selection. - packageService - command: #removeClass:; - commandArgs: (Array with: selection). - self issueCommand: packageService. - classListPresenter model: classListPresenter model. "force a gui update" - self isHierarchyTabSelected - ifTrue: - [classHierarchyPresenter model: classHierarchyPresenter model. - classHierarchyPresenter selection: (classHierarchyPresenter model asBag - detect: [:classService | classService name = parentNode object name])]. - self selectedClass - ifNil: [self resetClassTemplate "just emptied the last class in the package"] - ifNotNil: - [classDefinitionPresenter value: self selectedClass template. - self resetClassDefinitionPane]! - basicRemoveMethodCategories | service | service := self selectedClass @@ -1166,26 +1145,6 @@ registerPresentersForUpdates releasedReferencedServices: selectionChangingEvent selectionChangingEvent window presenter selectionOrNil ifNotNil: [:service | service postUpdate]! -removeClass - | classService answeringService classReferenceBrowser queryService | - classService := self selectedClass ifNil: [^self]. - answeringService := RowanAnsweringService new. - answeringService - command: #classHasSubclasses:; - commandArgs: (Array with: classService oop). - self issueCommand: answeringService. - answeringService answer ifTrue: [^MessageBox notify: 'Cannot remove class with subclasses']. - (MessageBox confirm: 'Really delete class ' , classService name , '?') ifFalse: [^self]. - queryService := JadePresenter basicBrowseClassReferences: classService name session: self gciSession. - queryService hasResults - ifTrue: [classReferenceBrowser := self browseClassReferences: classService name]. - self basicRemoveClass: classService. - queryService hasResults - ifTrue: - [MessageBox notify: classService name - , ' was removed. You will need to remove references to the class or your code may not load in the future.']. - ^classReferenceBrowser! - removeMethodCategories | selections | selections := categoryListPresenter selections. @@ -1754,7 +1713,6 @@ updateSUnitTab: service !JadeiteProjectsBrowserPresenter categoriesFor: #basicAddMethodCategory:!menu handlers support!private! ! !JadeiteProjectsBrowserPresenter categoriesFor: #basicOnDropClassList:!drag & drop!public! ! !JadeiteProjectsBrowserPresenter categoriesFor: #basicProjectTabLabel!displaying!private! ! -!JadeiteProjectsBrowserPresenter categoriesFor: #basicRemoveClass:!menu handlers support!private! ! !JadeiteProjectsBrowserPresenter categoriesFor: #basicRemoveMethodCategories!menu handlers support!private! ! !JadeiteProjectsBrowserPresenter categoriesFor: #basicRemoveMethods!menu handlers support!private! ! !JadeiteProjectsBrowserPresenter categoriesFor: #basicRenameCategoryFrom:to:!menu handlers!public! ! @@ -1844,7 +1802,6 @@ updateSUnitTab: service !JadeiteProjectsBrowserPresenter categoriesFor: #registerClassData!public!updating! ! !JadeiteProjectsBrowserPresenter categoriesFor: #registerPresentersForUpdates!event handlers!initialize/release!private!register presenters! ! !JadeiteProjectsBrowserPresenter categoriesFor: #releasedReferencedServices:!event handlers!public! ! -!JadeiteProjectsBrowserPresenter categoriesFor: #removeClass!menu handlers!public! ! !JadeiteProjectsBrowserPresenter categoriesFor: #removeMethodCategories!menu handlers!public! ! !JadeiteProjectsBrowserPresenter categoriesFor: #removeMethods:!private!services! ! !JadeiteProjectsBrowserPresenter categoriesFor: #removeMethodSelector:!private!services! ! diff --git a/sources/RowanDictionaryService.cls b/sources/RowanDictionaryService.cls index d4d33ed0..f7f20f1f 100644 --- a/sources/RowanDictionaryService.cls +++ b/sources/RowanDictionaryService.cls @@ -55,6 +55,20 @@ classHierarchyUpdate: presenter browser: browser browser: browser hierarchyServices: hierarchyServices! +confirmClassRemoval: classService + | messageStream | + messageStream := WriteStream on: String new. + messageStream + nextPutAll: 'Really delete class '; + nextPutAll: classService name; + nextPut: $?. + classService packageName = RowanService notRowanizedPackageName + ifTrue: + [messageStream + cr; + nextPutAll: 'Note that removal of unpackaged classes will not be tracked by Rowan']. + ^MessageBox confirm: messageStream contents! + defaultTemplate ^defaultTemplate! @@ -140,6 +154,7 @@ sortAspect !RowanDictionaryService categoriesFor: #classes:!accessing!public! ! !RowanDictionaryService categoriesFor: #classesUpdate:browser:!public!updating! ! !RowanDictionaryService categoriesFor: #classHierarchyUpdate:browser:!public!updating! ! +!RowanDictionaryService categoriesFor: #confirmClassRemoval:!accessing!public! ! !RowanDictionaryService categoriesFor: #defaultTemplate!accessing!private! ! !RowanDictionaryService categoriesFor: #defaultTemplate:!accessing!private! ! !RowanDictionaryService categoriesFor: #displayName!displaying!public! ! diff --git a/sources/RowanPackageService.cls b/sources/RowanPackageService.cls index cffd36fa..f81fa656 100644 --- a/sources/RowanPackageService.cls +++ b/sources/RowanPackageService.cls @@ -83,6 +83,9 @@ condenseExtensions: presenter dictionary removeAllKeys: rejections. ^dictionary! +confirmClassRemoval: classService + ^MessageBox confirm: 'Really delete class ' , classService name , '?'! + defaultTemplate ^defaultTemplate! @@ -219,6 +222,7 @@ updateList: presenter whilePreservingSelections: updates browser: browser !RowanPackageService categoriesFor: #classesUpdate:browser:!public!updating! ! !RowanPackageService categoriesFor: #classHierarchyUpdate:browser:!public!updating! ! !RowanPackageService categoriesFor: #condenseExtensions:!private!updating! ! +!RowanPackageService categoriesFor: #confirmClassRemoval:!accessing!public! ! !RowanPackageService categoriesFor: #defaultTemplate!accessing!private! ! !RowanPackageService categoriesFor: #defaultTemplate:!accessing!private! ! !RowanPackageService categoriesFor: #displayName!displaying!public! !