Re: Auto selection
- From: "Ed" <iamfractal@xxxxxxxxxxx>
- Date: 23 Nov 2006 03:55:08 -0800
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
.
- Follow-Ups:
- Re: Auto selection
- From: tailorma_de
- Re: Auto selection
- References:
- Auto selection
- From: tailorma_de
- Auto selection
- Prev by Date: Auto selection
- Next by Date: Re: Auto selection
- Previous by thread: Auto selection
- Next by thread: Re: Auto selection
- Index(es):
Relevant Pages
|