Re: Auto selection
- From: "Ed" <iamfractal@xxxxxxxxxxx>
- Date: 23 Nov 2006 05:45:08 -0800
tailorma_de skrev:
Essentially, your GUI must be aware of the business objects thatit's
presenting at any time, and which object is in focus is a matter for
the GUI only (not the business model).
Okay. Selection/Focus is a part of the UI. This thightens my
assumption.
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 "Here's a new node created" sounds interesting. Of
course.
Btw, with node you mean an business object, right?
Yes, sorry, I was thinking of nodes in a graph (which is the closest
I've come to programming in this area).
The tree was just an example. It could also be something else. However,
I would like to know how it should be realized with a tree (deep
structure should be also possible). Would you use an event? What would
raise the event? Would you pass the parent business object as a
parameter?
Well, let's run with the file-explorer theme.
The event that triggers the creation of a folder is the use clicking
somewhere and selecting, "New Folder."
The squence could be:
1. Event CreateNewFileCommand received in business model with something
as abstract as the x and y coordinates of the mouse click.
2. Business model asks GUI to identify the folder that corresponds to
this (x, y). (Remember, the GUI must know at all times what folders
it's displaying and where each is on the screen.) A method like: Folder
getFolderAt(x, y);
[Of course, some other logic, outside your business model could do this
translation for you, if seeing graphical coordinates within your
business model looks a bit strange (which, let's face it, it does.)]
3. Business model creates new Folder object. (This can be structured
any way you like within the business model: a tree, a map of
parent-to-child, an amorphous array, ...).
4. Business model tells the GUI to update itself, passing the
newly-create Folder as a parameter, e.g., void update(Folder folder).
5. GUI notes that this new Folder will be the newly-selected Folder.
Then draws the enter file hierarchy from scratch (though it checks each
Folder it's drawing to see whether it's the selected one and draws
accordingly). Note that the GUI can draw these Folders independently of
how they're structured in the business model, but it must know the
parentage of each node if it is to draw them heirarchically. Thus the
GUI is dependent on the business model far more than the business model
is dependent on the GUI.
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.).
I'm not sure how to understand this in the context. Do you mean this in
a strict MVC design? Please excuse, I'm not that experienced with those
'higher' leveled programming techniques.
I did mean in an MVC context, but don't worry about formal MVC unless
someone's shouting for it: it's enough to try to separate the business
model behaviour from the GUI behaviour as much as is practical.
..ed
--
www.EdmundKirwan.com - Home of The Fractal Class Composition.
Download Fractality, free Java code analyzer:
www.EdmundKirwan.com/servlet/fractal/frac-page130.html
.
- References:
- Auto selection
- From: tailorma_de
- Re: Auto selection
- From: Ed
- Re: Auto selection
- From: tailorma_de
- Auto selection
- Prev by Date: Re: Auto selection
- Next by Date: Re: Auto selection
- Previous by thread: Re: Auto selection
- Next by thread: Re: Auto selection
- Index(es):
Relevant Pages
|