|
|
HTML Link Generator |
This helper generates a clickable HTML link that invokes helpers or navigates into Rhapsody.
|
Applicable To |
Project |
|
Menu
Entry |
Power
Pack HTML Link Generator |
|
Applicable To |
All |
|
Menu
Entry |
Power
Pack Generate Web Link |
|
Demonstration |
When launched the helper presents a UI with three tabs:
· Helper Link: Generates a link that invokes a plugin.
· Navigation Link: Generates a link that navigates to a model element.
· Import a Link: Reads a previously generated link into fields for modification.

The Display Text field defines the text to display in the generated html link/button
The Style Classes field defines the style(s) to apply to any generated styled button (see below).
The Generate buttons can be used to generate various types of HTML link:
· Generate Link: A basic textual link.
· Generate Button: A basic HTML button using native html (no styles).
· Generate Styled Button: A button styled using the CSS styles from the Style Classes field.
Clicking any of the create buttons shows the generated link in the Output panel but also places it onto the Windows clipboard. If you have inadvertently copied something else onto the clipboard, you can use the Copy to Clipboard button to re-copy the generated link.
Generated links send requests to the Power Pack Web Link Listener.
If the Generate Styled Button is used then the generated html code contains CSS styles, for example:
<button class="btn
btn-primary"
onclick="fetch('http://localhost:7777/?navigate=GUID
997e8169-eb98-40f4-9c4b-27f708897f30').then(r =>
r.text()).then(d => console.log('Navigate Response:
'+d)).catch(e => console.error('Error sending navigate
request:', e));">Locate a Model Element in
Rhapsody</button>
The HTML file you paste this code into must then define those style(s). A sample may be generated by clicking Generate Button Style which generates the following:
<style>
.btn {
display: inline-block;
padding: 0.375rem 0.75rem;
font-size: 1rem;
line-height: 1.5;
border: 1px solid
transparent;
border-radius: 0.25rem;
text-align: center;
cursor: pointer;
}
.btn-primary {
color: #fff;
background-color: #007bff;
border-color: #007bff;
}
.btn-bad {
color: #fff;
background-color: #ff5733;
border-color: #007bff;
}
</style>
The Navigate tab has a single field where you can enter either the GUID or Full Path of a model element. These may be easily obtained using Get GUID or Get Full Path *

The resulting generated link will navigate to the model element in Rhapsody.
*If the Generate Web Link menu was used to launch the helper, then the UI automatically switches to the Navigate tab and pre-fills the GUID and Display name fields with the selected model element data.
The Helper tab has two fields:
· Helper Name
· Parameters
This field must contain the name of the plugin from the HEP file (not the menu entry name), for example:

The Parameters field may be used to supply additional data to the helper being invoked (see below).
The generated html links call an embedded web link listener in the Power Pack which in turn will ask Rhapsody to invoke the specified helper through an API function call. Rhapsody only allows such helpers to be invoked if the class that extends RPUserPlugin overrides the RhpPluginInvokeItem(String args) and/or RhpPluginInvokeItem() methods, for example:
The following helpers in the Power Pack implement the above methods and may therefore be invoked from a generated html link:
Invokes the Model Checker with the (optional) specified parameters.
Helper Name: RPModelChecker
Parameters (optional): autorun=true, runOnGUID=GUID
(Replace GUID with the GUID of the desired starting element. GUIDs may be easily obtained using Get GUID)
Invoked the Generate as HTML helper on the specified model element.
Helper Name: GenerateAsHTML
Parameters (mandatory): Full Path to starting model element
Launches the Model Visualizer in structure mode.
Helper Name: PPModelVisualizer
Parameters (mandatory): GUID of starting element
Previously generated links may be imported for modification by pasting the generated link into the Paste Link Text field and clicking Import:

The helper parses the link and populates the correct fields before switching to the appropriate tab.