class Syskit::GUI::ModelViews::Profile
Visualization of a syskit profile
Attributes
instanciation_method[RW]
Public Class Methods
new(page)
click to toggle source
Calls superclass method
# File lib/syskit/gui/model_views/profile.rb, line 123 def initialize(page) super(page) @instanciation_method = :compute_system_network register_type Syskit::InstanceRequirements, ProfileElementView.new(page), method: :compute_system_network, show_requirements: true end
Public Instance Methods
compute_toplevel_links(model, options)
click to toggle source
# File lib/syskit/gui/model_views/profile.rb, line 164 def compute_toplevel_links(model, options) explicit_selections = mapping_to_links( model.dependency_injection.explicit, true, options[:interactive]) defaults = model.dependency_injection.defaults.inject(Hash.new) do |h, k| h[k] = k h end default_selections = mapping_to_links( defaults, false, options[:interactive]) definitions = Hash.new model.definitions.keys.sort.each do |name| definitions[name] = model.resolved_definition(name) end definitions = mapping_to_links( definitions, false, options[:interactive]) definitions.each do |obj| doc = first_paragraph(obj.object.doc || "") obj.format = "%s: #{doc}" end devices = Hash.new model.robot.each_device.sort_by(&:name).each do |dev| req = dev.to_instance_requirements model.inject_di_context(req) devices[dev.name] = req end devices = mapping_to_links( devices, false, options[:interactive]) [explicit_selections, default_selections, definitions, devices].each do |collection| collection.each do |el| el.object = el.object.to_instance_requirements el.rendering_options[:method] = instanciation_method end end return explicit_selections, default_selections, definitions, devices end
first_paragraph(string)
click to toggle source
# File lib/syskit/gui/model_views/profile.rb, line 151 def first_paragraph(string) paragraph = String.new string.each_line do |line| line = line.chomp if line.empty? return paragraph else paragraph << " " << line end end paragraph end
mapping_to_links(mapping, with_value, interactive = true)
click to toggle source
# File lib/syskit/gui/model_views/profile.rb, line 135 def mapping_to_links(mapping, with_value, interactive = true) mapping.keys.map do |key| object = mapping[key] id = element_link_target(object, interactive) if with_value text = ModelViews.render_mapping(page, key, object) key_text, value_text = text.first.split(": ") text[0] = "%s: #{value_text}" Element.new(object, "<pre>#{text.join("\n")}</pre>", id, key_text, Hash.new(buttons: []), Hash.new) else Element.new(object, "%s", id, key, Hash.new(buttons: []), Hash.new) end end end
render(model, interactive: true, **push_options)
click to toggle source
# File lib/syskit/gui/model_views/profile.rb, line 206 def render(model, interactive: true, **push_options) explicit_selections, default_selections, definitions, devices = compute_toplevel_links(model, interactive: interactive) ComponentNetworkBaseView.html_defined_in(page, model, with_require: true) render_links("Explicit Selection", explicit_selections) render_links("Default selections", default_selections) render_links("Definitions", definitions) render_links("Devices", devices) page.save if !interactive render_all_elements(explicit_selections + default_selections + definitions + devices, interactive: false, **push_options) end end
render_object_as_text(model)
click to toggle source
# File lib/syskit/gui/model_views/profile.rb, line 131 def render_object_as_text(model) render_instance_requirements(model.to_instance_requirements).join("\n") end