1. Introduction

Events are an easy way to extend TranslationStudio and respond to specific events during the working process.

You own event consists of 2 classes:

Description Interface

Event declaration class

com.idmedia.translationstudio.api.connector.IConnectorEvent

Event implementation of an event interface based on the generic event handler interface

com.idmedia.translationstudio.api.connector.IEventHandler

The event class declaration will be used to obtain the event id to which you want to register your event. This event declaration class also provides the class to instanciate if such an event you wish to register is being triggered.

2. The Event Declaration

A sample event declaration would be this:

package com.translationstudio.sampleevent;

import com.idmedia.translationstudio.api.connector.IConnectorEvent;

/**
 * Sample Event. This event can be registered with TranslationStudio by providing the complete
 * path: com.translationstudio.sampleevent.Event
 */
public class Event implements IConnectorEvent<EventImpl>
{
    /**
     * The event id you want to register
     */
    @NotNull
    @Override
    public String getId()
    {
        return com.idmedia.translationstudio.api.events.IProcessTranslatedFileEvent.EVENT_ID;
    }

    /**
     * {@inheritDoc }
     */
    @NotNull
    @Override
    public Class<EventImpl> get()
    {
        return EventImpl.class;
    }
}

The actual business logic is implemented in the event implementation.

3. Event Implementation

A very simple event implementation would look like this:

package com.translationstudio.sampleevent;

import com.idmedia.translationstudio.api.events.IProcessTranslatedFileEvent

/**
 * Implementing the actual event
 */
public class EventImpl implements IProcessTranslatedFileEvent
{
    /**
     * Process XML file
     *
     * @param bytesXml Input byte representation of the XML file
     * @return byte content to save. If NULL or empty, nothing will be stored
     * @throws IllegalStateException if the XML file is corrupt and must not be imported (basically, remove it)
     */
    @Override
    @Nullable
    public byte[] process(@NotNull byte[] bytesXml) throws IllegalStateException
    {
        /** just accept the file as it is */
        return null;
    }
}

4. Deploying your event

Simply deploy the JAR file to the TranslationStudio ./lib folder and restart the application.

5. Registering your event with TranslationStudio

To actually register your event, add your event declaration class to the connector event list in the configuration panel (plugins section), e.g. com.translationstudio.sampleevent.Event.

6. List of events