Author: vyemialyanchyk
Date: 2010-10-18 10:45:39 -0400 (Mon, 18 Oct 2010)
New Revision: 25899
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java
Log:
https://jira.jboss.org/browse/JBIDE-7355 - fixed
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java 2010-10-18
14:39:26 UTC (rev 25898)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java 2010-10-18
14:45:39 UTC (rev 25899)
@@ -277,8 +277,8 @@
//
Element hibernatetool = target.addElement(CodeGenerationStrings.HIBERNATETOOL);
hibernatetool.addAttribute(CodeGenerationStrings.DESTDIR, getVar(varBuildDir));
- String templatePath = getResLocation(attributes.getTemplatePath());
if (attributes.isUseOwnTemplates()) {
+ String templatePath = getResLocation(attributes.getTemplatePath());
hibernatetool.addAttribute(CodeGenerationStrings.TEMPLATEPATH, templatePath);
}
if (rootConsoleConfig != null) {
@@ -372,11 +372,12 @@
if (val == null || 0 == val.toString().compareTo(ad.defaultValue)) {
continue;
}
+ String processedVal = processPropertyValue(val);
if (setSubTags.contains(ad.guiName)) {
Element subTag = exporter.addElement(ad.name);
- subTag.addText(val.toString());
+ subTag.addText(processedVal);
} else {
- exporter.addAttribute(ad.name, val.toString());
+ exporter.addAttribute(ad.name, processedVal);
}
}
for (Object obj : list2Remove) {
@@ -386,9 +387,10 @@
for (Map.Entry<String, Object> propEntry : expPropsSorted.entrySet()) {
Object key = propEntry.getKey();
Object val = propEntry.getValue();
+ String processedVal = processPropertyValue(val);
Element property = exporter.addElement(CodeGenerationStrings.PROPERTY);
property.addAttribute(CodeGenerationStrings.KEY, key.toString());
- property.addAttribute(CodeGenerationStrings.VALUE, "" + val);
//$NON-NLS-1$
+ property.addAttribute(CodeGenerationStrings.VALUE, processedVal);
}
}
return root;
@@ -436,6 +438,26 @@
}
return consoleConfig.getPreferences();
}
+
+ /**
+ * Check is the value a path in current file system,
+ * if true - update result value (workspace related path is
+ * converted to absolute path).
+ *
+ * @param val
+ * @return
+ */
+ public String processPropertyValue(Object val) {
+ if (val == null) {
+ return ""; //$NON-NLS-1$
+ }
+ String res = val.toString();
+ String processedVal = getResLocation(res);
+ if ((new java.io.File(processedVal)).exists()) {
+ res = processedVal;
+ }
+ return res;
+ }
public IResource findResource(String path) {
final IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();