Archive for August, 2009

*.apache.org is down

August 28th, 2009

At the time of writing all apache.org sub-domains are down, displaying *.apache.org is currently offline. No ETA for resumption of services is available..

Now I understand my Maven dependencies were not resolved (I was trying to get some snapshot dependencies from the incubator).

This seems to be an unscheduled down time, I hope they will be able to fix the issue soon. To Apache admins : may the force be with you :-)

CollabNet merge client

August 12th, 2009

The CollabNet team has made a fantastic work with the new merge client in Subclipse 1.6.x. I was used to the previous merge dialog and I was surprised how merging with SVN can be easy with a good wizard.

Let’s take a look at these screenshots :

Select merge operation

Merge wizard 1

Select branch to reintegrate

Merge wizard 2

Pre-merge checks

No screenshot here but if there is something wrong in the current working copy, the wizard warns you and provides quick fixes.

Merge options

Merge wizard 3

Results

Merge wizard 4

Merge graph

The branch and merge history can be shown in the history graph. We can see the previous merge on this test project.

Merge graph

Great work guys :-)

Displaytag + Struts 2 localization

August 12th, 2009

Displaytag 1.2 (current latest release) provides several LocaleResolver, but none works with the latest version of Struts 2.1.X. There was a small change in Xwork API breaking the I18nWebworkadapter. ActionContext#getValueStack() now returns a ValueStack instead of OgnlValueStack.

Here is the updated LocaleResolver for Struts 2.1.6 :
/**
* Licensed under the Artistic License; you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://displaytag.sourceforge.net/license.html
*
* THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
package org.displaytag.localization;

import java.util.Iterator;
import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.Tag;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.views.jsp.TagUtils;
import org.displaytag.Messages;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.LocaleProvider;
import com.opensymphony.xwork2.TextProvider;
import com.opensymphony.xwork2.util.ValueStack;

/**
* Struts2 implementation of a resource provider and locale resolver.
* @author Richard HALLIER
* @author Fabrizio Giustina
* @author Nicolas Richeton - Fix for Struts 2.1.6
* @version $Revision: 1081 $ ($Author: fgiust $)
*/
public class I18nStruts2Adapter implements LocaleResolver, I18nResourceProvider
{

/**
* prefix/suffix for missing entries.
*/
public static final String UNDEFINED_KEY = "???"; //$NON-NLS-1$

/**
* logger.
*/
private static Log log = LogFactory.getLog(I18nStruts2Adapter.class);

/**
* @see LocaleResolver#resolveLocale(HttpServletRequest)
*/
public Locale resolveLocale(HttpServletRequest request)
{

Locale result = null;
ValueStack stack = ActionContext.getContext().getValueStack();

Iterator iterator = stack.getRoot().iterator();
while (iterator.hasNext())
{
Object o = iterator.next();

if (o instanceof LocaleProvider)
{
LocaleProvider lp = (LocaleProvider) o;
result = lp.getLocale();

break;
}
}

if (result == null)
{
log.debug("Missing LocalProvider actions, init locale to default");
result = Locale.getDefault();
}

return result;
}

/**
* @see I18nResourceProvider#getResource(String, String, Tag, PageContext)
*/
public String getResource(String resourceKey, String defaultValue, Tag tag, PageContext pageContext)
{

// if resourceKey isn't defined either, use defaultValue
String key = (resourceKey != null) ? resourceKey : defaultValue;

String message = null;
ValueStack stack = TagUtils.getStack(pageContext);
Iterator iterator = stack.getRoot().iterator();

while (iterator.hasNext())
{
Object o = iterator.next();

if (o instanceof TextProvider)
{
TextProvider tp = (TextProvider) o;
message = tp.getText(key);

break;
}
}

// if user explicitely added a titleKey we guess this is an error
if (message == null && resourceKey != null)
{
log.debug(Messages.getString("Localization.missingkey", resourceKey)); //$NON-NLS-1$
message = UNDEFINED_KEY + resourceKey + UNDEFINED_KEY;
}

return message;
}

}

Fixing Struts2 initialization error on Jetty restart

August 12th, 2009

[ERROR] Error reconfiguring/restarting webapp after change in watched files
Caught exception while loading file struts-default.xml – [unknown location]

Caused by: java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration

This issue seems to only occur with Java 6 and is related to the Xalan version included in this JDK.

Add xalan to your pom or in an endorsed/shared directory and the problem goes away.

<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
</dependency>

More details there : JIRA item.

Collaboration between ShareMedia and Remus Information Management

August 11th, 2009

ShareMedia and Remus information Management are two open source RCP applications which have similar features :

ShareMedia is a multi-platform photo manager. It supports several repositories such as local computer, Jabber, Picasa web or Flickr.

RIM is a free OpenSource client application for the management of information with a connection to multitude of data repositories like Flickr, Youtube or Facebook and a desktop-integration for an optimal usage for the offline management, visualization and easy accessibility of information to the user.

A few weeks ago, Tom Seidel and I decided to work on Eclipse bundles that will be shared between the two projects in order to speed up development and improve reusability of our code.

Our first goal is to define a common API which will be used by both applications and to port the existing image viewers from ShareMedia to this new API. ShareMedia has two full screen viewers including an OpenGL based one, inspired from CoverFlow from iTunes (see screencast bellow @0:55).

While these bundles are mainly targeted to ShareMedia and RIM, they can also be used in the Eclipse IDE and in any RCP application.

We now have a first implementation of the viewer API and two basic viewers. A few features are still missing and there is no background image loading so the IU may freeze a few seconds while loading large images, but it is working.

The following explains how to install the viewers in Eclipse and in an RCP application.

Installing the demo viewer into Eclipse :

The viewer has a dependency on Nebula Gallery which is not yet packaged into the feature. So you have to install the gallery widget from its update site :

http://download.eclipse.org/technology/nebula/gallery/update-N/

then install the demo viewer from ShareMedia / RIM update site :

http://smedia-rim.sourceforge.net/update/site.xml

Testing the viewer :

Select one or several image files in the package viewer / navigator view, open the context menu and select View in full screen…

viewer-fullscreen

Your monitors will fade to black and the first file will be displayed on your primary monitor. Commands are : ESC – Return to Eclipse , SPACE – Next image.

Multi-monitor setups are supported. Your secondary monitor will let you select the image to display on the primary monitor using a gallery of all items from your selection.

How to add a viewer to your application :

First, you will have to add the following bundles to your application

  • org.sharemediarim.api : the base API plugin, always required
  • org.sharemediarim.simple : the basic viewers. These are the only viewers available right now, just wait :-)
  • org.sharemediarim.viewers.adapter.file : the adapter for IFile objects. Only if you want do show eclipse resources (IFile) in the viewer.
  • org.apache.sanselan : dependency of o.s.v.adapter.file, used to read image thumbnails.
  • org.sharemedia.rim.viewers : Eclipse integration. Adds full screen action for IFile items in the context menu.

If you didn’t use the Eclipse integration, you can open the viewer from your code (usually in an action) :

1 – Create a viewer : a viewer can display images, but not necessary in full screen. It can also be hosted in a view :

IViewer viewer= new SampleViewer();

2 – Create a full screen viewer from the previous viewer. You can also provide additional viewers which will be displayed on secondary monitors.

final GenericFullScreenViewer fullScreenViewer = new GenericFullScreenViewer(new SampleViewer());

3 – Set the viewer’s input. Objects within the selection must implement IAdaptable and have an adapter to Image or IAdvancedImage. We provide a default Adapter for IFile in org.sharemediarim.viewers.adapter.file.

fullScreenViewer.setInput(structuredSelection);

4 – Register a listener to dispose the viewer on close. You can also reuse the viewer every time, and dispose it only on exit.

fullScreenViewer.addCloseListener(new Listener() {
public void handleEvent(Event event) {
viewer.dispose();
}});

5 – Finally, open the viewer :

fullScreenViewer.open();

Get involved :

If you are interested by using these viewers in your application or by creating new implementations, don’t hesitate to get in touch with us and help improve this API and viewers.

Project home page : http://sourceforge.net/projects/smedia-rim/

Issue tracker : http://www.remus-software.org/jira/browse/SMEDIARIM

Forum : http://sourceforge.net/forum/forum.php?forum_id=977188