From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:28:59 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <class> <name>AccessAdaptor</name> <environment>Core</environment> <super>Core.Announcer</super> <private>false</private> none model accessor mutator accessPath privateModelValue modelAnnouncesUpdate modelUpdateAnnouncement <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.AccessAdaptor
AccessAdaptor encapsulates a complex way of retrieving data from the model behind the uniform #value/#value: interface. One creates an AccessAdaptor (either by "AccessAdaptor new model: <anObject>" or "AccessAdaptor with: <anObject>") and then sets the various attributes to configure how the adaptor should access the model to retrieve the value it reports (the "accessor") and update the model to store the value (the "mutator"). The accessor and mutator values may be either a Symbol, an Integer or a Block. If the accessor is a Symbol, it is a unary selector sent to the model as a message and the result is returned as the adaptor's value. If the mutator is a Symbol, it is a one-argument selector sent to the model as a message with the new value as the argument. If no mutator is configured explicitly, the accessor with ':' appended is used as the mutator. If an accessor is an Integer, then when accessing, the #at: method is sent with the accessor as the argument, and when mutating, #at:put: with the accessor as the first argument and the new value as the second. If the accessor is a Block, it should be a one-argument block, where the model is sent in as parameter. The value returned by the block is the value returned by the adaptor. If the mutator is a block, it is a two-argument block where the first parameter is the underlying model and the second is the new value that is to be assigned for that model. The accessPath, if specified, contains a collection of vaid accessors (Symbols or Integers). When getting or setting, each item in the accessPath is performed against the model, before the final accessor or mutator is performed. This array of selectors and/or numbers, allows one to "drill" into a domain model. For example, if one had a collection of companies as a domain object for which one wanted the first item, and from that item the shipping address, and from the address the state, one could specify the accessPath: #(1 #shippingAddress) and the accessor: #state. The user may also send in a ObservedValue to the model: message. This allows the user to embed the model object into something they can change later without having to touch the AccessAdaptor. When the user does this, the ObservedValue is set to let the AccessAdaptor know if the user changes the value in the ObservedValue, and to rehook itself to now work on THAT new value. If the user is using a domain object that itself triggers events when it is changed, the user may set the modelUpdateAnnouncement to be the announcement class broadcast by the domain model that we want to watch for. Once that is set, the AccessAdaptor will itself trigger the ModelUpdated announcements, which the user can then subscribe to and be notified about. Instance Variables: accessor <Symbol | BlockContext | Integer> The access executor for this model accessPath <(Collection of: (Symbol | Integer))> The default is nil model <Object> The model object being managed by this adaptor modelAnnouncesUpdate <Boolean> True if the receiver should subscribe to and listed to modelUpdateAnnouncements. mutator <Symbol | BlockContext | Integer | nil> Default is nil. privateModelValue <ObservedValue | nil> PRIVATE: Used internally when the model is wrapped in an ObservedValue object modelUpdateAnnouncement <Announcement class | nil> If not nil, the announcement class the reeiver should listen to to respond to changes in the model. Announcements ValueAboutToChange Announced when the value held by the receiver is about to change. This announcement is vetoable, and if the #veto message is sent to it, the change is aborted and none of the following announcements are broadcast. ValueChanging Announced just before changing the value, when the change is imminent. ValueChanged Announced right after changing the value. ModelUpdated Announced when the underlying model broadcasts "modelUpdateAnnouncement" thus notifying the world that the value in the model itself, or the value in the model has changed external to the behavior of this AccessAdaptor
</comment> <class> <name>ObservedTwoDList</name> <environment>Core</environment> <super>Core.ArrayedCollection</super> <private>false</private> none collection rows columns transposed subscriptionRegistry <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.ObservedTwoDList
ObservedTwoDList is the two-dimensional analogue of an ObservedList. However, while ObservedLists are dynamically extensible, ObservedTwoDLists are not. The individual elements of the TwoDList are accessible either in terms of index points or in terms of their position in the underlying sequence. This class has the idea of transposing the data that it is responsible for. When an ObservedTwoDList has "transposed" the data, all that is actually occuring is that the interpretation of the 'x' and 'y' values is swapped. Thus the data is still in it's original list form, only the point access is transposed to give the behavior of having actually transposed the data. Instance Variables: collection <ArrayedCollection> The elements of the TwoDList in linear array rows <Integer> The number of rows columns <Integer> The number of columns transposed <Boolean> A flag to indicate whether or not this list have been "transposed" subscriptionRegistry <SubscriptionRegistry | nil> The locally stored registry for subscriptions to announcements of the receiver. Announcements ValueAboutToChange Announced when the value held by the receiver is about to change in any way. This announcement is vetoable, and if the #veto message is sent to it, the change is aborted and none of the following announcements are broadcast. Note that ObservedLists don't set newValue and oldValue attributes of this announcement. ValueChanging Announced just before changing the value, when the change is imminent. Note that ObservedLists don't set newValue and oldValue attributes of this announcement. ValueChanged Announced right after changing the value. Note that ObservedLists don't set newValue and oldValue attributes of this announcement. ElementsReplaced Announced after some elements within a contiguous range have been replaced with other objects without changing the size of the collection, for example by using #at:put: or #repaceFrom:to:with:startingAt:. The 'indexes' attribute of the announcement contains an Interval of indexes affected. The 'elements' attribute contains the elements that used to reside at those indexes. ElementsReordered Announced after the order of elements in the collection has been changed, without adding or removing any elements. For example, the #sort: message causes this to be triggered. ElementsTransposed Announced after transposing the list. Object Reference: An ObservedTwoDList is a two-dimensional list, representing rows and columns in a table. It is typically used to hold the data for a Grid. Because its size cannot be changed dynamically, it is only used for a Grid whose size does not change. For a dynamically extensible Grid, use a ObservedList instead. An ObservedTwoDList has an underlying one-dimensional collection of elements. It is typically created by sending a variant of #on:columns:rows: to this class, with the collection of elements as the first argument. The specified number of rows and columns, when multiplied together, are expected to equal the size of the base collection. An element in an ObservedTwoDList can be accessed either via column-and-row numbers or via a flat index number for the underlying collection.
</comment> <class> <name>ContentsChangeAnnouncement</name> <environment>Core</environment> <super>Core.Announcement</super> <private>false</private> none indexes <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.ContentsChangeAnnouncement
ContentsChangeAnnouncement is an abstract superclass of announcements notifying about the change in elements of an ObservedList of ObservedTwoDList. It typically includes the Interval of collection idexes affected by the change, accessible as #indexes. Announcements from ObservedTwoDList use the point of the change instead, accessible as #location. Instance Variables: indexes <Interval | Point | nil> The location of the change, if applicable.
</comment> <class> <name>ElementsReordered</name> <environment>Core</environment> <super>Core.ContentsChangeAnnouncement</super> <private>false</private> none <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.ElementsReordered
ElementsReordered notifies about the change of order of elements in the collection, without adding or removing any elements. The 'indexes' attribute is not used by this announcement.
</comment> <class> <name>ElementsTransposed</name> <environment>Core</environment> <super>Core.ElementsReordered</super> <private>false</private> none transposed <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.ElementsTransposed
ElementsTransposed notifies about transposing an ObservedTwoDList. The 'transposed' attribute contains the new state of the transposed flag of the collection. Instance Variables: transposed <Boolean> Shows whether the 2D list is transposed or not after the change.
</comment> <class> <name>ValueChangeAnnouncement</name> <environment>Core</environment> <super>Core.Announcement</super> <private>false</private> none newValue oldValue <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.ValueChangeAnnouncement
ValueChangeAnnouncement is an abstract superclass of announcements informing of an object's value changing. It can carry both the old and the new value if the announces chooses to provide them. Instance Variables: newValue <Object | nil> The new value. oldValue <Object | nil> The old value.
</comment> <class> <name>ValueChanged</name> <environment>Core</environment> <super>Core.ValueChangeAnnouncement</super> <private>false</private> none <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.ValueChanged
ValueChanged is one of the three announcements of the standard value change sequence. An object notifying about the change of a value does so as a sequence of three announcements: ValueAboutToChange sequence stops here if the above is vetoed ValueChanging <value changes at this point> ValueChanged All announcements carry the old and the new values, if at all possible. ValueAboutToChange is vetoable; vetoing it cancels the value change. Subscribe to it if you are interested in preventing some of the value changes to happen. ValueChanging is broadcast before an imminent value change. Subscribe to it to be notified before a value change. Do not use AboutToChangeValue for that purpose--AboutToChangeValue doesn't guarantee that the value change is imminent, since a subscriber receiving an announcement later could veto it. ValueChanged is broadcast after a value change.
</comment> <class> <name>ElementsRemoved</name> <environment>Core</environment> <super>Core.ContentsChangeAnnouncement</super> <private>false</private> none elements <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.ElementsRemoved
ElementsRemoved notifies about removing a contiguous range of elements from a collection (or a single element). The 'indexes' attribute contains the indexes of the removed elements *before the removal*. The 'elements' attribute contains a collection of elements that have been removed. Instance Variables: elements <Collection> A collection of objects just removed from the collection. This is always a collection, even if only one element has been removed.
</comment> <class> <name>ObservedList</name> <environment>Core</environment> <super>Core.ArrayedCollection</super> <private>false</private> none collection limit collectionSize subscriptionRegistry <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.ObservedList
ObservedList is an OrderedCollection-like object which announces changes of its contents. It has both the fast #at:put: commands of an Arrayed object, as well as the ability to use the #add: protocol of an growable collection. Instance Variables: collection <SequenceableCollection of: Object> Private: The raw collection it holds. collectionSize <ArithmeticValue> Private: The raw collection size. limit <Number> Private: The maximum position inside the collection that is used. subscriptionRegistry <SubscriptionRegistry | nil> Holds subscriptions to announcements of the receiver. Announcements ValueAboutToChange Announced when the value held by the receiver is about to change in any way. This announcement is vetoable, and if the #veto message is sent to it, the change is aborted and none of the following announcements are broadcast. Note that ObservedLists don't set newValue and oldValue attributes of this announcement. ValueChanging Announced just before changing the value, when the change is imminent. Note that ObservedLists don't set newValue and oldValue attributes of this announcement. ValueChanged Announced right after changing the value. Note that ObservedLists don't set newValue and oldValue attributes of this announcement. ElementsReplaced Announced after some elements within a contiguous range have been replaced with other objects without changing the size of the collection, for example by using #at:put: or #repaceFrom:to:with:startingAt:. The 'indexes' attribute of the announcement contains an Interval of indexes affected. The 'elements' attribute contains the elements that used to reside at those indexes. ElementsInserted Announced after new elements have been inserted into the collection, increasing its size. For example, #add:, #addLast:, #addAll:, #insertCollection:before: all broadcast this announcement. The 'indexes' attribute of the announcement contains an Interval of indexes affected. ElementsRemoved Announced after elements have been removed from the collection, reducing its size. The 'elements' attribute contains a collection of removed objects. ElementsReordered Announced after the order of elements in the collection has been changed, without adding or removing any elements. For example, the #sort: message causes this to be triggered.
</comment> <class> <name>ObservedValue</name> <environment>Core</environment> <super>Core.Announcer</super> <private>false</private> none value <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.ObservedValue
A ObservedValue is an Announcements-aware equilvalent of ValueHolder. It holds onto an object, accessible through #value/value: pair of messages, and announces ValueAboutToChange, ValueChanging and ValueChanged announcements as the value is being changed. Instance Variables: value <Object> The value that, when gets replaced via #value: will broadcast the standard sequence of three change announcements (see below). Announcements ValueAboutToChange Announced when the value held by the receiver is about to change. This announcement is vetoable, and if the #veto message is sent to it, the change is aborted and none of the following announcements are broadcast. ValueChanging Announced just before changing the value, when the change is imminent. ValueChanged Announced right after changing the value.
</comment> <class> <name>BufferedValue</name> <environment>Core</environment> <super>Core.ObservedValue</super> <private>false</private> none model coordinator <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.BufferedValue
BufferedValue hides behing itself another ObservedValue object (the model). Any #value: messages sent to BufferedValue store the argument in the BufferedValue rather than the model. Sending #value to the BufferedValue answers that locally stored value if it's present rather than the value of the model. This stored value can later be committed into the model by sending the #commit message to the buffered value. #reset message will cause the BufferedValue to discard its current local value. In addition to this #commit/#reset protocol, a BufferedValue can be configured to commit and reset its value by watching a "coordinator" object. This way, a group of BufferedValues can be controlled centrally by changing a single observed value. Changing the coordinator's value to true commits all BufferedValues watching it, and changing it to false resets them. A coordinator is set by sending the #coordinator: message to the BufferedValue. Instance Variables: model <ObservedValue> This is the model object whose value the receiver is buffering. coordinator <(ObservedValue on: Boolean) | nil> The optional coordinator triggering the receiver's commits and resets.. Class Variables: NotYetAssigned <Object> A distinguished value used to indicate that the receiver has no local value set yet, so that the model's current value is "showing through".
</comment> <class> <name>CopiedBufferedValue</name> <environment>Core</environment> <super>Core.BufferedValue</super> <private>false</private> none <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.CopiedBufferedValue
CopiedBufferedValue is exactly like a BufferedValue except that it copies the underlying object in the model into the local value, rather than having the model's value "show through" when there is no local one. In other words, for a newly created BufferedValue "bufferedValue value == bufferedValue model value" is true, while for CopiedBufferedValue it's false (unless the value is an object for which copy does not create a new instance, such as immediates and Symbols).
</comment> <class> <name>ElementsReplaced</name> <environment>Core</environment> <super>Core.ContentsChangeAnnouncement</super> <private>false</private> none elements <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.ElementsReplaced
ElementsReplaced notifies about replacing a range of elements in a collection (even if the range includes only one element) with other elements. The 'indexes' variable shows the location of the change, and the 'elements' holds the collection of objects previously at the affected indexes. Instance Variables: elements <Collection>
</comment> <class> <name>ModelUpdated</name> <environment>Core</environment> <super>Core.Announcement</super> <private>false</private> none <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.ModelUpdated
ModelUpdated is broadcast by an AccessAdaptor to notify any interested parties about the model of the adaptor signaling a changed event.
</comment> <class> <name>ValueChanging</name> <environment>Core</environment> <super>Core.ValueChangeAnnouncement</super> <private>false</private> none <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.ValueChanging
ValueChanging is one of the three announcements of the standard value change sequence. An object notifying about the change of the value does so as a sequence of three announcements: ValueAboutToChange sequence stops here if the above is vetoed ValueChanging <value changes at this point> ValueChanged All announcements carry the old and the new values, if at all possible. ValueAboutToChange is vetoable; vetoing it cancels the value change. Subscribe to it if you are interested in preventing some of the value changes to happen. ValueChanging is broadcast before an imminent value change. Subscribe to it to be notified before a value change. Do not use AboutToChangeValue for that purpose--AboutToChangeValue doesn't guarantee that the value change is imminent, since a subscriber receiving an announcement later could veto it. ValueChanged is broadcast after a value change.
</comment> <class> <name>ElementsInserted</name> <environment>Core</environment> <super>Core.ContentsChangeAnnouncement</super> <private>false</private> none <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.ElementsInserted
ElementsInserted notifies about adding new elements to a collection, thus increasing its size. The indexes of the new elements are included as the 'indexes' attribute.
</comment> <class> <name>ValueAboutToChange</name> <environment>Core</environment> <super>Core.ValueChangeAnnouncement</super> <private>false</private> none vetoed <imports></imports> <category>Model-Observables</category> <attributes> <package>Model-Observables</package> </attributes> </class> <comment> Core.ValueAboutToChange
ValueAboutToChange is one of the three announcements of the standard value change sequence. An object notifying about the change of the value does so as a sequence of three announcements: ValueAboutToChange sequence stops here if the above is vetoed ValueChanging <value changes at this point> ValueChanged All announcements carry the old and the new values, if at all possible. ValueAboutToChange is vetoable; vetoing it cancels the value change. Subscribe to it if you are interested in preventing some of the value changes to happen. ValueChanging is broadcast before an imminent value change. Subscribe to it to be notified before a value change. Do not use AboutToChangeValue for that purpose--AboutToChangeValue doesn't guarantee that the value change is imminent, since a subscriber receiving an announcement later could veto it. ValueChanged is broadcast after a value change.
</comment> <name>NotYetAssigned</name> <environment>Core.BufferedValue</environment> <private>false</private> <constant>true</constant> <category>unassigned value</category> <initializer>Object new</initializer> <attributes> <package>Model-Observables</package> </attributes> <methods> Core.AccessAdaptor <category>accessing</category>
accessor ^accessor
accessor: aUnarySymbolOrIntegerOrOneArgBlock accessor := aUnarySymbolOrIntegerOrOneArgBlock. (accessor notNil and: [modelAnnouncesUpdate and: [modelUpdateAnnouncement isNil]]) ifTrue: [self setUpdateForModel]
accessPath ^accessPath
accessPath: nilOrACollectionOfSymbolAndOrInteger accessPath := nilOrACollectionOfSymbolAndOrInteger
model ^model
model: anObjectOrObservedValue privateModelValue ifNotNil: [privateModelValue removeAllActionsWithReceiver: self]. model := anObjectOrObservedValue isObservedValue ifTrue: [self setPrivateModelValue: anObjectOrObservedValue] ifFalse: [anObjectOrObservedValue]. modelAnnouncesUpdate ifTrue: [self setUpdateForModel]. self announce: ModelUpdated
modelAnnouncesUpdate ^modelAnnouncesUpdate
modelAnnouncesUpdate: aBoolean modelAnnouncesUpdate = aBoolean ifTrue: [^self]. modelAnnouncesUpdate := aBoolean. modelAnnouncesUpdate ifTrue: [self setUpdateForModel] ifFalse: [self removeUpdateForModel]
modelUpdateAnnouncement ^modelUpdateAnnouncement
modelUpdateAnnouncement: announcementClassOrSetOrNil | rehookup | modelUpdateAnnouncement = announcementClassOrSetOrNil ifTrue: [^self]. self removeUpdateForModel. rehookup := modelUpdateAnnouncement ~= announcementClassOrSetOrNil and: [announcementClassOrSetOrNil notNil]. modelUpdateAnnouncement := announcementClassOrSetOrNil. modelUpdateAnnouncement notNil ifTrue: [modelAnnouncesUpdate := true]. rehookup ifTrue: [self setUpdateForModel]
mutator mutator ifNil: [self accessor isSymbol ifTrue: [^(self accessor, ':') asSymbol]]. ^mutator
mutator: aKeywordSymbolOrIntegerOrOneArgBlockOrNil mutator := aKeywordSymbolOrIntegerOrOneArgBlockOrNil
value accessPath isNil ifTrue: [^self accessorValueFor: model]. ^self accessorValueFor: self finalAccessPathValue.
value: anObject | originalValue | originalValue := self value. (self announce: (ValueAboutToChange from: originalValue to: anObject)) isVetoed ifTrue: [^self]. self announce: (ValueChanging from: originalValue to: anObject); setObjectFrom: anObject; announce: (ValueChanged from: originalValue to: anObject)
</methods> <methods> Core.AccessAdaptor <category>private</category>
accessorValueFor: anObject ^self valueFor: anObject using: self accessor
execute: executor on: target with: anObject "If the mutator is a Block, we assume that the block will mutate the model in some way. We never directly assign to the model" (executor isKindOf: BlockClosure) ifTrue: [^executor value: target value: anObject]. (executor isNil and: [target isObservedValue]) ifTrue: [^target value: anObject]. executor isSymbol ifTrue: [target perform: executor with: anObject] ifFalse: [target at: executor put: anObject]
finalAccessPathValue ^accessPath inject: model into: [:sum :each | self valueFor: sum using: each].
modelChanged model := privateModelValue value. self announce: ModelUpdated
modelUpdated self announce: ModelUpdated
removeUpdateForModel model unsubscribe: self
setModelTo: anObject ^self execute: self mutator on: (privateModelValue isObservedValue ifTrue: [privateModelValue] ifFalse: [model]) with: anObject
setObjectFrom: anObject "Do nothing if the model is nil AND the privateModelValue is not an ObservedValue" (model isNil and: [privateModelValue isObservedValue not]) ifTrue: [^nil]. accessPath isNil ifTrue: [self setModelTo: anObject] ifFalse: [self execute: self mutator on: self finalAccessPathValue with: anObject]
setPrivateModelValue: anObjectOrValueEventAnswering privateModelValue := anObjectOrValueEventAnswering. privateModelValue when: ValueChanged send: #modelChanged to: self. ^privateModelValue value
setUpdateForModel self modelUpdateAnnouncement ifNotNil: [:announcementClass | model ifNotNil: [model when: announcementClass send: #modelUpdated to: self]]
setValue: anObject self setObjectFrom: anObject
valueFor: anObject using: aParameter "By the time we get here, if anObject came from our model, then if the model was a value event, it is now the inner value" anObject isNil ifTrue: [^nil]. (aParameter isKindOf: BlockClosure) ifTrue: [^aParameter value: anObject]. (aParameter isNil and: [privateModelValue isObservedValue]) ifTrue: [^privateModelValue value]. ^aParameter isSymbol ifTrue: [anObject perform: aParameter] ifFalse: [anObject at: aParameter]
</methods> <methods> Core.AccessAdaptor <category>testing</category>
isAccessAdaptor ^true
isObservedValue ^true
</methods> <methods> Core.AccessAdaptor <category>initialize-release</category>
initialize super initialize. modelAnnouncesUpdate := false
</methods> <methods> Core.AccessAdaptor class <category>instance creation</category>
with: anIntialValue ^self new model: anIntialValue
with: anObject accessor: anAccessingEvaluable ^self with: anObject updateAnnouncement: nil accessor: anAccessingEvaluable mutator: nil
with: anObject accessor: anAccessingEvaluable mutator: aMutatingEvaluable ^self with: anObject updateAnnouncement: nil accessor: anAccessingEvaluable mutator: aMutatingEvaluable
with: anObject mutator: aMutatingEvaluable ^self with: anObject updateAnnouncement: nil accessor: nil mutator: aMutatingEvaluable
with: anObject updateAnnouncement: aClass ^self with: anObject updateAnnouncement: aClass accessor: nil mutator: nil
with: anObject updateAnnouncement: aClass accessor: anAccessingEvaluable ^self with: anObject updateAnnouncement: aClass accessor: anAccessingEvaluable mutator: nil
with: anObject updateAnnouncement: aClass accessor: anAccessingEvaluable mutator: aMutatingEvaluable | instance | instance := self with: anObject. instance modelUpdateAnnouncement: aClass. instance accessor: anAccessingEvaluable. instance mutator: aMutatingEvaluable. ^instance
with: anObject updateAnnouncement: aClass mutator: aMutatingEvaluable ^self with: anObject updateAnnouncement: aClass accessor: nil mutator: aMutatingEvaluable
</methods> <methods> Core.ObservedTwoDList <category>accessing</category>
at: anIntegerOrPoint ^anIntegerOrPoint indexAccessInto: self
at: anIntegerOrPoint put: anElement ^anIntegerOrPoint indexAccessInto: self put: anElement
atInteger: anInteger ^collection at: anInteger
atInteger: anInteger put: anObject | oldValue | (self announce: ValueAboutToChange) isVetoed ifTrue: [^nil]. self announce: ValueChanging. oldValue := collection at: anInteger. collection at: anInteger put: anObject. self announce: (ElementsReplaced new location: (self pointIndexFor: anInteger); elements: (Array with: oldValue)). self announce: ValueChanged. ^anObject
atPoint: aPoint ^self atInteger: (self integerIndexFor: (self isTransposed ifTrue: [aPoint transpose] ifFalse: [aPoint]))
atPoint: aPoint put: anObject ^self atInteger: (self integerIndexFor: (self isTransposed ifTrue: [aPoint transpose] ifFalse: [aPoint])) put: anObject
columnSize ^self isTransposed ifTrue: [rows] ifFalse: [columns]
dimensions ^self isTransposed ifTrue: [rows @ columns] ifFalse: [columns @ rows]
rowSize ^self isTransposed ifTrue: [columns] ifFalse: [rows]
size ^collection size
subscriptionRegistryOrNil ^subscriptionRegistry
transpose self transposed: self isTransposed not
transposed: aBoolean aBoolean == self isTransposed ifTrue: [^self]. transposed := aBoolean. self announce: (ElementsTransposed new transposed: aBoolean)
</methods> <methods> Core.ObservedTwoDList <category>enumerating</category>
collectRows: aBlock | newCollection start | newCollection := self species withSize: self rowSize. start := 1. 1 to: self rowSize do: [:index | newCollection at: index put: (aBlock value: (self copyFrom: start to: start + self columnSize - 1)). start := start + self columnSize]. ^newCollection
</methods> <methods> Core.ObservedTwoDList <category>private</category>
defaultElement ^collection defaultElement
executeWithoutEvents: aBlock self subscriptionRegistry allSubscriptions suspendWhile: aBlock
integerIndexFor: aPoint ^columns * (aPoint y - 1) + aPoint x
pointIndexFor: anInteger | base | base := (anInteger - 1) // columns. ^(anInteger - (base * columns)) @ (base + 1)
setCollection: aCollection columns: columnsInteger rows: rowsInteger collection := aCollection. rows := rowsInteger. columns := columnsInteger
species ^ObservedList
subscriptionRegistry: aSubscriptionRegistry subscriptionRegistry := aSubscriptionRegistry
</methods> <methods> Core.ObservedTwoDList <category>testing</category>
isObservedTwoDList ^true
isTransposed ^transposed isNil ifTrue: [transposed := false] ifFalse: [transposed]
</methods> <methods> Core.ObservedTwoDList <category>copying</category>
postCopy subscriptionRegistry := nil. collection := collection copy
</methods> <methods> Core.ObservedTwoDList <category>sorting</category>
sort | sortCollection | (self announce: ValueAboutToChange) isVetoed ifTrue: [^nil]. self announce: ValueChanging. sortCollection := self collectRows: [:each | each]. self executeWithoutEvents: [ | start | SequenceableCollectionSorter sort: sortCollection using: [:each :other | each first displayString < other first displayString]. collection := Array new: rows * columns. start := 1. sortCollection do: [:eachArray | eachArray do: [:eachValue | collection at: start put: eachValue. start := start + 1]]]. self announce: ValueChanged. self announce: ElementsReordered
sortWith: aBlock | sortCollection | (self announce: ValueAboutToChange) isVetoed ifTrue: [^nil]. self announce: ValueChanging. sortCollection := self collectRows: [:each | each]. self executeWithoutEvents: [ | start | SequenceableCollectionSorter sort: sortCollection using: aBlock. collection := Array new: rows * columns. start := 1. sortCollection do: [:eachArray | eachArray do: [:eachValue | collection at: start put: eachValue. start := start + 1]]]. self announce: ValueChanged. self announce: ElementsReordered
</methods> <methods> Core.ObservedTwoDList <category>initialize-release</category>
release collection := nil. subscriptionRegistry release. subscriptionRegistry := nil. super release
</methods> <methods> Core.ObservedTwoDList class <category>instance creation</category>
columns: columnsInteger rows: rowsInteger | collection instance | collection := Array new: rowsInteger * columnsInteger. instance := self basicNew. ^instance setCollection: collection columns: columnsInteger rows: rowsInteger
on: aCollection columns: columnsInteger ^self on: aCollection columns: columnsInteger rows: (aCollection size asFloat / columnsInteger) ceiling
on: aCollection columns: columnsInteger rows: rowsInteger | collection instance arraySize columnSize | arraySize := columnsInteger * rowsInteger. columnSize := aCollection size. instance := self basicNew. arraySize = columnSize ifTrue: [^instance setCollection: aCollection columns: columnsInteger rows: rowsInteger]. collection := aCollection species new: rowsInteger * columnsInteger. collection replaceFrom: 1 to: (arraySize min: columnSize) with: aCollection startingAt: 1. instance := self basicNew. ^instance setCollection: collection columns: columnsInteger rows: rowsInteger
on: aCollection rows: rowsInteger ^self on: aCollection columns: (aCollection size asFloat / rowsInteger) floor rows: rowsInteger
on: aCollection rows: rowsInteger columns: columnsInteger ^self on: aCollection columns: columnsInteger rows: rowsInteger
rows: rowsInteger columns: columnsInteger | collection instance | collection := Array new: rowsInteger * columnsInteger. instance := self basicNew. ^instance setCollection: collection columns: columnsInteger rows: rowsInteger
</methods> <methods> Core.ContentsChangeAnnouncement <category>initialize-release</category>
from: startInteger to: endInteger "The change is between the the indexes passed as the arguments. The indexes are inclusive, just like copyFrom:to:." indexes := startInteger to: endInteger
index: anInteger "The change affects only one elements at the given index." indexes := anInteger to: anInteger
location: anObject "The change affects a single element identified by a key which is not an integer." indexes := anObject
</methods> <methods> Core.ContentsChangeAnnouncement <category>accessing</category>
indexes "Answer the indexes affected by the change." ^indexes
location "Answer the location affected by the change. This is intended for collections where the location is identified by an arbitrary key (such as point coordinates in a 2D list)." ^indexes
</methods> <methods> Core.ElementsTransposed <category>accessing</category>
transposed ^transposed
transposed: anObject transposed := anObject
</methods> <methods> Core.ValueChangeAnnouncement <category>accessing</category>
newValue ^newValue
newValue: anObject newValue := anObject
oldValue ^oldValue
oldValue: anObject oldValue := anObject
</methods> <methods> Core.ValueChangeAnnouncement class <category>instance creation</category>
from: anObject to: anotherObject ^self new oldValue: anObject; newValue: anotherObject
newValue: anObject oldValue: anotherObject ^self new newValue: anObject; oldValue: anotherObject
</methods> <methods> Core.ElementsRemoved <category>initialize-release</category>
elements: aCollection elements := aCollection
</methods> <methods> Core.ElementsRemoved <category>accessing</category>
elements ^elements
</methods> <methods> Core.ObservedList <category>adding</category>
add: anObject "Include newObject as one of the receiver's elements. Answer newObject." ^self addLast: anObject
add: newObject after: oldObject "Add the argument, newObject, as an element of the receiver. Put it in the position just succeeding oldObject. Answer newObject." | index | index := self findIndexOf: oldObject. self add: newObject beforeIndex: index + 1. ^newObject
add: newObject before: oldObject "Add the argument, newObject, as an element of the receiver. Put it in the position just preceding oldObject. Answer newObject." | index | index := self findIndexOf: oldObject. self add: newObject beforeIndex: index. ^newObject
add: anObject beforeIndex: anIndex "Add the argument, newObject, as an element of the receiver. Put it in the position just preceding the indexed position spot. Answer anObject." anIndex <= limit ifTrue: [self privateInsertObject: anObject beforeIndex: anIndex] ifFalse: [anIndex = (limit + 1) ifTrue: [self addLast: anObject] ifFalse: [^self subscriptBoundsErrorFor: #add:beforIndex: index: anIndex value: anObject]]. ^anObject
addAll: aCollection "Add each element of aCollection at the end of the instance. Answer aCollection." ^self addAllLast: aCollection
addAll: aCollection after: oldObject "Add the argument, aCollection, as elements of the receiver. Put it in the position just succeeding oldObject. Answer newObject." | index | index := self findIndexOf: oldObject. self addAll: aCollection beforeIndex: index + 1. ^aCollection
addAll: aCollection before: oldObject "Add the argument, aCollection, as elements of the receiver. Put it in the position just preceding oldObject. Answer newObject." | index | index := self findIndexOf: oldObject. self addAll: aCollection beforeIndex: index. ^aCollection
addAll: aCollection beforeIndex: anIndex "Add the argument, aCollection, as elements of the receiver. Put them in the position just preceding the indexed position spot. Answer aCollection." self insertCollection: aCollection before: anIndex. ^aCollection
addAllFirst: aCollection "Add each element of aCollection at the beginning of the receiver. Answer aCollection." ^self addAll: aCollection beforeIndex: 1
addAllLast: aCollection "Add each element of aCollection at the end of the receiver. Answer aCollection." | newCollectionSize | (self announce: ValueAboutToChange) isVetoed ifTrue: [^nil]. self announce: ValueChanging. newCollectionSize := aCollection size. limit + newCollectionSize > collectionSize ifTrue: [self growCollectionBy: (self growSize max: newCollectionSize)]. self moveElementsFrom: aCollection ofSize: newCollectionSize toMyCollectionStartingAt: limit + 1. limit := limit + newCollectionSize. self announce: (ElementsInserted new from: self size - aCollection size + 1 to: self size). self announce: ValueChanged. ^aCollection
addFirst: anObject "Add anObject to the beginning of the receiver. Add anObject." ^self add: anObject beforeIndex: 1
addLast: anObject "Add newObject to the end of the receiver. Answer newObject." limit = collectionSize ifTrue: [self growCollection]. ^self privateAddLast: anObject
changeSizeTo: newSize "The receiver changes its size to newSize." | newCollection | newSize < 0 ifTrue: [self error: #errNeedPositiveIntegerArg << #dialogs >> 'This message needs a positive integer argument']. collectionSize >= newSize ifTrue: [newSize + 1 to: limit do: [:index | collection at: index put: nil]. limit := newSize. ^self]. newCollection := self biggerCollectionWithAtLeast: newSize. newCollection replaceFrom: 1 to: self size with: collection startingAt: 1. collection := newCollection. collectionSize := collection size. limit := newSize
</methods> <methods> Core.ObservedList <category>accessing</category>
after: anObject "Answer the element after anObject. If the receiver does not contain anObject or if the receiver contains no elements after anObject, provide an error notification." | index | index := self findIndexOf: anObject. ^index = limit ifTrue: [self lastObjectError] ifFalse: [self privateAt: index + 1]
at: anIndex "Answer the element at index anIndex." ^anIndex > limit ifTrue: [self errorSubscriptBounds: anIndex] ifFalse: [self privateAt: anIndex]
at: anIndex put: anObject "Put anObject at element anIndex." ^anIndex <= limit ifTrue: [self privateAt: anIndex put: anObject] ifFalse: [anIndex = (limit + 1) ifTrue: [self addLast: anObject] ifFalse: [self errorSubscriptBounds: anIndex]]
before: anObject "Answer the element before anObject. If the receiver does not contain anObject or if the receiver contains no elements before anObject, provide an error notification." | index | index := self findIndexOf: anObject. ^index = 1 ifTrue: [self firstObjectError] ifFalse: [self privateAt: index - 1]
capacity ^collectionSize
first "Answer the first element. If the receiver is empty, provide an error notification." limit = 0 ifTrue: [^self emptyCollectionError]. ^self privateAt: 1
indexOf: anElement ifAbsent: exceptionBlock "Answer the index of anElement within the receiver. If the receiver does not contain anElement, answer the result of evaluating the exceptionBlock." ^self privateIndexOf: anElement ifAbsent: exceptionBlock
last "Answer the last element. If the receiver is empty, create an error notification." limit = 0 ifTrue: [^self emptyCollectionError]. ^self privateAt: limit
replaceAllWith: aCollection (self subscriptionRegistry subscriptionsFor: ValueChanged) suspendWhile: [self removeFrom: 1 to: self size]. ^(self subscriptionRegistry subscriptionsFor: ValueAboutToChange, ValueChanging) suspendWhile: [self addAll: aCollection].
replaceFrom: start to: stop with: replacement startingAt: repStart "This destructively replaces elements from start to stop in the receiver starting at index, repStart, in the collection, replacement. Answer the receiver." | oldElements | start > (limit + 1) ifTrue: [^self errorSubscriptBounds: start]. ^stop <= limit ifTrue: [(self announce: ValueAboutToChange) isVetoed ifTrue: [^nil]. self announce: ValueChanging. oldElements := collection copyFrom: start to: stop. collection replaceFrom: start to: stop with: replacement startingAt: repStart. self announce: (ElementsReplaced new from: start to: stop; elements: oldElements). self announce: ValueChanged. self] ifFalse: [self errorSubscriptBounds: stop]
size "Answer how many elements the receiver contains." ^limit
zeroIndex ^0
</methods> <methods> Core.ObservedList <category>converting</category>
asObservedList "I am myself" ^self
</methods> <methods> Core.ObservedList <category>private</category>
biggerCollectionWithAtLeast: anAmount "Answer a collection for the receiver with at least anAmount room for storage." ^collection species new: (collectionSize + self growSize max: anAmount)
changeCapacityTo: aSize "Make the receiver's collection be larger by aSize." | newCollection | aSize < self size ifTrue: [self error: (#errSmallSizeError << #dialogs >> 'I can''t shrink that small')]. newCollection := collection species new: aSize. newCollection replaceFrom: 1 to: limit with: collection startingAt: 1. collection := newCollection. collectionSize := newCollection size
executeWithoutEvents: aBlock self subscriptionRegistry allSubscriptions suspendWhile: aBlock
findIndexOf: anObject "Answer the index of an anObject in the receiver's collection." ^self privateIndexOf: anObject ifAbsent: [self notFoundError]
growCollection "Make the receiver's collection be larger." self growCollectionBy: self growSize
growCollectionBy: anInteger "Make the receiver's collection be larger by anInteger." self changeCapacityTo: self capacity+anInteger
growSize "Answer a size by which to grow the receiver's collection." ^collection growSize
insertCollection: aCollection before: anIndex "Insert aCollection before anIndex in the receiver's collection." ^anIndex <= limit ifTrue: [| newCollectionSize | (self announce: ValueAboutToChange) isVetoed ifTrue: [^nil]. self announce: ValueChanging. newCollectionSize := aCollection size. self moveDown: newCollectionSize fromIndex: anIndex. self moveElementsFrom: aCollection ofSize: newCollectionSize toMyCollectionStartingAt: anIndex. limit := limit + newCollectionSize. self announce: (ElementsInserted new from: anIndex to: anIndex + aCollection size - 1). self announce: ValueChanged] ifFalse: [anIndex = (limit + 1) ifTrue: [self addAllLast: aCollection] ifFalse: [self subscriptBoundsErrorFor: #insertCollection:before: index: anIndex value: aCollection]]
setCollection: anArray limit: aSmallInteger "Set the receiver's collection to be anArray with initial limit of aSmallInteger." collection := anArray. limit := aSmallInteger. collectionSize := collection size
trim "Discard the extra slots that the collection was reserving for future growth room." self changeCapacityTo: self size
</methods> <methods> Core.ObservedList <category>enumerating</category>
do: aBlock "Evaluate aBlock with each of the receiver's elements as the argument." 1 to: limit do: [:index | aBlock value: (self privateAt: index)]
reverseDo: aBlock "Evaluate aBlock with each of the receiver's elements as the argument, starting with the last element and taking each in sequence up to the first." "Override the superclass for performance" limit to: 1 by: -1 do: [:index | aBlock value: (self privateAt: index)]
select: aBlock "Evaluate aBlock with each of my elements as the argument. Collect into a new collection like the receiver, only those elements for which aBlock evaluates to true." | newCollection | newCollection := self species new. 1 to: limit do: [:index | | element | element := self at: index. (aBlock value: element) ifTrue: [newCollection addLast: element]]. ^newCollection
</methods> <methods> Core.ObservedList <category>private-errors</category>
errorSubscriptBounds: anIndex self error: (#errAttemptedNonExistentElement << #dialogs >> 'attempt to index non-existent element')
firstObjectError self error: (#errFirstObject << #dialogs >> 'specified object is first object')
lastObjectError self error: (#errLastObject << #dialogs >> 'specified object is last object')
notEnoughElementsError self error: (#errRemovedTooManyCollection << #dialogs >> 'attempt to remove more elements than are in the collection')
</methods> <methods> Core.ObservedList <category>testing</category>
isTextEmphasis self class == ObservedList ifFalse: [^false]. ^self allSatisfy: [:each | each isSymbol or: [each isAssociation]]
</methods> <methods> Core.ObservedList <category>private-collection accessing</category>
moveDown: anAmount fromIndex: anIndex "Move elements in collection down by anAmount starting at anIndex." limit + anAmount > collectionSize ifTrue: [| newCollection | newCollection := self biggerCollectionWithAtLeast: limit + anAmount. newCollection replaceFrom: 1 to: anIndex -1 with: collection startingAt: 1. newCollection replaceFrom: anIndex + anAmount to: limit+ anAmount with: collection startingAt: anIndex. collection := newCollection. collectionSize := collection size] ifFalse: [collection replaceFrom: anIndex + anAmount to: limit + anAmount with: collection startingAt: anIndex].
moveElementsFrom: aCollection ofSize: cSize toMyCollectionStartingAt: anIndex "Move the elements from aCollection into the receivers collection starting at anIndex." aCollection isSequenceable ifTrue: [collection replaceFrom: anIndex to: anIndex + cSize - 1 with: aCollection startingAt: 1] ifFalse: [| index | index := anIndex. aCollection do: [:element | collection at: index put: element. index := index + 1]].
privateAddLast: anObject "Add anObject to the valid end of the receiver's collection." (self announce: ValueAboutToChange) isVetoed ifTrue: [^nil]. self announce: ValueChanging. limit := limit + 1. collection at: limit put: anObject. self announce: (ElementsInserted new index: limit). self announce: ValueChanged. ^anObject
privateAt: anIndex "Answer the object stored at anIndex in collection." ^collection at: anIndex
privateAt: anInteger put: anObject "Store anObject into an index in collection." | oldValue | (self announce: ValueAboutToChange) isVetoed ifTrue: [^nil]. self announce: ValueChanging. oldValue := collection at: anInteger. collection at: anInteger put: anObject. self announce: (ElementsReplaced new index: anInteger; elements: (Array with: oldValue)). self announce: ValueChanged. ^anObject
privateIndexOf: anElement ifAbsent: exceptionBlock "Answer the index of anElement within the receiver. If the receiver does not contain anElement, answer the result of evaluating the exceptionBlock." 1 to: limit do: [:index | (collection at: index) = anElement ifTrue: [^index]]. ^exceptionBlock value
privateInsertObject: anObject beforeIndex: anIndex "Insert anObject in collection before index anIndex." (self announce: ValueAboutToChange) isVetoed ifTrue: [^nil]. self announce: ValueChanging. self moveDown: 1 fromIndex: anIndex. collection at: anIndex put: anObject. limit := limit + 1. self announce: (ElementsInserted new index: anIndex). self announce: ValueChanged.
privateRemoveIndex: anIndex "Remove the element of the collection at position anIndex." | object | (self announce: ValueAboutToChange) isVetoed ifTrue: [^nil]. self announce: ValueChanging. object := collection at: anIndex. collection replaceFrom: anIndex to: limit - 1 with: collection startingAt: anIndex + 1. collection at: limit put: self defaultElement. limit := limit - 1. self announce: (ElementsRemoved new index: anIndex; elements: (Array with: object)). self announce: ValueChanged. ^object
privateRemoveIndex: start to: stop returnElements: returnBoolean "Remove the elements in the range start to stop within collection. Answer a collection of the removed elements if returnBoolean is true." | removedElements numElements newLimit default | (self announce: ValueAboutToChange) isVetoed ifTrue: [^nil]. self announce: ValueChanging. numElements := stop - start + 1. removedElements := Array new: numElements. removedElements replaceFrom: 1 to: numElements with: collection startingAt: start. newLimit := limit - numElements. collection replaceFrom: start to: newLimit with: collection startingAt: stop + 1. default := self defaultElement. newLimit + 1 to: limit do: [:index | collection at: index put: default]. limit := newLimit. self announce: (ElementsRemoved new from: start to: stop; elements: removedElements). self announce: ValueChanged. ^returnBoolean ifTrue: [removedElements] ifFalse: [nil]
</methods> <methods> Core.ObservedList <category>removing</category>
remove: oldObject ifAbsent: anExceptionBlock "Remove oldObject as one of the receiver's elements. If several of the elements are equal to oldObject, only one is removed. If no element is equal to oldObject, answer the result of evaluating anExceptionBlock. Otherwise, answer the argument, oldObject." | index | index := self indexOf: oldObject ifAbsent: [^anExceptionBlock value]. ^self removeAtIndex: index
removeAllSuchThat: aBlock "Evaluate aBlock for each element of the receiver. Remove each element for which aBlock evaluates to true. " | newCollection element index | newCollection := self class new. index := 1. [index <= limit] whileTrue: [element := self privateAt: index. (aBlock value: element) ifTrue: [newCollection addLast: element. self privateRemoveIndex: index] ifFalse: [index := index + 1]]. ^newCollection
removeAtIndex: anIndex "Remove the element of the collection at position anIndex. Answer the object removed." ^anIndex > limit ifTrue: [self errorSubscriptBounds: anIndex] ifFalse: [self privateRemoveIndex: anIndex]
removeFirst "Remove the first element of the receiver. If the receiver is empty, provide an error notification." ^self removeAtIndex: 1
removeFirst: numElements "Remove the first numElements elements of the receiver, and answer an Array of them. If the receiver has fewer than numElements elements, create an error notification." numElements > limit ifTrue: [^self notEnoughElementsError]. ^self privateRemoveIndex: 1 to: numElements returnElements: true
removeFrom: start to: stop "Remove the elements in the range start to stop. Answer a collection of the removed elements." ^self removeFrom: start to: stop returnElements: true
removeFrom: start to: stop returnElements: returnBoolean "Remove the elements in the range start to stop. Answer a collection of the removed elements if returnBoolean is true." start > stop ifTrue: [^returnBoolean ifTrue: [Array new] ifFalse: [nil]]. start > limit ifTrue: [^self errorSubscriptBounds: start]. stop > limit ifTrue: [^self errorSubscriptBounds: stop]. ^self privateRemoveIndex: start to: stop returnElements: returnBoolean
removeLast "Remove the last element of the receiver. If the receiver is empty, provide an error notification." ^self removeAtIndex: limit
removeLast: numElements "Remove the last numElements elements of the receiver, and answer an Array of them. If the receiver has fewer than numElements elements, create an error notification." numElements > limit ifTrue: [^self notEnoughElementsError]. ^self privateRemoveIndex: limit - numElements + 1 to: limit returnElements: true
</methods> <methods> Core.ObservedList <category>announcements</category>
subscriptionRegistry: aSubscriptionRegistry subscriptionRegistry := aSubscriptionRegistry
subscriptionRegistryOrNil ^subscriptionRegistry
</methods> <methods> Core.ObservedList <category>copying</category>
postCopy subscriptionRegistry := nil. collection := collection copy.
</methods> <methods> Core.ObservedList <category>sorting</category>
sort (self announce: ValueAboutToChange) isVetoed ifTrue: [^nil]. self announce: ValueChanging. self subscriptionRegistry allSubscriptions suspendWhile: [SequenceableCollectionSorter sort: self]. self announce: ValueChanged. self announce: ElementsReordered
sortWith: aBlock (self announce: ValueAboutToChange) isVetoed ifTrue: [^nil]. self announce: ValueChanging. self subscriptionRegistry allSubscriptions suspendWhile: [SequenceableCollectionSorter sort: self using: aBlock]. self announce: ValueChanged. self announce: ElementsReordered
</methods> <methods> Core.ObservedList <category>initialize-release</category>
release collection := nil. subscriptionRegistry release. subscriptionRegistry := nil. super release
</methods> <methods> Core.ObservedList class <category>testing</category>
needsSafeRebinding ^true
</methods> <methods> Core.ObservedList class <category>instance creation</category>
new "Answer a new empty instance of the receiver." ^self new: 5
new: sizeInteger "Answer a new empty instance of the receiver. The size is determined by the actual number of stored elements. Creating an instance using new: results in an empty collection, regardless of the size declared." ^self basicNew setCollection: (Array new: sizeInteger) limit: 0
new: size withAll: value "Answer a new instance of the receiver whose every element is equal to the argument, value." ^self new setCollection: (Array new: size withAll: value ) limit: size
withSize: size "Override, because this class distinguishes between size and capacity." ^(self new: size) changeSizeTo: size
</methods> <methods> Core.ObservedValue <category>converting</category>
asObservedValue ^self
</methods> <methods> Core.ObservedValue <category>testing</category>
isObservedValue ^true
</methods> <methods> Core.ObservedValue <category>accessing</category>
numArgs ^0
object ^value
quietlySetValue: anObject value := anObject.
setValue: anObject value := anObject.
value ^value
value: anObject "Lines to be removed when breaking dependency on TriggerEvent framework are marked with a double double quote." | oldValue | oldValue := value. (self announce: (ValueAboutToChange from: oldValue to: anObject)) isVetoed ifTrue: [^self]. self announce: (ValueChanging from: oldValue to: anObject). self setValue: anObject. self announce: (ValueChanged from: oldValue to: anObject)
</methods> <methods> Core.ObservedValue class <category>instance creation</category>
with: anIntialValue ^self new setValue: anIntialValue
</methods> <methods> Core.BufferedValue <category>testing</category>
isBufferedValue ^true
</methods> <methods> Core.BufferedValue <category>accessing</category>
coordinator ^coordinator
coordinator: anObservedValue coordinator ifNotNil: [coordinator unsubscribe: self]. coordinator := anObservedValue. coordinator when: ValueChanged send: #coordinatorValueChanged: to: self.
model ^model
model: anObservedValue model := anObservedValue
notYetAssigned ^self class notYetAssigned
value ^value == self notYetAssigned ifTrue: [ self model value ] ifFalse: [ value ]
</methods> <methods> Core.BufferedValue <category>private</category>
coordinatorValueChanged: aChangedValue aChangedValue newValue ifTrue: [self commit] ifFalse: [self reset]. coordinator setValue: nil
</methods> <methods> Core.BufferedValue <category>commands</category>
commit value == self notYetAssigned ifTrue: [^self]. model value: value
reset value := self notYetAssigned
</methods> <methods> Core.BufferedValue <category>initialize-release</category>
initialize super initialize. model := nil asObservedValue. value := self notYetAssigned
</methods> <methods> Core.BufferedValue class <category>instance creation</category>
model: aValueEvent ^self new model: aValueEvent
</methods> <methods> Core.BufferedValue class <category>accessing</category>
notYetAssigned NotYetAssigned isNil ifTrue: [#{Core.BufferedValue.NotYetAssigned} initialize]. ^NotYetAssigned
</methods> <methods> Core.CopiedBufferedValue <category>commands</category>
commit model value: value
reset value := model value copy
</methods> <methods> Core.CopiedBufferedValue <category>accessing</category>
model: anObservedValue model := anObservedValue. value := model value copy
</methods> <methods> Core.ElementsReplaced <category>accessing</category>
elements ^elements
elements: anObject elements := anObject
</methods> <methods> Core.ValueAboutToChange <category>vetoing</category>
isVetoed ^vetoed notNil
veto vetoed := true
</methods> <methods> Core.Object <category>converting</category>
asObservedValue ^ObservedValue with: self
</methods> <methods> Core.Object <category>testing</category>
isAccessAdaptor ^false
isBufferedValue ^false
isObservedTwoDList ^false
isObservedValue ^false
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>Object</name> <environment>Core</environment> <super></super> <private>false</private> none <imports></imports> <category>Kernel-Objects</category> <attributes> <package>Kernel-Objects</package> </attributes> </class> <class> <name>Announcer</name> <environment>Core</environment> <super>Core.Object</super> <private>false</private> none subscriptionRegistry <imports></imports> <category>Model-Observables</category> <attributes> <package>System-Announcements</package> </attributes> </class> <class> <name>Announcement</name> <environment>Core</environment> <super>Core.Object</super> <private>false</private> none <imports></imports> <category>System-Announcements</category> <attributes> <package>System-Announcements</package> </attributes> </class> <class> <name>ArrayedCollection</name> <environment>Core</environment> <super>Core.SequenceableCollection</super> <private>false</private> none <imports></imports> <category>Collections-Abstract</category> <attributes> <package>Collections-Abstract</package> </attributes> </class>