"Adapter tervminta" "Tailored Adapter" Shape subclass: #TextShape instanceVariableNames: 'textView' classVariableNames: '' poolDictionaries: '' TextShape class>>new "Return a new instance of me pointing to an instance of TextView." ^self basicNew textView: TextView new TextShape>>textView "Return my Adaptee" ^textView TextShape>>textView: aTextView "Set my Adaptee" textView := aTextView TextShape>>boundingBox "Translate and delegate this to my TextView object." ^self textView getExtent TextShape>>isEmpty ^self textView isEmpty "Message-based Pluggable Adapter" Object subclass: #MessageAdapter instanceVariableNames: 'adaptee getSelector setSelector' classVariableNames: '' poolDictionaries: '' MessageAdapter class>>on: anAdaptee "Instance creation" ^self new adaptee: anAdaptee MessageAdapter>>adaptee: anObject adaptee := anObject MessageAdapter>>adaptee ^adaptee MessageAdapter>>getSelector: aSymbol "Setup my getter message translation. aSymbol is the selector to send to my Adaptee when I receive the #value message" getSelector:= aSymbol MessageAdapter>>setSelector: aSymbol "Setup my setter message translation. aSymbol is the selector to send to my Adaptee when I receive the #value: message" setSelector:= aSymbol MessageAdapter>>onAspect: aspectSymbol "A handy method to set both setter and getter messages in one shot; assumes both have the same name, differing only by the ':' suffix for the setter." self getSelector: aspectSymbol; setSelector: (aspectSymbol, ':') asSymbol MessageAdapter>>value "Return the aspect of my Adaptee specified by my getSelector" ^adaptee perform: getSelector MessageAdapter>>value: anObject "Set the aspect of my Adaptee specified by my setSelector" ^adaptee perform: setSelector with: anObject "adapter := MessageAdapter on: myApplicationModel. adapter getSelector: #socialSecurity; setSelector: #socialSecurity:." "adapter onAspect: #socialSecurity."