<?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/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>ctron&#039;s blog</title> <atom:link href="http://dentrassi.de/feed/" rel="self" type="application/rss+xml" /><link>http://dentrassi.de</link> <description>Life, the Universe and Everything</description> <lastBuildDate>Thu, 26 Jan 2012 14:47:33 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Working with ODFDOM</title><link>http://dentrassi.de/2012/01/26/working-with-odfdom/</link> <comments>http://dentrassi.de/2012/01/26/working-with-odfdom/#comments</comments> <pubDate>Thu, 26 Jan 2012 14:46:24 +0000</pubDate> <dc:creator>ctron</dc:creator> <category><![CDATA[Development]]></category><guid
isPermaLink="false">http://dentrassi.de/?p=153</guid> <description><![CDATA[While working a little bit with ODFDOM to automatically generate some documentation I found some tasks rather difficult to accomplish due to the fact that they were hardly documented. There is a lot of ODF documentation, but how to ...]]></description> <content:encoded><![CDATA[<p>While working a little bit with ODFDOM to automatically generate some documentation I found some tasks rather difficult to accomplish due to the fact that they were hardly documented. There is a lot of ODF documentation, but how to use it with ODFDOM is another story.</p><p>So first a list of documentation I found:</p><ul><li><a
href="http://odfdom.odftoolkit.org/0.8.7/odfdom/apidocs/">offical javadoc of ODFDOM</a></li><li><a
href="http://odfdom.odftoolkit.org/0.8.7/odfdom/apidocs/doc-files/OpenDocument-v1.2-cd05-part1.html">ODF Documentation hosted by ODFDOM</a></li><li><a
href="http://www.langintro.com/odfdom_tutorials/">ODFDOM samples</a> (slightly out of date)</li></ul><h2>Adding a new paragraph with a pre-defined style</h2><p>To create a new paragraph with a style I used the following static function:</p><pre class="brush: java; title: ; notranslate">
public static OdfTextParagraph newStyledParagraph ( final OdfTextDocument odt, final String style, final String content ) throws Exception
{
  final OdfTextParagraph p;
  if ( content != null ) {
    p = odt.newParagraph ( content );
  } else {
    p = odt.newParagraph ();
  }
  p.setStyleName ( style );
  return p;
}
</pre><h2>Adding fields (like title and subtitle)</h2><p>The following snippet will create a new paragraph</p><pre class="brush: java; title: ; notranslate">
OdfTextParagraph p;
p = OdfHelper.newStyledParagraph ( odt, &quot;Title&quot;, null );
p.newTextTitleElement ();

p = OdfHelper.newStyledParagraph ( odt, &quot;Subtitle&quot;, null );
p.newTextSubjectElement ();
</pre><h2>Creating a new parapgraph style</h2><p>The next snippet creates a new a new style called &#8220;Source Text&#8221; dereived from &#8220;Text Boby&#8221;. The <code>setFontFamily</code> method is a helper to set all font properties at once.</p><pre class="brush: java; title: ; notranslate">
protected void setFontFamily ( final OdfStyleBase style, final String value )
{
    style.setProperty ( OdfTextProperties.FontFamily, value );
    style.setProperty ( OdfTextProperties.FontFamilyAsian, value );
    style.setProperty ( OdfTextProperties.FontFamilyComplex, value );
}

private void createStyles ( final OdfTextDocument odt )
{
    final OdfOfficeStyles styles = odt.getOrCreateDocumentStyles ();

    final OdfStyle style = styles.newStyle ( &quot;Source Text&quot;, OdfStyleFamily.Paragraph );
    style.setStyleParentStyleNameAttribute ( &quot;Text Body&quot; );
    style.setProperty ( OdfParagraphProperties.Margin, &quot;1cm&quot; );
    style.setProperty ( OdfParagraphProperties.BackgroundColor, &quot;#DDDDDD&quot; );
    setFontFamily ( style, &quot;Courier New&quot; );
}
</pre><h2>Copy content from one to another ODF File</h2><p>While most of the document I made was created some static part a the beginning was needed. Instead of creating it manually I created a new ODT File in LibreOffice and imported the content to the generated document.</p><p>The following snipped does that:</p><pre class="brush: java; title: ; notranslate">
private void createStaticContent ( final OdfTextDocument odt, final File file ) throws Exception
{
    // check if file is readable and is a file
    if ( !file.canRead () || !file.isFile () )
    {
        return;
    }

    // Load the document to import

    final OdfTextDocument staticOdt = OdfTextDocument.loadDocument ( file );

    // Create a new text section which will receive the content. This is optional.
    // You could also load the content directly on the root of the document

    final TextSectionElement section = new TextSectionElement ( odt.getContentDom () );
    odt.getContentRoot ().appendChild ( section );
    section.setTextProtectedAttribute ( true );
    section.setTextNameAttribute ( &quot;Static Content&quot; ); //$NON-NLS-1$

    // iterate over all nodes
    final NodeList childNodes = staticOdt.getContentRoot ().getChildNodes ();
    for ( int i = 0; i &lt; childNodes.getLength (); i++ )
    {
        // clone node from source
        final Node newNode = childNodes.item ( i ).cloneNode ( true );
        // import to target DOM
        final Node adoptedNode = odt.getContentDom ().adoptNode ( newNode );
        // append to section
        section.appendChild ( adoptedNode );
    }
}
Since only content is imported the styles of the target document will be used for the content that was imported.
</pre><p
class="wp-flattr-button"></p><p><a
href="http://dentrassi.de/?flattrss_redirect&amp;id=153&amp;md5=cd3245622b979d453f4b8b9399921310" title="Flattr" target="_blank"><img
src="http://dentrassi.de/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded> <wfw:commentRss>http://dentrassi.de/2012/01/26/working-with-odfdom/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Mayas knew about IPv4</title><link>http://dentrassi.de/2012/01/05/mayas-knew-about-ipv4/</link> <comments>http://dentrassi.de/2012/01/05/mayas-knew-about-ipv4/#comments</comments> <pubDate>Thu, 05 Jan 2012 21:23:19 +0000</pubDate> <dc:creator>ctron</dc:creator> <category><![CDATA[Nonsense]]></category><guid
isPermaLink="false">http://dentrassi.de/?p=146</guid> <description><![CDATA[Scientists recently found a correlation between the Maya calendar and the remaining amount of old IP addresses. While it was already known that the calendar marked the end of a period at the end of the year 2012, only ...]]></description> <content:encoded><![CDATA[<p>Scientists recently found a correlation between the Maya calendar and the remaining amount of old IP addresses. While it was already known that the calendar marked the <u>e</u>nd of a period at the end of the year 2012, only recently they found the correlation to the amount of remaining IP addresses. The only open question is,nif this really is the end of the world as we know it.</p><p
class="wp-flattr-button"></p>]]></content:encoded> <wfw:commentRss>http://dentrassi.de/2012/01/05/mayas-knew-about-ipv4/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Lick to unlock</title><link>http://dentrassi.de/2011/12/16/lick-to-unlock/</link> <comments>http://dentrassi.de/2011/12/16/lick-to-unlock/#comments</comments> <pubDate>Fri, 16 Dec 2011 20:17:00 +0000</pubDate> <dc:creator>ctron</dc:creator> <category><![CDATA[Rumored Products]]></category><guid
isPermaLink="false">http://dentrassi.de/?p=143</guid> <description><![CDATA[The recent advances of Android seem to have forced Apple to find new features to distinguish it from the quite popular getting system. Android took a complete new way of unlocking your phone by using your face as key ...]]></description> <content:encoded><![CDATA[<p>The recent advances of Android seem to have forced Apple to find new features to distinguish it from the quite popular getting system. Android took a complete new way of unlocking your phone by using your face as key to unlock your mobile gadget. While the droidish companion already allowed pin code and pattern unlock, the iPhone only provides pin and &#8220;slide to unlock&#8221;. As android does.</p><p>But now Apple is ready to strike back and has added a bunch of new features to it upcoming iPhone 5 S. Adding a sensor to the touch screen that can performed a chemical analysis of substances that touches it allows the iOS to provide a neat new feature: Lick to unlock!</p><p>Right, by licking over the screen your phone it can detect if you are the respectful owner of the device. Insider information told us that Apple wanted to release this feature earlier, but hat to fix some simple issues that did not occur in the lab. No one tested the sensor after having lunch.</p><p>But Apple would not be called innovative if this would would be the end of the story. The additional &#8220;lunch information&#8221; is extracted and rendered out of the unlock pattern. But instead is feed into Siri to provider her with additional information of what the owner ate, when and were. This allows Siri to provide more accurate suggestions of restaurants and even can provide you a list of nearest dentists when if thinks appropriate.</p><p>We are really looking forward to &#8220;unlicking&#8221; our phone.</p><p
class="wp-flattr-button"></p>]]></content:encoded> <wfw:commentRss>http://dentrassi.de/2011/12/16/lick-to-unlock/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Bye bye Lotus Notes</title><link>http://dentrassi.de/2011/12/12/bye-bye-lotus-notes/</link> <comments>http://dentrassi.de/2011/12/12/bye-bye-lotus-notes/#comments</comments> <pubDate>Mon, 12 Dec 2011 09:19:53 +0000</pubDate> <dc:creator>ctron</dc:creator> <category><![CDATA[Uncategorized]]></category><guid
isPermaLink="false">http://dentrassi.de/?p=137</guid> <description><![CDATA[We used it for some time. It was nice. But now our ways seem to ...well, let me just say: PNG, 64bit Linux, Windows 7, ...I was migrating E-Mails from Notes to Courier IMAP using "imapsync" when I stumbled ...]]></description> <content:encoded><![CDATA[<p>We used it for some time. It was nice. But now our ways seem to &#8230;</p><p>well, let me just say: PNG, 64bit Linux, Windows 7, &#8230;</p><p>I was migrating E-Mails from Notes to Courier IMAP using &#8220;<a
href="http://freecode.com/projects/imapsync">imapsync</a>&#8221; when I stumbled over two strange problems&#8230;</p><p><span
id="more-137"></span></p><h1>Missing &#8220;sent&#8221; folder</h1><p>I was not able to synchronize the &#8220;Sent&#8221; folder. Since the &#8220;Sent&#8221; folder does not seem to exists in the IMAP namespace and also Notes seems to have two sent folders (one for Notes one for IMAP). In the recent 8.5.2 release a new &#8220;IMAP Folder Sync&#8221; option was added (see <a
href="http://www.dominopower.com/issues/issue201103/00002621001.html">http://www.dominopower.com/issues/issue201103/00002621001.html</a>) that should fix this issue. Since we had 8.5.2 installed I tried and failed. This feature instantly caused a deadlock in the Domino server when the mail file was accessed with a write operation. In addition the &#8220;Sent&#8221; folder was absent. Event running &#8220;convert&#8221; in the mail file locked the server up and resolved nothing. The only &#8220;solution&#8221; was to create a &#8220;SentXX&#8221; folder (or any other name) and copy the messages in Notes to that folder, synchronizing the folder and move the messages back to the &#8220;Sent&#8221; folder in Courier IMAP.</p><h1>IMAP Idle/Lookup/Protocol error</h1><p>Converting e-mails takes some time and for some users the process just stopped with a timeout message like this:</p><p><code>Could not fetch message #123 from MyFolder timeout waiting 600s for data from server</code></p><p>Re-running the task continued with the messages that were not converted up to now (thanks to imapsync) but immediately stopped at the first message with the same timeout. Looking on the domino server side I noticed that the &#8220;imap&#8221; process was idling at 0% CPU load, which is strange since it normally takes up to 200% when converting messages.</p><p>Running &#8220;imapsync&#8221; the flags &#8211;debug and &#8211;debugimap showed a strange response in the protocol stream at the end of attachments:</p><p>While the normal response seem to be something like:</p><p><code>10 OK FETCH completed</code></p><p>in these cases the response was:</p><p><code>10 O   K FETCH completed</code> (or something similar).</p><p>Which was not interpreted by &#8220;imapsync&#8221; as response and kept it waiting until it timed out.</p><p>Scrolling up in the log file a little bit showed the message that caused the problem and fiddling around with the message a little bit provided a workaround that helped.</p><p>Locate the message in the mail file. Open it. Edit the message (e.g. by double clicking the content). Make no changes! (You could but you should not since you don&#8217;t want to edit received mail). And &#8220;Save and close&#8221; the message. Et voilá, it worked. Re-running &#8220;imapsync&#8221; did convert this message and successfully all following until it runs in the next timeout.</p><p>I hope this helps anybody running into the same issues.</p><p>Bye bye Notes!</p><p>PS: I used the following parameters with imapsync:</p><p><code>imapsync --host1 domino.mydomain.com --user1 "Ford Prefect" --passfile1 passfile1 --ssl1 --authmech1 PLAIN --host2 localhost --user2 ford.prefect@mydomain.com --passfile2 passfile2 --ssl2 --authmech2 PLAIN --skipsize  --nofoldersizes  --regextrans2 "s/\\\\/\\./g"  --useheader Subject --useheader Date  --allowsizemismatch --skipsize  --regextrans2 "s/\\//_/g" --include "^Folder Prefix"</code></p><p><code>--useheader Date --useheader Subject</code> : was necessary since Notes seemed to change the message IDs, which caused duplicate messages each time imapsync was run. These two arguments limited the equality of messages to Subject and Date, which was OK for me.</p><p><code>--nofoldersizes</code> : stopped imapsync from calculating the size of the folder before it runs. This caused a huge speedup since this seems to be a major task for notes to provide this operation.</p><p><code>--skipsize --allowsizemismatch</code> : also was required to prevent imapsync from canceling messages that had another amount of payload data than the header suggested. Notes sometimes reported wrong message sizes which could be the same issue as the protocol error above.</p><p><code>--regextrans2 "s/\\\\/\\./g"</code> : was necessary since imapsync sometimes did not apply the IMAP namespace and prefix correctly when using regular expressions for the folder names.</p><p><code>--regextrans2 "s/\\//_/g"</code> : was necessary since Lotus Notes allows &#8220;/&#8221; in the folder name, which Courier IMAP does not. So all &#8220;/&#8221; where converted to &#8220;_&#8221; for the moment.</p><p><code>--include "^Folder Prefix"</code> : was quite useful to limit the imapsync run to a specific folder name if you need to close in on some issues or want more control on the current migration. Leaving out this parameter simply converts all folders.</p><p>PPS: Running &#8220;imapsync&#8221; seemed to be extremely slow before enabling specific IMAP features in the Notes mail files. I had to run &#8220;convert&#8221; for each file file in order to enable IMAP folder references and generate IMAP specific attributes. This could be due to the fact that we never used IMAP in Notes and therefore had IMAP features not enabled. Which prevents Notes from creating these information during normal runtime. This information is the generated &#8220;on demand&#8221; but not stored.</p><p>Enable IMAP for mailfile: <code>load convert -e mail/mailfile.nsf</code><br
/> Enable IMAP folder references: <code>load convert -m mail/mailfile.nsf</code><br
/> Generate IMAP attributes: <code>load convert -h mail/mailfile.nsf</code></p><p
class="wp-flattr-button"></p><p><a
href="http://dentrassi.de/?flattrss_redirect&amp;id=137&amp;md5=f950ad5aa0922f0aec1d253209ce9a9b" title="Flattr" target="_blank"><img
src="http://dentrassi.de/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded> <wfw:commentRss>http://dentrassi.de/2011/12/12/bye-bye-lotus-notes/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>JPA, EJB and Spring</title><link>http://dentrassi.de/2011/10/11/jpa-ejb-and-spring/</link> <comments>http://dentrassi.de/2011/10/11/jpa-ejb-and-spring/#comments</comments> <pubDate>Tue, 11 Oct 2011 16:20:36 +0000</pubDate> <dc:creator>ctron</dc:creator> <category><![CDATA[Development]]></category><guid
isPermaLink="false">http://dentrassi.de/?p=116</guid> <description><![CDATA[Today I stumbled over a rather interesting issue in combination with JBoss, Hibernate, Spring, JPA and EJB.First of all, we have mixed environment of EJB3 and Spring 3 using JPA2. All in JBoss 6 AS, with default Hibernate 3.6 ...]]></description> <content:encoded><![CDATA[<p>Today I stumbled over a rather interesting issue in combination with JBoss, Hibernate, Spring, JPA and EJB.</p><p>First of all, we have mixed environment of EJB3 and Spring 3 using JPA2. All in JBoss 6 AS, with default Hibernate 3.6 as JPA provider. Now for a long time everything works fine until we re-organize the dependencies of our modules. Starting with that we got some strange JPA behavior like &#8220;class is not an entity&#8221; and some rather weird getter issues.</p><p>Altogether it looked like some classloader issue. But it took some time to find that one.</p><p>In the beginning there was a JPA persistence unit called &#8220;someModel&#8221;. The problem with spring was, that it needs to be imported using the &#8220;jee:jndi-lookup&#8221; tag, which requires a JNDI name. That one was provided by JBoss itself using the &#8220;jboss.entity.manager.factory.jndi.name&#8221; property in the &#8220;persistence.xml&#8221; file. This triggers JBoss/Hibernate to bind the persistence unit with that specified name. Of course the name was &#8220;persistence/someModel&#8221;.</p><p>Now everything grew, EJB was added in order to gain modularity. And now that the dependencies and the start order was changed, the same persistence unit was used multiple times in multiple EJBs beside the spring application. While EJB seems not to have any problems finding its persistence unit, spring needs a bit more information and requires the already discusses &#8220;jee:jndi-lookup&#8221; tag in order to find its persistence unit.</p><p>As it turned out, the multiple persistence units all registered with the same name, leaving spring with the first (or last) registration, but not necessarily the correct registration. So spring accesses &#8220;some&#8221; persistence unit with that name and possible used the wrong classloader.</p><p>The solution was quite and and lot cleaner than using the &#8220;jboss.entity.manager.factory.jndi.name&#8221; property. But, less intuitive I have to say.</p><p>In the &#8220;web.xml&#8221; of the servlet that starts the application context a reference has to be added to the persistence unit:</p><pre class="brush: xml; title: ; notranslate">
	&lt;persistence-unit-ref&gt;
		&lt;persistence-unit-ref-name&gt;persistence/someModel&lt;/persistence-unit-ref-name&gt;
		&lt;persistence-unit-name&gt;someModel&lt;/persistence-unit-name&gt;
	&lt;/persistence-unit-ref&gt;
</pre><p>This will register the local (in the EAR file hosting the WAR) peristence unit &#8220;someModel&#8221; in the local JNDI space as &#8220;persistence/someModel&#8221; and you are done. Spring will can still import it as &#8220;persistence/someModel&#8221;.</p><p
class="wp-flattr-button"></p><p><a
href="http://dentrassi.de/?flattrss_redirect&amp;id=116&amp;md5=d3011a101fead37f83e18826226a0c21" title="Flattr" target="_blank"><img
src="http://dentrassi.de/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded> <wfw:commentRss>http://dentrassi.de/2011/10/11/jpa-ejb-and-spring/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Struggling with Acceleo 3.0 after Eclipse 3.7 upgrade</title><link>http://dentrassi.de/2011/08/11/struggling-with-acceleo-3-0-after-eclipse-3-7-upgrade/</link> <comments>http://dentrassi.de/2011/08/11/struggling-with-acceleo-3-0-after-eclipse-3-7-upgrade/#comments</comments> <pubDate>Thu, 11 Aug 2011 07:46:04 +0000</pubDate> <dc:creator>ctron</dc:creator> <category><![CDATA[Development]]></category><guid
isPermaLink="false">http://dentrassi.de/?p=111</guid> <description><![CDATA[While the upgrade from Eclipse 3.6.2 to 3.7 went without nearly any trouble the upgrade of the Acceleo plugins to the versions provided with Eclipse Indigo was "a little bit more" problematic.Starting the generator after the upgrade simply brought ...]]></description> <content:encoded><![CDATA[<p>While the upgrade from Eclipse 3.6.2 to 3.7 went without nearly any trouble the upgrade of the Acceleo plugins to the versions provided with Eclipse Indigo was &#8220;a little bit more&#8221; problematic.</p><p>Starting the generator after the upgrade simply brought up:</p><pre>Exception in thread "Main Thread" org.eclipse.acceleo.engine.AcceleoEvaluationException: The type of the first parameter of the main template named 'myTemplate' is a proxy.
    at org.eclipse.acceleo.engine.service.AcceleoService.doGenerate(AcceleoService.java:507)
    at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.generate(AbstractAcceleoGenerator.java:175)
    at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.doGenerate(AbstractAcceleoGenerator.java:154)
...</pre><p>The main template did not accept the model anymore. Although everything was registered and working with the previous version.</p><p>Googling a bit I found out that Acceleo provides a different serialization model which stores models in binary form instead of XMI. Since all my models I flipped the switch in the project settings:</p><div
id="attachment_112" class="wp-caption alignnone" style="width: 635px"><a
href="http://dentrassi.de/wp-content/uploads/acceleo.png"><img
class="size-full wp-image-112" title="Acceleo Project Settings" src="http://dentrassi.de/wp-content/uploads/acceleo.png" alt="" width="625" height="596" /></a><p
class="wp-caption-text">Acceleo Project Settings</p></div><p>Which worked at first until I stumbled over the next problem a few hours later:</p><pre>org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop iteration at line 18 in Module myModule for block for (myObject.null). Last recorded value of self was com.thfour.config.model.model.impl.MyObjectImpl@81b69bf (....).
    at subModule.subModule(null)(subModule.mtl:18)
    at subModule.subModule(null)(subModule.mtl:6)
    at subModule.subModule(null)(subModule.mtl:4)
    at module.module(MyObject)(module.mtl:0)
    at module.module(MyObject)(module.mtl:7)</pre><p>After some debugging it seemed as if the main module could not pass a model object to a template that is located in another bundle. We have structured our model generator to have a common part and a project specific bundle. At first it looked like as it this stopped working by an unknown reason.</p><p>After some testing, flipping switches, debugging, restructuring I found out that the solution was rather simple. The same switch (Binary, XMI) has to be set to the common generator module as well. All modules must agree to a model format (either binary or XMI).</p><p>While I can understand this for the generator that is launched, I cannot understand this for submodules that provide common generating templates and should not even care about the serialization form. But it is as it is <img
src='http://dentrassi.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /></p><p
class="wp-flattr-button"></p>]]></content:encoded> <wfw:commentRss>http://dentrassi.de/2011/08/11/struggling-with-acceleo-3-0-after-eclipse-3-7-upgrade/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>openscada.org update</title><link>http://dentrassi.de/2011/03/10/openscada-org-update/</link> <comments>http://dentrassi.de/2011/03/10/openscada-org-update/#comments</comments> <pubDate>Thu, 10 Mar 2011 08:45:25 +0000</pubDate> <dc:creator>ctron</dc:creator> <category><![CDATA[Uncategorized]]></category><guid
isPermaLink="false">http://dentrassi.de/?p=93</guid> <description><![CDATA[Finally we made it! openscada.org has been updated to look good and contain new information. Finally :)]]></description> <content:encoded><![CDATA[<p>Finally we made it! <a
href="http://openscada.org" target="_blank">openscada.org</a> has been updated to look good and contain new information. Finally <img
src='http://dentrassi.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p
class="wp-flattr-button"></p>]]></content:encoded> <wfw:commentRss>http://dentrassi.de/2011/03/10/openscada-org-update/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Fancy tooltips in Eclipse</title><link>http://dentrassi.de/2011/02/21/fancy-tooltips-in-eclipse/</link> <comments>http://dentrassi.de/2011/02/21/fancy-tooltips-in-eclipse/#comments</comments> <pubDate>Mon, 21 Feb 2011 11:34:39 +0000</pubDate> <dc:creator>ctron</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[Eclipse]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[JFace]]></category> <category><![CDATA[SWT]]></category><guid
isPermaLink="false">http://dentrassi.de/?p=94</guid> <description><![CDATA[Tooltips are quick way to add information to a widget that received the users attention. While one can argue about the pros and cons of tooltips this post focuses on the style of tooltips once you decided to use ...]]></description> <content:encoded><![CDATA[<p>Tooltips are quick way to add information to a widget that received the users attention. While one can argue about the pros and cons of tooltips this post focuses on the style of tooltips once you decided to use them.</p><p><span
id="more-94"></span>A default use case is to add a description to e.g. an icon based button:</p><p><a
href="http://dentrassi.de/wp-content/uploads/tooltip_native_short.png"><img
class="alignnone size-full wp-image-95" title="tooltip_native_short" src="http://dentrassi.de/wp-content/uploads/tooltip_native_short.png" alt="" width="272" height="106" /></a></p><p>Now and then you might find yourself in the need to add some more information than just a short text. While I think the upper example is a good example for using a tooltip the following is now really:</p><p><a
href="http://dentrassi.de/wp-content/uploads/tooltip_native_long.png"><img
class="alignnone size-full wp-image-96" title="tooltip_native_long" src="http://dentrassi.de/wp-content/uploads/tooltip_native_long.png" alt="" width="460" height="125" /></a></p><p>The problem is not necessarily the amount of information but the way it is presented. So why is it used? Because it is quite easy to use with SWT. The following line of code sets the tooltip text:</p><pre class="brush: java; title: ; notranslate">
Button button = ...
button.setToolTipText ( &quot;Read descriptor: &quot; + readDescriptor + &quot;\nWrite descriptor: &quot; + writeDescriptor );
</pre><p>This call is using the widget toolkit&#8217;s own way to activate and render the tooltip. On the pro side you have the native look and feel and the quick way to add it, on the con side it only looks good when you have short and compact tooltips. Also you might run into problems with different behaviors on different platforms.</p><p>But Eclipse would not be Eclipse if there wasn&#8217;t a second way to add tooltips to you user interface. In JFace you will find a <a
title="ToolTip" href="http://help.eclipse.org/helios/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/jface/window/ToolTip.html" target="_blank">ToolTip</a> class which is the base for custom made tooltips. Using <tt><a
href="http://help.eclipse.org/helios/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/jface/window/DefaultToolTip.html" target="_blank">DefaultToolTip</a> you have a working base that provides a plain implementation quite similar in the rendering as the native tooltip:</tt></p><p><a
href="http://dentrassi.de/wp-content/uploads/tooltip_jface_default.png"><img
class="alignnone size-full wp-image-98" title="tooltip_jface_default" src="http://dentrassi.de/wp-content/uploads/tooltip_jface_default.png" alt="" width="319" height="112" /></a></p><p>Adding this a bit more complex but also provides some more options:</p><pre class="brush: java; title: ; notranslate">
DefaultToolTip toolTip = new DefaultToolTip ( widget );
toolTip.setShift ( new Point ( 5, 5 ) );
toolTip.setText ( &quot;Hello World&quot; );
</pre><p>Browsing through the setters of the class you will find a lot to customize. On the con side, as you can see in the screenshot, it look like the native tooltip, but not exactly.</p><p>Now if this is still not enough customizing you can also dereive directly from <tt>org.eclipse.jface.window.ToolTip</tt> and implement <tt>createToolTipContentArea</tt> yourself:</p><pre class="brush: java; title: ; notranslate">
protected Composite createToolTipContentArea ( final Event event, final Composite parent )
{
 ...
}
</pre><p>In our case we created a tooltip containing a header, an icon and a styled text:<br
/> <a
href="http://dentrassi.de/wp-content/uploads/tooltip_jface_custom.png"><img
class="alignnone size-full wp-image-99" title="tooltip_jface_custom" src="http://dentrassi.de/wp-content/uploads/tooltip_jface_custom.png" alt="" width="544" height="215" /></a></p><p>The pros and cons should be obvious.</p><p>But &#8230; there is one more thing. Eclipse would not be Eclipse if there would not be another way to do it (I know I repeat myself here). SWT also provides another <a
href="http://help.eclipse.org/helios/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/ToolTip.html" target="_blank">ToolTip</a> class. This class provides tooltips and &lt;q&gt;balloons/q&gt;:</p><p><a
href="http://dentrassi.de/wp-content/uploads/tooltip_swt_balloon.png"><img
class="alignnone size-full wp-image-100" title="tooltip_swt_balloon" src="http://dentrassi.de/wp-content/uploads/tooltip_swt_balloon.png" alt="" width="378" height="156" /></a></p><p>The problem with these tooltips is, that they seem to be made for the Tray that can pop up balloons (see <a
href="http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet225.java?view=co" target="_blank">Snippet</a>). You still can position the tooltip manually and align it to you control, but I would guess that using JFace is a much cleaner approach.</p><p
class="wp-flattr-button"></p>]]></content:encoded> <wfw:commentRss>http://dentrassi.de/2011/02/21/fancy-tooltips-in-eclipse/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Some thoughts on software testing</title><link>http://dentrassi.de/2011/02/17/some-thoughts-on-software-testing/</link> <comments>http://dentrassi.de/2011/02/17/some-thoughts-on-software-testing/#comments</comments> <pubDate>Thu, 17 Feb 2011 11:17:35 +0000</pubDate> <dc:creator>ctron</dc:creator> <category><![CDATA[Development]]></category><guid
isPermaLink="false">http://dentrassi.de/?p=85</guid> <description><![CDATA[If you are working as a software developer in a project based development environment you will, hopefully, encounter the day the customer wants to see the result that was promised to him. The worst thing that can happen is ...]]></description> <content:encoded><![CDATA[<p>If you are working as a software developer in a project based development environment you will, hopefully, encounter the day the customer wants to see the result that was promised to him. The worst thing that can happen is that after months of development you finally end up in a scenario of <q>it is not working</q> or <q>it is not what we need</q>. Sure there are numerous reasons of why this happened and what types development process you could have used. But often quality management and software development definitions are written once and never lived as described. developers consider it a burden that is unnecessary and is blocking them in their daily task of creating new functionality.</p><p><span
id="more-85"></span>While one can argue about the pros and cons of formal quality management and rules of software development processes it ends up in the psychology of the team if and how good the testing has been performed. Some simply tricks ease the whole process and improve the result without adding lots of rules and frustration:</p><h1>Reduce deployment times</h1><p>If it takes 30 minutes from one change in the source code to the living result on the test system it will take ages to find and solve issues. Of course a coordinated build system is an important part of development. But quickly patching an issue is as well. If you need three steps to solve the issue and need half an hour to create a new version you have wasted 1½ hours instead of maybe five minutes if your development environment is quick enough. Not all issues can be resolved on the local development machine, so deployment has to be quick on the path up to the integration and testing system.</p><h1>Early set up of a test system</h1><p>Two days to the test. Everybody is confident that testing will go well. Everything was tested&#8230; on machines of developers. Installing the system on the testing machines turns out to be a huge problem and the day your customer arrives you have a badly set up system, developers worked over night and weekend to find the remaining hard coded path of <q>/home/user/local/development</q> which are not working in the test system.</p><p>Adding different operating systems of developers, additionally installed software packaged and more system resources the development system is always different to the test system. In addition you normally don&#8217;t deploy your software in the development system but simply start it from the IDE.</p><p>So as soon as you have your first few functions, set up a test system and deploy you software as it would be done during the real testing. You will be surprised how many bug/issues you will find in advance.</p><h1>Test with the customer</h1><p>If you have your test system that early you can also invite your customer to test with you. While not all customers are interested in that, some are and you should take the chance to do so. The first thing you will think is something like <q>this costs us more time than it is worth</q>. But in the end you have tested most functionally long before your final test and end up with a test system that is already known by your customer before the tests start. Unexpected but correct reactions of your system are already common knowledge and need no explanation. And of course you will get feedback much earlier and can integrate that into your development process ending up with a product that is much closer to your customer than introducing him to a brand new system on day 1 of the test.</p><p>Also let your developers test with the customer. Hiding developers in the basement and letting management perform the testing is not always a good choice of job assignment. There may be good reasons to let management do the final and formal testing. But during the beginning direct contact with the technical counterparts of your customer and your developers will give your own people a much better understanding of what the customer needs and you will loose much less information in the process. Many developers will also see this as benefit of seeing where their solution will later be put to use. Of course some prefer the basement <img
src='http://dentrassi.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /></p><h1>Add obstacles between test and development systems</h1><p>While a short path between development and test system is important it might turn out to be good idea to add some temporary obstacles to that path. Otherwise you might end up with two development systems instead of one development system and one test system.</p><p>Cutting of the network access or relocating the machines to a different part of the building are some ways to do that. This will pull people together in one room for testing and bind their focus in the subject. And it will also show that when the system is productive in the future the way to reach it might be a lot more problematic than just connecting to a local server. New ideas and ways of how to test and debug will automatically turn up and can later be used in the productive system.</p><h1>Who is testing</h1><p>At least one person <q>non developer</q> should be responsible for testing. This does not mean that no developer should test but people tend to test the same way all over again. Just using the system another way might turn up lots of interesting issues. You will encounter situations you only can get out of using a developer, which will not be possible in the productive system. So the earlier you let people test that do not know the source code and can influence system internals the earlier you will get a system that can be managed by administrators of your customer alone (if this is what you wish). In the end the customer will click in a different way and will find issues with his approach on the system.</p><p>Also if you focus on special &lt;q&gt;test users&lt;/q&gt; reduce the problem of having all developers think &lt;q&gt;the other one&lt;/q&gt; tested that cool new feature which went out untested.</p><h1>Test cases</h1><p>I am a little biased about automated test cases. In the end you will have a manual test. Most systems I know cannot be completely tested using an automated test system. Developing a specialized solution in one project is totally different to a product that developed once and sold many times. Writing test cases can be quite difficult and time consuming. if you have to re-write them for every new project it might turn out easier to just perform then <q>manually</q>.</p><p>On the other hand automated test cases definitely will improve quality. But the are no guarantee for successful test with your customer. You will never reach a point where you have your system covered 100% by your automated tests. See it reaching light speed. You never can and getting closer will cost you more and more energy. Also automated test cases are just source code that might contains bugs ore may simply be wrong.</p><h1>Finally</h1><p>There is lots more to say about testing. Important is to test early, often, quick and separated and as realistic as you can.</p><p
class="wp-flattr-button"></p>]]></content:encoded> <wfw:commentRss>http://dentrassi.de/2011/02/17/some-thoughts-on-software-testing/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Access to WMI in Java using Eclipse SWT OLE integration</title><link>http://dentrassi.de/2011/02/04/access-to-wmi-in-java-using-eclipse-swt-ole-integration/</link> <comments>http://dentrassi.de/2011/02/04/access-to-wmi-in-java-using-eclipse-swt-ole-integration/#comments</comments> <pubDate>Fri, 04 Feb 2011 16:58:44 +0000</pubDate> <dc:creator>ctron</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[Eclipse]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[SWT]]></category> <category><![CDATA[Win32]]></category><guid
isPermaLink="false">http://dentrassi.de/?p=59</guid> <description><![CDATA[Today I ran into a problem which could easily solved using a short WMI query. The problem was that the query must be executed within a Java UI application. Googling for a solution I came only up with either ...]]></description> <content:encoded><![CDATA[<p>Today I ran into a problem which could easily solved using a short WMI query. The problem was that the query must be executed within a Java UI application. Googling for a solution I came only up with either quite some ugly workarounds (like generating a VBScript fragment, forking off the VBScript runtime and parsing the result) or some full blown COM/DCOM interfaces (like J-Integra or J-Interop). Although I really like J-Interop (we are using it for DCOM when accessing OPC server in OpenSCADA Utgard) it has some drawbacks. For J-Interop every access (even local access) is a network based access. Since J-Interop only supports DCOM it is free of any platform specific code but required the machine to be accessible using &#8220;remoting&#8221; functionality (DCOM). Since I wanted to query the WMI from a UI application and I am sure that the WMI query will stay on the Win32 version of the application I was not keen on adding &#8220;remoting&#8221; as a requirement to the UI application.</p><p>After some digging I remembered that SWT brings an OLE interface which provides direct COM access. So I started poking around and finally come up with a solution that works quite well.</p><p><a
href="http://dentrassi.de/wp-content/uploads/wmisample.png"><img
class="size-thumbnail wp-image-68 alignright" title="wmisample" src="http://dentrassi.de/wp-content/uploads/wmisample-150x150.png" alt="" width="150" height="150" /></a> For the impatient: The full source code is available from github <a
href="https://github.com/ctron/wmisample">https://github.com/ctron/wmisample</a> and the screenshot is here.</p><p><span
id="more-59"></span>The solution requires: win32 or win64, SWT and some classes from the SWT internal namespace. The latter is a catch that does not hurt too much.</p><p>First one needs a SWbemServices object which is obtained by asking the SWbemLocator to create one:</p><pre class="brush: java; title: ; notranslate">
OleAutomation automation = new OleAutomation(&quot;WbemScripting.SWbemLocator&quot;);
Variant service = automation.invoke(Helper.getId(automation, &quot;ConnectServer&quot;));
</pre><p>The variant will hold a VT_DISPATCH value which references the SWbemServices instance. Instead of calling the <q>ConnectServer</q> method with any parameters one can also call with full remote server support (see <a
href="http://msdn.microsoft.com/en-us/library/aa393720%28v=VS.85%29.aspx" target="_blank">MSDN</a>).</p><p>The next, and rather easy, step is to execute the query:</p><pre class="brush: java; title: ; notranslate">
OleAutomation serviceAutomation = service.getAutomation();

Variant resultList = serviceAutomation.invoke(
   Helper.getId(serviceAutomation, &quot;ExecQuery&quot;),
   new Variant[] {
      new Variant(query),
      new Variant(&quot;WQL&quot;),
      new Variant(32) });
</pre><p>The Helper.getId method fetches the dispatch id (function number) from the name of the function. So instead of calling a function by name you call it by id and look up the id by the name first:</p><pre class="brush: java; title: ; notranslate">
public static int getId(OleAutomation auto, String name) {
   int result[] = auto.getIDsOfNames(new String[] { name });
   if (result == null || result.length &lt; 1) {
      throw new RuntimeException(String.format(
         &quot;Object does not support '%s'&quot;, name));
   }
   return result[0];
}
</pre><p>The result of the <q>ExecQuery</q> call is an object of the type <tt>SWbemObjectSet</tt>. The strange thing with this object is, that <a
href="http://msdn.microsoft.com/en-us/library/aa393762%28v=VS.85%29.aspx" target="_blank">by documentation</a> it only has an <q>Item</q> method which requires that you actually don&#8217;t want to know and provide. While all examples you find which that the result is directly used in VB <q>for each</q> constructs. But the object also provides an undocumented (still valid) <q>_NewEnum</q> method which is used by e.g. VB by default for <q>for each</q> loops. So one can call this method explicitly and iterate over the result.</p><p>The problem here is, that the result to the <q>_NewEnum</q> call is a VT_UNKNOWN variant since the result is a COM object without support for IDispatch. So one has to play plain COM games and QueryInterface for IEnumVARIANT and iterate using <q>Next</q>.</p><p>And here comes the part were one needs to use SWT internal methods, since this requires allocating memory and performing pointer stuff. So be warned, from here on your are actually calling operating system memory allocating functions that may: a) crash your application when used improperly (like it does when you use C or C++) and b) produce memory leaks that are not covered by the Java VM but by direct calls to <q>alloc</q> calls in the OS.</p><p>In order to separate this stuff from the rest of the classes it all went into the Helper class, providing an <q>forEachVariant</q> method using a visitor interface:</p><pre class="brush: java; title: ; notranslate">
public static interface VariantVisitor {
  public void visit(Variant variant);
}
</pre><p>The method first gets the <q>enum</q> using the property (not method) <q>_NewEnum</q> which returns a variant of type VT_UNKNOWN:</p><pre class="brush: java; title: ; notranslate">
Variant enumObject = enumerableAuto.getProperty(
  Helper.getId(enumerableAuto, &quot;_NewEnum&quot;)
);
</pre><p>Now one needs to QueryInterface to get the IEnumVARIANT interface for the unknown:</p><pre class="brush: java; title: ; notranslate">
long /* int */[] ppvObject = new long /* int */[1];
int rc = enumObject.getUnknown().QueryInterface(COM.IIDIEnumVARIANT, ppvObject);
if (rc != OS.S_OK)
  return rc; // in case of error
</pre><p>Looks actually like call in C. The result will be a pointer to a IEnumVARIANT in ppvObject. You should also be aware of the fact that QueryInterface also performes an AddRef, so you have to perform one Release call when you are done in order to decrease the usage count on the instance.</p><p>Next one can pass the pointer to the instance to an instance of IEnumVARIANT (which is also from SWT internal) and already provides mapping to the function calls Reset, Next, Release.</p><pre class="brush: java; title: ; notranslate">
IEnumVARIANT enumVariant = new IEnumVARIANT(ppvObject[0]);
enumVariant.Reset();
</pre><p>And now comes the <q>fun</q> part of the whole thing. Allocating memory and iterating over the enumeration:</p><pre class="brush: java; title: ; notranslate">
int[] pceltFetched = new int[1];
long rgelt = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT,Variant.sizeof);

try {
  while (enumVariant.Next(1, rgelt, pceltFetched) == OLE.S_OK
    &amp;&amp; pceltFetched[0] == 1) {
      Variant v = Variant.win32_new(rgelt);
      variantVisitor.visit(v);
   }
} finally {
    OS.GlobalFree(rgelt);
}
</pre><p>First a new Variant structure is allocated (again, this is OS memory allocation, not JVM!). Next the while loop iterates over the enumeration using Next calls and passes the variants to the visitor interface. The try-finally block ensures that when something goes wrong, at least the memory is freed in order to prevent memory leaks.</p><p>Actually is was asking myself why this IEnumVARIANT implementation does not perform the full magic and provides a way to access enums without using internal stuff. But I guess the SWT team has not too much interest in working on OLE/COM stuff and likes to keeps things as minimalistic as possible.</p><p>As last step the while executeQuery method iterates over the <q>SWbemObjectSet</q> enumeration which returns Variants (VT_DISPATCH) pointing to instances of <q>SWbemObject</q>. They again have a property <q>Properties_</q> that, which again is an enumeration of <q>Name</q> and <q>Value</q> pairs. The one needs to iterate again in order to request all properties.</p><p>it was quite interesting to see what is possible with Eclipse SWT and quite annoying to dig through incomplete COM documentation. But in the end it worked <img
src='http://dentrassi.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>Don&#8217;t forget to check the full source code at github: <a
href="https://github.com/ctron/wmisample" target="_blank">https://github.com/ctron/wmisample</a></p><p>Just clone (aka check out) the source:</p><pre class="brush: plain; title: ; notranslate">
git clone git://github.com/ctron/wmisample.git wmisample.git
</pre><p>If you don&#8217;t like to use git, you can also use the &#8220;Downloads&#8221; button on github and download a ZIP instead.</p><p>The full forEach method is:</p><pre class="brush: java; title: ; notranslate">
	public static int forEachVariant(Variant enumerable,
			VariantVisitor variantVisitor) {
		OleAutomation enumerableAuto = enumerable.getAutomation();

		try {
			Variant enumObject = enumerableAuto.getProperty(Helper.getId(
					enumerableAuto, &quot;_NewEnum&quot;));

			long /* int */[] ppvObject = new long /* int */[1];
			int rc = enumObject.getUnknown().QueryInterface(
					COM.IIDIEnumVARIANT, ppvObject);

			if (rc != OS.S_OK)
				return rc;

			IEnumVARIANT enumVariant = new IEnumVARIANT(ppvObject[0]);

			try {
				enumVariant.Reset();

				int[] pceltFetched = new int[1];

				long rgelt = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT,
						Variant.sizeof);

				try {
					while (enumVariant.Next(1, rgelt, pceltFetched) == OLE.S_OK
							&amp;&amp; pceltFetched[0] == 1) {
						Variant v = Variant.win32_new(rgelt);
						variantVisitor.visit(v);
					}
				} finally {
					OS.GlobalFree(rgelt);
				}
			} finally {
				enumVariant.Release();
			}

			return OLE.S_OK;

		} finally {
			enumerableAuto.dispose();
		}
	}
</pre><p>And the full query logic method is:</p><pre class="brush: java; title: ; notranslate">
	public List&lt;WMIObjectInformation&gt; executeQuery(String query) {
		OleAutomation serviceAutomation = service.getAutomation();
		try {
			final List&lt;WMIObjectInformation&gt; result = new LinkedList&lt;WMIObjectInformation&gt;();

			Variant resultList = serviceAutomation.invoke(
					Helper.getId(serviceAutomation, &quot;ExecQuery&quot;),
					new Variant[] { new Variant(query), new Variant(&quot;WQL&quot;),
							new Variant(32) });

			if (resultList == null) {
				throw new RuntimeException(serviceAutomation.getLastError());
			}

			Helper.forEachVariant(resultList, new VariantVisitor() {

				@Override
				public void visit(Variant variant) {

					final Map&lt;String, Object&gt; params = new HashMap&lt;String, Object&gt;();

					Variant properties = Helper.getParameter(variant,
							&quot;Properties_&quot;);

					Helper.forEachVariant(properties, new VariantVisitor() {

						@Override
						public void visit(Variant variant) {

							Variant name = Helper.getParameter(variant, &quot;Name&quot;);
							Variant value = Helper.getParameter(variant,
									&quot;Value&quot;);
							Object objectValue = Helper.convertVariant(value);

							params.put(name.getString(), objectValue);
						}
					});

					result.add(new WMIObjectInformation(Helper.getParameter(
							Helper.getParameter(variant, &quot;Path_&quot;), &quot;Path&quot;)
							.getString(), params));
				}
			});

			return result;
		} finally {
			serviceAutomation.dispose();
		}
	}
</pre><p
class="wp-flattr-button"></p>]]></content:encoded> <wfw:commentRss>http://dentrassi.de/2011/02/04/access-to-wmi-in-java-using-eclipse-swt-ole-integration/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: dentrassi.de @ 2012-02-23 00:57:37 -->
