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.
Difference between revisions of "Skalli/User Guide/Tutorial/Extensions/Five Minutes Tutorial"
(inital version) |
m (add a screenshot for the extension) |
||
Line 2: | Line 2: | ||
In this tutorial we will create a small infobox with static text which will be displayed on every project details page in Skalli. | 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: | ||
+ | |||
+ | [[Image:Skalli_UserGuide_Tutorial_Extensions_FiveMinutesTutorial_HelloWorld.jpg]] | ||
We will skip over most of the details here. For more in-depth explanations please refer to the extended Hello World tutorial. | We will skip over most of the details here. For more in-depth explanations please refer to the extended Hello World tutorial. |
Revision as of 09:29, 10 May 2011
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; } }
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>
Service-Component: OSGI-INF/ExtensionServiceProjectHelloWorldBox.xmlto 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.