Browse Source

Cosmetic changes:
- Moved HLListItemNotFound to 'Helios-Exceptions'
- Adds class comments to Helios exceptions
- Reformatting of some HLListWidget methods

Nicolas Petton 10 years ago
parent
commit
2c6d7a81df
4 changed files with 39 additions and 22 deletions
  1. 6 9
      js/Helios-Core.js
  2. 6 0
      js/Helios-Exceptions.js
  3. 15 13
      st/Helios-Core.st
  4. 12 0
      st/Helios-Exceptions.st

+ 6 - 9
js/Helios-Core.js

@@ -1,10 +1,7 @@
-define("amber_core/Helios-Core", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Infrastructure", "amber_core/Canvas", "amber_core/Helios-Exceptions"], function(smalltalk,nil,_st){
+define("amber_core/Helios-Core", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Infrastructure", "amber_core/Canvas"], function(smalltalk,nil,_st){
 smalltalk.addPackage('Helios-Core');
 smalltalk.packages["Helios-Core"].transport = {"type":"amd","amdNamespace":"amber_core"};
 
-smalltalk.addClass('HLListItemNotFound', smalltalk.HLError, [], 'Helios-Core');
-
-
 smalltalk.addClass('HLModel', smalltalk.InterfacingObject, ['announcer', 'environment'], 'Helios-Core');
 smalltalk.HLModel.comment="I am the abstract superclass of all models of Helios.\x0aI am the \x22Model\x22 part of the MVC pattern implementation in Helios.\x0a\x0aI provide access to an `Environment` object and both a local (model-specific) and global (system-specific) announcer.\x0a\x0aThe `#withChangesDo:` method is handy for performing model changes ensuring that all widgets are aware of the change and can prevent it from happening.\x0a\x0aModifications of the system should be done via commands (see `HLCommand` and subclasses).";
 smalltalk.addMethod(
@@ -2188,7 +2185,7 @@ return self}
 catch(e) {if(e===$early)return e[0]; throw e}
 }, function($ctx1) {$ctx1.fill(self,"activateItem:",{anObject:anObject,listData:listData},smalltalk.HLListWidget)})},
 args: ["anObject"],
-source: "activateItem: anObject\x0a\x09| listData |\x0a\x09listData := [self listDataKeyFor: anObject] on: HLListItemNotFound do: [^self].\x0a\x09self activateListItem: ((wrapper asJQuery find: 'li[list-data=\x22', listData , '\x22]') eq: 0)",
+source: "activateItem: anObject\x0a\x09| listData |\x0a\x09\x0a\x09listData := [ self listDataKeyFor: anObject ] \x0a\x09\x09on: HLListItemNotFound \x0a\x09\x09do: [ ^ self ].\x0a\x09\x09\x0a\x09self activateListItem: ((wrapper asJQuery find: 'li[list-data=\x22', listData , '\x22]') eq: 0)",
 messageSends: ["on:do:", "listDataKeyFor:", "activateListItem:", "eq:", "find:", "asJQuery", ","],
 referencedClasses: ["HLListItemNotFound"]
 }),
@@ -2483,7 +2480,7 @@ return _st($HLListItemNotFound())._signal();
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"listDataKeyFor:",{anObject:anObject},smalltalk.HLListWidget)})},
 args: ["anObject"],
-source: "listDataKeyFor: anObject\x0a\x09^(self items indexOf: anObject ifAbsent: [HLListItemNotFound signal]) asString",
+source: "listDataKeyFor: anObject\x0a\x09^ (self items \x0a\x09\x09indexOf: anObject \x0a\x09\x09ifAbsent: [ HLListItemNotFound signal ]) asString",
 messageSends: ["asString", "indexOf:ifAbsent:", "items", "signal"],
 referencedClasses: ["HLListItemNotFound"]
 }),
@@ -2538,7 +2535,7 @@ return self}
 catch(e) {if(e===$early)return e[0]; throw e}
 }, function($ctx1) {$ctx1.fill(self,"refresh",{listData:listData},smalltalk.HLListWidget)})},
 args: [],
-source: "refresh\x0a\x09| listData |\x0a\x0a\x09super refresh.\x0a\x09listData := [self listDataKeyFor: self selectedItem] on: HLListItemNotFound do: [^self].\x0a\x09self ensureVisible: ((wrapper asJQuery find: 'li[list-data=\x22', listData , '\x22]') eq: 0)\x0a\x09",
+source: "refresh\x0a\x09| listData |\x0a\x0a\x09super refresh.\x0a\x09listData := [ self listDataKeyFor: self selectedItem ] \x0a\x09\x09on: HLListItemNotFound \x0a\x09\x09do: [ ^ self ].\x0a\x09self ensureVisible: ((wrapper asJQuery find: 'li[list-data=\x22', listData , '\x22]') eq: 0)\x0a\x09",
 messageSends: ["refresh", "on:do:", "listDataKeyFor:", "selectedItem", "ensureVisible:", "eq:", "find:", "asJQuery", ","],
 referencedClasses: ["HLListItemNotFound"]
 }),
@@ -2762,7 +2759,7 @@ smalltalk.addClass('HLNavigationListWidget', smalltalk.HLListWidget, ['previous'
 smalltalk.addMethod(
 smalltalk.method({
 selector: "activateItem:",
-category: 'as yet unclassified',
+category: 'actions',
 fn: function (anObject){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -2783,7 +2780,7 @@ return self}
 catch(e) {if(e===$early)return e[0]; throw e}
 }, function($ctx1) {$ctx1.fill(self,"activateItem:",{anObject:anObject},smalltalk.HLNavigationListWidget)})},
 args: ["anObject"],
-source: "activateItem: anObject\x0a\x09self activateListItem: ((wrapper asJQuery find: 'li[list-data=\x22',  (self items indexOf: anObject ifAbsent: [^self]) asString, '\x22]') eq: 0)",
+source: "activateItem: anObject\x0a\x09self activateListItem: ((wrapper asJQuery find: 'li[list-data=\x22',  (self items indexOf: anObject ifAbsent: [ ^self ]) asString, '\x22]') eq: 0)",
 messageSends: ["activateListItem:", "eq:", "find:", "asJQuery", ",", "asString", "indexOf:ifAbsent:", "items"],
 referencedClasses: []
 }),

+ 6 - 0
js/Helios-Exceptions.js

@@ -3,8 +3,14 @@ smalltalk.addPackage('Helios-Exceptions');
 smalltalk.packages["Helios-Exceptions"].transport = {"type":"amd","amdNamespace":"amber_core"};
 
 smalltalk.addClass('HLError', smalltalk.Error, [], 'Helios-Exceptions');
+smalltalk.HLError.comment="I am the abstract superclass of all Helios-specific errors.";
 
 
 smalltalk.addClass('HLChangeForbidden', smalltalk.HLError, [], 'Helios-Exceptions');
+smalltalk.HLChangeForbidden.comment="I get signaled when a (often user) requested change is forbidden. A confirmation message can then be displayed to the user.\x0a\x0aSee `HLModel >> withChangesDo:`.";
+
+
+smalltalk.addClass('HLListItemNotFound', smalltalk.HLError, [], 'Helios-Exceptions');
+smalltalk.HLListItemNotFound.comment="I get signaled by a `HLListWidget` when a non-existing item in the list is activated.";
 
 });

+ 15 - 13
st/Helios-Core.st

@@ -1,8 +1,4 @@
 Smalltalk current createPackage: 'Helios-Core'!
-HLError subclass: #HLListItemNotFound
-	instanceVariableNames: ''
-	package: 'Helios-Core'!
-
 InterfacingObject subclass: #HLModel
 	instanceVariableNames: 'announcer environment'
 	package: 'Helios-Core'!
@@ -784,7 +780,11 @@ activateFirstListItem
 
 activateItem: anObject
 	| listData |
-	listData := [self listDataKeyFor: anObject] on: HLListItemNotFound do: [^self].
+	
+	listData := [ self listDataKeyFor: anObject ] 
+		on: HLListItemNotFound 
+		do: [ ^ self ].
+		
 	self activateListItem: ((wrapper asJQuery find: 'li[list-data="', listData , '"]') eq: 0)
 !
 
@@ -836,14 +836,18 @@ focus
 !
 
 listDataKeyFor: anObject
-	^(self items indexOf: anObject ifAbsent: [HLListItemNotFound signal]) asString
+	^ (self items 
+		indexOf: anObject 
+		ifAbsent: [ HLListItemNotFound signal ]) asString
 !
 
 refresh
 	| listData |
 
 	super refresh.
-	listData := [self listDataKeyFor: self selectedItem] on: HLListItemNotFound do: [^self].
+	listData := [ self listDataKeyFor: self selectedItem ] 
+		on: HLListItemNotFound 
+		do: [ ^ self ].
 	self ensureVisible: ((wrapper asJQuery find: 'li[list-data="', listData , '"]') eq: 0)
 !
 
@@ -937,6 +941,10 @@ previous: aWidget
 
 !HLNavigationListWidget methodsFor: 'actions'!
 
+activateItem: anObject
+	self activateListItem: ((wrapper asJQuery find: 'li[list-data="',  (self items indexOf: anObject ifAbsent: [ ^self ]) asString, '"]') eq: 0)
+!
+
 nextFocus
 	self next ifNotNil: [ self next focus ]
 !
@@ -945,12 +953,6 @@ previousFocus
 	self previous ifNotNil: [ self previous focus ]
 ! !
 
-!HLNavigationListWidget methodsFor: 'as yet unclassified'!
-
-activateItem: anObject
-	self activateListItem: ((wrapper asJQuery find: 'li[list-data="',  (self items indexOf: anObject ifAbsent: [^self]) asString, '"]') eq: 0)
-! !
-
 !HLNavigationListWidget methodsFor: 'events'!
 
 setupKeyBindings

+ 12 - 0
st/Helios-Exceptions.st

@@ -2,8 +2,20 @@ Smalltalk current createPackage: 'Helios-Exceptions'!
 Error subclass: #HLError
 	instanceVariableNames: ''
 	package: 'Helios-Exceptions'!
+!HLError commentStamp!
+I am the abstract superclass of all Helios-specific errors.!
 
 HLError subclass: #HLChangeForbidden
 	instanceVariableNames: ''
 	package: 'Helios-Exceptions'!
+!HLChangeForbidden commentStamp!
+I get signaled when a (often user) requested change is forbidden. A confirmation message can then be displayed to the user.
+
+See `HLModel >> withChangesDo:`.!
+
+HLError subclass: #HLListItemNotFound
+	instanceVariableNames: ''
+	package: 'Helios-Exceptions'!
+!HLListItemNotFound commentStamp!
+I get signaled by a `HLListWidget` when a non-existing item in the list is activated.!