Bug 498361 : added "input_directory" variable, correction of gGet

Change-Id: I67eed26dc02d7f150264ab230bd2d795127b5fdd
Signed-off-by: jcelmer <jan.celmer@atos.net>
diff --git a/plugins/org.eclipse.gendoc.bundle.acceleo.commons/src/org/eclipse/gendoc/bundle/acceleo/commons/files/CommonService.java b/plugins/org.eclipse.gendoc.bundle.acceleo.commons/src/org/eclipse/gendoc/bundle/acceleo/commons/files/CommonService.java
index e0003e5..fd58789 100644
--- a/plugins/org.eclipse.gendoc.bundle.acceleo.commons/src/org/eclipse/gendoc/bundle/acceleo/commons/files/CommonService.java
+++ b/plugins/org.eclipse.gendoc.bundle.acceleo.commons/src/org/eclipse/gendoc/bundle/acceleo/commons/files/CommonService.java
@@ -46,6 +46,7 @@
 import org.eclipse.gendoc.services.IGendocDiagnostician;
 import org.eclipse.gendoc.services.IRegistryService;
 import org.eclipse.gendoc.tags.ITagExtensionService;
+import org.eclipse.gendoc.tags.handlers.IConfigurationService;
 import org.eclipse.gendoc.tags.handlers.IEMFModelLoaderService;
 import org.osgi.framework.Bundle;
 
@@ -158,7 +159,16 @@
 		IRegistryService registry = GendocServices.getDefault().getService(
 				IRegistryService.class);
 		if (registry != null) {
-			return registry.get(key);
+			Object result = registry.get(key);
+			if (result == null && key instanceof String){
+				// fix problems using deferred values
+				IConfigurationService conf = GendocServices.getDefault().getService(IConfigurationService.class);
+				String tmp = conf.getParameter((String) key);
+				if (tmp instanceof String) {
+					result = (String)tmp;
+				}
+			}
+			return result;
 		}
 		return null;
 	}
diff --git a/plugins/org.eclipse.gendoc.tags.handlers/src/org/eclipse/gendoc/tags/handlers/DefaultParameterValue.java b/plugins/org.eclipse.gendoc.tags.handlers/src/org/eclipse/gendoc/tags/handlers/DefaultParameterValue.java
index 4d7f732..fc98991 100644
--- a/plugins/org.eclipse.gendoc.tags.handlers/src/org/eclipse/gendoc/tags/handlers/DefaultParameterValue.java
+++ b/plugins/org.eclipse.gendoc.tags.handlers/src/org/eclipse/gendoc/tags/handlers/DefaultParameterValue.java
@@ -34,7 +34,8 @@
 {
     private static final String KEY_INPUT = "input";
     private static final String KEY_INPUT_EXT = "input_ext";
-
+    private static final String KEY_INPUT_DIRECTORY = "input_directory";
+    
     private static final String KEY_DATE = "date";
 
     public Map<String, String> getValue()
@@ -52,44 +53,39 @@
     public Map<String, IDeferredValue> getDeferredValues()
     {
         // these values are deferred to be sure that the document service is
-        // already loaded
+        // already loaded    	
         Map<String, IDeferredValue> result = new HashMap<String, IDeferredValue>();
         IDeferredValue documentDeferred = new IDeferredValue()
         {
-            String documentName = null;
-
             public String get()
             {
-                if (documentName == null)
-                {
-                	String  document = getDocument();
-                    return document.substring(0, document.lastIndexOf("."));
-                }
-                return documentName;
+            	String  document = getDocument();
+                return document.substring(0, document.lastIndexOf("."));
             }
-
-
         };
         // fill document name
         result.put(KEY_INPUT, documentDeferred);
         IDeferredValue documentDeferred2 = new IDeferredValue()
         {
-            String documentName = null;
-
             public String get()
             {
-                if (documentName == null)
-                {
-                	String  document = getDocument();
-                    return document;
-                }
-                return documentName;
+            	String  document = getDocument();
+                return document;
             }
-
-
         };
         // fill document name with extension
         result.put(KEY_INPUT_EXT, documentDeferred2);
+        IDeferredValue documentDeferred3 = new IDeferredValue()
+        {
+            public String get()
+            {
+        		IDocumentService docService = GendocServices.getDefault().getService(IDocumentService.class);
+            	String pathFile = docService.getDocument().getPath().substring(0, docService.getDocument().getPath().lastIndexOf('/'));
+                return pathFile;
+            }
+        };
+        // fill document name with extension
+        result.put(KEY_INPUT_DIRECTORY, documentDeferred3);                
         return result;
     }
     
@@ -99,7 +95,7 @@
     		IDocumentService docService = GendocServices.getDefault().getService(IDocumentService.class);
     		if (docService != null)
     		{
-    			String name = docService.getDocument().getPath().substring(docService.getDocument().getPath().lastIndexOf('/') + 1, docService.getDocument().getPath().length());
+    			String name = docService.getDocument().getPath().substring(docService.getDocument().getPath().lastIndexOf('/') + 1);
     			return name;
     		}
     	}