------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real-time scheduling analysis tool. -- This program provides services to automatically check schedulability and -- other performance criteria of real-time architecture models. -- -- Copyright (C) 2002-2023, Frank Singhoff, Alain Plantec, Jerome Legrand, -- Hai Nam Tran, Stephane Rubini -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285, Université de Bretagne Occidentale -- -- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008. -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- The full list of contributors and sponsors can be found in README.md -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- Contact : cheddar@listes.univ-brest.fr -- ------------------------------------------------------------------------------ -- Last update : -- $Rev: 3657 $ -- $Date: 2020-12-13 13:25:49 +0100 (dim., 13 déc. 2020) $ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Ada.Text_IO; use Ada.Text_IO; with Glib; use Glib; with Glib.Values; use Glib.Values; with Gdk.Types; use Gdk.Types; with Gtk.Enums; use Gtk.Enums; with Gtk.Widget; use Gtk.Widget; with Gtk; use Gtk; with Gtk.Main; use Gtk.Main; with Glib.Error; use Glib.Error; with Gtk.Scrollable; use Gtk.Scrollable; with graphical_editor.select_time_line.callbacks; use graphical_editor.select_time_line.callbacks; with framework_config; use framework_config; with translate; use translate; with unbounded_strings; use unbounded_strings; use unbounded_strings.strings_table_package; with task_set; use task_set; use task_set.generic_task_set; with tasks; use tasks; with resource_set; use resource_set; use resource_set.generic_resource_set; with resources; use resources; with message_set; use message_set; use message_set.generic_message_set; with messages; use messages; with buffer_set; use buffer_set; use buffer_set.generic_buffer_set; with buffers; use buffers; with objects.extended; use objects.extended; package body graphical_editor.select_time_line is procedure gtk_new (select_time_line : out select_time_line_access; a_system : in system; call : in select_time_line_callback_type) is begin select_time_line := new select_time_line_record; graphical_editor.select_time_line.initialize (select_time_line, sys, call); end gtk_new; procedure initialize (select_time_line : access select_time_line_record'class; a_system : in system; call : in select_time_line_callback_type) is my_task_iterator : tasks_iterator; my_resource_iterator : resources_iterator; my_buffer_iterator : buffers_iterator; my_message_iterator : messages_iterator; a_task : generic_task_ptr; a_message : generic_message_ptr; a_resource : generic_resource_ptr; a_buffer : buffer_ptr; line : guint := 1; procedure new_object (an_object : generic_object_ptr) is begin Gtk_New (select_time_line.entries (select_time_line.nb_entries) .object_name); Set_Editable (select_time_line.entries (select_time_line.nb_entries).object_name, False); Set_Max_Length (select_time_line.entries (select_time_line.nb_entries).object_name, 0); Set_Text (select_time_line.entries (select_time_line.nb_entries).object_name, To_String (get_name_of_generic_object (an_object))); Set_Visibility (select_time_line.entries (select_time_line.nb_entries).object_name, True); Attach (select_time_line.table, select_time_line.entries (select_time_line.nb_entries).object_name, 0, 1, line, line + 1, Expand or Fill, 0, 0, 0); Gtk_New (select_time_line.entries (select_time_line.nb_entries) .object_type); Set_Editable (select_time_line.entries (select_time_line.nb_entries).object_type, False); Set_Max_Length (select_time_line.entries (select_time_line.nb_entries).object_type, 0); case an_object.object_type is when message_object_type => Set_Text (select_time_line.entries (select_time_line.nb_entries) .object_type, To_String (lb_message (current_language))); when task_object_type => Set_Text (select_time_line.entries (select_time_line.nb_entries) .object_type, To_String (lb_task (current_language))); when buffer_object_type => Set_Text (select_time_line.entries (select_time_line.nb_entries) .object_type, To_String (lb_buffer (current_language))); when resource_object_type => Set_Text (select_time_line.entries (select_time_line.nb_entries) .object_type, To_String (lb_resource (current_language))); when others => null; end case; Set_Visibility (select_time_line.entries (select_time_line.nb_entries).object_type, True); Attach (select_time_line.table, select_time_line.entries (select_time_line.nb_entries).object_type, 1, 2, line, line + 1, Expand or Fill, 0, 0, 0); Gtk_New (select_time_line.entries (select_time_line.nb_entries) .display_time_line, ""); Set_Active (select_time_line.entries (select_time_line.nb_entries) .display_time_line, False); Attach (select_time_line.table, select_time_line.entries (select_time_line.nb_entries) .display_time_line, 2, 3, line, line + 1, Expand or Fill, 0, 0, 0); line := line + 1; select_time_line.nb_entries := select_time_line.nb_entries + 1; end new_object; begin reset (time_line_to_display); select_time_line.nb_entries := 0; select_time_line.to_be_called := call; Gtk.Window.Initialize (select_time_line, window_toplevel); Set_Title (select_time_line, To_String (lb_select_time_line (current_language))); Set_Position (select_time_line, win_pos_center_always); Set_Modal (select_time_line, True); Set_Default_Size (select_time_line, 530, 550); Grab_Focus (select_time_line); Gtk_New (select_time_line.scroll); Set_Border_Width (select_time_line.scroll, Border_Width => 10); Set_Policy(select_time_line.scroll, HScrollbar_Policy => policy_automatic, VScrollbar_Policy => policy_automatic); Add (select_time_line, select_time_line.scroll); Gtk_New (select_time_line.table, 0, 0, True); Set_Row_Spacings (select_time_line.table, 8); Set_Col_Spacings (select_time_line.table, 7); Add_With_Viewport (select_time_line.scroll, select_time_line.table); Set_Focus_Hadjustment (select_time_line.table, Get_Hadjustment (select_time_line.scroll)); Set_Focus_Vadjustment (select_time_line.table, Get_Vadjustment (select_time_line.scroll)); Gtk_New (select_time_line.lab, To_String (lb_name (current_language))); Set_Alignment (select_time_line.lab, 0.5, 0.5); Set_Padding (select_time_line.lab, 0, 0); Set_Justify (select_time_line.lab, justify_center); Set_Line_Wrap (select_time_line.lab, False); Attach (select_time_line.table, select_time_line.lab, 0, 1, 0, 1, 0, 0, 0, 0); Gtk_New (select_time_line.lab, To_String (lb_type (current_language))); Set_Alignment (select_time_line.lab, 0.5, 0.5); Set_Padding (select_time_line.lab, 0, 0); Set_Justify (select_time_line.lab, justify_center); Set_Line_Wrap (select_time_line.lab, False); Attach (select_time_line.table, select_time_line.lab, 1, 2, 0, 1, 0, 0, 0, 0); Gtk_New (select_time_line.lab, To_String (lb_to_display (current_language))); Set_Alignment (select_time_line.lab, 0.5, 0.5); Set_Padding (select_time_line.lab, 0, 0); Set_Justify (select_time_line.lab, justify_center); Set_Line_Wrap (select_time_line.lab, False); Attach (select_time_line.table, select_time_line.lab, 2, 3, 0, 1, 0, 0, 0, 0); reset_iterator (sys.tasks, my_task_iterator); loop current_element (sys.tasks, a_task, my_task_iterator); new_object (generic_object_ptr (a_task)); exit when is_last_element (sys.tasks, my_task_iterator); next_element (sys.tasks, my_task_iterator); end loop; if not is_empty (sys.buffers) then reset_iterator (sys.buffers, my_buffer_iterator); loop current_element (sys.buffers, a_buffer, my_buffer_iterator); new_object (generic_object_ptr (a_buffer)); exit when is_last_element (sys.buffers, my_buffer_iterator); next_element (sys.buffers, my_buffer_iterator); end loop; end if; if not is_empty (sys.messages) then reset_iterator (sys.messages, my_message_iterator); loop current_element (sys.messages, a_message, my_message_iterator); new_object (generic_object_ptr (a_message)); exit when is_last_element (sys.messages, my_message_iterator); next_element (sys.messages, my_message_iterator); end loop; end if; if not is_empty (sys.resources) then reset_iterator (sys.resources, my_resource_iterator); loop current_element (sys.resources, a_resource, my_resource_iterator); new_object (generic_object_ptr (a_resource)); exit when is_last_element (sys.resources, my_resource_iterator); next_element (sys.resources, my_resource_iterator); end loop; end if; Gtk_New_Hseparator (select_time_line.hseparator); Attach (select_time_line.table, select_time_line.hseparator, 0, 3, line, line + 1, Fill, Expand or Fill, 0, 0); Gtk_New_Hbox (select_time_line.hbox, True, 0); Set_Border_Width (select_time_line.hbox, 6); Attach (select_time_line.table, select_time_line.hbox, 0, 3, line + 1, line + 2, Fill, Expand or Fill, 0, 0); Gtk_New (select_time_line.ok_button, "Ok"); Pack_Start (select_time_line.hbox, select_time_line.ok_button, True, True, 0); button_callback.Connect (select_time_line.ok_button, "clicked", button_callback.To_Marshaller (on_ok_pressed'access)); end initialize; function to_display (searched_name : in Unbounded_String; searched_type : in objects_type) return Boolean is ite : time_line_object_iterator; an_object : generic_object_ptr; begin if is_empty (time_line_to_display) then return True; end if; reset_iterator (time_line_to_display, ite); loop current_element (time_line_to_display, an_object, ite); if (get_name_of_generic_object (an_object) = searched_name) and (an_object.object_type = searched_type) then return True; end if; exit when is_last_element (time_line_to_display, ite); next_element (time_line_to_display, ite); end loop; return False; end to_display; end graphical_editor.select_time_line;