Skip to content

Commit

Permalink
Create graph context menu
Browse files Browse the repository at this point in the history
Ref. #345
  • Loading branch information
Alexander Senier committed Jul 17, 2020
1 parent cbba7dc commit 204ec1c
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions ide/gnatstudio/recordflux.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@
</on-failure>
</action>
<action name="rflx_display_graph">
<filter id="RecordFlux"/>
<shell lang="python" show-command="false">recordflux.graph(&quot;%F&quot;)</shell>
<external>%1</external>
<on-failure>
<shell lang="python" show-command="false">recordflux.parse_output(&quot;&quot;&quot;%1&quot;&quot;&quot;)</shell>
</on-failure>
<shell lang="python" show-command="false">recordflux.find_message_graph(&quot;%F&quot;)</shell>
<external>echo &quot;%1&quot;</external>
</action>
<!-- Aliases -->
<alias name="rflx_package">
<param name="name" description="The name of the RecordFlux package"/>
Expand Down Expand Up @@ -128,6 +139,11 @@
</menu>
</submenu>
<!-- Context menu -->
<contextual action="rflx_display_graph">
<Title>RecordFlux/Display message graph</Title>
</contextual>
</GNAT_Studio>
"""

Expand Down Expand Up @@ -282,7 +298,7 @@ def get_source_files():


def run(files, mode, options=None):
assert mode == "check" or mode == "generate"
assert mode == "check" or mode == "generate" or mode == "graph"
options = options or []

GPS.MDI.save_all(force=True)
Expand All @@ -302,18 +318,30 @@ def check(filename):
return check_all([filename])


def generate_all(filenames=None):
filenames = filenames or get_source_files()
create_missing = GPS.Project.root().get_attribute_as_string("Create_Missing_Dirs")
def output_dir():
output_dir = GPS.Project.root().get_attribute_as_string("Output_Dir", "RecordFlux")
assert output_dir, "Output directory not configured"
create_missing = GPS.Project.root().get_attribute_as_string("Create_Missing_Dirs")
if create_missing and create_missing.lower() == "true":
if os.path.exists(output_dir):
assert os.path.isdir(output_dir)
else:
os.makedirs(output_dir)
return run(filenames, mode="generate", options=["-d", output_dir])
return output_dir


def generate_all(filenames=None):
filenames = filenames or get_source_files()
return run(filenames, mode="generate", options=["-d", output_dir()])


def generate(filename):
return generate_all([filename])


def graph(filename):
return run([filename], mode="graph", options=["-d", output_dir()])


def find_message_graph(filename):
return output_dir() + "/ICMP_Message.svg"

0 comments on commit 204ec1c

Please sign in to comment.