Re: Auto selection




tailorma_de skrev:

I have a design question: How could I auto-select a new created
business object reprensentation in my GUI?

My application is divided into the business model and UI and I use the
command pattern. I can describe my problem with an IDE since it is the
same thing.

Imagine I create a new code file within a project. There may be a
dialog where the user has to specify the file name. When the user then
clicks on Ok the new file is created and it is added to the project
somehow. Now there is a project tree view in the GUI and within this
view a new node gets visible, representing the new file. Then the
question comes up: How can this node gets selected automatically?

How could this be done? Assuming that the execution of a command
CreateNewCodeFile has no return value I don't know how to get a
reference to the new business object. If I would get this reference
somehow, I could find the representing item, since (in my case) it also
keeps a reference to the business object.

I have already thought about something like a
RecentlyCreatedObjectManager class where I could get a reference to it
whenever a new business object is created by a command. Therefore the
command has to pass the reference to the manager. Good idea? I don't
think so...

Should I make a snapshot of the project tree before starting the
command and then compare the new tree with the old tree after command
executing to find the new node? I guess this also not best practice...

How have you done it or what could you recommend?

Cheers,
Robert

This sounds like a focusing issue, and as such, you could perhaps read
up on how other GUI-frameworks handling focusing (Java's JTree, for
example).

Essentially, your GUI must be aware of the business objects that it's
presenting at any time, and which object is in focus is a matter for
the GUI only (not the business model). And if your GUI is aware of each
object it's presenting, then it should keep a record of the last object
to be added, and present this object with the, "Selected," form of the
graphic.

So, when you pass your command CreateNewCodeFile to the model, then the
model will eventually send a message to the GUI to say either, "Here's
a new node created," or, "The model's been updated: go figure."

The first approach seems much easier. This way, the GUI can note that
this latest node is the node in-focus, and re-draw the display with the
appropriate node highlighted. This also makes navigation of the
graphics easier by user-commands such as arrow-keys (the GUI can expose
an api with such methosd as: Node[] getSelectedNodes[], Node
getNextNode() etc.).

With the second approach, the GUI needs to maintain a record of the old
business objects and, at each Create/Delete, compare the new list with
the old to find the new node; but still the GUI must be the one to
record the highlighting of this node.

..ed

--
www.EdmundKirwan.com - Home of The Fractal Class Composition.

Download Fractality, free Java code analyzer:
www.EdmundKirwan.com/servlet/fractal/frac-page130.html

.



Relevant Pages

  • Re: Win98 -- all kidding aside
    ... available to me through the GUI, ... the command line will always ... give the greater power and flexibility for certain tasks. ... things than Windows. ...
    (Ubuntu)
  • Re: Access user input from command line
    ... I am trying to create a GUI with an edit box for user input ... below) in the command prompt or through other m files (I get ... % hObject handle to figure ...
    (comp.soft-sys.matlab)
  • Re: For The Newbies
    ... make such wild accusations about people that don't agree with your ... I SAID I was using KDE and KNode. ... uses Linux should _only_ ever use the command line and never a GUI. ...
    (alt.linux)
  • Re: Cobol books & experiences
    ... they are enthused about the command line? ... criticism of MicroSoft for trying to get us to work in a totally Windows ... even when debugging GUI code? ... that so often THEY forgot to put sufficient gas into that small generator. ...
    (comp.lang.cobol)
  • Re: Very Basic Help Needed
    ... "install samba etc" command, which I assume worked as I didn't get any error ... instead of using the Run window, ... many of the programs you use in a gui are actually ... the GUI is not set up for root usage. ...
    (Debian-User)