text stringlengths 0 234 |
|---|
while Target <= List'Last and List'First + Pos < Middle and Quarter /= 0 loop |
Swap (List (List'First + Pos), List (Target)); |
Pos := Pos + 1; |
if Target <= Middle then |
Target := List'Last - Quarter; |
else |
Target := List'First + Quarter; |
Quarter := Quarter / 2; |
end if; |
end loop; |
end Dispatch; |
-- ------------------------------ |
-- Render the tag cloud component. |
-- ------------------------------ |
overriding |
procedure Encode_Children (UI : in Tag_UICloud; |
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is |
procedure Free is |
new Ada.Unchecked_Deallocation (Object => Tag_Info_Array, |
Name => Tag_Info_Array_Access); |
Table : Tag_Info_Array_Access := null; |
begin |
if not UI.Is_Rendered (Context) then |
return; |
end if; |
declare |
use type Util.Beans.Basic.List_Bean_Access; |
Max : constant Integer := UI.Get_Attribute ("rows", Context, 1000); |
Layout : constant String := UI.Get_Attribute ("layout", Context); |
Bean : constant Util.Beans.Basic.List_Bean_Access |
:= ASF.Components.Utils.Get_List_Bean (UI, "value", Context); |
Count : Natural; |
Tags : AWA.Tags.Beans.Tag_Ordered_Sets.Set; |
List : AWA.Tags.Beans.Tag_Info_List_Bean_Access; |
begin |
-- Check that we have a List_Bean but do not complain if we have a null value. |
if Bean = null or Max <= 0 then |
return; |
end if; |
if not (Bean.all in AWA.Tags.Beans.Tag_Info_List_Bean'Class) then |
ASF.Components.Base.Log_Error (UI, "Invalid tag list bean: it does not " |
& "implement 'Tag_Info_List_Bean' interface"); |
return; |
end if; |
List := AWA.Tags.Beans.Tag_Info_List_Bean'Class (Bean.all)'Unchecked_Access; |
Count := List.Get_Count; |
if Count = 0 then |
return; |
end if; |
-- Pass 1: Collect the tags and keep the most used. |
for I in 1 .. Count loop |
Tags.Insert (List.List.Element (I - 1)); |
if Integer (Tags.Length) > Max then |
Tags.Delete_Last; |
end if; |
end loop; |
Count := Natural (Tags.Length); |
Table := new Tag_Info_Array (1 .. Count); |
for I in 1 .. Count loop |
Table (I) := Tags.First_Element; |
Tags.Delete_First; |
end loop; |
-- Pass 2: Assign weight to each tag. |
UI.Compute_Cloud_Weight (Table.all, Context); |
-- Pass 3: Dispatch the tags using some layout algorithm. |
if Layout = "dispatch" then |
Dispatch (Table.all); |
end if; |
-- Pass 4: Render each tag. |
UI.Render_Cloud (Table.all, Context); |
Free (Table); |
exception |
when others => |
Free (Table); |
raise; |
Function Definition: procedure Unchecked_Free is new Ada.Unchecked_Deallocation |
Function Body: (Tag_Impl, Tag_Impl_Ptr); |
pragma Warnings (Off, "*redundant conversion*"); |
Ptr : Tag_Impl_Ptr := Tag_Impl (Object.all)'Access; |
pragma Warnings (On, "*redundant conversion*"); |
begin |
Unchecked_Free (Ptr); |
end Destroy; |
procedure Find (Object : in out Tag_Impl; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.