Better Studio interactivity in day to day flows

The release of  SDL Trados Studio 2019 SR2 gave us the opportunity to make some improvements to our public APIs and give our 3rd Party developers more access to Studio's functional flows as well as user interface styling. Throughout this article we will present the functionality we exposed in our APIs and the means by which you can make the most out of it.

Improved Notification System

The notification system in Studio, which can be accessed via the Notification View pane (on the right-hand side), was intended as a mechanism allowing us to promote notifications in a non-intrusive manner, while translators interact with SDL Trados Studio. We continued to take advantage of it, but while developing new features, we realized it had some short-comings that needed to be addressed. After we fixed the issues, we decided to make them available in the public APIs. In order to allow translators to remove a specific notification, we introduced two new properties on the `IStudioNotification` interface. As developers, you will have full control over which notifications can be removed by translators and which not, as well as over what should happen within the remove logic.
We also enhanced the control over the notification system by exposing additional events. With the help of these events we now give full access to creating and removing notification groups, but also to what happens inside a group: remove a notification from a group, add a specific notification to a group or create that group if it does not exist.
The following code snippet demonstrates how to publish dismissible notifications via the IStudioEventAggregator.
The ClearNotificationAction class implements the logic required to remove the notification from the group. It implements the IStudioNotificationCommand interface which is just an extension over the standard WPF ICommand.
If you are unclear about which properties need to be set in order to control various UI elements and inject custom behavior, we created a diagram mapping the elements of a Notification Group and a Notification to the properties of the IStudioNotificationGroup and IStudioNotification interfaces. You can also check-out the Wiki page with code examples on how to work with the Notification system in Studio 2019.

Improved interactivity with projects

In this section we will present some of the new API events and interfaces that we exposed to help your plugins integrate better with Trados Studio's project and package flows.

Accessing the New Project wizard

With Studio 2019 SR2 you can now request for New Project wizard to be opened from your code by publishing the OpenNewProjectWizardEvent via the IStudioEventAggregator. This event will also allow you to pre-specify data for the new project in a ProjectWizardData object.
Please note that you can either pass a project template or a project reference template. In the event you pass values for both, SDL Trados Studio will use the project template file. Here is a small code sample on how to implement the event publishing:
And this is how it should behave in Studio:

Executing custom logic within package flows

Up until Studio 2019 SR2 the only option you had to invoke the Open Package wizard from a plugin was similar to this:
Going forward, you will now be able to trigger the same Open Package wizard and pass along additional details such as the package file path, the project icon and even a custom job to be executed after the package is imported in Studio. Same as above, all you need to do is publish an OpenProjectPackageEvent object with your desired data.
Here is a code sample from the above capture. The details on how to implement a custom job will be presented later on in this article.
The same improvements were added for creating return packages, where you can specify a custom job to be executed when triggering the Create Return Package wizard. You might find these useful if your plugin needs to upload the package to a server, as everything will be processed together within the wizard. To achieve this, publish the CreateReturnPackageEvent using the IStudioEventAggregator.
And this is the code sample:
The IExternalJob and IExternalJobWithProgress interfaces are the bridge that will allow you to inject custom code into the wizards as well as into SDL Trados Studio's job mechanism. This gives you the advantage to achieve the same look and feel for long processing jobs besides helping you complete your work faster. Once you have an implementation ready all you need to do is publish ExecuteExternalJobEvent using IStudioEventAggregator. As a result, SDL Trados Studio will pick the job and execute it on a background thread or inject it into the previously-mentioned events. If the job is canceled for any reason, you can handle that from the JobCanceled method.
Here is a code sample on how such an implementation should look like:

Please note that the JobData property acts as a bridge between SDL Trados Studio and your plugin in case of using the job inside the Open Package and Create Return Package wizards. Trados Studio will set the file path on the property as follows: 

  • The file path to the project that was just imported into SDL Trados Studio, in the case of the Open Package wizard,
  • The file path for the created package, in the case of the Create Return Package wizard.

Other improvements

In this section we will present some additional changes which we consider useful for plugin development.

Knowing when the SDL Trados Studio main window was created

There are situations when you want to know when your application has completed loading in order to perform a specific user operation. For example, you want to display a log-in prompt for the translators from your plugin. For such a scenario (but not only), we exposed the StudioWindowCreatedNotificationEvent which will be published from SDL Trados Studio once it completes loading. Now you only need to subscribe to this event and you are set to go.

Refreshing the Projects view

For situations where you would like to have the list of SDL Trados Studio projects refreshed in the Projects view you can now publish a `RefreshProjectsEvent` object via the event aggregator.
With this, we bring to an end our improvements for Studio 2019 SR2 public APIs. You can find more code examples on GitHub, and make sure to checkout our other article on the exposed WPF Styles (link to Andrea's article).