Skip to content

Commit

Permalink
Updated tips and tricks for on change.
Browse files Browse the repository at this point in the history
  • Loading branch information
ylussaud committed Aug 8, 2023
1 parent 23d42eb commit 3409b5f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h2 id="PythonandJava">Python and Java</h2>
<p>This section explains how the Python layer of Python4Capella and Java layer of Capella work together.</p>
<h3 id="Compatibilities">Compatibilities</h3>
<ul>
<li>Pyhton4Capella after 1.1.0:
<li>Python4Capella after 1.1.0:
<ul>
<li>Capella 5.x to Capella 6.x included
<ul>
Expand All @@ -31,7 +31,7 @@ <h3 id="Compatibilities">Compatibilities</h3>
</li>
</ul>
<ul>
<li>Pyhton4Capella before 1.1.0:
<li>Python4Capella before 1.1.0:
<ul>
<li>Capella 1.4.x to Capella 5.x included</li>
<li>PyDev 8.2.0</li>
Expand Down Expand Up @@ -240,20 +240,20 @@ <h3 id="View">View</h3>
<p>TODO</p>
<h2 id="Runascriptonresourcechange">Run a script on resource change</h2>
<p>You can configure a script to be executed whenever a file from your workspace is modified. This can be handy to automate reporting or publication of your Capella model. You need to add the following header to your script:</p>
<pre><code># name : Trigger on resource change
<pre><code># onResourceChange : *.capella
# script-type : Python
# description : Trigger on resource change
# onResourceChange : *.capella
</code></pre>
<p>You can then use
<code>argv[0]</code> to get the name of the modified resource and
<code>argv[1]</code> to get the change kind.
</p>
<p>You can also use an absolute worspace path:</p>
<pre><code># onResourceChange : workspace://Python4Capella/test.txt
# script-type : Python
</code></pre>
<p>A basic script that open the modified Capella model can look like this:</p>
<pre><code># name : Trigger on resource change
<pre><code># onResourceChange : *.capella
# script-type : Python
# description : Trigger on resource change
# onResourceChange : *.capella

include('workspace://Python4Capella/simplified_api/capella.py')
if False:
Expand All @@ -274,6 +274,13 @@ <h2 id="Runascriptonresourcechange">Run a script on resource change</h2>
model = CapellaModel()
model.open(aird_path)

</code></pre>
<p>if you are only interested in save changes, you can use the
<code>onSave</code> property the same way you use the
<code>onResourceChange</code>:
</p>
<pre><code># onSave : *.capella
# script-type : Python
</code></pre>
<h2 id="UserInput">User Input</h2>
<p>Some time selecting an element from your model or using an external source for your data is not enough and you will need to prompt the user to input some information. This section explains how you can get parameters passed to the script or create and use dialogs.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,20 @@ h2. Run a script on resource change

You can configure a script to be executed whenever a file from your workspace is modified. This can be handy to automate reporting or publication of your Capella model. You need to add the following header to your script:

bc. # name : Trigger on resource change
bc. # onResourceChange : *.capella
# script-type : Python
# description : Trigger on resource change
# onResourceChange : *.capella

You can then use @argv[0]@ to get the name of the modified resource and @argv[1]@ to get the change kind.

You can also use an absolute worspace path:

bc. # onResourceChange : workspace://Python4Capella/test.txt
# script-type : Python

A basic script that open the modified Capella model can look like this:

bc.. # name : Trigger on resource change
bc.. # onResourceChange : *.capella
# script-type : Python
# description : Trigger on resource change
# onResourceChange : *.capella

include('workspace://Python4Capella/simplified_api/capella.py')
if False:
Expand All @@ -247,6 +248,10 @@ if capella_path[len(capella_path)-8:] == '.capella':
model = CapellaModel()
model.open(aird_path)

p. if you are only interested in save changes, you can use the @onSave@ property the same way you use the @onResourceChange@:

bc.. # onSave : *.capella
# script-type : Python
h2. User Input

Some time selecting an element from your model or using an external source for your data is not enough and you will need to prompt the user to input some information. This section explains how you can get parameters passed to the script or create and use dialogs.
Expand Down

0 comments on commit 3409b5f

Please sign in to comment.