5. Examples

5.1. Overview

Most examples consist of two eclipse projects. One can be used to build an eclipse plugin which has to be installed in the Eclipse plugins folder (these projects have the suffix .plugin) and sample pure::variants projects (these projects have the suffix .pvproject). These projects can only be used when the respective Eclipse plugin is installed.

To ease the installation process, installed SDK provides two example packages installable from "New"->"Examples"->"Variant Management SDK". The Extensibility Example Plugins package contains all eclipse plugin projects and installs them into the workspace when selected. The Extensibility Example Projects package contains all example projects.

5.2. Metrices Plug-in Example

This example plugin is part of the pure::variants Extensibility Guide (PVESDK).

The name of the plugin is com.ps.pvesdk.examples.metrics

Purpose of the example

The plugin demonstrates how a new model metric can be implemented.

The example collects some simple statistical information about a model and prepares the data structure to be shown in the metrics view. It counts the number of elements in a model and also counts for each used element type the number of occurences in the model.

The example registers the class com.ps.pvesdk.examples.metrics.Example as metrics provider for the com.ps.consul.eclipse.metrics.ModelMetrics (in plugin.xml). The complete implementation is in Example.java

Using the example

The plugin has to be exported as "Deployable plug-in or fragment" and then installed inside the eclipse installation. See the Eclipse PDE Guide or the pure::variants Extensibility Guide for more information on the export procedure.

An easy alternative is to start a "Runtime Workbench". To do this, switch to the "Plug-in Development" perspective ("Window"->"Perspective"->"Other") and select "Run...". Here create a "Run-time workbench" configuration. Make sure that "Clear workspace before launch" is deselected.

The plugin adds a new entry ("PVESDK Example...")to the Metrics list in "Window"->"Preferences"->"Variant Management"->"Metrics". Mark the checkbox and close the preference page. Open a feature or family model and select "Show metrics" from the context menu. The dialog will show (among other) the example metric result.

Related Documentation

The Metrics API is described in the pure::variants Extensibility Guide available in the Eclipse online help system.

5.3. Feature Element Details Editor Tab Plug-in Example

This example plugin is part of the pure::variants Extensibility Software Development Kit (PVESDK).

The name of the plugin is com.ps.pvesdk.examples.detailseditor.

Purpose of the example

The plugin demonstrates how a additional editor tab for feature or family model editors can be implemented. It also shows how to connect to the ModelUpdate service, to provide additional functionality on model changes.

The example's code is derived from the feature models details tab and can be used as starting point for custom editors.

Using the example

The plugin has to be exported as "Deployable plug-in or fragment" and then installed inside the eclipse installation. See the Eclipse PDE Guide or the pure::variants Extensibility Guide for more information on the export procedure.

An easy alternative is to start a "Runtime Workbench". To do this, switch to the "Plug-in Development" perspective ("Window"->"Perspective"->"Other") and select "Run...". Here create a "Run-time workbench" configuration. Make sure that "Clear workspace before launch" is deselected.

The plugin provides a new tab in the feature model editor "Detail Example" and has also an own preference page "Example Details Page" in the section "Variant Management".

Related Documentation

The used pure::variants Java API and extension points are described in the pure::variants Extensibility Guide available in the Eclipse online help system.

5.4. SimpleFeature Editor Plug-in Example

This example plugin is part of the pure::variants Extensibility Software Development Kit (PVESDK).

The name of the plugin is com.ps.pvesdk.examples.element.simpleeditor.

Purpose of the example

The example shows how to extend the pure::variants Eclipse editor's user interface with custom dialogs for user specific model elements.

Plugin Structure

The plugin uses the pure::variants extension point "com.ps.consul.eclipse.ui.ElementEditors" to register its ability to act as editor and wizard for feature elements (elements of class "ps:feature") of type "ps:simplefeature". This is done in the file "plugin.xml" (page Extensions).

The basic code for pure::variants Eclipse plugins is in class "SimpleFeatureEditor". It is responsible for initialization and implements the necessary plugin interface for custom element dialogs "com.ps.consul.eclipse.ui.dialogs.ICustomElementEditor".

The code handling the UI presentation and element creation/updating is divided into several classes. The class "SimpleFeatureDialog" is the main class, the other classes are in the sub package panes.

5.5. Modeling EventHandler Plug-in Example

This example plugin is part of the pure::variants Extensibility Software Development Kit (PVESDK).

The name of the plugin is com.ps.pvesdk.examples.modeling.eventhandler.plugin.

Purpose of the example

The example shows how to implement a ModelUpdateListener, which can be used to check updates to the model before the are performed to the model. This can be used to avoid unintended changes to the model.

The example uses the ModeUpdateListener to check, if an element has a visible name. If the visible name is missing the user is informed and can decide to not apply the change to the model.

Additionally the user is asked to use the unique name as visible name for each newly created element, which does not have a visible name defined yet.

Using the example

The plugin has to be exported as "Deployable plug-in or fragment" and then installed inside the eclipse installation. See the Eclipse PDE Guide or the pure::variants Extensibility Guide for more information on the export procedure.

An easy alternative is to start a "Runtime Workbench". To do this, switch to the "Plug-in Development" perspective ("Window"->"Perspective"->"Other") and select "Run...". Here create a "Run-time workbench" configuration. Make sure that "Clear workspace before launch" is deselected.

Related Documentation

The used pure::variants Java API and extension points are described in the pure::variants Extensibility Guide available in the Eclipse online help system.