Skip to content

Commit

Permalink
Add searching to text tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolandscat committed Dec 3, 2024
1 parent 7737d10 commit 6e41a34
Show file tree
Hide file tree
Showing 12 changed files with 443 additions and 68 deletions.
18 changes: 10 additions & 8 deletions apps/adl_workbench/src/gui/archetype_tool/gui_archetype_viewer.e
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ feature -- UI Feedback
ev_application.clipboard.set_text (a_path)
end

feature -- Access

source_control: GUI_SOURCE_CONTROL

serialisation_control: GUI_SERIALISATION_CONTROL

opt_control: GUI_OPT_CONTROL

instance_control: GUI_INSTANCE_CONTROL

feature {NONE} -- Events

on_path_map_key_press (key: EV_KEY)
Expand Down Expand Up @@ -211,18 +221,10 @@ feature {NONE} -- Implementation

clients_suppliers_control: GUI_CLIENTS_SUPPLIERS_CONTROL

source_control: GUI_SOURCE_CONTROL

validity_report_control: GUI_VALIDITY_REPORT_CONTROL

statistical_information_control: GUI_ARCHETYPE_INFORMATION_TOOL

serialisation_control: GUI_SERIALISATION_CONTROL

opt_control: GUI_OPT_CONTROL

instance_control: GUI_INSTANCE_CONTROL

set_differential_tab_texts
-- set text on tabs for differential form of archetype
do
Expand Down
64 changes: 64 additions & 0 deletions apps/adl_workbench/src/gui/archetype_tool/gui_instance_control.e
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ inherit
enable_edit, disable_edit, can_populate, can_repopulate
end

SHARED_GUI_ADDRESS_BAR
export
{NONE} all
end

GUI_SEARCHABLE_TOOL
export
{NONE} all
end

create
make

Expand Down Expand Up @@ -52,6 +62,13 @@ feature {NONE}-- Initialization
-- set initial visual characteristics
differential_view := True

-- make focus actions for rich text controls set this overall tool as current search client
across gui_controls as gui_ctl_csr loop
if attached {EVX_TEXT_EDITOR_CONTROL} gui_ctl_csr.item as evx_txt_edit then
evx_txt_edit.set_text_focus_in_action (agent address_bar.set_current_client (Current))
end
end

ev_root_container.set_data (Current)
end

Expand All @@ -71,6 +88,53 @@ feature -- Status Report
Result := is_populated
end

feature -- Search

matching_ids (a_regex: STRING): ARRAYED_SET[STRING]
do
create Result.make (0)
Result.compare_objects
if attached ev_root_container.selected_item as sel_item and then
attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit and then evx_txt_edit.has_text (a_regex)
then
Result.extend (a_regex)
else
Result.extend (get_msg_line ("regex_e1", <<a_regex>>))
end
end

item_selectable: BOOLEAN
do
Result := True
end

valid_item_id (a_key: STRING): BOOLEAN
do
Result := not a_key.is_empty -- and is printable
end

select_item_by_id (id: STRING)
do
if attached ev_root_container.selected_item as sel_item and then attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit then
evx_txt_edit.search_and_display (id)
end
end

select_next
do
if attached ev_root_container.selected_item as sel_item and then attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit then
evx_txt_edit.search_next
end
end

select_previous
-- Go to the previous match for previous search, if available
do
if attached ev_root_container.selected_item as sel_item and then attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit then
evx_txt_edit.search_previous
end
end

feature -- Commands

enable_edit
Expand Down
67 changes: 67 additions & 0 deletions apps/adl_workbench/src/gui/archetype_tool/gui_opt_control.e
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ inherit
can_populate, can_repopulate
end

GUI_SEARCHABLE_TOOL
export
{NONE} all
end

SHARED_GUI_ADDRESS_BAR
export
{NONE} all
end

STRING_UTILITIES
export
{NONE} all
Expand Down Expand Up @@ -167,6 +177,13 @@ feature {NONE}-- Initialization

gui_controls.extend (evx_odin_text_editor)

-- make focus actions for rich text controls set this overall tool as current search client
across gui_controls as gui_ctl_csr loop
if attached {EVX_TEXT_EDITOR_CONTROL} gui_ctl_csr.item as evx_txt_edit then
evx_txt_edit.set_text_focus_in_action (agent address_bar.set_current_client (Current))
end
end

-- set initial visual characteristics
differential_view := False

Expand All @@ -189,6 +206,56 @@ feature -- Status Report
Result := is_populated
end

feature -- Search

matching_ids (a_regex: STRING): ARRAYED_SET[STRING]
-- generate list of schema elemtn ids (packages and classes)
do
create Result.make (0)
Result.compare_objects
if attached ev_root_container.selected_item as sel_item and then
attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit and then evx_txt_edit.has_text (a_regex)
then
Result.extend (a_regex)
else
Result.extend (get_msg_line ("regex_e1", <<a_regex>>))
end
end

item_selectable: BOOLEAN
do
Result := True
end

valid_item_id (a_key: STRING): BOOLEAN
do
Result := not a_key.is_empty -- and is printable
end

select_item_by_id (id: STRING)
local
ev_text: EV_RICH_TEXT
do
if attached ev_root_container.selected_item as sel_item and then attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit then
evx_txt_edit.search_and_display (id)
end
end

select_next
do
if attached ev_root_container.selected_item as sel_item and then attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit then
evx_txt_edit.search_next
end
end

select_previous
-- Go to the previous match for previous search, if available
do
if attached ev_root_container.selected_item as sel_item and then attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit then
evx_txt_edit.search_previous
end
end

feature {NONE} -- Implementation

gui_controls: ARRAYED_LIST [EVX_CONTROL_SHELL]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ inherit
enable_edit, disable_edit, can_populate, can_repopulate
end

GUI_SEARCHABLE_TOOL
export
{NONE} all
end

SHARED_GUI_ADDRESS_BAR
export
{NONE} all
end

STRING_UTILITIES
export
{NONE} all
Expand Down Expand Up @@ -132,6 +142,13 @@ feature {NONE}-- Initialization

gui_controls.extend (evx_odin_text_editor)

-- make focus actions for rich text controls set this overall tool as current search client
across gui_controls as gui_ctl_csr loop
if attached {EVX_TEXT_EDITOR_CONTROL} gui_ctl_csr.item as evx_txt_edit then
evx_txt_edit.set_text_focus_in_action (agent address_bar.set_current_client (Current))
end
end

-- set initial visual characteristics
differential_view := True

Expand Down Expand Up @@ -170,6 +187,56 @@ feature -- Commands
gui_controls.do_all (agent (an_item: EVX_CONTROL_SHELL) do an_item.disable_editable end)
end

feature -- Search

matching_ids (a_regex: STRING): ARRAYED_SET[STRING]
-- generate list of schema elemtn ids (packages and classes)
do
create Result.make (0)
Result.compare_objects
if attached ev_root_container.selected_item as sel_item and then
attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit and then evx_txt_edit.has_text (a_regex)
then
Result.extend (a_regex)
else
Result.extend (get_msg_line ("regex_e1", <<a_regex>>))
end
end

item_selectable: BOOLEAN
do
Result := True
end

valid_item_id (a_key: STRING): BOOLEAN
do
Result := not a_key.is_empty -- and is printable
end

select_item_by_id (id: STRING)
local
ev_text: EV_RICH_TEXT
do
if attached ev_root_container.selected_item as sel_item and then attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit then
evx_txt_edit.search_and_display (id)
end
end

select_next
do
if attached ev_root_container.selected_item as sel_item and then attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit then
evx_txt_edit.search_next
end
end

select_previous
-- Go to the previous match for previous search, if available
do
if attached ev_root_container.selected_item as sel_item and then attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit then
evx_txt_edit.search_previous
end
end

feature {NONE} -- Implementation

gui_controls: ARRAYED_LIST [EVX_CONTROL_SHELL]
Expand Down
66 changes: 65 additions & 1 deletion apps/adl_workbench/src/gui/archetype_tool/gui_source_control.e
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ inherit
enable_edit, disable_edit, can_populate, can_repopulate
end

GUI_SEARCHABLE_TOOL
export
{NONE} all
end

SHARED_GUI_ADDRESS_BAR
export
{NONE} all
end

OPERATOR_TYPES
export
{NONE} all
Expand Down Expand Up @@ -75,6 +85,12 @@ feature {NONE}-- Initialization

gui_controls.extend (evx_adl_serialised_editor)

-- make focus actions for rich text controls set this overall tool as current search client
across gui_controls as gui_ctl_csr loop
if attached {EVX_TEXT_EDITOR_CONTROL} gui_ctl_csr.item as evx_txt_edit then
evx_txt_edit.set_text_focus_in_action (agent address_bar.set_current_client (Current))
end
end

differential_view := True
ev_root_container.set_data (Current)
Expand All @@ -84,6 +100,54 @@ feature -- Access

ev_root_container: EV_NOTEBOOK

feature -- Search

matching_ids (a_regex: STRING): ARRAYED_SET[STRING]
-- generate list of schema elemtn ids (packages and classes)
do
create Result.make (0)
Result.compare_objects
if attached ev_root_container.selected_item as sel_item and then
attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit and then evx_txt_edit.has_text (a_regex)
then
Result.extend (a_regex)
else
Result.extend (get_msg_line ("regex_e1", <<a_regex>>))
end
end

item_selectable: BOOLEAN
do
Result := True
end

valid_item_id (a_key: STRING): BOOLEAN
do
Result := not a_key.is_empty -- and is printable
end

select_item_by_id (id: STRING)
do
if attached ev_root_container.selected_item as sel_item and then attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit then
evx_txt_edit.search_and_display (id)
end
end

select_next
do
if attached ev_root_container.selected_item as sel_item and then attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit then
evx_txt_edit.search_next
end
end

select_previous
-- Go to the previous match for previous search, if available
do
if attached ev_root_container.selected_item as sel_item and then attached {EVX_TEXT_EDITOR_CONTROL} sel_item.data as evx_txt_edit then
evx_txt_edit.search_previous
end
end

feature -- Status Report

can_populate (a_source: attached like source; a_params: TUPLE [diff_view: BOOLEAN; a_lang: STRING]): BOOLEAN
Expand Down Expand Up @@ -187,7 +251,7 @@ feature {NONE} -- Implementation

do_populate
local
sel_tab: detachable EV_NOTEBOOK_TAB
sel_tab: EV_NOTEBOOK_TAB
do
gui_controls.do_all (agent (an_item: EVX_CONTROL_SHELL) do an_item.populate end)

Expand Down
Loading

0 comments on commit 6e41a34

Please sign in to comment.