I can't find why my dialog never works the first time

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

I can't find why my dialog never works the first time

Joseph Frippiat
In my application (see an extract of the source code below), I have a
configuration view (dialog) to select the communication port to use.
This view fails allways the first time it is used by my "main" shell.
The error log is :

10:12:22, mercredi 24 mai 2006: 'Not found: COM1'
ComboBox(Object)>>errorNotFound:
[] in ComboBox(ListControlView)>>selection:
ComboBox(ListControlView)>>selection:ifAbsent:
ComboBox(ListControlView)>>selection:
ComboBox(ListControlView)>>selectionOrNil:
[] in ListPresenter(SelectableItemsPresenter)>>selectionOrNil:
[] in NotFoundError(Exception)>>_evaluateHandler:in:
BlockClosure>>ifCurtailed:
BlockClosure>>ensure:
NotFoundError(Exception)>>_evaluateHandler:in:
NotFoundError(Exception)>>_propagateFrom:
NotFoundError(Exception)>>_propagate
NotFoundError(Exception)>>signal
NotFoundError(Exception)>>signal:with:
NotFoundError(Exception)>>signalWith:
ComboBox(Object)>>errorNotFound:
[] in ComboBox(ListControlView)>>selection:
ComboBox(ListControlView)>>selection:ifAbsent:
ComboBox(ListControlView)>>selection:
ComboBox(ListControlView)>>selectionOrNil:
[] in ListPresenter(SelectableItemsPresenter)>>selectionOrNil:
ExceptionHandler(ExceptionHandlerAbstract)>>markAndTry
[] in ExceptionHandler(ExceptionHandlerAbstract)>>try:
BlockClosure>>ifCurtailed:
BlockClosure>>ensure:
ExceptionHandler(ExceptionHandlerAbstract)>>try:
BlockClosure>>on:do:
ListPresenter(SelectableItemsPresenter)>>selectionOrNil:
ConfigurationDialog>>onViewOpened
ConfigurationDialog(Shell)>>view:
ConfigurationDialog(Shell)>>createView:
ConfigurationDialog class(Presenter class)>>create:on:
ConfigurationDialog class(Presenter class)>>createOn:
ConfigurationDialog class(Dialog class)>>showModalOn:
RemoteMonitoringShell>>configure
Symbol>>forwardTo:
CommandDescription>>performAgainst:
[] in Command>>value
BlockClosure>>ifCurtailed:
BlockClosure>>ensure:
Command>>value
ShellView>>performCommand:
RemoteMonitoringShell(Shell)>>performCommand:
CommandQuery>>perform
DelegatingCommandPolicy(CommandPolicy)>>route:
[] in PushButton(View)>>onCommand:
BlockClosure>>ifCurtailed:
BlockClosure>>ensure:
Cursor>>showWhile:
PushButton(View)>>onCommand:

------->8------->8------->8-------

1) I have a model with the instance variable 'comPort'.  This variable
is initialized with the value 'COM1' :

myModel>>initialize
        comPort := 'COM1'.
        ...

2) My model knows the valid serial ports names :

myModel>>comPorts
        "Return the list of the supported communication ports."

        ^#('COM1' 'COM2' 'COM3' 'COM4' 'COM5' 'COM6' 'COM7' 'COM8')

3) I have a dialog view called from my main shell :

myMainShell>>configure
        "Display the configuration menu"

        ConfigurationDialog showModalOn: self model

4) The dialog view is built with the following methods :

ConfigurationDialog Class>>defaultModel
        "Answer a default model to be assigned to the receiver when it
        is initialized."

        ^myModel new

ConfigurationDialog>>createComponents
        "Create the presenters contained by the receiver"

        super createComponents.
        portsList := self add: ListPresenter new name: 'portsList'.
        currentPort := self add: ValuePresenter new name: 'currentPort'

ConfigurationDialog>>model: aModel
        super model: aModel.
        portsList model: (ListModel on: self model comPorts).
        currentPort model: (aModel aspectValue: #comPort)

ConfigurationDialog>>onViewOpened
        "Received when the receiver's view has been connected. "

        super onViewOpened.
        portsList selectionOrNil: currentPort value

ConfigurationDialog>>apply
        "Apply the changes cached in the receiver back to the model. "

        super apply.
        self model subject comPort: portsList selection

------->8------->8------->8-------

Thanks,

Joseph


Reply | Threaded
Open this post in threaded view
|

Re: I can't find why my dialog never works the first time

Chris Uppal-3
Joseph,

> comPort := 'COM1'.

> ^#('COM1' 'COM2' 'COM3' 'COM4' 'COM5' 'COM6' 'COM7' 'COM8')

> portsList model: (ListModel on: self model comPorts).

One guess:

ListModels use identity comparison by default.  The value of comPort won't be
included (by that criterion) in your list of standard ports, and so the
combo-box will blow up if it attempts to use that as its #selection.  If that
is causing this problem then you should be able to fix it by using an equality
search policy in your list model.  E.g:

    portsList model: (ListModel
                                    on: self model comPorts
                                    searchPolicy: SearchPolicy equality).

Alternatively, you could change the model initialisation to read:

    comPort := self class comPorts first.

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: I can't find why my dialog never works the first time

Joseph Frippiat
Chris Uppal wrote:
> If that
> is causing this problem then you should be able to fix it by using an equality
> search policy in your list model.  E.g:
>
>     portsList model: (ListModel
>                                     on: self model comPorts
>                                     searchPolicy: SearchPolicy equality).

Chris,

that solves the problem.

Thank you very much,

Joseph