Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Skalli/User Guide/Tutorial/Extensions/Five Minutes Tutorial"

m (Add Required Dependencies)
m (Introduction)
Line 1: Line 1:
 
= Introduction =
 
= Introduction =
  
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 info box with static text content, which will be displayed on every project detail page in Skalli.
  
 
This is how the infobox will look like:
 
This is how the infobox will look like:
Line 7: Line 7:
 
[[Image:Skalli_UserGuide_Tutorial_Extensions_FiveMinutesTutorial_HelloWorld.jpg]]
 
[[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 [[Skalli/User_Guide/Tutorial/Extensions/Extended_Tutorial|extended tutorial]].
  
 
= Preparation =
 
= Preparation =

Revision as of 10:25, 6 December 2011

Introduction

In this tutorial we will create a small info box with static text content, which will be displayed on every project detail page in Skalli.

This is how the infobox will look like:

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 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 imported packages and required bundles in MANIFEST.MF to get your project building again:

Import-Package: org.eclipse.skalli.api.java,
 org.eclipse.skalli.model.core,
 org.eclipse.skalli.view.ext
Require-Bundle: com.vaadin;bundle-version="6.4.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 Tutorial .

Back to the top