EV_GRID questions

9 messages Options
Embed this post
Permalink
Jimmy Johnson

EV_GRID questions

Reply Threaded More More options
Print post
Permalink
In the following code I am trying to do a breadth-first traversal of a tree.  I get an EV_GRID_ROW from a queue and create an EV_GRID_ROW for each child and queue that child.

I assume a row added as a child would make the parent have an expand/contract icon and do all that great tree processing.  I have tried several things and items end up in the wrong columns or I violate a precondition.  Reference the code below.

So, for lines 1, 2, and 3:
How do I create a new row and position/parent it correctly?
How do I obtain that row just created?

For lines 4 and 5:
I want to add 2 items to each sub-row, in what I would call the 1st and 2nd column after the [blank?] columns accounting for any indenting.  At what index do I place the items?  Line 4 violates the precondition to `set_item', "is_index_valid_for_item_insertion_if_subrow: a_item /= Void and then is_part_of_tree_structure implies is_index_valid_for_item_setting_if_tree_node (i)".

Thanks,

Jimmy J. Johnson


q: LINKED_QUEUE [EV_GRID_ROW]
first_row, pr, r: EV_GRID_ROW
field_lab, object_lab: EV_GRID_LABEL_ITEM

from q.extend (first_row)
until q.is_empty
loop
  pr := q.item
  q.remove
  from i := 1
  until i > stop_count
    loop
--1      insert_new_row_parented (pr.index + pr.subrow_count_recursive + 1, pr)
--2      insert_new_row (row_count + 1)
--3      r := row (row_count)
      if condition then
        q.extend (r)
      end
      create field_lab.make_with_text (i.out))
      create object_lab.make_with_text (i.out))
--4      r.set_item (r.index_of_first_item + 1, field_lab)
--5      r.set_item (r.index_of_first_item + 1, object_lab)
      i := i + 1
  end
end


Peter Gummer-2

Re: EV_GRID questions

Reply Threaded More More options
Print post
Permalink
Jimmy wrote:

> In the following code I am trying to do a breadth-first traversal of  
> a tree.  I get an EV_GRID_ROW from a queue and create an EV_GRID_ROW  
> for each child and queue that child.

Not sure if this will help, Jimmy, but sometimes it's easier to see  
some examples.

http://www.openehr.org/svn/ref_impl_eiffel/BRANCHES/specialisation/apps/adl_workbench/src/controls/gui_test_archetype_tree_control.e 
  populates a multi-column EV_GRID. The first column is a tree. The  
routines that may be most helpful to you are 'populate' and  
'populate_gui_tree_node_enter'.

http://www.openehr.org/svn/ref_impl_eiffel/BRANCHES/specialisation/apps/adl_workbench/src/controls/gui_compiler_error_control.e 
  populates an EV_GRID that finishes up looking a lot like  
EiffelStudio's Errors List tool. (I mention this because it may help  
you understand what it's doing if you can imagine something already  
familiar to you.) There are a few categories of errors, under which we  
display rows that are the children of each category. The code in this  
class is a bit less obvious than in the first example, because it's  
driven by agents rather than from a plainly visible top-level loop.  
The routines that may be most helpful to you are 'extend_and_select'  
and 'ensure_row_for_category'.

- Peter Gummer

Jimmy Johnson

Re: EV_GRID questions

Reply Threaded More More options
Print post
Permalink
Peter, thanks for the examples.  I think I missunderstood what EV_GRID gives.  If it is like the error list you get an expandable/collapsable row which can hold EV_ROW_ITEMs only, and there is only one level [column?], the left most, which holds the expand/contract icon.

What I was hoping for is a tree like the clusters view but instead simply displaying text after the icon, I want a complex widget there so you could do things such as break the text into differenct pieces and color the parts differently and assign actions to each part or add a drawing area, etc.

Thanks again,

Jimmy J. Johnson


Jocelyn.Fiat

Re: Re: EV_GRID questions

Reply Threaded More More options
Print post
Permalink
If you want to see EV_GRID in action.
Please open EiffelStudio, most of the widget are built with EV_GRID.

Feature tool, class tool, object tool, watch tool, callstack tool,
breakpoints tools, error and warning tool, configuration tool,
preferences tool ...
Some of them use dynamic content functionality

Hope this helps,
Jocelyn

boxer41a wrote:

> Peter, thanks for the examples.  I think I missunderstood what EV_GRID gives.  If it is like the error list you get an expandable/collapsable row which can hold EV_ROW_ITEMs only, and there is only one level [column?], the left most, which holds the expand/contract icon.
>
> What I was hoping for is a tree like the clusters view but instead simply displaying text after the icon, I want a complex widget there so you could do things such as break the text into differenct pieces and color the parts differently and assign actions to each part or add a drawing area, etc.
>
> Thanks again,
>
> Jimmy J. Johnson
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>
>
>  

Jimmy Johnson

Re: EV_GRID questions

Reply Threaded More More options
Print post
Permalink
Okay, looking at the features tool, callees mode, I see that it does indeed have two levels that are expandable.

I am not a new comer to EiffelVission but I cannot seem to build a grid.  I keep violating the preconditions either for the grid or for the row; I must be doing something out of order.  EV_ROW and EV_GRID must be very tightly coupled.  

How about a simple example to build a mutilevel tree in an EV_GRID?


--- In [hidden email], Jocelyn <eiffel@...> wrote:

>
> If you want to see EV_GRID in action.
> Please open EiffelStudio, most of the widget are built with EV_GRID.
>
> Feature tool, class tool, object tool, watch tool, callstack tool,
> breakpoints tools, error and warning tool, configuration tool,
> preferences tool ...
> Some of them use dynamic content functionality
>
> Hope this helps,
> Jocelyn
>
> boxer41a wrote:
> > Peter, thanks for the examples.  I think I missunderstood what EV_GRID gives.  If it is like the error list you get an expandable/collapsable row which can hold EV_ROW_ITEMs only, and there is only one level [column?], the left most, which holds the expand/contract icon.
> >
> > What I was hoping for is a tree like the clusters view but instead simply displaying text after the icon, I want a complex widget there so you could do things such as break the text into differenct pieces and color the parts differently and assign actions to each part or add a drawing area, etc.
> >
> > Thanks again,
> >
> > Jimmy J. Johnson
> >
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
>


Peter Gummer-2

Re: Re: EV_GRID questions

Reply Threaded More More options
Print post
Permalink
Jimmy Johnson wrote:

> How about a simple example to build a mutilevel tree in an EV_GRID?



That's what the first example I gave you does:

> http://www.openehr.org/svn/ref_impl_eiffel/BRANCHES/specialisation/apps/adl_workbench/src/controls/gui_test_archetype_tree_control.e
>  populates a multi-column EV_GRID. The first column is a tree. The
> routines that may be most helpful to you are 'populate' and
> 'populate_gui_tree_node_enter'.



- Peter Gummer
Jimmy Johnson

Re: EV_GRID questions

Reply Threaded More More options
Print post
Permalink
Okay, another look.  Missed a step on first look.  I think I have the basic sequence and am off to try.  Thanks again for the help.

  -- 1.  Create an [descendent of] EV_GRID_ITEM.
create root_item.make_with_text ("Root")
  -- 2.  Add the item to the EV_GRID.
grid.set_item (1, 1, root_grid_item)
  -- I never explicitely create an EV_ROW?
  -- 3.  Get the EV_GRID_ROW in which the label was placed.
row := root_item.row
  -- I would never have thought to querry the
  -- EV_GRID_ITEM to have it get an EV_GRID_ROW
  -- [I assume] from the EV_GRID.
  -- 4.  Let that EV_ROW create a new EV_ROW as child.
row.insert_subrow (subrow_count + 1)
  -- 5.  Get that new child row.
row := row.subrow (row.subrow_count)
  -- 6.  Create a new [descnedant of] EV_GRID_ITEM.
create child_item.make_with_text ("child of...")
  -- 7.  Add the item to the row.
row.set_item (1, child_item)
  -- 8.  Repeat appropriate steps.

  -- Little fuzzy in step 7 as to which column to use.  I assume the "1" in first argument to ` above refers to the first column (the one with the expand/contract icon)  of the EV_GRID to which the EV_ROW belongs?



Jimmy Johnson

Re: EV_GRID questions

Reply Threaded More More options
Print post
Permalink
Thanks to all for the help.  It's working.  More questions though.

1.  In the Class tool, exported features view, how are the multiple colors (e.g. green featute name, blue type/class) obtained?  



rfo

RE: Re: EV_GRID questions

Reply Threaded More More options
Print post
Permalink
In reply to this post by Jimmy Johnson
Another approach, more row-oriented and therefore possibly a bit less
confusing s to create rows and then add items.

1. Create the grid
  create grid
2. Add the root row
  grid.insert_new_row (1)
3. Snag newly added row
  l_row := grid.row (1)
4. Add root item to root row
  l_row.set_item (1, create {EV_GRID_LABEL_ITEM}.make_with_text
("Root"))

Now that you have a root, you're off to the races as before
5. Add a child row to the root row
  idx := idx + 1; grid.insert_new_row_parented (idx, l_row)
6. Snag the new row
  l_row := grid.row (idx)
7. Add a suitable child item to the new row
  row.set_item (idx, create {EV_GRID_LABEL_ITEM}.make_with_text ("child
of..."))




     R

==================================================
Roger F. Osmond


> -------- Original Message --------
> Subject: [eiffel_software] Re: EV_GRID questions
> From: "boxer41a" <[hidden email]>
> Date: Tue, September 08, 2009 12:59 pm
> To: [hidden email]
> Okay, another look.  Missed a step on first look.  I think I have the basic sequence and am off to try.  Thanks again for the help.
>   -- 1.  Create an [descendent of] EV_GRID_ITEM.
> create root_item.make_with_text ("Root")
>   -- 2.  Add the item to the EV_GRID.
> grid.set_item (1, 1, root_grid_item)
>   -- I never explicitely create an EV_ROW?
>   -- 3.  Get the EV_GRID_ROW in which the label was placed.
> row := root_item.row
>   -- I would never have thought to querry the
>   -- EV_GRID_ITEM to have it get an EV_GRID_ROW
>   -- [I assume] from the EV_GRID.
>   -- 4.  Let that EV_ROW create a new EV_ROW as child.
> row.insert_subrow (subrow_count + 1)
>   -- 5.  Get that new child row.
> row := row.subrow (row.subrow_count)
>   -- 6.  Create a new [descnedant of] EV_GRID_ITEM.
> create child_item.make_with_text ("child of...")
>   -- 7.  Add the item to the row.
> row.set_item (1, child_item)
>   -- 8.  Repeat appropriate steps.
>   -- Little fuzzy in step 7 as to which column to use.  I assume the "1" in first argument to ` above refers to the first column (the one with the expand/contract icon)  of the EV_GRID to which the EV_ROW belongs?