1 7 package com.bull.eclipse.jonas.actions.middlegen; 8 9 15 16 import java.io.File ; 17 import java.io.FileInputStream ; 18 import java.io.FileOutputStream ; 19 import java.io.FileWriter ; 20 import java.io.IOException ; 21 import java.util.Properties ; 22 23 import org.apache.velocity.VelocityContext; 24 import org.apache.velocity.app.VelocityEngine; 25 import org.apache.velocity.exception.MethodInvocationException; 26 import org.apache.velocity.exception.ParseErrorException; 27 import org.apache.velocity.exception.ResourceNotFoundException; 28 import org.eclipse.core.resources.IResource; 29 import org.eclipse.core.runtime.CoreException; 30 import org.eclipse.core.runtime.IPath; 31 import org.eclipse.jdt.internal.ui.JavaPlugin; 32 import org.eclipse.jface.dialogs.InputDialog; 33 import org.eclipse.jface.preference.IPreferenceStore; 34 35 import com.bull.eclipse.jonas.CreateJonasBase; 36 import com.bull.eclipse.jonas.JonasLauncherPlugin; 37 import com.bull.eclipse.jonas.JonasPluginResources; 38 import com.bull.eclipse.jonas.JonasProject; 39 import com.bull.eclipse.jonas.actions.JonasProjectAbstractActionDelegate; 40 import com.bull.eclipse.jonas.utils.AntUtils; 41 import com.bull.eclipse.jonas.utils.EjbManagement; 42 import com.bull.eclipse.jonas.utils.FileUtil; 43 import com.bull.eclipse.jonas.utils.TemplateDirUtil; 44 45 public class MiddlegenHibernateActionDelegate extends MiddlegenActionAbstract { 46 47 public boolean doActionOn(JonasProject prj) throws Exception { 48 this.prj = prj; 49 IPath prjPath = prj.getProject().getLocation(); 50 51 middleGenDir = new File (prjPath.append("hibernatepersistence").toOSString()); 52 tempMiddlegen = TemplateDirUtil.getTemplateDir().concat(File.separator).concat("middlegen"); 53 54 copyConfigurationFile("cmp2persistence", "hibernatepersistence"); 55 createPropertiesFile("hibernate"); 56 57 startIHM("hibernatedoclet"); 58 59 return false; 60 } 61 62 63 private void generate(String templateFileName, String targetFileName, VelocityEngine vEngine, VelocityContext vContext) 64 throws Exception , IOException , ResourceNotFoundException, 65 ParseErrorException, MethodInvocationException { 66 FileWriter fileWriter = null; 67 fileWriter = new FileWriter (targetFileName); 68 vEngine.mergeTemplate(templateFileName, vContext, fileWriter); 69 fileWriter.close(); 70 } 71 } 72 | Popular Tags |