<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>Tim Pietrusky's blog</title>
	<atom:link href="http://blog.tim-pietrusky.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tim-pietrusky.de</link>
	<description>Rich Ajax Platform (RAP), Rich Client Platform (RCP)</description>
	<pubDate>Thu, 16 Apr 2009 18:51:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Working with RAP: Usefull links</title>
		<link>http://blog.tim-pietrusky.de/2009/rich-ajax-platform-rap/working-with-rap-usefull-links/</link>
		<comments>http://blog.tim-pietrusky.de/2009/rich-ajax-platform-rap/working-with-rap-usefull-links/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 00:00:03 +0000</pubDate>
		<dc:creator>Tim Pietrusky</dc:creator>
		
		<category><![CDATA[Rich Ajax Platform (RAP)]]></category>

		<category><![CDATA[Rich Ajax Platform]]></category>

		<guid isPermaLink="false">http://blog.tim-pietrusky.de/?p=541</guid>
		<description><![CDATA[New to the Rich Ajax Platform? You don&#8217;t know how to get started? Then you might want to check my collection of usefull links to work with RAP!


Eclipse RAP

Official web page for RAP from Eclipse with downloads, demos and some getting started screencasts.

http://www.eclipse.org/rap/

Eclipse RAP Wiki

Official wiki for RAP from Eclipse with different informations. (FAQ&#8217;s, RWT, [...]]]></description>
			<content:encoded><![CDATA[<p>New to the Rich Ajax Platform? You don&#8217;t know how to get started? Then you might want to check my collection of usefull links to work with <abbr title="Rich Ajax Platform">RAP</abbr>!</p>
<p><span id="more-541"></span><br />
</p>
<h4 class="prettyH4">Eclipse RAP</h4>
<p style="padding-left: 15px;">
Official web page for RAP from Eclipse with downloads, demos and some getting started screencasts.
</p>
<p class="prettyLink"><a href="http://www.eclipse.org/rap/" target="_blank">http://www.eclipse.org/rap/</a></p>
<div class="prettyLine"></div>
<h4 class="prettyH4">Eclipse RAP Wiki</h4>
<p style="padding-left: 15px;">
Official wiki for RAP from Eclipse with different informations. (FAQ&#8217;s, RWT, Stress/Load testing etc.)
</p>
<p class="prettyLink"><a href="http://wiki.eclipse.org/RAP" target="_blank">http://wiki.eclipse.org/RAP</a></p>
<div class="prettyLine"></div>
<h4 class="prettyH4">Eclipse RAP Developer Guide</h4>
<p style="padding-left: 15px;">
Official documentation for RAP from Eclipse with lots of informations. (for example RWT theming, branding, internationalization etc.)
</p>
<p class="prettyLink"><a href="http://help.eclipse.org/stable/index.jsp?nav=/33" target="_blank">http://help.eclipse.org/stable/index.jsp?nav=/33</a></p>
<div class="prettyLine"></div>
<h4 class="prettyH4">Eclipse Platform Plug-in Developer Guide</h4>
<p style="padding-left: 15px;">
Official documentation for the Eclipse Platform with lots of informations about Plug-in development.
</p>
<p class="prettyLink"><a href="http://help.eclipse.org/stable/index.jsp?nav=/2" target="_blank">http://help.eclipse.org/stable/index.jsp?nav=/2</a></p>
<div class="prettyLine"></div>
<h4 class="prettyH4">Eclipse RAP Newsgroup</h4>
<p style="padding-left: 15px;">
Official newsgroup for RAP from Eclipse. Search/ask for any problems.
</p>
<p class="prettyLink"><a href="http://www.eclipse.org/newsportal/thread.php?group=eclipse.technology.rap" target="_blank">http://www.eclipse.org/newsportal/thread.php?group=eclipse.technology.rap</a></p>
<div class="prettyLine"></div>
<h4 class="prettyH4">EclipseSource Blog</h4>
<p style="padding-left: 15px;">
Official blog from the creators of RAP - EclipseSource (former Innoopract).
</p>
<p class="prettyLink"><a href="http://eclipsesource.com/blogs/tag/eclipse-rap/" target="_blank">http://eclipsesource.com/blogs/tag/eclipse-rap/</a></p>
<div class="prettyLine"></div>
<h4 class="prettyH4">Tutorial: RCP-Mail goes RAP</h4>
<p style="padding-left: 15px;">
Screencast to create a RAP application using the &#8220;RCP Mail Template&#8221;.
</p>
<p class="prettyLink"><a href="http://www.volanakis.de/nuggets/RCP_Mail_goes_RAP/index.html" target="_blank">http://www.volanakis.de/nuggets/RCP_Mail_goes_RAP/index.html</a></p>
<div class="prettyLine"></div>
<h4 class="prettyH4">Tutorial: Developing Eclipse RCP applications with Eclipse Ganymede (3.4)</h4>
<p style="padding-left: 15px;">
Although this is a tutorial about RCP, you can use a lot of the stuff in RAP too.
</p>
<p class="prettyLink"><a href="http://www.vogella.de/articles/RichClientPlatform/article.html" target="_blank">http://www.vogella.de/articles/RichClientPlatform/article.html</a></p>
<div class="prettyLine"></div>
<h4 class="prettyH4">IBM&#8217;s article: Web 2.0, the Eclipse way</h4>
<p style="padding-left: 15px;">
This article from IBM in two parts is a good introduction into the Rich Ajax Platform.
</p>
<p class="prettyLink"><a href="http://www.ibm.com/developerworks/opensource/library/os-eclipse-richajax1/" target="_blank">[1] http://www.ibm.com/developerworks/opensource/library/os-eclipse-richajax1/</a></p>
<p class="prettyLink"><a href="http://www.ibm.com/developerworks/opensource/library/os-eclipse-richajax2/" target="_blank">[2] http://www.ibm.com/developerworks/opensource/library/os-eclipse-richajax2/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tim-pietrusky.de/2009/rich-ajax-platform-rap/working-with-rap-usefull-links/feed/</wfw:commentRss>
		</item>
		<item>
		<title>RAP 1.2 M6 released</title>
		<link>http://blog.tim-pietrusky.de/2009/rich-ajax-platform-rap/rap-12-m6-released/</link>
		<comments>http://blog.tim-pietrusky.de/2009/rich-ajax-platform-rap/rap-12-m6-released/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 11:31:08 +0000</pubDate>
		<dc:creator>Tim Pietrusky</dc:creator>
		
		<category><![CDATA[Rich Ajax Platform (RAP)]]></category>

		<category><![CDATA[Rich Ajax Platform]]></category>

		<guid isPermaLink="false">http://blog.tim-pietrusky.de/?p=514</guid>
		<description><![CDATA[The RAP-Team released a new milestone build (RAP 1.2 M6) of their Rich Ajax Platform and added some missing SWT API in RAP and the org.eclipse.ui.intro extension point to create your own intro support. 


If you want to see all the changes of the new milestone release, you should possibly visit the “New and Noteworthy” [...]]]></description>
			<content:encoded><![CDATA[<p>The <abbr title="Rich Ajax Platform">RAP</abbr>-Team released a new milestone build (RAP 1.2 M6) of their Rich Ajax Platform and added some missing SWT API in RAP and the <code>org.eclipse.ui.intro</code> extension point to create your own intro support. </p>
<p><span id="more-514"></span><br />
</p>
<p>If you want to see all the changes of the new milestone release, you should possibly visit the “New and Noteworthy” page <a href="" onclick="Effect.ScrollTo('prettyLinks'); return false;">[1]</a>.</p>
<div class="prettyIndex">
<p><a href="#RWT" onclick="Effect.ScrollTo('RWT'); return false;">RWT</a></p>
<p><a href="#Forms" onclick="Effect.ScrollTo('Forms'); return false;">Forms</a></p>
<p><a href="#Workbench" onclick="Effect.ScrollTo('Workbench'); return false;">Workbench</a></p>
</div>
<h3 id="RWT" class="prettyH3">RWT</h3>
<h4 class="prettyH4">New API added</h4>
<div class="prettyList">
<p><code>TypedEvent#display</code></p>
<p><code>Display</code>: Set user data <br />
  <code>setData(Object)</code> <br />
  <code>setData(String, Object)</code>, etc.</p>
<p><code>Display#timerExec()</code></p>
<p><code>Monitor</code>: <br />
  <code>getPrimaryMonitor()</code> on <code>Display</code> <br />
  <code>getMonitor()</code> on <code>Control</code></p>
<p><code>Device#getClientArea()</code></p>
<p><code>RowLayout#center</code></p>
<p><code>Widget#notifyListeners()</code></p>
<p><code>CTabFolder#getItem(Point)</code></p>
<p><code>DateTime#setDate(int, int, int)</code></p>
<p><code>SashForm</code>: sashWidth and <code>setMaximizedControl()</code></p>
<p><code>Shell#forceActive()</code></p>
<p><code>Spinner</code>: Selection listener</p>
<p><code>TabItem#setToolTipText(String)</code></p>
<p><code>Text#setLineHeight()</code></p>
<p><code>ToolItem</code>: <code>setDisabledImage()</code> and <code>setHotImage()</code></p>
</div>
<h4 class="prettyH4_line">CCombo widget</h4>
<p style="padding-left: 30px;">The <code>org.eclipse.swt.custom.CCombo</code> widget was added and it works much the same as in SWT.</p>
<h3 id="Forms" class="prettyH3">Forms</h3>
<h4 class="prettyH4">FormText</h4>
<p style="padding-left: 30px;">You can now use the <code>org.eclipse.ui.forms.widgets.FormText</code>  as a read-only text control that is capable of rendering wrapped text. Text can be rendered as-is or by parsing the formatting XML tags (<code>&lt;p&gt;</code>, <code>&lt;li&gt;</code>, <code>&lt;a&gt;</code>, <code>&lt;img&gt;</code>, <code>&lt;control&gt;</code> and <code>&lt;span&gt;</code>).</p>
<h3 id="Workbench" class="prettyH3">Workbench</h3>
<h4 class="prettyH4">Intro support</h4>
<p style="padding-left: 30px;">It is now possible to create your own intro support for your application, because the <code> org.eclipse.ui.intro</code> extension point provides a generic mechanism for this. For more information please visit <a href="" onclick="Effect.ScrollTo('prettyLinks'); return false;">[2]</a>.</p>
<h4 class="prettyH4_line">Databinding</h4>
<p style="padding-left: 30px;">The databinding core plug-ins were restructured. Like in RCP, the RAP workbench has a dependency to core databinding. That&#8217;s why <code>org.eclipse.databinding.observable</code> and <code>org.eclipse.databinding.property</code> are now required to run the workbench. You should update your build scripts and launch configurations after that.</p>
<div class="prettyLinks" id="prettyLinks">
<p><a href="http://www.eclipse.org/rap/noteworthy/news_12M6.php" target="_blank">[1] RAP 1.2 M6 -  New and Noteworthy</a></p>
<p><a href="http://www.eclipse.org/rap/noteworthy/news_12M6.php#Workbench" target="_blank">Workbench: Intro support</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.tim-pietrusky.de/2009/rich-ajax-platform-rap/rap-12-m6-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Integrating BIRT into RAP applications</title>
		<link>http://blog.tim-pietrusky.de/2009/rich-ajax-platform-rap/integrating-birt-into-rap-applications/</link>
		<comments>http://blog.tim-pietrusky.de/2009/rich-ajax-platform-rap/integrating-birt-into-rap-applications/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 14:03:57 +0000</pubDate>
		<dc:creator>Tim Pietrusky</dc:creator>
		
		<category><![CDATA[BIRT]]></category>

		<category><![CDATA[Rich Ajax Platform (RAP)]]></category>

		<category><![CDATA[Rich Ajax Platform]]></category>

		<guid isPermaLink="false">http://blog.tim-pietrusky.de/?p=337</guid>
		<description><![CDATA[Today I will show you a simple way on how to integrate BIRT into your RAP application to produce reports and display them in the Browser widget. 
At the moment I&#8217;m writing my diploma thesis and among other things I used BIRT (for the first time ever). It was really hard for me to get [...]]]></description>
			<content:encoded><![CDATA[<p>Today I will show you a simple way on how to integrate <abbr title="Business Intelligence and Reporting Tools">BIRT</abbr> into your <abbr title="Rich Ajax Platform">RAP</abbr> application to produce reports and display them in the <code>Browser</code> widget. </p>
<p>At the moment I&#8217;m writing my diploma thesis and among other things I used BIRT (for the first time ever). It was really hard for me to get it running in RAP, but finally it worked!</p>
<p><span id="more-337"></span><br />
</p>
<div class="prettyIndex">
<p><a href="" onclick="Effect.ScrollTo('one'); return false;">1. Setting up the environment</a></p>
<p><a href="" onclick="Effect.ScrollTo('two'); return false;">2. Copying BIRT Runtime to RAP target</a></p>
<p><a href="" onclick="Effect.ScrollTo('three'); return false;">3. Create a new project</a></p>
<p><a href="" onclick="Effect.ScrollTo('four'); return false;">4. Generate a report with the BIRT Report Designer</a></p>
<p><a href="" onclick="Effect.ScrollTo('five'); return false;">5. Render BIRT report and show it in the <code>Browser</code> widget</a></p>
<p><a href="" onclick="Effect.ScrollTo('six'); return false;">6. Print BIRT report - the simple way</a></p>
</div>
<h4>Changelog</h4>
<div class="prettyChangelog">
<p><strong>April 8, 2009:</strong> &#8220;6. Print BIRT report - the simple way&#8221; added.</p>
</div>
<h3 id="one" class="prettyH3">1. Setting up the environment</h3>
<p>So what do we need? I used the following settings (Windows):</p>
<div class="prettyRequirements">
<p><a href="http://www.eclipse.org/downloads/packages/release/ganymede/sr1" target="_blank">Eclipse for RCP/Plug-in Developers SR1</a></p>
<p><a href="http://download.eclipse.org/birt/downloads/" target="_blank">BIRT Runtime (for Deployment)</a></p>
</div>
<p>Why do we use the Eclipse SR1 (3.4.1)? Because the Eclipse SR2 does not work properly with RAP.<br />
We need the BIRT Runtime later.</p>
<p>Start Eclipse, open the Eclipse update manager (Help\Software Updates), choose the &#8220;Available Software&#8221;-tab and &#8220;Add Site&#8221;. Now add the following site:</p>
<div class="prettyRequirements">
<p>http://download.eclipse.org/rt/rap/1.2/update</p>
</div>
<p>And of course, we need BIRT installed in Eclipse to produce nice charts. In the update manager, choose your Eclipse release (for example &#8220;Ganymade Update Site&#8221;) and select &#8220;Charting &amp; Reporting&#8221; and &#8220;Database Development&#8221;. (You can also visit &#8220;<a href="http://download.eclipse.org/birt/downloads/updmaninst2.2.php" target="_blank">Installing BIRT using Update Manager Instructions</a>&#8221; for help!)</p>
<p>We can now install the selected software (RAP and BIRT). This may take some time.</p>
<p>Restart Eclipse, open the &#8220;Welcome&#8221; view (Help\Welcome), choose &#8220;Rich Ajax Platform&#8221; and &#8220;Install Target Platform&#8221;.</p>
<h3 id="two" class="prettyH3">2. Copying BIRT Runtime to RAP target</h3>
<p>Unpack the previously downloaded BIRT Runtime to any folder on your harddrive. Switch to &#8220;birt-runtime\ReportEngine\plugins&#8221; and delete the following plugins, because the RAP ones are newer than in BIRT (RAP 1.2 M5 and BIRT 2.3.2): </p>
<div class="prettyInfoDelete">
<p>org.eclipse.core.contenttype</p>
<p>org.eclipse.core.expressions</p>
<p>org.eclipse.core.jobs</p>
<p>org.eclipse.core.runtime</p>
<p>org.eclipse.equinox.app</p>
<p>org.eclipse.equinox.common</p>
<p>org.eclipse.equinox.preferences</p>
<p>org.eclipse.equinox.registry</p>
<p>org.eclipse.osgi.services</p>
<p>org.eclipse.osgi</p>
<p>org.eclipse.update.configurator</p>
</div>
<p>Now copy all remaining plugins to the RAP target&#8217;s &#8220;plugins&#8221; directory. You can find the right folder in Eclipse by &#8220;Window\Preferences&#8221; and then &#8220;Plug-in Development\Target Platform&#8221;.<br />
(for example: &#8220;eclipse\configuration\org.eclipse.rap.target-1.2\eclipse\plugins&#8221;)</p>
<p>Back in Eclipse switch to &#8220;Window\Preferences\Plug-in Development\Target Platform&#8221; and hit &#8220;Reload&#8221;.</p>
<p>That&#8217;s it.</p>
<h3 id="three" class="prettyH3">3. Create a new project</h3>
<p>Now that it is everything ready we choose the &#8220;Plug-in Development&#8221; perspective and create a new project. Leave the default settings as they are.</p>
<p><a rel="lightbox" href="http://blog.tim-pietrusky.de/wp-content/uploads/2009/03/2009_birt_in_rap_new_project_1.png"><img title="BIRT in RAP - New Project" src="http://blog.tim-pietrusky.de/wp-content/uploads/2009/03/2009_birt_in_rap_new_project_1_thumb.png" alt="BIRT in RAP - New Project" width="181" height="70" class="size-full prettyImg" /></a></p>
<p>Use one of the templates to create the project because then everything is configured correctly. I used the &#8220;RAP Application with a View&#8221;.</p>
<p>If everything was created properly, you should now see the following classes:</p>
<div class="prettyList">
<p><code>Activator</code></p>
<p><code>Application</code></p>
<p><code>ApplicationActionBarAdvisor</code></p>
<p><code>ApplicationWorkbenchAdvisor</code></p>
<p><code>ApplicationWorkbenchWindowAdvisor</code></p>
<p><code>Perspective</code></p>
<p><code>View</code>
</div>
<p>To test the application you should open the plugin.xml (Overview) an hit &#8220;Launch a RAP Application&#8221;. </p>
<p><a rel="lightbox" href="http://blog.tim-pietrusky.de/wp-content/uploads/2009/03/2009_birt_in_rap_launch_rap.png"><img src="http://blog.tim-pietrusky.de/wp-content/uploads/2009/03/2009_birt_in_rap_launch_rap_thumb.png" alt="BIRT in RAP - Launch RAP" title="BIRT in RAP - Launch RAP" width="125" height="70" class="size-full prettyImg" /></a></p>
<p>What&#8217;s next? We customize the run configuration to handle the BIRT chart generation.<br />
Open the &#8220;Run Configurations&#8221; (Run\Run Configurations) and select the following bundles at the &#8220;Bundles&#8221; tab:</p>
<div class="prettyInfoSelect">
<p>com.ibm.icu instead of com.ibm.icu.base</p>
<p>org.eclipse.birt.api</p>
<p>org.eclipse.birt.chart.device.extension</p>
<p>org.eclipse.birt.chart.engine</p>
<p>org.eclipse.birt.chart.engine.extension</p>
<p>org.eclipse.birt.chart.reportitem</p>
<p>org.eclipse.birt.core</p>
<p>org.eclipse.birt.data</p>
<p>org.eclipse.birt.data.aggregation</p>
<p>org.eclipse.birt.report.data.adapter</p>
<p>org.eclipse.birt.report.engine</p>
<p>org.eclipse.birt.report.engine.emitter.html</p>
<p>org.eclipse.birt.report.item.crosstab.core</p>
<p>org.eclipse.birt.report.model</p>
</div>
<p>Then push the &#8220;Add Required Bundles&#8221; button. You should have about 70 bundles selected now. Start the application again. </p>
<p>Our application is now bundle-ready to render BIRT reports!</p>
<h3 id="four" class="prettyH3">4. Generate a report with the BIRT Report Designer</h3>
<p>Switch to the &#8220;Report Design&#8221; perspective, create a new blank BIRT report (File\New\Other\Business Intelligence and Reporting Tools\Report) and then add a chart to it. (I added a bar chart; 2D with Depth; translucent; Color by category)</p>
<p>If you don&#8217;t know how to create a BIRT report you should visit <a href="" onclick="Effect.ScrollTo('prettyLinks'); return false;">[1]</a>.</p>
<p>Then create a new &#8220;Scripted Data Source&#8221; and a &#8220;Scripted Data Set&#8221; for the report. This is an easy way to transfer data from a Java class to the report. </p>
<p>Double click the &#8220;Scripted Data Set&#8221; and add the two &#8220;Output Columns&#8221; named &#8220;category&#8221; (String) and &#8220;value&#8221; (Integer) to it. </p>
<p>Select the &#8220;Scripted Data Set&#8221; (1) and switch to the &#8220;Script&#8221; tab (2). Make sure that the &#8220;open&#8221; script is selected (3). </p>
<p><a rel="lightbox" href="http://blog.tim-pietrusky.de/wp-content/uploads/2009/03/2009_birt_in_rap_report_data_source.png"><img src="http://blog.tim-pietrusky.de/wp-content/uploads/2009/03/2009_birt_in_rap_report_data_source_thumb.png" alt="BIRT in RAP - Report Data Source" title="BIRT in RAP - Report Data Source" width="193" height="70" class="size-full prettyImg" /></a></p>
<p>Add the following snippet to the script. </p>
<pre name="code" class="javascript">
i = 0;
dataset = params["CHART_DATASET"].value;
</pre>
<p>The <code>CHART_DATA</code> is a report parameter which is defined in the Java class. More about this later. </p>
<p>Now switch to the &#8220;fetch&#8221; script and paste the following snippet: </p>
<pre name="code" class="javascript">
if ( i < dataset.length ) {
  row["value"] = dataset[i][0];
  row["category"] = dataset[i][1];
  i++;
  return true;
}
  return false;
</pre>
<p>Now double click the chart, select the created &#8220;Scripted Data Set&#8221; and enter the value (<code>row["value"]</code>) and the category (<code>row["category"]</code>). We ignore the errors which are shown above. </p>
<p><a rel="lightbox" href="http://blog.tim-pietrusky.de/wp-content/uploads/2009/03/2009_birt_in_rap_report_select_data.png"><img src="http://blog.tim-pietrusky.de/wp-content/uploads/2009/03/2009_birt_in_rap_report_select_data_thumb.png" alt="BIRT in RAP - Report Select Data" title="BIRT in RAP - Report Select Data" width="123" height="70" class="size-full prettyImg" /></a></p>
<h3 id="five" class="prettyH3">5. Render BIRT report and show it in the <code>Browser</code> widget</h3>
<p>Switch to the &#8220;Plug-In Development&#8221; perspective, open the &#8220;View.java&#8221; and clean it up. It should now look like this:</p>
<pre name="code" class="java">
public class View extends ViewPart {
  public static final String ID = "de.tim_pietrusky.birt_in_rap.view";

  public void createPartControl(Composite parent) {
  }  

  public void setFocus() {}
}
</pre>
<p>Now we breathe life into the view by</p>
<div class="prettyList">
<p>setting up the right URL to the BIRT report file</p>
<p>setting a report parameter to &#8220;transfer&#8221; some data set to the report</p>
<p>setting the output of the task to render as HTML</p>
<p>handling the path of the rendered chart image</p>
</div>
<pre name="code" class="java">
  private Browser browser;

  private static final String reportName = "birt_in_rap_report.rptdesign";
  private static final String reportDirLocal = "/resources/birt/";
  private static final String reportDirServer = "/birt/";
  private String reportDesign; // Full path to the local BIRT report file
  private String URL;

  private IReportEngine engine = null;
  private EngineConfig config = null;
  private IReportRunnable design = null;
  private IRunAndRenderTask task;
  private HTMLRenderOption renderOptions;

  private ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

  public void createPartControl(Composite parent) {
    this.setPartName("BIRT in RAP");
    browser = new Browser(parent, SWT.NONE);
    configureURL();

    try {
      config = new EngineConfig();
      IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
      engine = factory.createReportEngine(config);

      URL url;
      InputStream fs = null;
      try {
        url = new URL(reportDesign);
        fs = url.openStream();
      } catch (MalformedURLException ex) {
        ex.printStackTrace();
      } catch (IOException ex) {
        ex.printStackTrace();
      }

      design = engine.openReportDesign(fs);

      // Create task to run and render the report
      task = engine.createRunAndRenderTask(design);

      // Example dataset
      Object[][] dataset = new Object[3][2];
      for (int i = 0; i < dataset.length; i++) {
        dataset[i][0] = (i + 1) * 2;
        dataset[i][1] = "category " + (i + 1);
      }

      // Set the dataset for the chart as report parameter
      task.setParameterValue("CHART_DATASET", dataset);

      // Render the report to HTML
      renderOptions = new HTMLRenderOption();
      renderOptions.setOutputFormat(HTMLRenderOption.HTML);
      renderOptions.setOutputStream(outputStream);

      // Please delete the unnecessary \"
      // I needed it to show the right code in my blog
      String webAppBase = (ContextProvider.getWebAppBase()).replaceAll("\\\\\"", "/");
      String path = webAppBase + reportDirServer + RWT.getSessionStore().getId();

      // Handle the image-path
      renderOptions.setImageHandler(new HTMLServerImageHandler());
      renderOptions.setImageDirectory(path);
      renderOptions.setBaseImageURL(URL + reportDirServer + RWT.getSessionStore().getId());

      task.setRenderOption(renderOptions);
      task.run();
      task.close();

      // Set the HTML output to the Browser widget
      browser.setText(outputStream.toString());

      engine.destroy();

    } catch (EngineException ex) {
      ex.printStackTrace();
    }
  }

  // Set the URL for the BIRT report for different environments.
  private void configureURL() {
    // Protocol, ip &#038; port
    ServletContext sc = RWT.getRequest().getSession().getServletContext();

    String realPath = sc.getRealPath("/");

    HttpServletRequest request = RWT.getRequest();
    String protocol = "http://";
    String ip = request.getLocalAddr();
    int port = request.getLocalPort();
    URL = protocol + ip + ":" + port;
    String webAppName = "";

    if (realPath == null) { // Start application locally within Eclipse (Windows)
      reportDesign = URL + reportDirLocal + reportName;
    } else { // Start application on a server (Apache Tomcat or so)
      webAppName = sc.getContextPath();
      reportDesign = URL + webAppName + reportDirLocal + reportName;
      URL = URL + webAppName;
    }
  }
</pre>
<p>There are some unresolved imports to fix. Open the &#8220;plugin.xml&#8221;, switch to the &#8220;Dependencies&#8221; tab and add the following plugins: </p>
<div class="prettyInfoAdd">
<p>org.eclipse.birt.core</p>
<p>org.eclipse.birt.report.engine</p>
<p>org.eclipse.birt.chart.engine</p>
</div>
<p>Ok. Everything ready? No, because our application needs to know how to find the BIRT report file on the server. So we need to register the resources directory via an extension point. Open the &#8220;plugin.xml&#8221; (if it is not already opened), switch to the &#8220;Dependencies&#8221; tab and add the following equinox plugin:</p>
<div class="prettyInfoAdd">
<p>org.eclipse.equinox.http.registry</p>
</div>
<p>Switch to the &#8220;Extensions&#8221; tab and add the following extension point:</p>
<div class="prettyInfoAdd">
<p>org.eclipse.equinox.http.registry.resources</p>
</div>
<p>Edit the extension element details with alias = &#8220;/resources/birt&#8221; and base-name = &#8220;/resources/birt&#8221; (Without the quotation marks). This path is the same as above at line 4.</p>
<p><a rel="lightbox" href="http://blog.tim-pietrusky.de/wp-content/uploads/2009/03/2009_birt_in_rap_register_resource.png"><img src="http://blog.tim-pietrusky.de/wp-content/uploads/2009/03/2009_birt_in_rap_register_resource_thumb.png" alt="BIRT in RAP - Register resources" title="BIRT in RAP - Register resources - Thumb" width="314" height="70" class="size-full prettyImg" /></a></p>
<p>Start the application and you will see your BIRT chart in the <code>Browser</code> widget. </p>
<p><a rel="lightbox" href="http://blog.tim-pietrusky.de/wp-content/uploads/2009/03/2009_birt_in_rap_browser.png"><img src="http://blog.tim-pietrusky.de/wp-content/uploads/2009/03/2009_birt_in_rap_browser_thumb.png" alt="BIRT in RAP - BIRT chart in Browser widget" title="BIRT in RAP - BIRT chart in Browser widget - Thumb" width="82" height="70" class="size-full prettyImg" /></a></p>
<h3 id="six" class="prettyH3">6. Print BIRT report - the simple way</h3>
<p>A simple (and for now the only, see <a href="" onclick="Effect.ScrollTo('prettyLinks'); return false;">[2]</a>.) way to print a BIRT report within the <code>browser</code> widget is to execute a JavaScript in the <code>browser</code>. </p>
<p>So first, we open our <code>View.java</code> and add the following method: </p>
<pre name="code" class="java">
  public void executeScript(String script) {
    browser.execute(script);
  }
</pre>
<p>The <code>browser</code> widget is now prepared to execute JavaScript from the &#8220;outside&#8221; of the <code>View.java</code>. </p>
<p>Next we need to give the user the possibility to print the BIRT report when he clicks for example on an element in the file menu. Let&#8217;s call it &#8220;Print report&#8221;. So we create a new class named &#8220;PrintAction.java&#8221; which extends <code>org.eclipse.jface.action.Action</code>.</p>
<p><a rel="lightbox" href="http://blog.tim-pietrusky.de/wp-content/uploads/2009/04/2009_birt_in_rap_print_action.png"><img src="http://blog.tim-pietrusky.de/wp-content/uploads/2009/04/2009_birt_in_rap_print_action_thumb.png" alt="BIRT in RAP - PrintActin.java" title="BIRT in RAP - PrintAction.java - Thumb" width="82" height="70" class="size-full prettyImg" /></a></p>
<p>Now we fill the <code>PrintAction.java</code> with life:</p>
<pre name="code" class="java">
  public static final String ID = "de.tim_pietrusky.birt_in_rap.printAction"; //$NON-NLS-1$

  public PrintAction(IWorkbenchWindow window) {
    setId(PrintAction.ID);
    setText("Print report");
  }

  public void run() {
    View view = (View) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
        .getActivePage().findView(View.ID);

    view.executeScript("window.print();");
  }
</pre>
<p>At line 9 we get the current instance of the <code>View.java</code>, to call the <code>View#executeScript()</code> method. (<code>window.print();</code> is the JavaScript method to forward a call to the OS to print the page)</p>
<p>At the end we need to register the created action with the <code>ApplicationActionBarAdvisor.java</code> to be used by the user. I looks like this: </p>
<pre name="code" class="java">
  ...
  private PrintAction printAction;

  protected void makeActions(IWorkbenchWindow window) {
    ...
    printAction = new PrintAction(window);
    register(printAction);
  }

  protected void fillMenuBar(IMenuManager menuBar) {
    MenuManager fileMenu = new MenuManager("&#038;File",IWorkbenchActionConstants.M_FILE);
    menuBar.add(fileMenu);
    ...
    fileMenu.add(printAction);
  }
  ...
</pre>
<p></p>
<p>Questions? Suggestions? If not then thank you for your attention.</p>
<p>You can download the whole project and my Target Platform:</p>
<div class="prettyDownload">
<p><a href="http://rapidshare.com/files/218835286/de.tim-pietrusky.birt_in_rap.zip" target="_blank">Project: de.tim_pietrusky.birt_in_rap</a></p>
<p><a href="http://rapidshare.com/files/211444849/org.eclipse.rap.target-1.2.zip" target="_blank">Target Platform: org.eclipse.rap.target-1.2</a></p>
</div>
<div class="prettyLinks" id="prettyLinks">
<p><a href="http://www.eclipse.org/birt/phoenix/tutorial/" target="_blank">[1] BIRT Tutorial</a></p>
<p><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=44823" target="_blank">[2] [browser] print() method for org.eclipse.swt.browser.Browser</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.tim-pietrusky.de/2009/rich-ajax-platform-rap/integrating-birt-into-rap-applications/feed/</wfw:commentRss>
		</item>
		<item>
		<title>RAP 1.2 M5 released</title>
		<link>http://blog.tim-pietrusky.de/2009/rich-ajax-platform-rap/rap-12-m5-released/</link>
		<comments>http://blog.tim-pietrusky.de/2009/rich-ajax-platform-rap/rap-12-m5-released/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 18:11:38 +0000</pubDate>
		<dc:creator>Tim Pietrusky</dc:creator>
		
		<category><![CDATA[Rich Ajax Platform (RAP)]]></category>

		<category><![CDATA[Rich Ajax Platform]]></category>

		<guid isPermaLink="false">http://blog.tim-pietrusky.de/?p=39</guid>
		<description><![CDATA[Today the RAP-Team released the 5th milestone build (RAP 1.2 M5) of their Rich Ajax Platform.
So what&#8217;s new? I give you a short overview of the changed/added features. 


If you want to see all the changes of the new milestone release, you should possibly visit the &#8220;New and Noteworthy&#8221; page [1].

Common
RWT

Common
com.ibm.icu.base
RAP now uses the Replacement [...]]]></description>
			<content:encoded><![CDATA[<p>Today the <abbr title="Rich Ajax Platform">RAP</abbr>-Team released the 5th milestone build (RAP 1.2 M5) of their Rich Ajax Platform.</p>
<p>So what&#8217;s new? I give you a short overview of the changed/added features. </p>
<p><span id="more-39"></span><br />
</p>
<p>If you want to see all the changes of the new milestone release, you should possibly visit the &#8220;New and Noteworthy&#8221; page <a href="" onclick="Effect.ScrollTo('prettyLinks'); return false;">[1]</a>.</p>
<div class="prettyIndex">
<p><a href="#Common" onclick="Effect.ScrollTo('Common'); return false;">Common</a></p>
<p><a href="#RWT" onclick="Effect.ScrollTo('RWT'); return false;">RWT</a></p>
</div>
<h3 id="Common" class="prettyH3">Common</h3>
<h4 class="prettyH4">com.ibm.icu.base</h4>
<p style="padding-left: 30px;">RAP now uses the Replacement Plug-in com.ibm.icu.base <a href="" onclick="Effect.ScrollTo('prettyLinks'); return false;">[2]</a> (about 100 KB in size), which reduces the overall size of the target platform by almost 3 MB.</p>
<h3 id="RWT" class="prettyH3">RWT</h3>
<h4 class="prettyH4">ColorDialog</h4>
<p style="padding-left: 30px;">As seen in SWT is now available for RWT in RAP. You can choose a color and get the RGB values.</p>
<pre name="code" class="java">
ColorDialog dialog = new ColorDialog(shell);
RGB result = dialog.open();
</pre>
<h4 class="prettyH4_line">Button widget</h4>
<p style="padding-left: 30px;">The <code>button</code> widget has been reworked.</p>
<div class="prettyList">
<p>custom implementations for check boxes and radio buttons.</p>
<p><code>Button#setGrayed()</code> is implemented for check box behavior as in SWT.</p>
<p>Hover for both radio and check buttons.</p>
<p>Theming (check and radio icons) for the default, selected, hover and grayed (only check box) state.</p>
<pre name="code" class="css">
Button-RadioIcon {
  background-image: url( radio-unselected.png );
}

Button-CheckIcon:selected:grayed {
  background-image: url( check-grayed.png );
}
</pre>
<p><code>Button#setImage()</code> now works as in SWT.</p>
</div>
<h4 class="prettyH4_line">Themeable System Images</h4>
<p style="padding-left: 30px;">It is now possible to customize the system images used for SWT MessageBox and JFace MessageDialog via theming. You can also receive these images from <code>Display#getSystemImage()</code>.</p>
<pre name="code" class="css">
Display {
  rwt-error-image: url (error.png);
  rwt-information-image: url (information.png);
  rwt-warning-image: url (information.png);
  rwt-question-image: url (question.png);
  rwt-warning-image: url (warning.png);
}
</pre>
<div class="prettyLinks" id="prettyLinks">
<p>[1] <a href="http://www.eclipse.org/rap/noteworthy/news_12M5.php" target="_blank">RAP 1.2 M5 - New and Noteworthy</a>
  </p>
<p>[2] <a href="http://wiki.eclipse.org/index.php/ICU4J#Replacement_Plug-in" target="_blank">Replacement Plug-in com.ibm.icu.base</a>
  </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.tim-pietrusky.de/2009/rich-ajax-platform-rap/rap-12-m5-released/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
