Skip to content

Commit

Permalink
Add a new explorer mode that removes abstract classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolandscat committed Sep 12, 2024
1 parent 1d62477 commit 6466dd5
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 5 deletions.
12 changes: 12 additions & 0 deletions apps/adl_workbench/src/env/shared_app_ui_resources.e
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,18 @@ feature -- Application Switches
app_cfg.put_boolean_value("/gui/show_entire_ontology", flag)
end

show_abstract_classes: BOOLEAN
-- Display abstract classes in the ontology class tree
do
Result := app_cfg.boolean_value ("/gui/show_abstract_classes")
end

set_show_abstract_classes (flag: BOOLEAN)
-- Set flag for show_abstract_classes.
do
app_cfg.put_boolean_value("/gui/show_abstract_classes", flag)
end

display_archetype_source: BOOLEAN
-- Display "(f)" marker on archetypes created in flat form
do
Expand Down
14 changes: 12 additions & 2 deletions apps/adl_workbench/src/gui/library_tool/gui_archetype_explorer.e
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ feature {NONE} -- Implementation
ev_semantic_grid_populate_enter (aci: ARCH_LIB_ITEM)
-- Add a node representing `an_item' to `gui_file_tree'.
do
if not aci.is_root and (aci.subtree_artefact_total > 0 or else show_entire_ontology or else attached {ARCH_LIB_ARCHETYPE} aci) then
if show_node (aci) then
-- add row to grid
if ev_tree_item_stack.is_empty then
gui_semantic_grid.add_row (aci)
Expand All @@ -235,7 +235,7 @@ feature {NONE} -- Implementation

ev_semantic_grid_populate_exit (aci: ARCH_LIB_ITEM)
do
if not aci.is_root and (aci.subtree_artefact_total > 0 or else show_entire_ontology or else attached {ARCH_LIB_ARCHETYPE} aci) then
if show_node (aci) then
ev_tree_item_stack.remove
end
end
Expand Down Expand Up @@ -589,6 +589,16 @@ feature {NONE} -- Implementation
end
end

show_node (aci: ARCH_LIB_ITEM): BOOLEAN
do
Result := not aci.is_root
and (aci.subtree_artefact_total > 0 or show_entire_ontology or attached {ARCH_LIB_ARCHETYPE} aci)
and (show_abstract_classes
or aci.local_archetype_count > 0
or attached {ARCH_LIB_ARCHETYPE} aci
or aci.subtree_artefact_total > 0 and attached {ARCH_LIB_MODEL} aci)
end

end


15 changes: 15 additions & 0 deletions apps/adl_workbench/src/gui/main/gui_agents.e
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ feature {NONE} -- Access
on_toggle_view_all_classes_agent: detachable PROCEDURE [ANY, TUPLE[BOOLEAN]]
-- agent to call when 'show all classes' UI option is toggled

on_toggle_view_abstract_classes_agent: detachable PROCEDURE [ANY, TUPLE[BOOLEAN]]
-- agent to call when 'show abstract classes' UI option is toggled

save_resources_agent: detachable PROCEDURE [ANY, TUPLE]
-- save resources file

Expand Down Expand Up @@ -197,6 +200,13 @@ feature -- Command
end
end

call_on_toggle_view_abstract_classes_agent (a_flag: BOOLEAN)
do
if attached on_toggle_view_abstract_classes_agent as att_agt then
att_agt.call ([a_flag])
end
end

call_save_resources_agent
do
if attached save_resources_agent as att_agt then
Expand Down Expand Up @@ -301,6 +311,11 @@ feature -- Modification
on_toggle_view_all_classes_agent := an_agent
end

set_on_toggle_view_abstract_classes_agent (an_agent: like on_toggle_view_abstract_classes_agent)
do
on_toggle_view_abstract_classes_agent := an_agent
end

set_save_resources_agent (an_agent: like save_resources_agent)
do
save_resources_agent := an_agent
Expand Down
17 changes: 16 additions & 1 deletion apps/adl_workbench/src/gui/main/main_window.e
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ feature {NONE} -- Initialization
gui_agents.set_close_test_tool_agent (agent close_test_tool)

gui_agents.set_on_toggle_view_all_classes_agent (agent on_toggle_view_all_classes)
gui_agents.set_on_toggle_view_abstract_classes_agent (agent on_toggle_view_abstract_classes)

gui_agents.set_save_resources_agent (agent save_resources)
end
Expand Down Expand Up @@ -688,7 +689,7 @@ feature {NONE} -- Library events
feature {NONE} -- XML Menu events

set_xml_rules
-- Called by `select_actions' of `xml_menu_conv_rules'.
-- Called by `select_actions' of `xml_menu_conv_rules'.*dialog
do
execution_environment.launch (text_editor_command + " %"" + xml_rules_file_path + "%"")
mark_xml_rules_put_of_date -- assume that the user makes a change; not very scientific, but good enough for now
Expand Down Expand Up @@ -719,6 +720,20 @@ feature {NONE} -- Tools menu events
end
end

on_toggle_view_abstract_classes (a_flag: BOOLEAN)
-- the 'view all classes' setting says whether to display all RM classes in the
-- archetype explorer, or only those for which there are archetypes
do
set_show_abstract_classes (a_flag)
save_resources
if has_current_library then
library_tool.populate (current_library)
if test_tool.ev_root_container.is_displayed then
test_tool.populate
end
end
end

clean_generated_files
-- Remove all generated files in the current library and repopulate from scratch
do
Expand Down
8 changes: 7 additions & 1 deletion apps/adl_workbench/src/gui/main/option_dialog.e
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ feature {NONE} -- Initialization
ev_notebook_ui_settings_1_vb.extend (evx_show_all_classes_cb.ev_data_control)
gui_controls.extend (evx_show_all_classes_cb)

-- show abstract classes in archetype explorer
create evx_show_abstract_classes_cb.make (get_text ({ADL_MESSAGES_IDS}.ec_show_abstract_classes_text), get_text ({ADL_MESSAGES_IDS}.ec_show_abstract_classes_tooltip), agent show_abstract_classes)
ev_notebook_ui_settings_1_vb.extend (evx_show_abstract_classes_cb.ev_data_control)
gui_controls.extend (evx_show_abstract_classes_cb)

-- show 'lf' marker in archetype tree to indicate original source form (legacy or authored)
create evx_display_source_cb.make (get_text ({ADL_MESSAGES_IDS}.ec_show_source_format_text), get_text ({ADL_MESSAGES_IDS}.ec_show_source_format_tooltip), agent display_archetype_source)
ev_notebook_ui_settings_1_vb.extend (evx_display_source_cb.ev_data_control)
Expand Down Expand Up @@ -335,6 +340,7 @@ feature -- Events
set_display_archetype_source (evx_display_source_cb.is_selected)

gui_agents.call_on_toggle_view_all_classes_agent (evx_show_all_classes_cb.is_selected)
gui_agents.call_on_toggle_view_abstract_classes_agent (evx_show_abstract_classes_cb.is_selected)

set_default_tool_tab (Tool_tab_reverse_index.item (evx_tool_tab_cob.data_control_text))

Expand Down Expand Up @@ -406,7 +412,7 @@ feature {NONE} -- Implementation

evx_quiet_mode_cb, evx_validation_strict_cb, evx_rm_flattening_cb, evx_expand_definition_tree_cb, evx_show_line_numbers_cb: EVX_CHECK_BOX_CONTROL

evx_display_source_cb, evx_show_all_classes_cb, evx_show_flat_form: EVX_CHECK_BOX_CONTROL
evx_display_source_cb, evx_show_all_classes_cb, evx_show_abstract_classes_cb, evx_show_flat_form: EVX_CHECK_BOX_CONTROL

evx_auth_name_text, evx_auth_org_text, evx_auth_copyright_text, evx_auth_language_text: EVX_SINGLE_LINE_TEXT_CONTROL

Expand Down
4 changes: 3 additions & 1 deletion apps/resources/messages/compiled/adl_messages_db.e
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ feature -- Initialisation

make
do
create message_table.make (982)
create message_table.make (984)
message_table.put ("Terminology initialisation failed; reason: $1", ec_terminology_init_failed)
message_table.put ("Using ADL version $1 for output serialisation", ec_adl_version_warning)
message_table.put ("Validation level STRICT", ec_validation_strict)
Expand Down Expand Up @@ -509,6 +509,8 @@ feature -- Initialisation
message_table.put ("Indicate original format - ADL 1.4 legacy flat, ADL 1.5, etc", ec_show_source_format_tooltip)
message_table.put ("Show all classes in explorer", ec_show_all_classes_text)
message_table.put ("Show all archetypable classes in RM even if there are no archetypes based on them in the current library.", ec_show_all_classes_tooltip)
message_table.put ("Show abstract classes in explorer", ec_show_abstract_classes_text)
message_table.put ("Show abstract RM classes even if there are no archetypes based on them in the current library.", ec_show_abstract_classes_tooltip)
message_table.put ("Use RM icons", ec_use_rm_icons_text)
message_table.put ("Use RM-specific icons in visualisation of archetype definition?", ec_use_rm_icons_tooltip)
message_table.put ("Default Tool Tab: ", ec_options_tool_tab_text)
Expand Down
2 changes: 2 additions & 0 deletions apps/resources/messages/compiled/adl_messages_ids.e
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ feature -- Definitions
ec_show_source_format_tooltip: STRING = "show_source_format_tooltip"
ec_show_all_classes_text: STRING = "show_all_classes_text"
ec_show_all_classes_tooltip: STRING = "show_all_classes_tooltip"
ec_show_abstract_classes_text: STRING = "show_abstract_classes_text"
ec_show_abstract_classes_tooltip: STRING = "show_abstract_classes_tooltip"
ec_use_rm_icons_text: STRING = "use_rm_icons_text"
ec_use_rm_icons_tooltip: STRING = "use_rm_icons_tooltip"
ec_options_tool_tab_text: STRING = "options_tool_tab_text"
Expand Down
4 changes: 4 additions & 0 deletions apps/resources/messages/source/app_awb_ui_messages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ templates = <

["show_all_classes_text"] = <"Show all classes in explorer">
["show_all_classes_tooltip"] = <"Show all archetypable classes in RM even if there are no archetypes based on them in the current library.">

["show_abstract_classes_text"] = <"Show abstract classes in explorer">
["show_abstract_classes_tooltip"] = <"Show abstract RM classes even if there are no archetypes based on them in the current library.">

["use_rm_icons_text"] = <"Use RM icons">
["use_rm_icons_tooltip"] = <"Use RM-specific icons in visualisation of archetype definition?">

Expand Down
12 changes: 12 additions & 0 deletions components/archetype_repository/src/library/arch_lib_item.e
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ feature -- Access
end
end

local_archetype_count: INTEGER
-- count of archetype child objects
do
if attached children as att_children then
across att_children as child_csr loop
if attached {ARCH_LIB_ARCHETYPE} child_csr.item as ara then
Result := Result + 1
end
end
end
end

feature -- Status Report

has_artefacts: BOOLEAN
Expand Down

0 comments on commit 6466dd5

Please sign in to comment.