[bugzilla 372463] HTML Export for the Intent Documentation (Step 3)

- the exported documentation now uses images as defined by edit plugins
to display model elements
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/generator/modellinking/ModelingUnitLinkResolver.java b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/generator/modellinking/ModelingUnitLinkResolver.java
index fb012d6..4ad3cc3 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/generator/modellinking/ModelingUnitLinkResolver.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/generator/modellinking/ModelingUnitLinkResolver.java
@@ -27,7 +27,9 @@
 import org.eclipse.mylyn.docs.intent.collab.repository.RepositoryConnectionException;

 import org.eclipse.mylyn.docs.intent.core.genericunit.UnitInstruction;

 import org.eclipse.mylyn.docs.intent.core.modelingunit.ContributionInstruction;

+import org.eclipse.mylyn.docs.intent.core.modelingunit.InstanciationInstruction;

 import org.eclipse.mylyn.docs.intent.core.modelingunit.ModelingUnitInstruction;

+import org.eclipse.mylyn.docs.intent.core.modelingunit.ReferenceValueForStructuralFeature;

 import org.eclipse.mylyn.docs.intent.core.modelingunit.StructuralFeatureAffectation;

 

 /**

@@ -210,7 +212,11 @@
 		EClassifier foundClassifier = ePackage.getEClassifier(href);

 		if (foundClassifier != null) {

 			resolvedClass = foundClassifier;

+			if (instruction instanceof ReferenceValueForStructuralFeature) {

+				((ReferenceValueForStructuralFeature)instruction).setReferencedMetaType(resolvedClass);

+			}

 		}

+

 		return resolvedClass;

 	}

 

@@ -243,6 +249,15 @@
 				&& instruction instanceof ContributionInstruction) {

 			((ContributionInstruction)instruction).getReferencedElement().setReferencedElement(

 					(ModelingUnitInstruction)instanciationInstruction);

+		} else {

+			if (instanciationInstruction instanceof InstanciationInstruction

+					&& instruction instanceof ReferenceValueForStructuralFeature) {

+				((ReferenceValueForStructuralFeature)instruction).getReferencedElement()

+						.setReferencedElement((InstanciationInstruction)instanciationInstruction);

+				((ReferenceValueForStructuralFeature)instruction)

+						.setReferencedMetaType(((InstanciationInstruction)instanciationInstruction)

+								.getMetaType().getResolvedType());

+			}

 		}

 

 		return foundReference;

diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/propertytester/IsAssociatedToIntentDocumentTester.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/propertytester/IsAssociatedToIntentDocumentTester.java
new file mode 100644
index 0000000..a730754
--- /dev/null
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/propertytester/IsAssociatedToIntentDocumentTester.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Obeo.
+ * 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:
+ *     Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.docs.intent.client.ui.ide.propertytester;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.mylyn.docs.intent.client.ui.ide.builder.IntentNature;
+import org.eclipse.mylyn.docs.intent.collab.common.IntentRepositoryManager;
+import org.eclipse.mylyn.docs.intent.collab.common.location.IntentLocations;
+import org.eclipse.mylyn.docs.intent.collab.handlers.adapters.RepositoryAdapter;
+import org.eclipse.mylyn.docs.intent.collab.repository.Repository;
+import org.eclipse.mylyn.docs.intent.collab.repository.RepositoryConnectionException;
+import org.eclipse.mylyn.docs.intent.core.document.IntentDocument;
+import org.eclipse.mylyn.docs.intent.core.indexer.IntentIndexEntry;
+
+/**
+ * Returns true if the tester element is associated to an IntentDocument (i.e. is an Intent Document or can be
+ * adapted as such or is an Intent project).
+ * 
+ * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
+ */
+public class IsAssociatedToIntentDocumentTester extends PropertyTester {
+
+	/**
+	 * Default constructor.
+	 */
+	public IsAssociatedToIntentDocumentTester() {
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String,
+	 *      java.lang.Object[], java.lang.Object)
+	 */
+	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+		Object document = getIntentDocument(receiver);
+
+		// If we are facing an index entry, we get the associated IntentDocument if any
+		if (document instanceof IntentIndexEntry) {
+			document = ((IntentIndexEntry)document).getReferencedElement();
+		}
+		return document instanceof IntentDocument;
+	}
+
+	/**
+	 * Returns the intent document associated to the given element.
+	 * 
+	 * @param any
+	 *            the element from which get the Intent Document
+	 * @return the intent document if the given element is an Intent Project, or directly the Intent Document;
+	 *         null otherwise.
+	 */
+	public static IntentDocument getIntentDocument(Object any) {
+		IntentDocument document = null;
+		if (any instanceof IProject) {
+			// if the selected element is an IProject
+			// we get the associated intent document if any
+			IProject project = (IProject)any;
+			try {
+				if (project.hasNature(IntentNature.NATURE_ID)) {
+					Repository repository = IntentRepositoryManager.INSTANCE.getRepository(project.getName());
+
+					if (repository != null) {
+						RepositoryAdapter repositoryAdapter = repository.createRepositoryAdapter();
+						try {
+							EList<EObject> contents = repositoryAdapter.getResource(
+									IntentLocations.INTENT_INDEX).getContents();
+							if (!contents.isEmpty() && contents.iterator().next() instanceof IntentDocument) {
+								document = (IntentDocument)contents.iterator().next();
+							}
+						} finally {
+							repositoryAdapter.closeContext();
+						}
+					}
+				}
+			} catch (RepositoryConnectionException e) {
+				// silently fail, test will return false
+			} catch (CoreException e) {
+				// silently fail, test will return false
+			}
+		} else {
+			// If the selected element can be adapted as an EObject
+			if (any instanceof IAdaptable
+					&& ((IAdaptable)any).getAdapter(EObject.class) instanceof IntentDocument) {
+				// We consider the EObject (that may be the Intent document
+				document = (IntentDocument)((IAdaptable)any).getAdapter(EObject.class);
+			}
+		}
+		return document;
+	}
+}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab.ide/src/org/eclipse/mylyn/docs/intent/collab/ide/repository/WorkspaceRepositoryLoader.java b/plugins/org.eclipse.mylyn.docs.intent.collab.ide/src/org/eclipse/mylyn/docs/intent/collab/ide/repository/WorkspaceRepositoryLoader.java
index fb3f188..55a61b6 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab.ide/src/org/eclipse/mylyn/docs/intent/collab/ide/repository/WorkspaceRepositoryLoader.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab.ide/src/org/eclipse/mylyn/docs/intent/collab/ide/repository/WorkspaceRepositoryLoader.java
@@ -66,7 +66,9 @@
 	private void addIndexFileToResourceSet(String indexRelativePath) {
 		URI fileURI = workspaceRepository.getURIMatchingPath(indexRelativePath);
 		try {
-			workspaceRepository.getResourceSet().getResource(fileURI, true);
+			if (workspaceRepository.getResourceSet().getURIConverter() != null) {
+				workspaceRepository.getResourceSet().getResource(fileURI, true);
+			}
 		} catch (WrappedException e) {
 			try {
 				workspaceRepository.getResourceSet().createResource(fileURI).save(null);
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/model/intent.genmodel b/plugins/org.eclipse.mylyn.docs.intent.core/model/intent.genmodel
index 1df5767..50cf388 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/model/intent.genmodel
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/model/intent.genmodel
@@ -71,6 +71,7 @@
     </genClasses>

     <genClasses ecoreClass="modelingUnit.ecore#//ReferenceValueForStructuralFeature">

       <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference modelingUnit.ecore#//ReferenceValueForStructuralFeature/referencedElement"/>

+      <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference modelingUnit.ecore#//ReferenceValueForStructuralFeature/referencedMetaType"/>

     </genClasses>

     <genClasses ecoreClass="modelingUnit.ecore#//ContributionInstruction">

       <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference modelingUnit.ecore#//ContributionInstruction/referencedElement"/>

diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/model/modelingUnit.ecore b/plugins/org.eclipse.mylyn.docs.intent.core/model/modelingUnit.ecore
index b22588a..ce7eefe 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/model/modelingUnit.ecore
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/model/modelingUnit.ecore
@@ -81,6 +81,7 @@
       eSuperTypes="#//ValueForStructuralFeature">

     <eStructuralFeatures xsi:type="ecore:EReference" name="referencedElement" lowerBound="1"

         eType="#//InstanciationInstructionReference" containment="true"/>

+    <eStructuralFeatures xsi:type="ecore:EReference" name="referencedMetaType" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>

   </eClassifiers>

   <eClassifiers xsi:type="ecore:EClass" name="ContributionInstruction" eSuperTypes="#//ModelingUnitInstruction">

     <eStructuralFeatures xsi:type="ecore:EReference" name="referencedElement" lowerBound="1"

diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/ModelingUnitPackage.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/ModelingUnitPackage.java
index 9815442..fc4e6e2 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/ModelingUnitPackage.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/ModelingUnitPackage.java
@@ -1130,13 +1130,22 @@
 	int REFERENCE_VALUE_FOR_STRUCTURAL_FEATURE__REFERENCED_ELEMENT = VALUE_FOR_STRUCTURAL_FEATURE_FEATURE_COUNT + 0;
 
 	/**
+	 * The feature id for the '<em><b>Referenced Meta Type</b></em>' reference.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 * @ordered
+	 */
+	int REFERENCE_VALUE_FOR_STRUCTURAL_FEATURE__REFERENCED_META_TYPE = VALUE_FOR_STRUCTURAL_FEATURE_FEATURE_COUNT + 1;
+
+	/**
 	 * The number of structural features of the '<em>Reference Value For Structural Feature</em>' class.
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
 	 * @generated
 	 * @ordered
 	 */
-	int REFERENCE_VALUE_FOR_STRUCTURAL_FEATURE_FEATURE_COUNT = VALUE_FOR_STRUCTURAL_FEATURE_FEATURE_COUNT + 1;
+	int REFERENCE_VALUE_FOR_STRUCTURAL_FEATURE_FEATURE_COUNT = VALUE_FOR_STRUCTURAL_FEATURE_FEATURE_COUNT + 2;
 
 	/**
 	 * The meta object id for the '{@link org.eclipse.mylyn.docs.intent.core.modelingunit.impl.ContributionInstructionImpl <em>Contribution Instruction</em>}' class.
@@ -1670,6 +1679,17 @@
 	EReference getReferenceValueForStructuralFeature_ReferencedElement();
 
 	/**
+	 * Returns the meta object for the reference '{@link org.eclipse.mylyn.docs.intent.core.modelingunit.ReferenceValueForStructuralFeature#getReferencedMetaType <em>Referenced Meta Type</em>}'.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @return the meta object for the reference '<em>Referenced Meta Type</em>'.
+	 * @see org.eclipse.mylyn.docs.intent.core.modelingunit.ReferenceValueForStructuralFeature#getReferencedMetaType()
+	 * @see #getReferenceValueForStructuralFeature()
+	 * @generated
+	 */
+	EReference getReferenceValueForStructuralFeature_ReferencedMetaType();
+
+	/**
 	 * Returns the meta object for class '{@link org.eclipse.mylyn.docs.intent.core.modelingunit.ContributionInstruction <em>Contribution Instruction</em>}'.
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
@@ -2123,6 +2143,15 @@
 				.getReferenceValueForStructuralFeature_ReferencedElement();
 
 		/**
+		 * The meta object literal for the '<em><b>Referenced Meta Type</b></em>' reference feature.
+		 * <!-- begin-user-doc -->
+		 * <!-- end-user-doc -->
+		 * @generated
+		 */
+		EReference REFERENCE_VALUE_FOR_STRUCTURAL_FEATURE__REFERENCED_META_TYPE = eINSTANCE
+				.getReferenceValueForStructuralFeature_ReferencedMetaType();
+
+		/**
 		 * The meta object literal for the '{@link org.eclipse.mylyn.docs.intent.core.modelingunit.impl.ContributionInstructionImpl <em>Contribution Instruction</em>}' class.
 		 * <!-- begin-user-doc -->
 		 * <!-- end-user-doc -->
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/ReferenceValueForStructuralFeature.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/ReferenceValueForStructuralFeature.java
index 2303617..57ada17 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/ReferenceValueForStructuralFeature.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/ReferenceValueForStructuralFeature.java
@@ -10,6 +10,8 @@
  *******************************************************************************/
 package org.eclipse.mylyn.docs.intent.core.modelingunit;
 
+import org.eclipse.emf.ecore.EObject;
+
 /**
  * <!-- begin-user-doc -->
  * A representation of the model object '<em><b>Reference Value For Structural Feature</b></em>'.
@@ -19,6 +21,7 @@
  * The following features are supported:
  * <ul>
  *   <li>{@link org.eclipse.mylyn.docs.intent.core.modelingunit.ReferenceValueForStructuralFeature#getReferencedElement <em>Referenced Element</em>}</li>
+ *   <li>{@link org.eclipse.mylyn.docs.intent.core.modelingunit.ReferenceValueForStructuralFeature#getReferencedMetaType <em>Referenced Meta Type</em>}</li>
  * </ul>
  * </p>
  *
@@ -53,4 +56,30 @@
 	 */
 	void setReferencedElement(InstanciationInstructionReference value);
 
+	/**
+	 * Returns the value of the '<em><b>Referenced Meta Type</b></em>' reference.
+	 * <!-- begin-user-doc -->
+	 * <p>
+	 * If the meaning of the '<em>Referenced Meta Type</em>' reference isn't clear,
+	 * there really should be more of a description here...
+	 * </p>
+	 * <!-- end-user-doc -->
+	 * @return the value of the '<em>Referenced Meta Type</em>' reference.
+	 * @see #setReferencedMetaType(EObject)
+	 * @see org.eclipse.mylyn.docs.intent.core.modelingunit.ModelingUnitPackage#getReferenceValueForStructuralFeature_ReferencedMetaType()
+	 * @model
+	 * @generated
+	 */
+	EObject getReferencedMetaType();
+
+	/**
+	 * Sets the value of the '{@link org.eclipse.mylyn.docs.intent.core.modelingunit.ReferenceValueForStructuralFeature#getReferencedMetaType <em>Referenced Meta Type</em>}' reference.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @param value the new value of the '<em>Referenced Meta Type</em>' reference.
+	 * @see #getReferencedMetaType()
+	 * @generated
+	 */
+	void setReferencedMetaType(EObject value);
+
 } // ReferenceValueForStructuralFeature
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/impl/ModelingUnitPackageImpl.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/impl/ModelingUnitPackageImpl.java
index 8eb81a8..2a46281 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/impl/ModelingUnitPackageImpl.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/impl/ModelingUnitPackageImpl.java
@@ -676,6 +676,15 @@
 	 * <!-- end-user-doc -->
 	 * @generated
 	 */
+	public EReference getReferenceValueForStructuralFeature_ReferencedMetaType() {
+		return (EReference)referenceValueForStructuralFeatureEClass.getEStructuralFeatures().get(1);
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
 	public EClass getContributionInstruction() {
 		return contributionInstructionEClass;
 	}
@@ -800,6 +809,8 @@
 		referenceValueForStructuralFeatureEClass = createEClass(REFERENCE_VALUE_FOR_STRUCTURAL_FEATURE);
 		createEReference(referenceValueForStructuralFeatureEClass,
 				REFERENCE_VALUE_FOR_STRUCTURAL_FEATURE__REFERENCED_ELEMENT);
+		createEReference(referenceValueForStructuralFeatureEClass,
+				REFERENCE_VALUE_FOR_STRUCTURAL_FEATURE__REFERENCED_META_TYPE);
 
 		contributionInstructionEClass = createEClass(CONTRIBUTION_INSTRUCTION);
 		createEReference(contributionInstructionEClass, CONTRIBUTION_INSTRUCTION__REFERENCED_ELEMENT);
@@ -1013,6 +1024,10 @@
 				this.getInstanciationInstructionReference(), null, "referencedElement", null, 1, 1,
 				ReferenceValueForStructuralFeature.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE,
 				IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+		initEReference(getReferenceValueForStructuralFeature_ReferencedMetaType(), ecorePackage.getEObject(),
+				null, "referencedMetaType", null, 0, 1, ReferenceValueForStructuralFeature.class,
+				!IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES,
+				!IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 
 		initEClass(contributionInstructionEClass, ContributionInstruction.class, "ContributionInstruction",
 				!IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/impl/ReferenceValueForStructuralFeatureImpl.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/impl/ReferenceValueForStructuralFeatureImpl.java
index d872d03..e4803b4 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/impl/ReferenceValueForStructuralFeatureImpl.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/modelingunit/impl/ReferenceValueForStructuralFeatureImpl.java
@@ -11,6 +11,7 @@
 package org.eclipse.mylyn.docs.intent.core.modelingunit.impl;
 
 import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
 import org.eclipse.mylyn.docs.intent.core.modelingunit.InstanciationInstructionReference;
 import org.eclipse.mylyn.docs.intent.core.modelingunit.ModelingUnitPackage;
 import org.eclipse.mylyn.docs.intent.core.modelingunit.ReferenceValueForStructuralFeature;
@@ -23,6 +24,7 @@
  * The following features are implemented:
  * <ul>
  *   <li>{@link org.eclipse.mylyn.docs.intent.core.modelingunit.impl.ReferenceValueForStructuralFeatureImpl#getReferencedElement <em>Referenced Element</em>}</li>
+ *   <li>{@link org.eclipse.mylyn.docs.intent.core.modelingunit.impl.ReferenceValueForStructuralFeatureImpl#getReferencedMetaType <em>Referenced Meta Type</em>}</li>
  * </ul>
  * </p>
  *
@@ -68,4 +70,25 @@
 				newReferencedElement);
 	}
 
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public EObject getReferencedMetaType() {
+		return (EObject)eGet(
+				ModelingUnitPackage.Literals.REFERENCE_VALUE_FOR_STRUCTURAL_FEATURE__REFERENCED_META_TYPE,
+				true);
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public void setReferencedMetaType(EObject newReferencedMetaType) {
+		eSet(ModelingUnitPackage.Literals.REFERENCE_VALUE_FOR_STRUCTURAL_FEATURE__REFERENCED_META_TYPE,
+				newReferencedMetaType);
+	}
+
 } //ReferenceValueForStructuralFeatureImpl
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/src/org/eclipse/mylyn/docs/intent/exporter/ui/popup/actions/ExportIntentDocumentationAction.java b/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/src/org/eclipse/mylyn/docs/intent/exporter/ui/popup/actions/ExportIntentDocumentationAction.java
index 87ebc0e..aafa058 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/src/org/eclipse/mylyn/docs/intent/exporter/ui/popup/actions/ExportIntentDocumentationAction.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/src/org/eclipse/mylyn/docs/intent/exporter/ui/popup/actions/ExportIntentDocumentationAction.java
@@ -61,10 +61,13 @@
 	 */
 	public Object execute(ExecutionEvent event) throws ExecutionException {
 		ISelection selection = HandlerUtil.getCurrentSelection(event);
-		Object intentProject;
-		if (selection instanceof StructuredSelection
-				&& (intentProject = ((StructuredSelection)selection).getFirstElement()) instanceof IProject) {
-
+		if (selection instanceof StructuredSelection) {
+			IProject intentProject = null;
+			if (((StructuredSelection)selection).getFirstElement() instanceof IProject) {
+				intentProject = (IProject)((StructuredSelection)selection).getFirstElement();
+			} else if (((StructuredSelection)selection).getFirstElement() instanceof IntentDocument) {
+				// TODO
+			}
 			// Step 1 : open the export dialog
 			ExportOptionsDialog exportOptionsDialog = new ExportOptionsDialog(Display.getCurrent()
 					.getActiveShell(), new File(((IProject)intentProject).getLocationURI()).getAbsolutePath()
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.exporter/META-INF/MANIFEST.MF
index fcf5bc6..3976056 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/META-INF/MANIFEST.MF
@@ -18,7 +18,9 @@
  org.eclipse.acceleo.engine;visibility:=reexport,
  com.google.collect,
  org.eclipse.mylyn.docs.intent.core;visibility:=reexport,
- org.eclipse.mylyn.docs.intent.markup.gen
+ org.eclipse.mylyn.docs.intent.markup.gen,
+ org.eclipse.emf.edit,
+ org.eclipse.emf.edit.ui
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ActivationPolicy: lazy
 Eclipse-LazyStart: true
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/HTMLBootstrapGenDocument.java b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/HTMLBootstrapGenDocument.java
index c17b089..f6d1779 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/HTMLBootstrapGenDocument.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/HTMLBootstrapGenDocument.java
@@ -25,6 +25,7 @@
 import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.mylyn.docs.intent.exporter.services.IntentAcceleoServices;
 
 /**
  * Entry point of the 'HTMLBootstrapGenDocument' generation module.
@@ -166,31 +167,12 @@
 	 *            This will be used to display progress information to the user.
 	 * @throws IOException
 	 *             This will be thrown if any of the output files cannot be saved to disk.
-	 * @generated
+	 * @generated-not
 	 */
 	@Override
 	public void doGenerate(Monitor monitor) throws IOException {
-        /*
-         * TODO if you wish to change the generation as a whole, override this. The default behavior should
-         * be sufficient in most cases. If you want to change the content of this method, do NOT forget to
-         * change the "@generated" tag in the Javadoc of this method to "@generated NOT". Without this new tag,
-         * any compilation of the Acceleo module with the main template that has caused the creation of this
-         * class will revert your modifications. If you encounter a problem with an unresolved proxy during the
-         * generation, you can remove the comments in the following instructions to check for problems. Please
-         * note that those instructions may have a significant impact on the performances.
-         */
-
-        //org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(model);
-
-        //if (model != null && model.eResource() != null) {
-        //    List<org.eclipse.emf.ecore.resource.Resource.Diagnostic> errors = model.eResource().getErrors();
-        //    for (org.eclipse.emf.ecore.resource.Resource.Diagnostic diagnostic : errors) {
-        //        System.err.println(diagnostic.toString());
-        //    }
-        //}
-
-        super.doGenerate(monitor);
-    }
+		doGenerate(monitor, "Intent Documentation");
+	}
 
 	/**
 	 * Launches the generation described by this instance.
@@ -204,7 +186,9 @@
 	 */
 	public void doGenerate(Monitor monitor, String projectName) throws IOException {
 		this.projectName = projectName;
+		IntentAcceleoServices.initialize(getTargetFolder());
 		super.doGenerate(monitor);
+		IntentAcceleoServices.dispose();
 	}
 
 	/**
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/generateHTMLContent.mtl b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/generateHTMLContent.mtl
index f0eed3d..31cc259 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/generateHTMLContent.mtl
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/generateHTMLContent.mtl
@@ -8,6 +8,10 @@
 invoke('org.eclipse.mylyn.docs.intent.exporter.services.IntentAcceleoServices', 'getHeaderSizeForSection(java.lang.String)', Sequence{sectionID})
 /]
 
+[query public getQualifiedImageId(classifer : EObject) : String = 
+invoke('org.eclipse.mylyn.docs.intent.exporter.services.IntentAcceleoServices', 'getQualifiedImageID(org.eclipse.emf.ecore.EObject)', Sequence{classifer})
+/]
+
 [template public generateHTMLContent(intentDocument : IntentDocument)]
 	<div id="content" >
 		[for (chapter : IntentChapter | intentDocument.chapters)]
@@ -83,7 +87,7 @@
 
 [template public generateHTMLContent(instancation : InstanciationInstruction)]
 	<li class="jstree-open">
-		<img src="./icons/modelingunit_new_element.png"/>
+		[instancation.getImageForValue()/]
 
 		<a href="#"												
 			rel="popover" title=""
@@ -92,7 +96,7 @@
 		[if instancation.name->isEmpty()._not()]
 			[instancation.name/] - 
 		[/if]
-		 new [instancation.metaType.IntentHref/] (Definition)
+		 new [instancation.metaType.IntentHref/] [definitionInformation()/]
 
 		</a>
 		[if instancation.structuralFeatures->size() > 0]
@@ -107,13 +111,13 @@
 
 [template public generateHTMLContent(contribution : ContributionInstruction)]
 	<li class="jstree-open">
-		<img src="./icons/modelingunit_contribution.png"/>
+		[contribution.getImageForValue()/]
 
 		<a href="#"												
 			rel="popover" title="Contribution to [contribution.referencedElement.IntentHref/] [if contribution.referencedElement.IntentHref.oclIsInvalid()._not()](of type [contribution.referencedElement.IntentHref/])[/if]"
 			data-content="Some infos"
 		>
-		[contribution.referencedElement.IntentHref/] (Contribution)
+		[contribution.referencedElement.IntentHref/] [contributionInformation()/]
 		</a>
 		[if contribution.contributions->size() > 0]
 			<ul>
@@ -136,7 +140,7 @@
 		Resource [resourceDeclaration.name/]
 		</a>
 			[if resourceDeclaration.uri->isEmpty()._not()]
-				(URI :[resourceDeclaration.uri.toString()/])
+				(URI :<code style="color:blue; border:0px solid black;">[resourceDeclaration.uri.toString()/])</code>
 			[/if]
 			[if resourceDeclaration.content->size() > 0]
 				<ul>
@@ -194,7 +198,7 @@
 		[if newValueInstruction.value.name->isEmpty()._not()]
 			[newValueInstruction.value.name/] - 
 		[/if]
-		 new [newValueInstruction.value.metaType.IntentHref/] (Definition)
+		 new [newValueInstruction.value.metaType.IntentHref/] [definitionInformation()/]
 
 		</a>
 		[if newValueInstruction.value.structuralFeatures->size() > 0]
@@ -224,14 +228,6 @@
 >[reference.referencedElement.IntentHref/]</a>
 [/template]
 
-[template public getImageForValue(valueInstruction : ReferenceValueForStructuralFeature)]
-<img src="./icons/modelingunit_ref.png"/>
-[/template]
-
-[template public getImageForValue(valueInstruction : NewObjectValueForStructuralFeature)]
-<img src="./icons/modelingunit_new_element.png"/>
-[/template]
-
 [template public getImageForValue(valueInstruction : NativeValueForStructuralFeature)]
 <img src="./icons/modelingunit_value.gif"/>
 [/template]
@@ -240,9 +236,61 @@
 <img src="./icons/modelingunit_affect.png"/>
 [/template]
 
+[template public getImageForValue(valueInstruction : ReferenceValueForStructuralFeature)]
+[if valueInstruction.referencedMetaType.oclIsUndefined()]
+	 <img src="./icons/modelingunit_ref.png"/>
+[else]
+[let imagePath : String = valueInstruction.referencedMetaType.getQualifiedImageId()]
+	[if imagePath.size() > 2]
+		<img src="[imagePath/]"/>
+	[else]
+		<img src="./icons/modelingunit_ref.png"/>
+	[/if]
+[/let]
+[/if]
+[/template]
+
+[template public getImageForValue(valueInstruction : NewObjectValueForStructuralFeature)]
+[let imagePath : String = valueInstruction.value.metaType.resolvedType.getQualifiedImageId()]
+	[if imagePath.size() > 0]
+		<img src="[imagePath/]"/>
+	[else]
+		<img src="./icons/modelingunit_ref.png"/>
+	[/if]
+[/let]
+[/template]
+
+[template public getImageForValue(insanciationInstruction : InstanciationInstruction)]
+[let imagePath : String = insanciationInstruction.metaType.resolvedType.getQualifiedImageId()]
+	[if imagePath.size() > 0]
+		<img src="[imagePath/]"/>
+	[else]
+		<img src="./icons/modelingunit_new_element.png"/>
+	[/if]
+[/let]
+[/template]
+
+[template public getImageForValue(contributionInstruction : ContributionInstruction)]
+[let imagePath : String = contributionInstruction.referencedElement.referencedElement.oclAsType(InstanciationInstruction).metaType.resolvedType.getQualifiedImageId()]
+	[if imagePath.size() > 0]
+		<img src="[imagePath/]"/>
+	[else]
+		<img src="./icons/modelingunit_contribution.png"/>
+	[/if]
+[/let]
+[/template]
+
 [template public generateHTMLContent(defaultInstruction : UnitInstruction)]
 <b>UNKNOWN : [defaultInstruction.eClass().name/]</b>
 [/template]
 
 [template public generateHTMLContent(instancation : EObject)]
+[/template]
+
+[template public contributionInformation()]
+(Contribution)
+[/template]
+
+[template public definitionInformation()]
+(Definition)
 [/template]
\ No newline at end of file
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/services/IntentAcceleoServices.java b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/services/IntentAcceleoServices.java
index a745659..624ea15 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/services/IntentAcceleoServices.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/services/IntentAcceleoServices.java
@@ -10,7 +10,23 @@
  *******************************************************************************/
 package org.eclipse.mylyn.docs.intent.exporter.services;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.channels.FileChannel;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
 import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
+import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
 
 /**
  * Regroups all services use during doc export.
@@ -19,6 +35,10 @@
  */
 public final class IntentAcceleoServices {
 
+	private static AdapterFactoryItemDelegator itemDelegator;
+
+	private static File outputFolder;
+
 	/**
 	 * Returns the header size to apply to the section with the given ID. For example,
 	 * getHeaderSizeForSection(3_2) will return "2", getHeaderSizeForSection(4_3_2_1) will return "4".
@@ -41,4 +61,122 @@
 	public static String getDocumentTitle(EObject any) {
 		return any.eResource().getURI().segment(any.eResource().getURI().segmentCount() - 4).toString();
 	}
+
+	/**
+	 * Determines the image associated to the given EObject, copies it inside the exported documentation and
+	 * 
+	 * @param any
+	 *            the eobject to get the image from
+	 * @return the image associated to the given EObject
+	 */
+	public static String getQualifiedImageID(EObject any) {
+		String qualifiedImageID = "";
+		Object imageURL = null;
+		if (any instanceof EClass) {
+			EObject instance = ((EClassifier)any).getEPackage().getEFactoryInstance().create((EClass)any);
+			imageURL = getItemDelegator(any).getImage(instance);
+		} else if (any instanceof EClassifier) {
+			imageURL = getItemDelegator(any).getImage(any);
+		}
+		if (!(imageURL instanceof URL)) {
+			if (imageURL instanceof URI) {
+				try {
+					imageURL = new URL(imageURL.toString());
+				} catch (MalformedURLException e) {
+					// silent catch
+				}
+			} else {
+				if (imageURL instanceof org.eclipse.emf.edit.provider.ComposedImage) {
+					imageURL = ((org.eclipse.emf.edit.provider.ComposedImage)imageURL).getImages().iterator()
+							.next();
+				}
+			}
+		}
+		if (imageURL instanceof URL) {
+			try {
+				URL resolvedURL = FileLocator.resolve((URL)imageURL);
+				// If default "Item" image has been
+				if (resolvedURL.toString().contains("org.eclipse.emf.edit")
+						&& resolvedURL.toString().endsWith("/icons/full/obj16/Item.gif")) {
+					// we search for an "edit" plugin in the workspace
+					// TODO
+				}
+				qualifiedImageID = copyImageIfNeeded((EClassifier)any, resolvedURL, resolvedURL.openStream());
+			} catch (IOException e) {
+				// Silent catch, default image will be used
+			}
+		}
+		return qualifiedImageID;
+	}
+
+	private static String copyImageIfNeeded(EClassifier classifier, URL imageURL, InputStream sourceStream)
+			throws IOException {
+		File targetFile = new File(outputFolder.getAbsolutePath() + "/icons/generated/"
+				+ classifier.getEPackage().getName()
+				+ imageURL.getFile().substring(imageURL.getFile().lastIndexOf('/')));
+		// create folders if needed :
+		new File(outputFolder.getAbsolutePath() + "/icons/generated/" + classifier.getEPackage().getName())
+				.mkdirs();
+		if (!targetFile.exists()) {
+			copyFile(sourceStream, targetFile);
+		}
+		String copiedImagePath = targetFile.getAbsolutePath().toString();
+		String outputFolderPath = outputFolder.getAbsolutePath();
+		return "." + copiedImagePath.substring(outputFolderPath.length());
+	}
+
+	private static AdapterFactoryItemDelegator getItemDelegator(EObject any) {
+		if (itemDelegator == null) {
+			ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
+					ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+			adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
+			adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
+			itemDelegator = new AdapterFactoryItemDelegator(adapterFactory);
+		}
+		return itemDelegator;
+	}
+
+	public static void initialize(File generationOutputFolder) {
+		outputFolder = generationOutputFolder;
+	}
+
+	public static void dispose() {
+		if (itemDelegator != null) {
+			((ComposedAdapterFactory)itemDelegator.getAdapterFactory()).dispose();
+		}
+		itemDelegator = null;
+		outputFolder = null;
+	}
+
+	private static void copyFile(final InputStream sourceStream, final File destFile) throws IOException {
+		if (!destFile.exists()) {
+			destFile.createNewFile();
+		}
+
+		FileOutputStream outputStream = new FileOutputStream(destFile);
+		FileChannel destination = null;
+		try {
+			byte[] buf = new byte[1024];
+
+			int len;
+
+			while ((len = sourceStream.read(buf)) > 0) {
+
+				outputStream.write(buf, 0, len);
+
+			}
+
+			sourceStream.close();
+
+			outputStream.close();
+		} finally {
+			if (sourceStream != null) {
+				sourceStream.close();
+			}
+			if (destination != null) {
+				destination.close();
+			}
+		}
+	}
 }
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/tasks/HTMLBootstrapGenDocument.xml b/plugins/org.eclipse.mylyn.docs.intent.exporter/tasks/HTMLBootstrapGenDocument.xml
index a56c26d..aa502bb 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/tasks/HTMLBootstrapGenDocument.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/tasks/HTMLBootstrapGenDocument.xml
@@ -32,6 +32,17 @@
         <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.emf.cdo_4.0.0.v20110608-1639.jar"/>
         <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.emf.cdo.common_4.0.0.v20110608-1639.jar"/>
         <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.net4j.util_3.1.1.v20110625-1209.jar"/>
+        <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.emf.edit_2.7.0.v20110606-0949.jar"/>
+        <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.emf.ecore.change_2.7.0.v20110408-2116.jar"/>
+        <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.emf.edit.ui_2.7.0.v20110606-0949.jar"/>
+        <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.ui.views_3.6.0.I20110412-0800.jar"/>
+        <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.ui.workbench_3.7.0.I20110519-0100.jar"/>
+        <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.emf.common.ui_2.7.0.v20110606-0949.jar"/>
+        <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.ui_3.7.0.I20110602-0100.jar"/>
+        <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.swt_3.7.0.v3735b.jar"/>
+        <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.swt.win32.win32.x86_3.7.0.v3735b.jar"/>
+        <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.jface_3.7.0.I20110522-1430.jar"/>
+        <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.core.commands_3.6.0.I20110111-0800.jar"/>
     </path>
 
     <path id="org.eclipse.mylyn.docs.intent.exporter.classpath">