...
This tutorial introduces the IGB platform by demonstrating a very simple IGB plug-in App that adds a new entry to the IGB Tools menu.
...
Info |
---|
See Setting up your Development Environment for recommendations on how to set up your machine to be more compatible with IGB Development practices. |
Getting Started
...
Clone IGB Hello World App
Clone the IGB Hello World App project - this contains complete, working example of the Hello World IGB App.Use the following command in Git to clone the completed IGB App project to your working directory.:
Code Block |
---|
git clone https://bitbucket.org/lorainelab/igb-app-hello-world.git |
The image below shows an example of the IGB Tools Menu with the addition of a Hello World App item in the menu. The tutorial on this page will walk you through the steps required to add a menu item to one of the IGB menus, as seen in the image below. While this may seem trivial, it is not, because by adding a menu item to an IGB menu, a developer can create an entry point that their IGB App can hook into.
To demonstrate how an IGB plugin could hook into and expand the IGB toolbar, you can write a new class that implements the MenuBarEntryProvider interface.
This interface is designed to allow App developers to add new menu items to the IGB application's top level menus.
IGB has seven top-level menus, as seen below:
...
MenuBarEntryProvider interface
Once you have compiled the App and installed it in IGB, you'll see a new menu item - "Hello World App" in the IGB Tools menu, as show below:
The Hello World App contains a class that implements the MenuBarEntryProvider interface, show below:
Code Block | ||||
---|---|---|---|---|
| ||||
public interface MenuBarEntryProvider {
public Optional<List<MenuItem>> getMenuItems();
public MenuBarParentMenu getMenuExtensionParent();
} |
...
();
} |
To add a new menu item to IGB, you create a class that implements this interface. When you install the App in IGB, the OSGi run-time then adds it to whichever IGB menu is specified in the code.
...
Compile the App
To build your App, open the igb-app-hello-world project into Netbeans, select your it project in the Projects tab, and then select Run > Build.
Alternatively, you can build it from the command line by entering:
Code Block | ||
---|---|---|
| ||
mvn clean install |
it from the command line by entering:
Code Block | ||
---|---|---|
| ||
mvn clean install |
Building the App will create a new directory named "target" which can serve as a new App repository. This new directory contains compiled code as well as a meta-data about the App it contains.
Install the App in IGB
Start IGB and To run the App within IGB, you will need to add your target directory as a new plugin repository.
...
"target" directory to the IGB run-time as a new App repository.
To do this, launch IGB from within NetBeans or run the released version of IGB that you downloaded from BioViz.
To add your target directory:
- Within IGB, select Tools > App Manager
- Select select Manage Repositories... (top right corner). This opens the App Repositories tab in the IGB Preferences window
- Within the App Repositories tab in the Preferences window, select Add
- Enter a name for your repository, and then select the Choose local folder button
- Select the target directory of your maven project and click submit. The target directory is the actual target directory created by maven when you built your compiled the App.
- Close the Preferences window and return to the IGB App Manager
- Note that your App should now appear in the left pane of the IGB App Manager. Select it and click the Install button. This will cause the OSGi run-time to instantiate your new menu item and add it to IGB.
...
- Select Tools > Hello World App to run your App; observe the message that appears:
...
- App to run your App; observe the message that appears:
Next step: Modify your code
(optional)Re-open your IGB App project. Edit the message your IGB App prints and re-build your App. Then, return to the IGB App Manager, un-install and then re-install your App. When you select the the menu item again, the new message will print instead of the old one.
Note that you can rapidly repeat this edit-build-uninstall-install cycle. You don't have to re-build IGB or even restart it, which makes development much faster than if you had to modify the IGB code directly.
...
Dissecting the Hello World IGB App
...
How this works
Directory Structure
The Maven build system assumes that every Java project conforms to an expected directory structure. Here, the maven project includes
...