Created
July 1, 2012 17:12
-
-
Save petermichaux/3028996 to your computer and use it in GitHub Desktop.
View methods from Squeak ported to View methods in Maria
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maria.View.prototype.getModel = function() { | |
return this._model; | |
}; | |
maria.View.prototype.setModel = function(model) { | |
this._setModelAndController(model, this._controller); | |
}; | |
maria.View.prototype.getDefaultControllerConstructor = function() { | |
return maria.Controller; | |
}; | |
maria.View.prototype.getDefaultController = function() { | |
var constructor = this.getDefaultControllerConstructor(); | |
return new constructor(); | |
}; | |
maria.View.prototype.getController = function() { | |
if (!this._controller) { | |
this.setController(this.getDefaultController()); | |
} | |
return this._controller; | |
}; | |
maria.View.prototype.setController = function(controller) { | |
this._setModelAndController(this._model, controller); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model | |
"Answer the receiver's model." | |
^model | |
model: aModel | |
"Set the receiver's model to aModel. The model of the receiver's controller | |
is also set to aModel." | |
self model: aModel controller: controller | |
defaultControllerClass | |
"Answer the class of the default controller for the receiver. Subclasses | |
should redefine View|defaultControllerClass if the class of the default | |
controller is not Controller." | |
^Controller | |
defaultController | |
"Answer an initialized instance of the receiver's default controller. | |
Subclasses should redefine this message only if the default controller | |
instances need to be initialized in a nonstandard way." | |
^self defaultControllerClass new | |
controller | |
"If the receiver's controller is nil (the default case), answer an initialized | |
instance of the receiver's default controller. If the receiver does not | |
allow a controller, answer the symbol #NoControllerAllowed." | |
controller == nil ifTrue: [self controller: self defaultController]. | |
^controller | |
controller: aController | |
"Set the receiver's controller to aController. #NoControllerAllowed can be | |
specified to indicate that the receiver will not have a controller. The | |
model of aController is set to the receiver's model." | |
self model: model controller: aController |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment