Monday May 30, 2011

Learn to build On Track Gadgets in hours with the GWT Foundation Gadget

Written by Reza Rokni, Product Manager, Oracle On Track

Introduction

The GWT Foundation Gadget example has been built to allow you to build your own On Track Gadget using the Google Web Toolkit, allowing you to extend On Track conversations with a variety of custom capabilities. This Gadget will also serve as the base layer for future On Track Gadgets that the On Track team will make available on OTN. This document will take you through making a Hello World Gadget based on the foundation and deploying it to an On Track server.

Please note that this example is provided as is and does not form part of the On Track Product Distribution. Please use the Oracle Forum for On Track to raise any issues or questions.

Overview

The GWT Foundation Gadget sample is available here (look under Samples) as a zip file on the Oracle Technical Network. The zip file (GWTFoundationGadget.zip) includes everything you need to get started including this documentation file, the gwtfoundationgadet. jar file which contains the foundation classes, as well as a utility for uploading Gadgets to your On Track server.

These instructions will walk you through step by step how to use the Eclipse IDE and the Google Plugin for Eclipse with GWT Foundation Gadget so you can extend the sample with additional capabilities and build new On Track Gadgets of your own. These Gadgets can then be deployed to an On Track server and made available within conversations. The Eclipse IDE and Google Plugin for Eclipse were chosen as their usage us very common for GWT development, but these sample principles and code can be used with a variety of IDEs with GTW support.

Set-up

Pre-requisites for Development

  1. Download the GWT Foundation Gadget Sample and extract the contents including gwtfoundationgadget.jar into a known location on your file system
  2. Install Eclipse Helios
  3. Install Google Plugin for Eclipse version 3.6.
  4. Download Google Web Toolkit version 2.0.4 – Note, later versions will NOT work at this time and extract to a known location on your local file system
  5. Configure the Google Plugin for Eclipse for GWT 2.0.4
    • From Eclipse, Window > Preferences > Web Toolkit > Add > (Choose the directory where you extracted the GWT 2.0.4 SDK)
  6. Download gwt-gadgets version 1.2 and extract gwt-gadgets.jar to a known location on your local file system

Configure Your Eclipse Project

  1. Create a new Google Web Application Project with the following configuration
    • Provide a project name and package
    • Enable the Google Web Toolkit SDK with version 2.0.4
    • Deselect ‘Use Google App Engine’
    • Deselect ‘Generate GWT project sample code’
  2. Configure the Project with the necessary jar files in your build path
    • Right click on your project to select Properties
    • Select Java Build Path
    • Select the Libraries Tab
    • Add External JARS
    • Select the gwt-gadgets.jar and gwtfoundationgadget.jar files from their location on your local file system

Create Your Base Project Files

  1. Create a Google module which inherits the GTWFoundationGadget
    • From the Eclipse Project go to the /src directory and select your package folder
    • Right click on the package and select New > Other > Google Web Toolkit > Module
    • Provide a Module Name
    • Under Inherited Modules Add the GWTFoundationGadget (oracle.ontrack.sample.gadget)
  2. Create your Google Entry Point Class
    • From the Eclipse Project go to the /src directory and select your package folder
    • Right click on the package and select New > Other > Google Web Toolkit > Entry Point Class
    • Provide a Class Name
    • Browse to change the Superclass from java.lang.Object to GWTFoundationGadget (oracle.ontrack.sample.gadget)
  3. Add the folloing annotations to your Entry Point Class
    @ModulePrefs( title = "OnTrackGadget", author = "On Track Demo" )
    @UseLongManifestName( false )
    @AllowHtmlQuirksMode( false )

If they are not automatically added for you by Eclipse, add the following imports to your Entry Point Class for the above annotations

    import com.google.gwt.gadgets.client.Gadget.AllowHtmlQuirksMode;
    import com.google.gwt.gadgets.client.Gadget.ModulePrefs;
    import com.google.gwt.gadgets.client.Gadget.UseLongManifestName;

Writing and Compiling Your Gadget

You can now implement the capabilities of your Gadget in the Entry Point Class. For convenience you can access the On Track containers information using the following methods of the GWTFoundationGadget superclass.

  • getInstanceID = This gives you access to the unique XObjectID of the Gadget .
  • getConversationID = This gives you access to the unique XObjectID of the Conversation that the current Gadget is located in.
  • getUid = This is the User ID of the currently logged in user.

See Appendix A of this document or the /src directory contained with the GWTFoundationGadget.zip file for a complete sample Entry Point Class.

To compile your Gadget click on the GWT Compile Project icon in Eclipse

Packaging Your Gadget

Create a zip file archive of your Gadget which you will upload to the On Track server.

  1. Locate the war folder within your project
  2. Navigate to and open the subfolder which has the name Gadget (eg, packagename.Modulename)
  3. This folder should contain some js and png files as well as a file that has the extension gadget.xml
  4. Select all these files
  5. Right click the selected files choose Export > General > Archive File
  6. Export to a zip file in a known location on your local file system with the setting
  7. Create only selected directories
  8. This will create a zip file of your Gadget, with all the contained files in the root directory of the zip.

Deploying Your Gadget

The On Track Administration Console provides the ability to create Gadgets and set their Enabled Status. However, for development purposes to facilitate fast round trip deployment of your Gadget a command utility is provided with this sample which can be used to quickly publish your Gadget to the server. For On Track v1.0, it is mandatory to use this command line utility in place of the Administration Console for Gadgets based on the GWT Foundation Gadget as the utility also sets a mandatory meta-data attribute on the Gadget (set Local) which is not exposed as a setting in the Administration Console.

The source code for the UploadGadget utility is contained in the /src directory of the GWTFoundationGadget.zip file.

To use the command line UploadGadget utility:

  1. Modify the uploadGadget.properties file and set the appropriate information for your Gadget Name, FileName, and On Track Server details. The selected user must be an administrator on the machine to be able to create a Gadget.
  2. You will need to have the On Track SDK and dependent libraries available on your local file system
    • These files can be found in the MIDDLEWARE_HOME/Oracle_ONTRACK1/OnTrack/ClientSdk/ontrack-sdk/lib directory of an On Track installation.
    • Run the command line utility with Java using the following command, after modifying it to point to the directory with your On Track library jar files.

Windows Command:

java -cp ".;pathtoyourontrackjarfiles/*" UploadGadget UploadGadget.properties

Unix Command:

java -cp ".:pathtoyourontrackjarfiles/*" UploadGadget UploadGadget.properties

Testing Your Gadget

From the On Track web client, go to the Gadgets tab of a conversation and add a new instance of your Gadget to the conversation.

In Summary

By following these instructions, you are now able to start creating GWT Gadgets for On Track of your own. Look for future updates on http://www.oracle.com/technetwork/goto/ontrack which will provide examples of Gadgets built on this foundation which interact with the On Track APIs to work with and add to On Track data including conversations and people.

Appendix A : Example Code

package samples.client;
import com.google.gwt.gadgets.client.Gadget.AllowHtmlQuirksMode;
import com.google.gwt.gadgets.client.Gadget.ModulePrefs;
import com.google.gwt.gadgets.client.Gadget.UseLongManifestName;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Widget;

import oracle.ontrack.sample.gadget.client.GWTFoundationGadget;

import com.google.gwt.core.client.EntryPoint;

@ModulePrefs( title = "OnTrackGadget", author = "On Track Demo" )
@UseLongManifestName( false )
@AllowHtmlQuirksMode( false )
public class HelloWorld extends GWTFoundationGadget implements EntryPoint {

	@Override
	public Widget getImplementation()
	{
		this.getGadgetView().setHeader( "Hellow World! Welcome to Conversation ID : " + getConversationId());
		
		return new Button("A Button that does nothing, just for the fun of it!");
	}	
	
}

Monday Apr 18, 2011

Try Installing Oracle On Track This Week!

[Read More]
About

bocadmin_ww

Search

Categories
  • Oracle
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today