Merge branch 'master' of
ssh://tbuschto@git.eclipse.org/gitroot/rap/org.eclipse.rap.tools.git

Conflicts:
	bundles/org.eclipse.rap.doc/guide/articles/scripting.html
diff --git a/.gitignore b/.gitignore
index 051fb2d..be1df70 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,10 @@
 bin/
+
+# Maven
 target/
+# include packages with a "target" segment
+!/bundles/org.eclipse.rap.tools.intro/src/org/eclipse/rap/ui/internal/intro/target/
+!/tests/org.eclipse.rap.tools.tests/src/org/eclipse/rap/ui/internal/intro/target/
+
+# MacOS
 .DS_Store/
diff --git a/bundles/org.eclipse.rap.doc/guide/articles/tree-table.html b/bundles/org.eclipse.rap.doc/guide/articles/tree-table.html
index 54a8237..f254ac9 100644
--- a/bundles/org.eclipse.rap.doc/guide/articles/tree-table.html
+++ b/bundles/org.eclipse.rap.doc/guide/articles/tree-table.html
@@ -57,7 +57,7 @@
       These cells can display either data from a Tree- or TableItem, or static content.
     </p>
     <p>
-      <img src="../images/rowtemplate.png">
+      <img src="../images/rowtemplate.png" />
     </p>
     <p>
       To create a new template, construct an instance of the
diff --git a/tests/org.eclipse.rap.tools.tests/src/org/eclipse/rap/ui/internal/launch/RAPLaunchDelegate_Test.java b/tests/org.eclipse.rap.tools.tests/src/org/eclipse/rap/ui/internal/launch/RAPLaunchDelegate_Test.java
index aea84f4..b90d4e9 100644
--- a/tests/org.eclipse.rap.tools.tests/src/org/eclipse/rap/ui/internal/launch/RAPLaunchDelegate_Test.java
+++ b/tests/org.eclipse.rap.tools.tests/src/org/eclipse/rap/ui/internal/launch/RAPLaunchDelegate_Test.java
@@ -27,8 +27,10 @@
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
 import org.eclipse.rap.ui.tests.Fixture;
+import org.eclipse.rap.ui.tests.TargetUtil;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 
@@ -38,6 +40,11 @@
   private RAPLaunchConfig rapConfig;
   private RAPLaunchDelegate launchDelegate;
 
+  @BeforeClass
+  public static void setUpTarget() throws CoreException {
+    TargetUtil.initializeTargetPlatform();
+  }
+
   @Before
   public void setUp() throws CoreException {
     config = Fixture.createRAPLaunchConfig();
diff --git a/tests/org.eclipse.rap.tools.tests/src/org/eclipse/rap/ui/tests/TargetUtil.java b/tests/org.eclipse.rap.tools.tests/src/org/eclipse/rap/ui/tests/TargetUtil.java
new file mode 100644
index 0000000..fc9a659
--- /dev/null
+++ b/tests/org.eclipse.rap.tools.tests/src/org/eclipse/rap/ui/tests/TargetUtil.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2013 Borland Software Corporation and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Mickael Istria (EBM Websourcing) - Support for target platform creation
+ *    EclipseSource - ongoing development
+ ******************************************************************************/
+package org.eclipse.rap.ui.tests;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.osgi.baseadaptor.BaseData;
+import org.eclipse.osgi.framework.internal.core.AbstractBundle;
+import org.eclipse.pde.core.target.ITargetDefinition;
+import org.eclipse.pde.core.target.ITargetLocation;
+import org.eclipse.pde.core.target.ITargetPlatformService;
+import org.eclipse.pde.core.target.LoadTargetDefinitionJob;
+import org.eclipse.pde.internal.core.target.TargetPlatformService;
+import org.osgi.framework.Bundle;
+
+
+/**
+ * Helper to run unit tests with tycho, where the target platform is empty by default. For the
+ * origin of this code, see bug 422952.
+ */
+@SuppressWarnings( "restriction" )
+public class TargetUtil {
+
+  private static final String CORE_RUNTIME = "org.eclipse.core.runtime";
+  private static final ITargetPlatformService TP_SERVICE = TargetPlatformService.getDefault();
+
+  /**
+   * Loads a target platform that contains all bundles from the running OSGi platform.
+   */
+  public static void initializeTargetPlatform() throws CoreException {
+    ITargetDefinition targetDef = TP_SERVICE.newTarget();
+    targetDef.setName( "Tycho platform" );
+    targetDef.setTargetLocations( getAllBundleLocations() );
+    targetDef.setArch( Platform.getOSArch() );
+    targetDef.setOS( Platform.getOS() );
+    targetDef.setWS( Platform.getWS() );
+    targetDef.setNL( Platform.getNL() );
+    TP_SERVICE.saveTargetDefinition( targetDef );
+    loadTargetPlatform( targetDef );
+  }
+
+  private static ITargetLocation[] getAllBundleLocations() {
+    Bundle[] bundles = Platform.getBundle( CORE_RUNTIME ).getBundleContext().getBundles();
+    List<ITargetLocation> bundleContainers = new ArrayList<ITargetLocation>();
+    Set<File> dirs = new HashSet<File>();
+    for( Bundle bundle : bundles ) {
+      BaseData bundleData = ( BaseData )( ( AbstractBundle )bundle ).getBundleData();
+      File file = bundleData.getBundleFile().getBaseFile();
+      File folder = file.getParentFile();
+      if( !dirs.contains( folder ) ) {
+        dirs.add( folder );
+        bundleContainers.add( TP_SERVICE.newDirectoryLocation( folder.getAbsolutePath() ) );
+      }
+    }
+    return bundleContainers.toArray( new ITargetLocation[ bundleContainers.size() ] );
+  }
+
+  private static void loadTargetPlatform( ITargetDefinition targetDef ) {
+    Job job = new LoadTargetDefinitionJob( targetDef );
+    job.schedule();
+    try {
+      job.join();
+    } catch( InterruptedException exception ) {
+      throw new RuntimeException( exception );
+    }
+  }
+
+  private TargetUtil() {
+    // not designed for instantiation
+  }
+
+}