KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bull > eclipse > jonas > actions > middlegen > MiddlegenHibernateActionDelegate


1 /*
2  * Created on 2 juin 2003
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */

7 package com.bull.eclipse.jonas.actions.middlegen;
8
9 /**
10  * @author Emmanuel RIAS
11  *
12  * To change the template for this generated type comment go to
13  * Window>Preferences>Java>Code Generation>Code and Comments
14  */

15
16 import java.io.File JavaDoc;
17 import java.io.FileInputStream JavaDoc;
18 import java.io.FileOutputStream JavaDoc;
19 import java.io.FileWriter JavaDoc;
20 import java.io.IOException JavaDoc;
21 import java.util.Properties JavaDoc;
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 JavaDoc {
48         this.prj = prj;
49         IPath prjPath = prj.getProject().getLocation();
50                 
51         middleGenDir = new File JavaDoc(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 JavaDoc templateFileName, String JavaDoc targetFileName, VelocityEngine vEngine, VelocityContext vContext)
64             throws Exception JavaDoc, IOException JavaDoc, ResourceNotFoundException,
65             ParseErrorException, MethodInvocationException {
66         FileWriter JavaDoc fileWriter = null;
67         fileWriter = new FileWriter JavaDoc(targetFileName);
68         vEngine.mergeTemplate(templateFileName, vContext, fileWriter);
69         fileWriter.close();
70     }
71 }
72
Popular Tags