Writing a Basic Plug-in
Follow these steps to write a basic plug-in for Content Studio:
-
Set up the classpath
In order to write the plug-in you need
studio-api.jar
andclient-core.jar
in your classpath. You will find these in eitherengine-distribution/contrib/lib
orengine-distribution/lib
. -
Create a subclass of
StudioPlugin
Use the following example as a basis. You must implement an
initialize()
method that uses theStudioContext
object to retrieve the information it needs from Content Studio.public class CustomStudioPlugin extends StudioPlugin { public CustomStudioPlugin(final StudioPluginSpi pPluginSpi, final StudioContext pContext) { super(pPluginSpi, pContext); } @Override public void initialize() { // You need to put your initialization code here. getContext().addLifeCycleListener(new StudioLifeCycleListener.Stub() { @Override public void userSessionStarted(final SessionEvent pEvent) { getContext().getContentEditorContainer().addEditorListener(new EditorListener.Stub() { @Override public void editorOpened(final EditorEvent pEvent) { // This example starts a background task when the editor is opened. // But you can do whatever you want. // You can also use other listener methods like editorClosed() etc. ResourceHandle handle = pEvent.getEditor().getResourceHandle(); getContext().execute(new IconFetcherTask(getContext().getContentService(), handle)); } }); } }); } }
Note that
getContentEditorContainer()
is called inside theuserSessionStarted()
method implementation. This ensures that it does not get called until Content Studio is fully initialized and theContentEditorContainer
is available. -
Create a subclass of
StudioPluginSpi
Your subclass must override the
createStudioPlugin()
method and return an instance of theStudioPlugin
subclass you created in the previous step.public class CustomStudioPluginSpi extends StudioPluginSpi { public CustomStudioPluginSpi() { super("Custom Studio Plugin", "1.0", "Escenic"); } @Override public StudioPlugin createStudioPlugin(final String pId, final StudioContext pContext) { return new CustomStudioPlugin(this, pContext); } }