>From 0bc1601097cfc0b12ec341f87b27152d199bdd16 Mon Sep 17 00:00:00 2001 From: Gwenael Casaccio Date: Mon, 17 Jun 2013 21:13:04 +0200 Subject: [PATCH 1/2] Refactor some Smalltalk undo commands: make them subclass of commands. Smalltalk commands don't works as undoable commands, they could only be executed: a simple eval in the workspace could break the undo/redo code. --- packages/visualgst/ChangeLog | 32 +++++++++++++++++++ .../CategoryMenus/RenameCategoryCommand.st | 2 +- .../Commands/ClassMenus/AddClassCommand.st | 4 +-- .../Commands/ClassMenus/DeleteClassCommand.st | 2 +- .../Commands/ClassMenus/RenameClassCommand.st | 2 +- packages/visualgst/Commands/Command.st | 15 ++++++++- .../Commands/MethodMenus/DeleteMethodCommand.st | 2 +- .../Commands/NamespaceMenus/AddNamespaceCommand.st | 2 +- .../NamespaceMenus/DeleteNamespaceCommand.st | 2 +- .../NamespaceMenus/RenameNamespaceCommand.st | 2 +- .../Commands/SmalltalkMenus/AcceptItCommand.st | 4 +-- .../System/AddClassCommand.st} | 33 ++++++-------------- .../System/AddMethodCommand.st} | 26 ++++------------ .../System/AddNamespaceCommand.st} | 16 +++------- .../System/DeleteClassCommand.st} | 17 +++------- .../System/DeleteMethodCommand.st} | 20 +++--------- .../System/DeleteNamespaceCommand.st} | 14 +++------ .../System/RenameCategoryCommand.st} | 21 +++---------- .../System/RenameClassCommand.st} | 17 +++------- .../System/RenameNamespaceCommand.st} | 18 +++-------- packages/visualgst/package.xml | 36 +++++++++++----------- 21 files changed, 123 insertions(+), 164 deletions(-) rename packages/visualgst/{Undo/AddClassUndoCommand.st => Commands/System/AddClassCommand.st} (75%) rename packages/visualgst/{Undo/AddMethodUndoCommand.st => Commands/System/AddMethodCommand.st} (85%) rename packages/visualgst/{Undo/AddNamespaceUndoCommand.st => Commands/System/AddNamespaceCommand.st} (89%) rename packages/visualgst/{Undo/DeleteClassUndoCommand.st => Commands/System/DeleteClassCommand.st} (86%) rename packages/visualgst/{Undo/DeleteMethodUndoCommand.st => Commands/System/DeleteMethodCommand.st} (85%) rename packages/visualgst/{Undo/DeleteNamespaceUndoCommand.st => Commands/System/DeleteNamespaceCommand.st} (87%) rename packages/visualgst/{Undo/RenameCategoryUndoCommand.st => Commands/System/RenameCategoryCommand.st} (83%) rename packages/visualgst/{Undo/RenameClassUndoCommand.st => Commands/System/RenameClassCommand.st} (87%) rename packages/visualgst/{Undo/RenameNamespaceUndoCommand.st => Commands/System/RenameNamespaceCommand.st} (86%) diff --git a/packages/visualgst/ChangeLog b/packages/visualgst/ChangeLog index 9489ea3..36897ca 100644 --- a/packages/visualgst/ChangeLog +++ b/packages/visualgst/ChangeLog @@ -1,3 +1,35 @@ +2013-06-17 Gwenael Casaccio + + * Commands/System/AddClassCommand.st: New system command + * Commands/System/AddMethodCommand.st: New system command + * Commands/System/AddNamespaceCommand.st: New system command + * Commands/System/DeleteClassCommand.st: New system command + * Commands/System/DeleteMethodCommand.st: New system command + * Commands/System/DeleteNamespaceCommand.st: New system command + * Commands/System/RenameCategoryCommand.st: New system command + * Commands/System/RenameClassCommand.st: New system command + * Commands/System/RenameNamespaceCommand.st: New system command + * Commands/CategoryMenus/RenameCategoryCommand.st: Updated to new system command + * Commands/ClassMenus/AddClassCommand.st: Updated to new system command + * Commands/ClassMenus/DeleteClassCommand.st: Updated to new system command + * Commands/ClassMenus/RenameClassCommand.st: Updated to new system command + * Commands/Command.st: Updated to new system command + * Commands/MethodMenus/DeleteMethodCommand.st: Updated to new system command + * Commands/NamespaceMenus/AddNamespaceCommand.st: Updated to new system command + * Commands/NamespaceMenus/DeleteNamespaceCommand.st: Updated to new system command + * Commands/NamespaceMenus/RenameNamespaceCommand.st: Updated to new system command + * Commands/SmalltalkMenus/AcceptItCommand.st: Updated to new system command + * Undo/AddClassUndoCommand.st: Deleted + * Undo/AddMethodUndoCommand.st: Deleted + * Undo/AddNamespaceUndoCommand.st: Deleted + * Undo/DeleteClassUndoCommand.st: Deleted + * Undo/DeleteMethodUndoCommand.st: Deleted + * Undo/DeleteNamespaceUndoCommand.st: Deleted + * Undo/RenameCategoryUndoCommand.st: Deleted + * Undo/RenameClassUndoCommand.st: Deleted + * Undo/RenameNamespaceUndoCommand.st: Deleted + * package.xml: Update + 2013-06-17 Gwenael Casaccio * AbstractFinder.st: Add copyright header. diff --git a/packages/visualgst/Commands/CategoryMenus/RenameCategoryCommand.st b/packages/visualgst/Commands/CategoryMenus/RenameCategoryCommand.st index 883db28..f7dfc14 100644 --- a/packages/visualgst/Commands/CategoryMenus/RenameCategoryCommand.st +++ b/packages/visualgst/Commands/CategoryMenus/RenameCategoryCommand.st @@ -46,7 +46,7 @@ CategoryCommand subclass: RenameCategoryCommand [ | dlg | dlg := GtkEntryDialog title: 'Rename a category' text: 'Name of the category'. dlg hasPressedOk: [ - (RenameCategoryUndoCommand rename: target state category in: target state classOrMeta as: dlg result onModel: target viewedCategoryModel) push ] + (SysRenameCategoryCommand rename: target state category in: target state classOrMeta as: dlg result onModel: target viewedCategoryModel) executeIfValid ] ] ] diff --git a/packages/visualgst/Commands/ClassMenus/AddClassCommand.st b/packages/visualgst/Commands/ClassMenus/AddClassCommand.st index 2212fd4..1a6f1db 100644 --- a/packages/visualgst/Commands/ClassMenus/AddClassCommand.st +++ b/packages/visualgst/Commands/ClassMenus/AddClassCommand.st @@ -49,11 +49,11 @@ NamespaceCommand subclass: AddClassCommand [ ifFalse: [ Object ]. dlg := GtkEntryDialog title: 'Add a class' text: 'Name of the new class'. dlg hasPressedOk: [ - (AddClassUndoCommand + (SysAddClassCommand add: dlg result asSymbol to: target state namespace classCategory: target state classCategory - withSuperclass: superclass) push ] + withSuperclass: superclass) executeIfValid ] ] ] diff --git a/packages/visualgst/Commands/ClassMenus/DeleteClassCommand.st b/packages/visualgst/Commands/ClassMenus/DeleteClassCommand.st index 29e37b8..aca4ada 100644 --- a/packages/visualgst/Commands/ClassMenus/DeleteClassCommand.st +++ b/packages/visualgst/Commands/ClassMenus/DeleteClassCommand.st @@ -43,6 +43,6 @@ ClassCommand subclass: DeleteClassCommand [ execute [ - (DeleteClassUndoCommand delete: target state classOrMeta) push + (SysDeleteClassCommand delete: target state classOrMeta) executeIfValid ] ] diff --git a/packages/visualgst/Commands/ClassMenus/RenameClassCommand.st b/packages/visualgst/Commands/ClassMenus/RenameClassCommand.st index a34a007..3a9553c 100644 --- a/packages/visualgst/Commands/ClassMenus/RenameClassCommand.st +++ b/packages/visualgst/Commands/ClassMenus/RenameClassCommand.st @@ -46,7 +46,7 @@ ClassCommand subclass: RenameClassCommand [ | dlg | dlg := GtkEntryDialog title: 'Rename a class' text: 'Name of the class'. dlg hasPressedOk: [ - (RenameClassUndoCommand rename: target state classOrMeta as: dlg result asSymbol) push ] + (SysRenameClassCommand rename: target state classOrMeta as: dlg result asSymbol) executeIfValid ] ] ] diff --git a/packages/visualgst/Commands/Command.st b/packages/visualgst/Commands/Command.st index 8cd1ef5..32e826d 100644 --- a/packages/visualgst/Commands/Command.st +++ b/packages/visualgst/Commands/Command.st @@ -65,7 +65,7 @@ Object subclass: Command [ yourself ] - | target | + | target error | target: anObject [ @@ -85,6 +85,19 @@ Object subclass: Command [ ^ true ] + preconditionFailed: aString [ + + + error := aString. + ^ false + ] + + error [ + + + ^ error + ] + executeIfValid [ diff --git a/packages/visualgst/Commands/MethodMenus/DeleteMethodCommand.st b/packages/visualgst/Commands/MethodMenus/DeleteMethodCommand.st index b760541..0a17317 100644 --- a/packages/visualgst/Commands/MethodMenus/DeleteMethodCommand.st +++ b/packages/visualgst/Commands/MethodMenus/DeleteMethodCommand.st @@ -43,7 +43,7 @@ MethodCommand subclass: DeleteMethodCommand [ execute [ - (DeleteMethodUndoCommand delete: target state selector in: target state classOrMeta) push + (SysDeleteMethodCommand delete: target state selector in: target state classOrMeta) executeIfValid ] ] diff --git a/packages/visualgst/Commands/NamespaceMenus/AddNamespaceCommand.st b/packages/visualgst/Commands/NamespaceMenus/AddNamespaceCommand.st index f06c257..45992ca 100644 --- a/packages/visualgst/Commands/NamespaceMenus/AddNamespaceCommand.st +++ b/packages/visualgst/Commands/NamespaceMenus/AddNamespaceCommand.st @@ -46,7 +46,7 @@ NamespaceCommand subclass: AddNamespaceCommand [ | dlg | dlg := GtkEntryDialog title: 'Add a namespace' text: 'Name of the new namespace'. dlg hasPressedOk: [ - (AddNamespaceUndoCommand add: dlg result asSymbol to: target state namespace) push ] + (SysAddNamespaceCommand add: dlg result asSymbol to: target state namespace) executeIfValid ] ] ] diff --git a/packages/visualgst/Commands/NamespaceMenus/DeleteNamespaceCommand.st b/packages/visualgst/Commands/NamespaceMenus/DeleteNamespaceCommand.st index 62983e5..36e3e7c 100644 --- a/packages/visualgst/Commands/NamespaceMenus/DeleteNamespaceCommand.st +++ b/packages/visualgst/Commands/NamespaceMenus/DeleteNamespaceCommand.st @@ -46,7 +46,7 @@ NamespaceCommand subclass: DeleteNamespaceCommand [ | namespace | namespace := target state namespace. namespace subspaces isEmpty ifFalse: [ self error: 'Namespace has subspaces' ]. - (DeleteNamespaceUndoCommand delete: namespace) push + (SysDeleteNamespaceCommand delete: namespace) executeIfValid ] ] diff --git a/packages/visualgst/Commands/NamespaceMenus/RenameNamespaceCommand.st b/packages/visualgst/Commands/NamespaceMenus/RenameNamespaceCommand.st index d8b489d..76f15a6 100644 --- a/packages/visualgst/Commands/NamespaceMenus/RenameNamespaceCommand.st +++ b/packages/visualgst/Commands/NamespaceMenus/RenameNamespaceCommand.st @@ -46,7 +46,7 @@ NamespaceCommand subclass: RenameNamespaceCommand [ | dlg | dlg := GtkEntryDialog title: 'Rename a namespace' text: 'Name of the new namespace'. dlg hasPressedOk: [ - (RenameNamespaceUndoCommand rename: target state namespace as: dlg result asSymbol) push ] + (SysRenameNamespaceCommand rename: target state namespace as: dlg result asSymbol) executeIfValid ] ] ] diff --git a/packages/visualgst/Commands/SmalltalkMenus/AcceptItCommand.st b/packages/visualgst/Commands/SmalltalkMenus/AcceptItCommand.st index 996669e..f7c06a2 100644 --- a/packages/visualgst/Commands/SmalltalkMenus/AcceptItCommand.st +++ b/packages/visualgst/Commands/SmalltalkMenus/AcceptItCommand.st @@ -74,11 +74,11 @@ Command subclass: AcceptItCommand [ target state hasSelectedCategory ifFalse: [ ^ self acceptClassDefinition ]. - (AddMethodUndoCommand + (SysAddMethodCommand add: target sourceCode classified: target state category in: target state classOrMeta - browser: target) push + browser: target) executeIfValid ] ] diff --git a/packages/visualgst/Undo/AddClassUndoCommand.st b/packages/visualgst/Commands/System/AddClassCommand.st similarity index 75% rename from packages/visualgst/Undo/AddClassUndoCommand.st rename to packages/visualgst/Commands/System/AddClassCommand.st index 102b56c..55c636f 100644 --- a/packages/visualgst/Undo/AddClassUndoCommand.st +++ b/packages/visualgst/Commands/System/AddClassCommand.st @@ -1,6 +1,6 @@ "====================================================================== | -| AddClassUndoCommand class definition +| SysAddClassCommand class definition | ======================================================================" @@ -33,23 +33,21 @@ | ======================================================================" -UndoCommand subclass: AddClassUndoCommand [ +Command subclass: SysAddClassCommand [ - | first namespace newClassName parentClass newClass classCategory | + | namespace newClassName parentClass newClass classCategory | - AddClassUndoCommand class >> add: aSymbol to: aNamespace classCategory: aCategory withSuperclass: aClass [ + SysAddClassCommand class >> add: aSymbol to: aNamespace classCategory: aCategory withSuperclass: aClass [ ^ (self new) add: aSymbol to: aNamespace classCategory: aCategory withSuperclass: aClass; - precondition; yourself ] add: aSymbol to: aNamespace classCategory: aCategory withSuperclass: aClass [ - first := true. newClassName := aSymbol. namespace := aNamespace. classCategory := aCategory. @@ -62,7 +60,7 @@ UndoCommand subclass: AddClassUndoCommand [ ^ 'Add a class' ] - precondition [ + valid [ newClassName = #Smalltalk ifTrue: [ ^ self preconditionFailed: 'class name can''t be the same has a namespace name' ]. @@ -71,25 +69,12 @@ UndoCommand subclass: AddClassUndoCommand [ ^ true ] - undo [ + execute [ - parentClass removeSubclass: newClass. - namespace removeClass: newClass name - ] - - redo [ - - - first - ifTrue: [ - newClass := parentClass subclass: newClassName environment: namespace. - namespace at: newClass name put: newClass. - newClass category: classCategory fullname. - first := false ] - ifFalse: [ - parentClass addSubclass: newClass. - namespace insertClass: newClass ] + newClass := parentClass subclass: newClassName environment: namespace. + namespace at: newClass name put: newClass. + newClass category: classCategory fullname. ] ] diff --git a/packages/visualgst/Undo/AddMethodUndoCommand.st b/packages/visualgst/Commands/System/AddMethodCommand.st similarity index 85% rename from packages/visualgst/Undo/AddMethodUndoCommand.st rename to packages/visualgst/Commands/System/AddMethodCommand.st index 037ac76..bc0621a 100644 --- a/packages/visualgst/Undo/AddMethodUndoCommand.st +++ b/packages/visualgst/Commands/System/AddMethodCommand.st @@ -1,6 +1,6 @@ "====================================================================== | -| AddMethodUndoCommand class definition +| SysAddMethodCommand class definition | ======================================================================" @@ -33,11 +33,11 @@ | ======================================================================" -UndoCommand subclass: AddMethodUndoCommand [ +Command subclass: SysAddMethodCommand [ | selector method category classOrMeta oldCompiledMethod browserWidget compiledMethod | - AddMethodUndoCommand class >> add: aString classified: aCategory in: aClass [ + SysAddMethodCommand class >> add: aString classified: aCategory in: aClass [ ^ (self new) @@ -45,7 +45,7 @@ UndoCommand subclass: AddMethodUndoCommand [ yourself ] - AddMethodUndoCommand class >> add: aString classified: aCategory in: aClass browser: aGtkBrowserWidget [ + SysAddMethodCommand class >> add: aString classified: aCategory in: aClass browser: aGtkBrowserWidget [ ^ (self new) @@ -89,7 +89,7 @@ UndoCommand subclass: AddMethodUndoCommand [ ^ 'Add a method' ] - precondition [ + valid [ | parser node | @@ -109,21 +109,7 @@ UndoCommand subclass: AddMethodUndoCommand [ ^ true ] - undo [ - - - | selector | - browserWidget ifNotNil: [ browserWidget codeSaved ]. - - classOrMeta methodDictionary removeMethod: compiledMethod. - oldCompiledMethod - ifNotNil: [ - classOrMeta methodDictionary insertMethod: oldCompiledMethod. - selector := oldCompiledMethod selector ] - ifNil: [ selector := nil ]. - ] - - redo [ + execute [ browserWidget ifNotNil: [ browserWidget codeSaved ]. diff --git a/packages/visualgst/Undo/AddNamespaceUndoCommand.st b/packages/visualgst/Commands/System/AddNamespaceCommand.st similarity index 89% rename from packages/visualgst/Undo/AddNamespaceUndoCommand.st rename to packages/visualgst/Commands/System/AddNamespaceCommand.st index 902fdb8..2eafaec 100644 --- a/packages/visualgst/Undo/AddNamespaceUndoCommand.st +++ b/packages/visualgst/Commands/System/AddNamespaceCommand.st @@ -1,6 +1,6 @@ "====================================================================== | -| AddNamespaceUndoCommand class definition +| SysAddNamespace class definition | ======================================================================" @@ -33,10 +33,10 @@ | ======================================================================" -UndoCommand subclass: AddNamespaceUndoCommand [ +Command subclass: SysAddNamespaceCommand [ | parentNamespace namespaceName newNamespace | - AddNamespaceUndoCommand class >> add: aSymbol to: aNamespace [ + SysAddNamespaceCommand class >> add: aSymbol to: aNamespace [ ^ (self new) @@ -57,7 +57,7 @@ UndoCommand subclass: AddNamespaceUndoCommand [ ^ 'Add a namespace' ] - precondition [ + valid [ namespaceName = #Smalltalk ifTrue: [ ^ self preconditionFailed: 'class name can''t be the same has a namespace name' ]. @@ -68,13 +68,7 @@ UndoCommand subclass: AddNamespaceUndoCommand [ ^ true ] - undo [ - - - parentNamespace removeSubspace: newNamespace name - ] - - redo [ + execute [ parentNamespace insertSubspace: newNamespace diff --git a/packages/visualgst/Undo/DeleteClassUndoCommand.st b/packages/visualgst/Commands/System/DeleteClassCommand.st similarity index 86% rename from packages/visualgst/Undo/DeleteClassUndoCommand.st rename to packages/visualgst/Commands/System/DeleteClassCommand.st index 0487399..a3ad7dd 100644 --- a/packages/visualgst/Undo/DeleteClassUndoCommand.st +++ b/packages/visualgst/Commands/System/DeleteClassCommand.st @@ -1,6 +1,6 @@ "====================================================================== | -| DeleteClassUndoCommand class definition +| SysDeleteClassCommand class definition | ======================================================================" @@ -33,11 +33,11 @@ | ======================================================================" -UndoCommand subclass: DeleteClassUndoCommand [ +Command subclass: SysDeleteClassCommand [ | class | - DeleteClassUndoCommand class >> delete: aClass [ + SysDeleteClassCommand class >> delete: aClass [ ^ (self new) @@ -58,21 +58,14 @@ UndoCommand subclass: DeleteClassUndoCommand [ ^ 'Delete a class' ] - precondition [ + valid [ class subclasses isEmpty ifFalse: [ ^ self preconditionFailed: 'class has subclasses' ]. ^ true ] - undo [ - - - class superclass ifNotNil: [ class superclass addSubclass: class ]. - class environment insertClass: class - ] - - redo [ + execute [ class superclass ifNotNil: [ class superclass removeSubclass: class ]. diff --git a/packages/visualgst/Undo/DeleteMethodUndoCommand.st b/packages/visualgst/Commands/System/DeleteMethodCommand.st similarity index 85% rename from packages/visualgst/Undo/DeleteMethodUndoCommand.st rename to packages/visualgst/Commands/System/DeleteMethodCommand.st index 89336ca..f0ad368 100644 --- a/packages/visualgst/Undo/DeleteMethodUndoCommand.st +++ b/packages/visualgst/Commands/System/DeleteMethodCommand.st @@ -1,6 +1,6 @@ "====================================================================== | -| DeleteMethodUndoCommand class definition +| SysDeleteMethodCommand class definition | ======================================================================" @@ -33,11 +33,11 @@ | ======================================================================" -UndoCommand subclass: DeleteMethodUndoCommand [ +Command subclass: SysDeleteMethodCommand [ | selector classOrMeta compiledMethod | - DeleteMethodUndoCommand class >> delete: aSymbol in: aClass [ + SysDeleteMethodCommand class >> delete: aSymbol in: aClass [ ^ (self new) @@ -59,19 +59,7 @@ UndoCommand subclass: DeleteMethodUndoCommand [ ^ 'Delete a method' ] - precondition [ - - - ^ true - ] - - undo [ - - - classOrMeta methodDictionary insertMethod: compiledMethod. - ] - - redo [ + execte [ compiledMethod := classOrMeta >> selector. diff --git a/packages/visualgst/Undo/DeleteNamespaceUndoCommand.st b/packages/visualgst/Commands/System/DeleteNamespaceCommand.st similarity index 87% rename from packages/visualgst/Undo/DeleteNamespaceUndoCommand.st rename to packages/visualgst/Commands/System/DeleteNamespaceCommand.st index 8bd2c3b..718bdba 100644 --- a/packages/visualgst/Undo/DeleteNamespaceUndoCommand.st +++ b/packages/visualgst/Commands/System/DeleteNamespaceCommand.st @@ -1,6 +1,6 @@ "====================================================================== | -| DeleteNamespaceUndoCommand class definition +| SysDeleteNamespaceCommand class definition | ======================================================================" @@ -33,11 +33,11 @@ | ======================================================================" -UndoCommand subclass: DeleteNamespaceUndoCommand [ +Command subclass: SysDeleteNamespaceCommand [ | namespace treeStore | - DeleteNamespaceUndoCommand class >> delete: aNamespace [ + SysDeleteNamespaceCommand class >> delete: aNamespace [ ^ (self new) @@ -57,13 +57,7 @@ UndoCommand subclass: DeleteNamespaceUndoCommand [ ^ 'Delete a namespace' ] - undo [ - - - namespace superspace insertSubspace: namespace - ] - - redo [ + execute [ namespace superspace removeSubspace: namespace name diff --git a/packages/visualgst/Undo/RenameCategoryUndoCommand.st b/packages/visualgst/Commands/System/RenameCategoryCommand.st similarity index 83% rename from packages/visualgst/Undo/RenameCategoryUndoCommand.st rename to packages/visualgst/Commands/System/RenameCategoryCommand.st index 7a29841..3fc0beb 100644 --- a/packages/visualgst/Undo/RenameCategoryUndoCommand.st +++ b/packages/visualgst/Commands/System/RenameCategoryCommand.st @@ -1,6 +1,6 @@ "====================================================================== | -| RenameCategoryUndoCommand class definition +| SysRenameCategorycommand class definition | ======================================================================" @@ -33,11 +33,11 @@ | ======================================================================" -UndoCommand subclass: RenameCategoryUndoCommand [ +Command subclass: SysRenameCategoryCommand [ | category class newCategory treeStore | - RenameCategoryUndoCommand class >> rename: aString in: aClass as: aNewName onModel: aGtkTreeStore [ + SysRenameCategoryCommand class >> rename: aString in: aClass as: aNewName onModel: aGtkTreeStore [ ^ (self new) @@ -61,7 +61,7 @@ UndoCommand subclass: RenameCategoryUndoCommand [ ^ 'Rename a category' ] - precondition [ + valid [ newCategory = '*' ifTrue: [ ^ self preconditionFailed: 'Can''t create a * category' ]. @@ -69,18 +69,7 @@ UndoCommand subclass: RenameCategoryUndoCommand [ ^ true ] - undo [ - - - class methodDictionary do: [ :each | - each methodCategory = newCategory - ifTrue: [ each methodCategory: category ] ]. - treeStore - removeCategory: newCategory; - appendCategory: category - ] - - redo [ + execute [ class methodDictionary do: [ :each | diff --git a/packages/visualgst/Undo/RenameClassUndoCommand.st b/packages/visualgst/Commands/System/RenameClassCommand.st similarity index 87% rename from packages/visualgst/Undo/RenameClassUndoCommand.st rename to packages/visualgst/Commands/System/RenameClassCommand.st index 8d9c941..dd3edcc 100644 --- a/packages/visualgst/Undo/RenameClassUndoCommand.st +++ b/packages/visualgst/Commands/System/RenameClassCommand.st @@ -1,6 +1,6 @@ "====================================================================== | -| RenameClassUndoCommand class definition +| SysRenameClassCommand class definition | ======================================================================" @@ -33,11 +33,11 @@ | ======================================================================" -UndoCommand subclass: RenameClassUndoCommand [ +Command subclass: SysRenameClassCommand [ | class newClassName oldClassName | - RenameClassUndoCommand class >> rename: aClass as: aSymbol [ + SysRenameClassCommand class >> rename: aClass as: aSymbol [ ^ (self new) @@ -60,7 +60,7 @@ UndoCommand subclass: RenameClassUndoCommand [ ^ 'Rename a class' ] - precondition [ + execute [ newClassName = #Smalltalk ifTrue: [ ^ self preconditionFailed: 'class name can''t be the same has a namespace name' ]. @@ -69,15 +69,8 @@ UndoCommand subclass: RenameClassUndoCommand [ ^ true ] - undo [ - - - class environment removeClass: newClassName. - class setName: oldClassName. - class environment insertClass: class - ] - redo [ + valid [ class environment removeClass: oldClassName. diff --git a/packages/visualgst/Undo/RenameNamespaceUndoCommand.st b/packages/visualgst/Commands/System/RenameNamespaceCommand.st similarity index 86% rename from packages/visualgst/Undo/RenameNamespaceUndoCommand.st rename to packages/visualgst/Commands/System/RenameNamespaceCommand.st index 01b5923..80268c6 100644 --- a/packages/visualgst/Undo/RenameNamespaceUndoCommand.st +++ b/packages/visualgst/Commands/System/RenameNamespaceCommand.st @@ -1,6 +1,6 @@ "====================================================================== | -| RenameNamespaceUndoCommand class definition +| SysRenameNamespaceCommand class definition | ======================================================================" @@ -33,11 +33,11 @@ | ======================================================================" -UndoCommand subclass: RenameNamespaceUndoCommand [ +Command subclass: SysRenameNamespaceCommand [ | namespace oldName newName | - RenameNamespaceUndoCommand class >> rename: aNamespace as: aSymbol [ + SysRenameNamespaceCommand class >> rename: aNamespace as: aSymbol [ ^ (self new) @@ -60,7 +60,7 @@ UndoCommand subclass: RenameNamespaceUndoCommand [ ^ 'Rename a namespace' ] - precondition [ + execute [ newName = #Smalltalk ifTrue: [ ^ self preconditionFailed: 'Namespace name can''t be the same has a namespace name' ]. @@ -68,15 +68,7 @@ UndoCommand subclass: RenameNamespaceUndoCommand [ ^ true ] - undo [ - - - namespace superspace removeSubspace: namespace name. - namespace name: oldName. - namespace superspace insertSubspace: namespace - ] - - redo [ + valid [ namespace superspace removeSubspace: namespace name. diff --git a/packages/visualgst/package.xml b/packages/visualgst/package.xml index 4267d1d..45a7a8c 100644 --- a/packages/visualgst/package.xml +++ b/packages/visualgst/package.xml @@ -208,9 +208,9 @@ HistoryStack.st Undo/UndoStack.st Undo/UndoCommand.st - Undo/AddNamespaceUndoCommand.st - Undo/RenameNamespaceUndoCommand.st - Undo/DeleteNamespaceUndoCommand.st + Commands/System/AddNamespaceCommand.st + Commands/System/RenameNamespaceCommand.st + Commands/System/DeleteNamespaceCommand.st Source/SourceFormatter.st Source/NamespaceHeaderSource.st Source/NamespaceSource.st @@ -220,9 +220,9 @@ Source/MethodSource.st Source/PackageSource.st Source/BrowserMethodSource.st - Undo/AddClassUndoCommand.st - Undo/RenameClassUndoCommand.st - Undo/DeleteClassUndoCommand.st + Commands/System/AddClassCommand.st + Commands/System/RenameClassCommand.st + Commands/System/DeleteClassCommand.st AbstractFinder.st NamespaceFinder.st ClassFinder.st @@ -230,9 +230,9 @@ GtkWebBrowser.st GtkWebView.st GtkAssistant.st - Undo/RenameCategoryUndoCommand.st - Undo/AddMethodUndoCommand.st - Undo/DeleteMethodUndoCommand.st + Commands/System/RenameCategoryCommand.st + Commands/System/AddMethodCommand.st + Commands/System/DeleteMethodCommand.st WorkspaceVariableTracker.st GtkVariableTrackerWidget.st SyntaxHighlighter.st @@ -434,9 +434,9 @@ HistoryStack.st Undo/UndoStack.st Undo/UndoCommand.st - Undo/AddNamespaceUndoCommand.st - Undo/RenameNamespaceUndoCommand.st - Undo/DeleteNamespaceUndoCommand.st + Commands/System/AddNamespaceCommand.st + Commands/System/RenameNamespaceCommand.st + Commands/System/DeleteNamespaceCommand.st Source/SourceFormatter.st Source/NamespaceHeaderSource.st Source/NamespaceSource.st @@ -446,9 +446,9 @@ Source/MethodSource.st Source/PackageSource.st Source/BrowserMethodSource.st - Undo/AddClassUndoCommand.st - Undo/RenameClassUndoCommand.st - Undo/DeleteClassUndoCommand.st + Commands/System/AddClassCommand.st + Commands/System/RenameClassCommand.st + Commands/System/DeleteClassCommand.st AbstractFinder.st NamespaceFinder.st ClassFinder.st @@ -457,9 +457,9 @@ GtkWebView.st Extensions.st GtkAssistant.st - Undo/RenameCategoryUndoCommand.st - Undo/AddMethodUndoCommand.st - Undo/DeleteMethodUndoCommand.st + Commands/System/RenameCategoryCommand.st + Commands/System/AddMethodCommand.st + Commands/System/DeleteMethodCommand.st WorkspaceVariableTracker.st GtkVariableTrackerWidget.st SyntaxHighlighter.st -- 1.8.1.2