Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You can download the example in this how-to in [this GitHub repository](https://

1. Open the project that you previously created when you [created the menu extension](/apidocs-mxsdk/apidocs/extensibility-api/create-menu-extension/).
2. Add a new class to the project and name it `MyMenuExtension.cs`.
3. Replace the code in the file with the following code:
3. Replace the code in the file with the following code:

```csharp
using Mendix.StudioPro.ExtensionsAPI.UI.Menu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ In order for your extension to be loaded correctly as an extension in Studio Pro
{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/extensibility-api-howtos/build-todo-example-extension/step-one.png" >}}

3. Name the project *Mendix.ToDoExtension*.
4. Choose a location to store your extension, and click **Next**.
4. Choose a location to store your extension, and click **Next**.

{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/extensibility-api-howtos/build-todo-example-extension/step-two.png" >}}

5. Set **Framework** to *.NET 8.0 (Long Term Support)* and click **Create**.
5. Set **Framework** to *.NET 8.0 (Long Term Support)* and click **Create**.

{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/extensibility-api-howtos/build-todo-example-extension/step-three.png" max-width=80% >}}

Expand All @@ -56,15 +56,15 @@ The details of each step are described below.

#### 3.2.1 Referencing the Extensibility API NuGet Package

1. In Visual Studio, go to **Tools** > **NuGet Package Manager** > **Manage NuGet Packages for Solution**.
1. In Visual Studio, go to **Tools** > **NuGet Package Manager** > **Manage NuGet Packages for Solution**.

{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/extensibility-api-howtos/build-todo-example-extension/step-four.png" >}}

2. On the **Browse** tab, search for **Mendix ExtensionsAPI**.
2. On the **Browse** tab, search for **Mendix ExtensionsAPI**.

{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/extensibility-api-howtos/build-todo-example-extension/step-five.png" max-width=50% >}}

3. Select the NuGet package and click **Install**.
3. Select the NuGet package and click **Install**.

{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/extensibility-api-howtos/build-todo-example-extension/step-six.png" max-width=50% >}}

Expand All @@ -76,7 +76,7 @@ You now have a class library that can be loaded as an extension by Studio Pro. H
2. Right-click in the Solution Explorer and add a new file called *manifest.json*.
3. Right-click in the Solution Explorer and select **Properties**.
4. Ensure that you set the **Copy to Output Directory** property to **Copy always** to ensure that this file is included in your extensions output files.
5. Replace the contents of your manifest.json file with the following code:
5. Replace the contents of your manifest.json file with the following code:

```json
{
Expand All @@ -98,7 +98,7 @@ You now have a class library that can be loaded as an extension by Studio Pro. H
In this section, you will host a dockable pane within Studio Pro. This will provide you with a window where you can render the User Interface of the extension.

1. Add a new file to the solution called `ToDoListDockablePaneExtension.cs`.
2. Replace the contents of the file with the following code:
2. Replace the contents of the file with the following code:

```csharp
using System.ComponentModel.Composition;
Expand Down Expand Up @@ -399,7 +399,7 @@ Now, create the methods responsible for performing the logic:
In order to store the information to disk, add some model classes that will be able to store the Todo information.

1. Add a new class that will host the To do information itself. Call the file `ToDoModel.cs`
2. Replace the contents of the file with the following code:
2. Replace the contents of the file with the following code:

```csharp
using System.Text.Json.Serialization;
Expand Down Expand Up @@ -430,7 +430,7 @@ In order to store the information to disk, add some model classes that will be a
You will also need a model class that will store a list of all the todos that you have available.

3. Add another class and name it `ToDoListModel.cs`.
4. Replace the contents of this file with the following code:
4. Replace the contents of this file with the following code:

```csharp
using System.Text.Json.Serialization;
Expand All @@ -454,7 +454,7 @@ In order to store the information to disk, add some model classes that will be a
With the models created, you can now create a storage handler that will manage storing these models to disk.

1. Add a new class file and call it `ToDoStorage.cs`.
2. Replace the contents of the file with the following code:
2. Replace the contents of the file with the following code:

```csharp
using System.Text;
Expand Down Expand Up @@ -553,10 +553,11 @@ In this section, you will add a menu item to the toolbar that will allow you to

1. Create a `MenuExtension`.
2. Add another class and call it `ToDoListMenuExtension.cs`.
3. Replace the contents of the file with the following code:
3. Replace the contents of the file with the following code:

```csharp
using System.Collections.Generic;

using System.ComponentModel.Composition;
using Mendix.StudioPro.ExtensionsAPI.UI.DockablePane;
using Mendix.StudioPro.ExtensionsAPI.UI.Menu;
Expand Down Expand Up @@ -595,7 +596,7 @@ Up to now you have been adding all the logic that will allow your extension to r
* A JavaScript file that contains the client side logic for the user interface. Call it `main.js`

3. Open `index.html`.
4. Replace its contents with the following:
4. Replace its contents with the following:

```html
<html lang="en">
Expand Down Expand Up @@ -641,7 +642,7 @@ Up to now you have been adding all the logic that will allow your extension to r
</html>
```

5. Open `main.js` and add the JavaScript logic by replacing the contents of the file with the following:
5. Open `main.js` and add the JavaScript logic by replacing the contents of the file with the following:

```js
function postMessage(message, data) {
Expand Down Expand Up @@ -750,7 +751,7 @@ It is important to set these two `index.html` and `main.js` files to *Copy alway
So far you have configured the extension to be usable in Studio Pro. You added support for storing the to do items. You also added a user interface that users can interact with. The last step in this process is to link the extension c# logic with the web-based JavaScript logic.

1. Start with adding a utility class to help simplify the way you interact with web responses. Call the file `HttpListenerResponseUtils.cs`.
2. Replace the contents of the file with the following:
2. Replace the contents of the file with the following:

```csharp
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You can download the example in this how-to in [this GitHub repository](https://

1. Open the project that you previously created when you [created the menu extension](/apidocs-mxsdk/apidocs/extensibility-api/create-menu-extension/).
2. Add a new class to the project and name it `MyEntityContextMenuExtension.cs`.
3. Replace the code in the file with the following code:
3. Replace the code in the file with the following code:

```csharp
namespace MyCompany.MyProject.MendixExtension;
Expand Down Expand Up @@ -115,4 +115,4 @@ class MyDocumentContextMenuExtension(IMessageBoxService messageBoxService) : Con
yield return new MenuViewModel("This document is a page", () => messageBoxService.ShowInformation(page.Name));
}
}
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You can download the example in this how-to in [this GitHub repository](https://

1. Open the project that you previously created when you [created the menu extension](/apidocs-mxsdk/apidocs/extensibility-api/create-menu-extension/).
2. Add a new class to the project and name it `MyDockablePaneExtension.cs`.
3. Replace the code in the file with the following code:
3. Replace the code in the file with the following code:

```csharp
using System.ComponentModel.Composition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You can download the example in this how-to in [this GitHub repository](https://
1. Create a new project in Visual Studio based on `C# Class Library` template.
2. Choose a name for the project. Use a format similar to `MyCompany.MyProject.MendixExtension`, but it is not a hard requirement.
3. Choose `.NET 8.0` Framework.
4. Add `Mendix.StudioPro.ExtensionsAPI` NuGet package to the project references. Pick the version that does not exceed the Studio Pro version you installed. To do so, perform the following steps:
4. Add `Mendix.StudioPro.ExtensionsAPI` NuGet package to the project references. Pick the version that does not exceed the Studio Pro version you installed. To do so, perform the following steps:
1. Include a reference to the Extensions API [NuGet package](https://www.nuget.org/packages/Mendix.StudioPro.ExtensionsAPI):
2. Add new file named `manifest.json` to your project. Put the following content into it:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ In this more advanced example, you will see the `IMicroflowExpressionService.Cre
transaction.Commit();
}
```

The `IMicroflowService.CreateMicroflow` method is a bit easier to use than the `IMicroflowService.Initialize` method because it doesn't require manually creating the microflow with `IModel.Create<IMicroflow>` and then manually adding it to the `IFolderBase` container. It can do everything behind the scenes as long as everything is supplied to it. For a comprehensive example on how to create microflows, see [Create Microflows for Calculations](/apidocs-mxsdk/apidocs/extensibility-api/create-microflows-for-calculations/)

## 4 `TryInsertAfterStart` and `TryInsertBeforeActivity`
Expand Down Expand Up @@ -140,4 +141,4 @@ public void AddNewActivity(IModel currentApp, IMicroflow microflow, string activ

transaction.Commit();
}
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You can download the example in this how-to in [this GitHub repository](https://
2. Add a new folder *MicroflowTutorial* to your solution.
3. Create a `MenuExtension` class.
4. Add a new class to the project and call it `CreateMicroflowsMenu.cs`.
5. Replace the code in the file with the code below.
5. Replace the code in the file with the code below.

```csharp
using Mendix.StudioPro.ExtensionsAPI.UI.Menu;
Expand All @@ -41,6 +41,7 @@ You can download the example in this how-to in [this GitHub repository](https://
}
}
```

As you can see, the `GetMenus` method is overridden to add your own menus to Studio Pro. The class `CalculationsMicroflowCreator` (which you will add shortly) will be called from the action of your menu. You can see that this class has been injected in the constructor of your menu extension.

## 3. Microflow Creator
Expand Down Expand Up @@ -139,9 +140,11 @@ void CreateMultiplicationMicroflow(IModel currentApp, IFolderBase folder, IMicro
(multiplication2Param, "100"));
}
```

{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/multiplication-microflow.png" >}}

To create a microflow that performs an addition between two decimal values, you can use the code below. Just like the multiplication microflow example above, you can see that the String `addition1` and the String `addition2` match the parameters used in the expression for the return value. You can also see that their `DataType` is decimal.

```csharp
void CreateAdditionMicroflow(IModel currentApp, IFolderBase folder, IMicroflow callingMicroflow, string outputVariableName)
{
Expand All @@ -162,11 +165,13 @@ void CreateAdditionMicroflow(IModel currentApp, IFolderBase folder, IMicroflow c
(addition2Param, "2.2"));
}
```

{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/addition-microflow.png" >}}

Once a microflow is created, in order to enable this microflow to be called by other microflows, you need to add a call activity (`IActionActivity`). In the example, you have a method called `CreatMicroflowCallActivity` that can be used by both your multiplication and addition microflows.

There are a few prerequisites that you must complete before a microflow can be called by another microflow. This method can be broken down into parts:

```csharp
var microflowCallActivity = currentApp.Create<IActionActivity>();
var microflowCallAction = currentApp.Create<IMicroflowCallAction>();
Expand All @@ -176,6 +181,7 @@ microflowCallActivity.Action = microflowCallAction;

microflowCallAction.OutputVariableName = outputVariableName;
```

In order to create `IActionActivity`, `IMicroflowCallAction` must also be created, and set as the `Action` property of the `IActionActivity`.

Then, for `IMicroflowCallAction`, `IMicroflowCall` must also be created and set as the `MicroflowCall` property of the `IMicroflowCallAction`.
Expand All @@ -187,6 +193,7 @@ Finally, you can set `OutputVariableName` on `IActionActivity` , which is what t
## 4 Passing Parameters

It is also possible to pass a set of parameters to the action activity, which will be the inputs for the called microflow. This set of parameters is a simple `Tuple` of a name and an expression. In the example, these parameters are the two integers for the multiplication microflow and the two decimals for the addition microflow.

```csharp
foreach (var (parameterName, expression) in parameters)
{
Expand Down Expand Up @@ -228,6 +235,7 @@ void CreateMicroflowCallActivity(IModel currentApp,
```

To create a call activity for your multiplication and addition microflows, you can use something like the code below. As you can see, the parameter names for the activity match the parameter name from the microflow and their values are also passed in for integers and decimals.

```csharp
CreateMicroflowCallActivity(currentApp, callingMicroflow, mathMicroflow,
outputVariableName,
Expand Down Expand Up @@ -284,4 +292,4 @@ IQualifiedName FindJavaAction(string name, IModule module)
}
```

Download the [whole code](https://github.com/mendix/ExtensionAPI-Samples) to see the way it works in its entirety.
Download the [whole code](https://github.com/mendix/ExtensionAPI-Samples) to see the way it works in its entirety.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class MyMenuExtension(MyModalWebViewController myModalWebViewController) : MenuE
}
}
```

These changes inject your new controller class into the `MyMenuExtension` class. Then you add a new menu item called `Create Entity From Dialog` and call the controller's `ShowDialog` method.

Note that in this example, the parameter `currentApp` will be necessary, if the dialog needs to interact with the model. Additionally, `WebServerBaseUrl` is crucial, because, without the base path, navigating to the route you defined in the web server extension would not be possible.
Note that in this example, the parameter `currentApp` will be necessary, if the dialog needs to interact with the model. Additionally, `WebServerBaseUrl` is crucial, because, without the base path, navigating to the route you defined in the web server extension would not be possible.
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,3 @@ using (var transaction = model.StartTransaction("add entity"))
## 5 Read More

* [Understanding the Mendix Metamodel](/apidocs-mxsdk/mxsdk/mendix-metamodel/)

Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ that is employed by Studio Pro.
## 2 List of Available Extension Points

### 2.1 Studio Pro UI Extensions
- [ContextMenuExtension](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.UI.Menu/ContextMenuExtension-1.md) – This allows injecting new context menu items into model elements.
* [ContextMenuExtension](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.UI.Menu/ContextMenuExtension-1.md) – This allows injecting new context menu items into model elements.

- [MenuExtension](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.UI.Menu/MenuExtension.md) – This allows injecting new menu items into Studio Pro menu bar.
* [MenuExtension](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.UI.Menu/MenuExtension.md) – This allows injecting new menu items into Studio Pro menu bar.

- [DockablePaneExtension](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.UI.DockablePane/DockablePaneExtension.md) – allows introducing new
* [DockablePaneExtension](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.UI.DockablePane/DockablePaneExtension.md) – allows introducing new
[dockable pane](/refguide/studio-pro-overview/#panes) like Connector or Documentation. Panes integrate with Studio Pro
[layout system](/refguide/view-menu/#layout-of-panes) automatically.

{{% alert color="info" %}}It is advised to introduce a new **View** menu item for each pane, so that Studio Pro users have a way to open it.{{% /alert %}}

Additionally, there are additional features that provide access to the following:

- [Studio Pro configuration](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI/ExtensionBase/Configuration.md)
- [The currently opened app](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.UI/UIExtensionBase/CurrentApp.md), as well as event subscription mechanism to that app
- Events can be subscribed to by using the subscribe and unsubscribe methods exposed in [UIExtensionBase](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.UI/UIExtensionBase.md).
* [Studio Pro configuration](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI/ExtensionBase/Configuration.md)
* [The currently opened app](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.UI/UIExtensionBase/CurrentApp.md), as well as event subscription mechanism to that app
* Events can be subscribed to by using the subscribe and unsubscribe methods exposed in [UIExtensionBase](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.UI/UIExtensionBase.md).

### 2.2 Studio Pro and MxBuild Extensions
- [ConsistencyCheckExtension](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.ConsistencyCheck/ConsistencyCheckExtension-1.md) – This allows injecting custom logic into
the [Consistency check](https://docs.mendix.com/refguide/consistency-errors/) process.
* [ConsistencyCheckExtension](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.ConsistencyCheck/ConsistencyCheckExtension-1.md) – This allows injecting custom logic into
the [Consistency check](https://docs.mendix.com/refguide/consistency-errors/) process.
Loading