Jelajahi Sumber

Merge pull request #60 from mkroehnert/rename-package

add rename package command (fix #30)
Herbert Vojčík 9 tahun lalu
induk
melakukan
57b152a0fa
4 mengubah file dengan 276 tambahan dan 2 penghapusan
  1. 185 0
      src/Helios-Commands-Tools.js
  2. 50 0
      src/Helios-Commands-Tools.st
  3. 33 1
      src/Helios-Core.js
  4. 8 1
      src/Helios-Core.st

+ 185 - 0
src/Helios-Commands-Tools.js

@@ -2293,6 +2293,191 @@ messageSends: []
 $globals.HLRenameClassCommand.klass);
 
 
+$core.addClass('HLRenamePackageCommand', $globals.HLRenameCommand, [], 'Helios-Commands-Tools');
+$core.addMethod(
+$core.method({
+selector: "category",
+protocol: 'accessing',
+fn: function (){
+var self=this;
+return "Packages";
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "category\x0a\x09^ 'Packages'",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.HLRenamePackageCommand);
+
+$core.addMethod(
+$core.method({
+selector: "defaultInput",
+protocol: 'defaults',
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$recv($recv(self._model())._selectedPackage())._name();
+return $1;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"defaultInput",{},$globals.HLRenamePackageCommand)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "defaultInput\x0a\x09^ self model selectedPackage name",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["name", "selectedPackage", "model"]
+}),
+$globals.HLRenamePackageCommand);
+
+$core.addMethod(
+$core.method({
+selector: "displayLabel",
+protocol: 'accessing',
+fn: function (){
+var self=this;
+return "Rename package to:";
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "displayLabel\x0a\x09^ 'Rename package to:'",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.HLRenamePackageCommand);
+
+$core.addMethod(
+$core.method({
+selector: "execute",
+protocol: 'executing',
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+$recv(self._model())._renamePackageTo_(self._input());
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"execute",{},$globals.HLRenamePackageCommand)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "execute\x0a\x09self model renamePackageTo: self input",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["renamePackageTo:", "model", "input"]
+}),
+$globals.HLRenamePackageCommand);
+
+$core.addMethod(
+$core.method({
+selector: "isActive",
+protocol: 'testing',
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$recv($recv(self._model())._selectedPackage())._notNil();
+return $1;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"isActive",{},$globals.HLRenamePackageCommand)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "isActive\x0a\x09^ self model selectedPackage notNil",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["notNil", "selectedPackage", "model"]
+}),
+$globals.HLRenamePackageCommand);
+
+$core.addMethod(
+$core.method({
+selector: "isInputRequired",
+protocol: 'testing',
+fn: function (){
+var self=this;
+return true;
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "isInputRequired\x0a\x09^ true",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.HLRenamePackageCommand);
+
+
+$core.addMethod(
+$core.method({
+selector: "key",
+protocol: 'accessing',
+fn: function (){
+var self=this;
+return "p";
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "key\x0a\x09^ 'p'",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.HLRenamePackageCommand.klass);
+
+$core.addMethod(
+$core.method({
+selector: "label",
+protocol: 'accessing',
+fn: function (){
+var self=this;
+return "Rename package";
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "label\x0a\x09^ 'Rename package'",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.HLRenamePackageCommand.klass);
+
+$core.addMethod(
+$core.method({
+selector: "menuLabel",
+protocol: 'accessing',
+fn: function (){
+var self=this;
+return "Rename package...";
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "menuLabel\x0a\x09^ 'Rename package...'",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.HLRenamePackageCommand.klass);
+
+
 $core.addClass('HLRenameProtocolCommand', $globals.HLRenameCommand, [], 'Helios-Commands-Tools');
 $core.addMethod(
 $core.method({

+ 50 - 0
src/Helios-Commands-Tools.st

@@ -660,6 +660,56 @@ menuLabel
 	^ 'Rename class...'
 ! !
 
+HLRenameCommand subclass: #HLRenamePackageCommand
+	instanceVariableNames: ''
+	package: 'Helios-Commands-Tools'!
+
+!HLRenamePackageCommand methodsFor: 'accessing'!
+
+category
+	^ 'Packages'
+!
+
+displayLabel
+	^ 'Rename package to:'
+! !
+
+!HLRenamePackageCommand methodsFor: 'defaults'!
+
+defaultInput
+	^ self model selectedPackage name
+! !
+
+!HLRenamePackageCommand methodsFor: 'executing'!
+
+execute
+	self model renamePackageTo: self input
+! !
+
+!HLRenamePackageCommand methodsFor: 'testing'!
+
+isActive
+	^ self model selectedPackage notNil
+!
+
+isInputRequired
+	^ true
+! !
+
+!HLRenamePackageCommand class methodsFor: 'accessing'!
+
+key
+	^ 'p'
+!
+
+label
+	^ 'Rename package'
+!
+
+menuLabel
+	^ 'Rename package...'
+! !
+
 HLRenameCommand subclass: #HLRenameProtocolCommand
 	instanceVariableNames: ''
 	package: 'Helios-Commands-Tools'!

+ 33 - 1
src/Helios-Core.js

@@ -1388,6 +1388,38 @@ messageSends: ["withChangesDo:", "renameClass:to:", "environment", "theNonMetaCl
 }),
 $globals.HLToolModel);
 
+$core.addMethod(
+$core.method({
+selector: "renamePackageTo:",
+protocol: 'commands actions',
+fn: function (aPackageName){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+self._withChangesDo_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+return $recv(self._environment())._renamePackage_to_($recv(self._selectedPackage())._name(),aPackageName);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
+//>>excludeEnd("ctx");
+}));
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"renamePackageTo:",{aPackageName:aPackageName},$globals.HLToolModel)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aPackageName"],
+source: "renamePackageTo: aPackageName\x0a\x09self withChangesDo: [\x0a\x09\x09self environment\x0a\x09\x09\x09renamePackage: self selectedPackage name\x0a\x09\x09\x09to: aPackageName ]",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["withChangesDo:", "renamePackage:to:", "environment", "name", "selectedPackage"]
+}),
+$globals.HLToolModel);
+
 $core.addMethod(
 $core.method({
 selector: "renameProtocolTo:",
@@ -1709,7 +1741,7 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aPackage"],
-source: "selectedPackage: aPackage\x0a\x09selectedPackage = aPackage ifTrue: [ ^ self ].\x0a    \x0a\x09self withChangesDo: [\x0a\x09\x09selectedPackage := aPackage.\x0a\x09\x09self selectedClass: nil.\x0a\x09\x09self announcer announce: (HLPackageSelected on: aPackage) ]",
+source: "selectedPackage: aPackage\x0a\x09selectedPackage = aPackage ifTrue: [ ^ self ].\x0a\x0a\x09self withChangesDo: [\x0a\x09\x09selectedPackage := aPackage.\x0a\x09\x09self selectedClass: nil.\x0a\x09\x09self announcer announce: (HLPackageSelected on: aPackage) ]",
 referencedClasses: ["HLPackageSelected"],
 //>>excludeEnd("ide");
 messageSends: ["ifTrue:", "=", "withChangesDo:", "selectedClass:", "announce:", "announcer", "on:"]

+ 8 - 1
src/Helios-Core.st

@@ -213,7 +213,7 @@ selectedPackage
 
 selectedPackage: aPackage
 	selectedPackage = aPackage ifTrue: [ ^ self ].
-    
+
 	self withChangesDo: [
 		selectedPackage := aPackage.
 		self selectedClass: nil.
@@ -332,6 +332,13 @@ renameClassTo: aClassName
 			to: aClassName ]
 !
 
+renamePackageTo: aPackageName
+	self withChangesDo: [
+		self environment
+			renamePackage: self selectedPackage name
+			to: aPackageName ]
+!
+
 renameProtocolTo: aString
 	self withChangesDo: [
 		self environment