Hopefully someone can point me in the right direction here, I've been
pulling my hair out for the last day or so on this. I have a small translation framework I'm working on that adds a key field to push buttons, static texts, group boxes etc. to set the text/caption based on an external file. This is all working fine, but now I come to CardContainer's and need to update the sub views "arrangement" on startup to use the translation. In my LookupContainerView subclass I have my mutator specified as: key: anObject key := anObject. [self arrangement: (I18NStringFactory at: key)] on: NotFoundError do: [:x | self arrangement: key] which nicely updates the arrangement value to be whats currently translated, but this doesn't happed at run time. Initially I had assumed the accessors/mutators of published aspects would be called when loading the resource, but this doesn't appear to happen. In my other components such as my StaticText subclass I've "worked around this" by simply overriding the accessor/mutator of text to return the translated key ragardless of the text variable. However I'm finding overriding the arrangement/arrangement: methods doesn't "quite" work as I end up getting multiple tabs as the underlying TabView gets confused over the changing arrangement (so that it can't remove the existing tab). I just tried overriding the accessors/mutators for arrangement/arrangement: with the following to no avail either, I'm guessing the accessos/mutators just never get used :( arrangement self viewIsBeingComposed ifTrue: [^super arrangement] ifFalse: [[^(I18NStringFactory at: key)] on: NotFoundError do: [:x | ^key]] arrangement: a self viewIsBeingComposed ifTrue: [super arrangement: key] ifFalse: [[super arrangement: (I18NStringFactory at: key)] on: NotFoundError do: [:x | super arrangement: key]] viewIsBeingComposed self allParents do: [:parent| (parent isKindOf: ViewComposerArena) ifTrue: [^true]]. ^false. I've tried overriding various methods that look like they run on startup (onFullyCreated, onModelChanged, onStartup, onViewOpened etc. ) in order to force setting the arragnemt, but nothing seems to actually work. Anyone got any ideas or suggestions? Mark |
Mark,
> I've tried overriding various methods that look like they run on > startup (onFullyCreated, onModelChanged, onStartup, onViewOpened etc. ) > in order to force setting the arragnemt, but nothing seems to actually > work. > > Anyone got any ideas or suggestions? Have you tried leaving #arrangement[:] untouched, and calling something like: self subViews do: [:each || devtime runtime | devtimer := self arrangementOf: each. runtme := self I18NStringFactory at: devtime. self arrangementOf: each put: runtime]. as part of the initialisation code for your subclass of TabView ? Otherwise, I didn't really follow your explanation so I may be missing something, but if I were looking down this particular gun-barrel I'd try to interpose my code somewhere in the de-STBing process for the Views. I haven't tried any of the following, but there are several places where it seems as if a hook /should/ work. There is the code in category 'binary filing' on the class sice of View and its subclasses, where you can trap and modify the state of a "resurected" View. You could use a custom subclass of ViewProxy that knows to internationalise View instances as it resurects them. You could override View #state to include a MessageSend that caused a View instance to internationalise itself as it is de-STBed. The last two are virtually identical in effect, and I suspect that one or the other would be a good place to start. In fact I /suspect/ that it'd be possible to patch the base system so that it automatically internalitionalised views as they were de-STBed without (usually) any need for subclasses. But I've thought that before and found I was wrong... -- chris |
I assume by STB you refer to some deserialization process?
Currently I don't have a subclass of TabView, or CardContainer because everytime I try to "mutate" a CardContainer to my subclass (with no methods) I get internal errors and exceptions thrown up everywhere. I tried overriding the few methods in 'binary filing' that appeared like they might be usefull, only they never got called. I also override #state in my one of my custom view classes, but it was never called either. *sigh* |
Hazah - a radically different approach and I seem to be working better.
Screw all the messy subclasses and trying to be intelligent. On my main view class (as opposed to the original control view classes I was working with) having the following in #onViewOpened: I18NStringFactory translate: 'test' in: self view for: 'label.appName'. where translte:in:for: is defined as: translate: aPresenterNamed in: aView for: aKey | subview translation | translation := I18NStringFactory for: aKey. subview := (aView allSubViews select: [:each | each name isNil not and: [each name equals: aPresenterNamed]]) first. (subview isKindOf: ContainerView) ifTrue: [subview arrangement: translation]. Now I'm just simply adding the different view classes to handle them as I need to. With a bit of hacking this I should be able to get to the menus/ComandDescriptions as well. Mmm. |
In reply to this post by talios@gmail.com
[hidden email] wrote:
> I assume by STB you refer to some deserialization process? Yes, the deserialisation of "View resources" from their static representation as ByteArrays[*] held by the resource manager, and subsequent conversion into full objects which are then connected to "live" Windows widgets. I'd add more, but it seems you have found a happy solution coming from a different direction. -- chris ([*] The static representation is different in D6, although the underlying idea is the same.) |
Free forum by Nabble | Edit this page |