Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Skalli/User Guide/Tutorial/Extensions/Five Minutes Tutorial
Contents
Introduction
In this tutorial we will create a small infobox with static text which will be displayed on every project details page in Skalli.
This is how the infobox will look like:
We will skip over most of the details here. For more in-depth explanations please refer to the extended Hello World tutorial.
Preparation
You have set up Skalli and you are able to work with it locally.
Create a Bundle Project
Create a new bundle project called org.example.skalli.ext.simplehelloworld.
Create the ProjectInfoBox
To render info in read-only mode you need to implement a ProjectInfoBox. Create the class org.example.skalli.ext.simplehelloworld.ui.ExtensionServiceProjectHelloWorldBox.java:
package org.example.skalli.ext.simplehelloworld.ui; import org.eclipse.skalli.model.core.Project; import org.eclipse.skalli.view.ext.ExtensionUtil; import org.eclipse.skalli.view.ext.ProjectInfoBox; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; public class ExtensionServiceProjectHelloWorldBox implements ProjectInfoBox { @Override public String getCaption() { return "Hello World"; } @Override public float getPositionWeight() { //some high value to have it displayed as one of the last extensions return 100; } @Override public int getPreferredColumn() { return COLUMN_EAST; } @Override public boolean isVisible(Project project, String userId) { // the Hello World info box should be visible in all projects return true; } @Override public String getIconPath() { return null; } @Override public Component getContent(Project project, ExtensionUtil util) { Layout layout = new CssLayout(); layout.setSizeFull(); layout.addComponent(new Label("The project you are viewing is called \"" + project.getName() + "\".")); return layout; } }
Add Required Dependencies
Add the following bundles to the list of required bundles in MANIFEST.MF to get your project building again:
Require-Bundle: org.eclipse.skalli.model.core;bundle-version="0.1.0", org.eclipse.skalli.view.ext;bundle-version="0.1.0", com.vaadin;bundle-version="6.4.0", org.eclipse.skalli.api.java;bundle-version="0.1.0"
Register ProjectInfoBox as OSGi Service
Create a folder OSGI-INF containing a file named ExtensionServiceProjectHelloWorldBox.xml with the following content:
<?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.example.skalli.ext.simplehelloworld.infobox"> <implementation class="org.example.skalli.ext.simplehelloworld.ui.ExtensionServiceProjectHelloWorldBox"/> <service> <provide interface="org.eclipse.skalli.view.ext.ProjectInfoBox"/> </service> </scr:component>
Furthermore, add the line
Service-Component: OSGI-INF/ExtensionServiceProjectHelloWorldBox.xml
to the bundle's MANIFEST.MF. This will register the info box as OSGi service so that Skalli can find it.
Testing the Extension
Add the new plugin to your launch configuration and (re)start Skalli. You will see the new Hello World extension on all project detail pages now.
Further Steps
You can now add a data entry form so that the user can enter data for the extension, export your data through the rest API and much more. This will all be covered in the extended Hello World tutorial.